Problem: notSetRemoteDescription error on phone browsers

107 views
Skip to first unread message

Javier Inh

unread,
Mar 31, 2020, 12:01:59 PM3/31/20
to Ant Media Server
Hello, 

As I found in webrtc_adaptor.js code:

/**
                        * This error generally occurs in codec incompatibility.
                        * AMS for a now supports H.264 codec. This error happens when some browsers try to open it from VP8.
*/

So I modified webrtc_adaptor.js to remove VP8 and VP9 video codecs in webrtc sdp:

this.startPublishing = function(idOfStream) {
var streamId = idOfStream;

thiz.initPeerConnection(streamId);

thiz.remotePeerConnection[streamId].createOffer(thiz.sdp_constraints)
.then(function(configuration) {
//CLOUDAWS
configuration.sdp = thiz.removeCodec(configuration.sdp, 'VP8'); //Function to modify the sdp
configuration.sdp = thiz.removeCodec(configuration.sdp, 'VP9'); //Function to modify the sdp
//////
thiz.gotDescription(configuration, streamId);
})
.catch(function (error) {
console.error("create offer error for stream id: " + streamId + " error: " + error);
});
};
//CLOUDAWS
this.removeCodec = function(orgsdp, codec) {
var internalFunc = function(sdp) {
var codecre = new RegExp('(a=rtpmap:(\\d*) ' + codec + '\/90000\\r\\n)');
var rtpmaps = sdp.match(codecre);
if (rtpmaps == null || rtpmaps.length <= 2) {
console.log ("CODEC CLOUDAWS " + sdp);
return sdp;
}
var rtpmap = rtpmaps[2];
// var modsdp = sdp.replace(codecre, "");​
var modsdp = sdp.replace(codecre, "");
var rtcpre = new RegExp('(a=rtcp-fb:' + rtpmap + '.*\r\n)', 'g');
//  modsdp = modsdp.replace(rtcpre, "");​
modsdp = modsdp.replace(rtcpre, "");
var fmtpre = new RegExp('(a=fmtp:' + rtpmap + '.*\r\n)', 'g');
//    modsdp = modsdp.replace(fmtpre, "");​
modsdp = modsdp.replace(fmtpre, "");
var aptpre = new RegExp('(a=fmtp:(\\d*) apt=' + rtpmap + '\\r\\n)');
var aptmaps = modsdp.match(aptpre);
var fmtpmap = "";
if (aptmaps != null && aptmaps.length >= 3) {
fmtpmap = aptmaps[2];
// modsdp = modsdp.replace(aptpre, "");​
modsdp = modsdp.replace(aptpre, "");
var rtppre = new RegExp('(a=rtpmap:' + fmtpmap + '.*\r\n)', 'g');
modsdp = modsdp.replace(rtppre, "");
}
var videore = /(m=video.*\r\n)/;
var videolines = modsdp.match(videore);
if (videolines != null) {
//If many m=video are found in SDP, this program doesn't work.
var videoline = videolines[0].substring(0, videolines[0].length - 2);
var videoelem = videoline.split(" ");
var modvideoline = videoelem[0];
for (var i = 1; i < videoelem.length; i++) {
if (videoelem[i] == rtpmap || videoelem[i] == fmtpmap) {
continue;
}
modvideoline += " " + videoelem[i];
}
modvideoline += "\r\n";
modsdp = modsdp.replace(videore, modvideoline);
}
return internalFunc(modsdp);
};
return internalFunc(orgsdp);
}

With these code I achieved to remove codecs. Resulting offer:

