对于 chrome 之前的版本 71.0.3578.98 和 firefox 64.0.2 或 65.0,相同的代码可以正常工作。
它无法创建报价,因此永远不会更新 localDescription。
根本原因的任何线索或如何找到解决方案?
使用 chrome://webrtc-internals/ 进行调试我可以看到一个 setLocalDescriptionOnFailure ,现在我需要知道为什么以及如何修复它。
这是代码:
let RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
let useWebKit = !!window.webkitRTCPeerConnection;
if (!RTCPeerConnection) {
let win = iframe.contentWindow;
RTCPeerConnection = win.RTCPeerConnection
|| win.mozRTCPeerConnection
|| win.webkitRTCPeerConnection;
useWebKit = !!win.webkitRTCPeerConnection;
}
let mediaConstraints = {
optional: [{RtpDataChannels: true}]
};
let servers = {iceServers: [{urls: 'stun:stun.services.mozilla.com'}]};
let pc = new RTCPeerConnection(servers, mediaConstraints);
pc.createDataChannel('');
pc.createOffer((result) => {
pc.setLocalDescription(result, () => {}, () => {});
}, () => {});
setTimeout(function () {
let lines = pc.localDescription.sdp.split('\n');
lines.forEach(function (line) {
if (line.indexOf('a=candidate:') === 0) {
handleCandidate(line);
}
});
}, 1000);
"v=0
o=- 8970400063416288228 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=application 9 UDP/TLS/RTP/SAVPF 121
c=IN IP4 0.0.0.0
b=AS:30
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:zDvW
a=ice-pwd:VPi3OhCXtz5wLxrQZPr0txvz
a=ice-options:trickle
a=fingerprint:sha-256 03:6D:03:81:7D:DF:6F:1B:07:ED:FF:08:4B:C4:39:
A8:1A:86:57:5A:6F:95:68:DC:73:B0:2D:DF:0B:4A:60:89
a=setup:actpass
a=mid:0
a=sendrecv
a=msid:
a=rtcp-mux
a=rtpmap:121 google-data/90000
a=ssrc:2367456832 cname:zVi7CadofeEcO1vV
a=ssrc:2367456832 msid:-
a=ssrc:2367456832 mslabel:-
a=ssrc:2367456832 label: