Audio 拆分WebRTC音频流并在我的输出音频设备的不同通道中输出它们

Audio 拆分WebRTC音频流并在我的输出音频设备的不同通道中输出它们,audio,webrtc,Audio,Webrtc,我有一个简单的WebRTC(音频)群组聊天应用程序,主要基于中的代码,在不同房间的局域网上的笔记本电脑之间。在连接到聊天室的每台笔记本电脑上,代码自动混合所有其他音频流(全部减去该笔记本电脑捕获的流,即音频聊天室的正常操作模式) 在连接到聊天室的其中一台笔记本电脑上(我们称之为laptop0),我希望能够在通过WebRTC选择的输出设备的任意多个不同通道上输出不同的接收流(在我的情况下是3个,因为总共有4台连接的笔记本电脑),即来自 laptop1到输出通道1 laptop2到输出通道2 lap

我有一个简单的WebRTC(音频)群组聊天应用程序,主要基于中的代码,在不同房间的局域网上的笔记本电脑之间。在连接到聊天室的每台笔记本电脑上,代码自动混合所有其他音频流(全部减去该笔记本电脑捕获的流,即音频聊天室的正常操作模式)

在连接到聊天室的其中一台笔记本电脑上(我们称之为
laptop0
),我希望能够在通过WebRTC选择的输出设备的任意多个不同通道上输出不同的接收流(在我的情况下是3个,因为总共有4台连接的笔记本电脑),即来自

  • laptop1
    到输出通道1
  • laptop2
    到输出通道2
  • laptop3
    至输出通道3
  • 我的想法是将输出连接到DAW,以向不同的通道添加一些效果

    假设我有一个有足够通道的输出音频设备,有没有简单的方法? 下面是一段代码片段,我假设该代码位于可以实现该功能的区域(根据我对WebRTC极不了解的情况)

    var peer_connection = new RTCPeerConnection(
        {"iceServers": ICE_SERVERS},
        {"optional": [{"DtlsSrtpKeyAgreement": true}]} 
    );
    peers[peer_id] = peer_connection;
    
    peer_connection.onicecandidate = function(event) {
        if (event.candidate) {
            signaling_socket.emit('relayICECandidate', {
                'peer_id': peer_id, 
                'ice_candidate': {
                    'sdpMLineIndex': event.candidate.sdpMLineIndex,
                    'candidate': event.candidate.candidate
                }
            });
        }
    }
    peer_connection.onaddstream = function(event) {
        console.log("onAddStream", event);
        var remote_media = USE_VIDEO ? $("<video>") : $("<audio>");
        remote_media.attr("autoplay", "autoplay");
        // remote_media.attr('webkit-playsinline', '');
        if (MUTE_AUDIO_BY_DEFAULT) {
        remote_media.attr("muted", "true");
        }
        remote_media.attr("controls", "");
        peer_media_elements[peer_id] = remote_media;
        $('body').append(remote_media);
        attachMediaStream(remote_media[0], event.stream);
    }
    
    
    /* Add our local stream */
    peer_connection.addStream(local_media_stream);
    
    var peer\u connection=new rtpeerconnection(
    {“iceServers”:ICE_服务器},
    {“可选”:[{“DtlsSrtpKeyAgreement”:true}]}
    );
    对等方[对等方id]=对等方连接;
    peer_connection.onicecandidate=函数(事件){
    if(事件候选){
    信号插座发出('relayICECandidate'{
    “对等id”:对等id,
    “ice_候选人”:{
    “sdpMLineIndex”:event.candidate.sdpMLineIndex,
    “候选”:event.candidate.candidate
    }
    });
    }
    }
    peer_connection.onaddstream=函数(事件){
    日志(“onAddStream”,事件);
    var remote_media=使用_视频?$(“”):$(“”);
    远程媒体属性(“自动播放”、“自动播放”);
    //远程媒体属性(“webkit-playsinline”);
    if(默认情况下静音音频){
    远程媒体属性(“静音”、“真”);
    }
    remote_media.attr(“控制”);
    对等媒体元素[对等id]=远程媒体;
    $('body').append(远程_媒体);
    attachMediaStream(远程_媒体[0],事件流);
    }
    /*添加我们的本地流*/
    peer\u connection.addStream(本地\u媒体\u流);