v=0
o=- 1336756143568039701 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=msid-semantic: WMS gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:oQ6v
a=ice-pwd:eSGvCPCWa02NccxozCLAQfcN
a=ice-options:trickle
a=fingerprint:sha-256 92:F6:E1:EE:65:F5:83:0B:CA:4C:6E:FA:1D:F9:93:38:7B:8E:21:69:6F:08:06:26:C8:EE:F4:0D:E7:3D:F3:A4
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun 88f3d4d2-4ee7-42a1-a4e7-a49425dfa5aa
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:3330065160 cname:qBHnNONNLZ0u/GEQ
a=ssrc:3330065160 msid:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun 88f3d4d2-4ee7-42a1-a4e7-a49425dfa5aa
a=ssrc:3330065160 mslabel:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun
a=ssrc:3330065160 label:88f3d4d2-4ee7-42a1-a4e7-a49425dfa5aa
m=video 9 UDP/TLS/RTP/SAVPF 102 122 127 121 125 107 108 109 124 120 123 119 114 115 116
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:oQ6v
a=ice-pwd:eSGvCPCWa02NccxozCLAQfcN
a=ice-options:trickle
a=fingerprint:sha-256 92:F6:E1:EE:65:F5:83:0B:CA:4C:6E:FA:1D:F9:93:38:7B:8E:21:69:6F:08:06:26:C8:EE:F4:0D:E7:3D:F3:A4
a=setup:actpass
a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:13 urn:3gpp:video-orientation
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun 1875d522-7c14-4044-9540-244f2ac19f71
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 transport-cc
a=rtcp-fb:102 ccm fir
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=rtpmap:122 rtx/90000
a=fmtp:122 apt=102
a=rtpmap:127 H264/90000
a=rtcp-fb:127 goog-remb
a=rtcp-fb:127 transport-cc
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=rtpmap:121 rtx/90000
a=fmtp:121 apt=127
a=rtpmap:125 H264/90000
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 transport-cc
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:107 rtx/90000
a=fmtp:107 apt=125
a=rtpmap:108 H264/90000
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 transport-cc
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108
a=rtpmap:124 H264/90000
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 transport-cc
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=124
a=rtpmap:123 H264/90000
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 transport-cc
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032
a=rtpmap:119 rtx/90000
a=fmtp:119 apt=123
a=rtpmap:114 red/90000
a=rtpmap:115 rtx/90000
a=fmtp:115 apt=114
a=rtpmap:116 ulpfec/90000
a=ssrc-group:FID 1760319672 3497816362
a=ssrc:1760319672 cname:qBHnNONNLZ0u/GEQ
a=ssrc:1760319672 msid:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun 1875d522-7c14-4044-9540-244f2ac19f71
a=ssrc:1760319672 mslabel:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun
a=ssrc:1760319672 label:1875d522-7c14-4044-9540-244f2ac19f71
a=ssrc:3497816362 cname:qBHnNONNLZ0u/GEQ
a=ssrc:3497816362 msid:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun 1875d522-7c14-4044-9540-244f2ac19f71
a=ssrc:3497816362 mslabel:gEowYlm5gIr0TcLmrHg9tD50DYRWSRYCRvun
a=ssrc:3497816362 label:1875d522-7c14-4044-9540-244f2ac19f71


BUT:

I´m still having notSetRemoteDescription error on phone browsers

Any idea how to resolve this problem?

I´m not developer so I don't have enough knowlement about.

mahmut asım Onat

unread,
Apr 1, 2020, 9:59:54 AM4/1/20
to Ant Media Server
Hi,

Can you check whether your browser supports H.264 from this link: "https://mozilla.github.io/webrtc-landing/pc_test_no_h264.html"

Best,
Asim

Javier Inh

unread,
Apr 1, 2020, 11:22:26 AM4/1/20
to Ant Media Server
Hi,

Test failed, tested in two phones...

So I don´t understand why Webrtc demo is working (I can stream) in the two same smartphones H.264 is not present: https://webrtc.github.io/samples/src/content/peerconnection/pc1/

Any idea who can I achieve Webrtc streaming from phones (Android 9/10) with Ant Media?

I tested other Webrtc solutions and them works ok.

Thanks.

Marco Schiattarella

unread,
Apr 16, 2020, 5:12:21 AM4/16/20
to Ant Media Server
did you find a solutions? i'm having the same problem!

Javier Inh

unread,
Apr 16, 2020, 12:07:23 PM4/16/20
to Ant Media Server
No, the only option for me has been to use other streaming solution.

Marco Schiattarella

unread,
Apr 16, 2020, 12:42:32 PM4/16/20
to Ant Media Server
i'm doing the same, thank you
Reply all
Reply to author
Forward
0 new messages