firefoxwebrtcturnjanus-gateway

WebRTC live stream(H264) error in Firefox, can't generate valid SDP answer


I am trying to run H264 encoded live stream in Web Browser using Janus WebRTC Gateway. While testing with Chrome, the stream works fine but with firefox it shows ICE failed, add a TURN server and see about:webrtc for more details.

Following is my about:webrtc logs for firefox.

[ 6442450983 ] http://192.168.2.194:5000/ 15:18:19 GMT+0530 (IST)
PeerConnection ID: 1515491295667117 (id=6442450983 url=http://192.168.2.194:5000/)
ICE Stats
Local Candidate Remote Candidate    ICE State   Priority    Nominated   Selected    Bytes sent  Bytes received
ICE restarts:
ICE rollbacks:
SDP
Local SDP

v=0

o=mozilla...THIS_IS_SDPARTA-57.0.4 3500649212029345392 0 IN IP4 0.0.0.0

s=-

t=0 0

a=sendrecv

a=fingerprint:sha-256 11:44:F1:BD:D1:69:8E:17:E0:9A:AA:89:8E:76:9F:4E:09:E1:94:D0:37:34:EE:FE:DF:5E:FC:77:B0:4D:F7:53

a=ice-options:trickle

a=msid-semantic:WMS *

m=video 0 RTP/SAVPF 120

c=IN IP4 0.0.0.0

a=inactive

a=end-of-candidates

a=mid:video

a=rtpmap:120 VP8/90000

Remote SDP

v=0

o=- 1515491295396595 1515491295396595 IN IP4 106.51.68.195

s=-

t=0 0

a=sendrecv

a=group:BUNDLE video

a=msid-semantic:WMS janus

m=video 9 RTP/SAVPF 126

c=IN IP4 106.51.68.195

a=candidate:1 1 udp 2013266431 192.168.2.194 45887 typ host

a=candidate:2 1 udp 1677722111 106.51.68.195 45887 typ srflx raddr 192.168.2.194 rport 45887

a=sendonly

a=end-of-candidates

a=fingerprint:sha-256 D2:B9:31:8F:DF:24:D8:0E:ED:D2:EF:25:9E:AF:6F:B8:34:AE:53:9C:E6:F3:8F:F2:64:15:FA:E8:7F:53:2D:38

a=ice-options:trickle

a=ice-pwd:KsS99rsAZXj9lFd7psCT61

a=ice-ufrag:3tcw

a=mid:video

a=rtcp-fb:126 nack

a=rtcp-fb:126 goog-remb

a=rtcp-mux

a=rtpmap:126 H264/90000

a=setup:actpass

a=ssrc:3973486276 cname:janusvideo

a=ssrc:3973486276 msid:janus janusv0

a=ssrc:3973486276 mslabel:janus

a=ssrc:3973486276 label:janusv0

RTP Stats

I even tried adding following TURN Server

{urls: "turn:numb.viagenie.ca",
 username: "l1787875@mvrht.com",
 credential: "test"}

But the console error changes to ICE failed, your TURN server appears to be broken, see about:webrtc for more details, Keeping the about:webrtc logs same as before.

I figured out that somehow Firefox can't generate a valid answer for SDP offer generated by Janus. Created answer by Firefox has attribute rtpmap: 120 VP8/90000, whereas SDP offer made by Janus has attribute rtpmap: 127 H264/90000, which prevent Firefox to establish a SDP session with Janus. Chrome can generate the valid answer with rtpmap: 127 H264/90000 so it can display the stream perfectly.

I am using Mozilla firefox-57.0.4. Is there a way, I can get/ generate a valid SDP answer for incoming SDP offer from Janus?


Solution

  • This solution worked for me (last yellow message): https://groups.google.com/forum/#!topic/meetecho-janus/jKg5u9421kM

    I'm using Janus and I was getting the same error in Firefox. The problem was about the SDP profile-level-id. I just had to replace it:

                // Create offer/answer now
                 if(jsep === null || jsep === undefined) {
                         createOffer(handleId, media, callbacks);
                 } else {
                         if(adapter.browserDetails.browser === "edge") {
                                 // This is Edge, add an a=end-of-candidates at the end
                                 jsep.sdp += "a=end-of-candidates\r\n";
                         }
                         var oldsdp = jsep["sdp"];
                         var pattern=/420029/gi;
                         var newsdp = oldsdp.replace(pattern,"42e01f");
                         Janus.log(newsdp);
                         jsep["sdp"]=newsdp;
                         config.pc.setRemoteDescription(
                                         new RTCSessionDescription(jsep),
                                         function() {
                                                 Janus.log("Remote description accepted!");
                                                 createAnswer(handleId, media, callbacks);
                                         }, callbacks.error);
                 }
         }