我正在为局域网构建聊天应用程序。我使用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
)来获得两个浏览器之间的互操作性?
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
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
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收到答案。但onaddstream并没有在firefox中被触发
Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set data send codecs..
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
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.
Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set data send codecs.
答案 0 :(得分:5)
所以,有一些事情:
尝试使用FF Beta和Nightly(http://nightly.mozilla.org/)。当您报告此类内容时,请说明您正在使用的浏览器版本! : - )