【发布时间】:2014-07-31 06:42:26
【问题描述】:
我正在为 LAN 构建一个聊天应用程序。我使用 WebRTC,但无法让 Firefox 和 Google chrome 进行互操作。 我不知道应该传递给 RTCPeerConnection createOffer/createAnswer 的确切参数。
我在同一台计算机 Fedora Linux 20 上使用 Firefox 31 和 Google Chrome 36 进行了以下测试
RTCPeerConnection 的创建方式如下:
pc = new RTCPeerConnection(null, RTC_PC_OPTIONS);
答案/报价的创建方式如下:
pc.createOffer(onsuccess, onfail, CONSTRAINTS);
我的问题是:我应该传递哪些参数(RTC_PC_OPTIONS 和 CONSTRAINTS)以获得两个浏览器之间的互操作性?
测试 1
RTC_PC_OPTIONS = undefined
CONSTRAINTS = undefined
FFx2FFx FFx2Chrome Chrome2FFx Chrome2Chrome
------- ---------- ---------- -------------
dataChannel setup ok ok ok ok
dataChannel send/recv ok ok ok ok
Video stream ok ok err [1] ok
测试 2
MDN recomands this value for RTC_PC_OPTIONS
RTC_PC_OPTIONS = {
optional: [
{DtlsSrtpKeyAgreement: true},
{RtpDataChannels: true}
]
};
CONSTRAINTS = undefined
FFx2FFx FFx2Chrome Chrome2FFx Chrome2Chrome
------- ---------- ---------- -------------
dataChannel setup ok err [2] err [3] ok
dataChannel send/recv ok - - ok
Video stream ok - - err [4]
^~~~~~~~~~~~~~~~^
^
i used datachannel to do signaling for the video TRCPeerConnection,
that is why these were not tested
测试 3
RTC_PC_OPTIONS = undefined
CONSTRAINTS = { 'mandatory': { 'OfferToReceiveAudio': true, 'OfferToReceiveVideo': true } }
FFx2FFx FFx2Chrome Chrome2FFx Chrome2Chrome
------- ---------- ---------- -------------
dataChannel setup ok ok ok err [5]
dataChannel send/recv ok ok ok -
Video stream err [6] ok err [6] -
- Chrome 创建报价并将其发送给 FFx,FFx 接收报价,创建答案并将其发送给 chrome,
chrome 收到了答案。但是在firefox中不会触发onaddstream
- chrome收到FFx发送的offer后,在控制台记录错误:
Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set data send codecs..
- Chrome 发送报价,FFx 发送答案,
chrome 收到此错误:Failed to parse SessionDescription. m=application 35224 RTP/SAVPF Expects at least 4 fields.
FFx 收到此错误:ICE failed, see about:webrtc for more details
在about:webrtc:
Local candidate Remote candidate ICE State Priority Nominated Selected
a.b.c.d:35224/udp(host) a.b.c.d:45895/udp(host) frozen 9115005270282354000
- Chrome_1 收到错误:
Uncaught NetworkError: Failed to execute 'send' on 'RTCDataChannel': Could not send data
chrome_2 得到错误:
Uncaught SyntaxError: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': The ICE candidate could not be added.
- 调用者发送offer,被调用者报错:
Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set data send codecs.
- 喜欢 [1] 一切正常,但 onaddstream 未触发
【问题讨论】:
标签: google-chrome firefox webrtc