我想要附加远程流并将其发送到另一个对等端,像这样附加远程流:
firstPeer.onaddstream = function(remoteSteam) {
otherPeer.addStream(remoteStream); /* attaching remote stream */
};
但是它不工作!(我无法在其他浏览器中接收此流)
谁能告诉我如何连接远程流?如何将远端流发送到另一个对等端?
谢谢!
我之前测试过。但是,如果附加了" remote stream ",则stream不流动。
我发现chrome在创建offer sdp时错过了许多属性,同时offer sdp被设置为" recvonly "而不是" sendrecv "。
在最新的chrome金丝雀中,您可以像这样附加"远程流"。
var newStream = new webkitMediaStream(remoteStream);
peer2.addStream(newStream);
或其他:
var newStream = new webkitMediaStream([remoteStream.getAudioTracks(),remoteStream.getVideoTracks()]);
peer2.addStream(newStream);
在旧chrome中:
var newStream = new webkitMediaStream(remoteStream.audioTracks, remoteStream.videoTracks);
peer2.addStream(newStream);
填充" offer sdp "中缺失的属性;我使用了以下代码:
sdp = sdp.replace(/a=msid-semantic: WMS/g, 'a=msid-semantic: WMS ' + getChars());
sdp = sdp.replace(/recvonly/g, 'sendrecv')
var chars00 = getChars();
var numbers = getNumbers();
sdp += 'a=ssrc:'+ numbers+' cname:+Sb9HXiiNN/nhpZ1rn';
sdp += 'a=ssrc:'+ numbers+' msid:' + chars00 + ' v0rn';
sdp += 'a=ssrc:'+ numbers+' mslabel:' + chars00 + 'rn';
sdp += 'a=ssrc:'+ numbers+' label:' + chars00 + 'rn';
var replace = 'a=rtpmap:126 telephone-event/8000rn';
var chars00 = getChars();
var numbers = getNumbers();
replace += 'a=ssrc:'+ numbers+' cname:iecJoX+jqjkT8Dkyrn';
replace += 'a=ssrc:'+ numbers+' msid:' + chars00 + 'rn';
replace += 'a=ssrc:'+ numbers+' mslabel:' + chars00 + 'rn';
replace += 'a=ssrc:'+ numbers+' label:' + chars00;
sdp = sdp.replace(/a=rtpmap:126 telephone-event/8000/g, replace)
记住," getChars "one_answers" getNumbers "方法返回的是随机值。
测试的演示