Bladeren bron

fix(SDP): Reset sources to MSID map for plan-b clients.

When source-name signaling is enabbled on plan-b clients, the sources to MSID map needs to be cleared after every transformation since browser in plan-b mode produces a new set of SSRCs and trackID when a track is removed and new track is added to the peerconnection. This fixes an issue where the track index in the source-name gets incremented after a track replace operation.
dev1
Jaya Allamsetty 2 jaren geleden
bovenliggende
commit
d5c469527b

+ 0
- 1
modules/RTC/TraceablePeerConnection.js Bestand weergeven

@@ -1189,7 +1189,6 @@ TraceablePeerConnection.prototype._extractSSRCMap = function(desc) {
1189 1189
         if (FeatureFlags.isMultiStreamSupportEnabled()) {
1190 1190
             media = media.filter(mline => mline.direction === MediaDirection.SENDONLY
1191 1191
                 || mline.direction === MediaDirection.SENDRECV);
1192
-            logger.warn(`local m-lines is ${media.length}`);
1193 1192
         } else {
1194 1193
             media = [];
1195 1194
             [ MediaType.AUDIO, MediaType.VIDEO ].forEach(mediaType => {

+ 7
- 0
modules/sdp/LocalSdpMunger.js Bestand weergeven

@@ -343,6 +343,13 @@ export default class LocalSdpMunger {
343 343
             this._injectSourceNames(videoMLine);
344 344
         }
345 345
 
346
+        // Plan-b clients generate new SSRCs and trackIds whenever tracks are removed and added back to the
347
+        // peerconnection, therefore local track based map for msids needs to be reset after every transformation.
348
+        if (FeatureFlags.isSourceNameSignalingEnabled() && !this.tpc._usesUnifiedPlan) {
349
+            this.audioSourcesToMsidMap.clear();
350
+            this.videoSourcesToMsidMap.clear();
351
+        }
352
+
346 353
         return new RTCSessionDescription({
347 354
             type: sessionDesc.type,
348 355
             sdp: transformer.toRawSDP()

+ 37
- 0
modules/sdp/LocalSdpMunger.spec.js Bestand weergeven

@@ -201,3 +201,40 @@ describe('Transform msids for source-name signaling', () => {
201 201
         expect(videoMsid).toBe('sRdpsdg-video-0-1');
202 202
     });
203 203
 });
204
+
205
+describe('Track replace operations in plan-b', () => {
206
+    const tpc = new MockPeerConnection('1', false);
207
+    const localEndpointId = 'sRdpsdg';
208
+    let desc, newSdp, sdpStr, transformedDesc, videoMsid, videoMsidLine;
209
+    const localSdpMunger = new LocalSdpMunger(tpc, localEndpointId);
210
+
211
+    it('should not increment track index for new tracks', () => {
212
+        FeatureFlags.init({ sourceNameSignaling: true });
213
+
214
+        sdpStr = transform.write(SampleSdpStrings.simulcastRtxSdp);
215
+        desc = new RTCSessionDescription({
216
+            type: 'offer',
217
+            sdp: sdpStr
218
+        });
219
+        transformedDesc = localSdpMunger.transformStreamIdentifiers(desc);
220
+        newSdp = transform.parse(transformedDesc.sdp);
221
+
222
+        videoMsidLine = getSsrcLines(newSdp, 'video').find(ssrc => ssrc.attribute === 'msid')?.value;
223
+        videoMsid = videoMsidLine.split(' ')[0];
224
+
225
+        expect(videoMsid).toBe('sRdpsdg-video-0-1');
226
+
227
+        sdpStr = transform.write(SampleSdpStrings.simulcastRtxSdpReplacedTrack);
228
+        desc = new RTCSessionDescription({
229
+            type: 'offer',
230
+            sdp: sdpStr
231
+        });
232
+        transformedDesc = localSdpMunger.transformStreamIdentifiers(desc);
233
+        newSdp = transform.parse(transformedDesc.sdp);
234
+
235
+        videoMsidLine = getSsrcLines(newSdp, 'video').find(ssrc => ssrc.attribute === 'msid')?.value;
236
+        videoMsid = videoMsidLine.split(' ')[0];
237
+
238
+        expect(videoMsid).toBe('sRdpsdg-video-0-1');
239
+    });
240
+});

+ 42
- 0
modules/sdp/SampleSdpStrings.js Bestand weergeven

@@ -207,6 +207,41 @@ const simulcastRtxVideoMLineSdp = ''
207 207
 + 'a=ssrc-group:SIM 1757014965 1479742055 1089111804\r\n'
208 208
 + 'a=rtcp-mux\r\n';
209 209
 
210
+const simulcastRtxVideoMLineSdpReplacedTrack = ''
211
++ 'm=video 9 RTP/SAVPF 100 96\r\n'
212
++ 'c=IN IP4 0.0.0.0\r\n'
213
++ 'a=rtpmap:100 VP8/90000\r\n'
214
++ 'a=fmtp:96 apt=100\r\n'
215
++ 'a=rtcp:9 IN IP4 0.0.0.0\r\n'
216
++ 'a=rtcp-fb:100 ccm fir\r\n'
217
++ 'a=rtcp-fb:100 nack\r\n'
218
++ 'a=rtcp-fb:100 nack pli\r\n'
219
++ 'a=rtcp-fb:100 goog-remb\r\n'
220
++ 'a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\n'
221
++ 'a=setup:passive\r\n'
222
++ 'a=mid:video\r\n'
223
++ 'a=sendonly\r\n'
224
++ 'a=ice-ufrag:adPg\r\n'
225
++ 'a=ice-pwd:Xsr05Mq8S7CR44DAnusZE26F\r\n'
226
++ 'a=fingerprint:sha-256 6A:39:DE:11:24:AD:2E:4E:63:D6:69:D3:85:05:53:C7:3C:38:A4:B7:91:74:C0:91:44:FC:94:63:7F:01:AB:A9\r\n'
227
++ 'a=ssrc:1234567890 msid:0836cc8e-a7bb-47e9-affb-0599414bc56d abcdesfgh\r\n'
228
++ 'a=ssrc:1234567890 cname:peDGrDD6WsxUOki/\r\n'
229
++ 'a=ssrc:2345678901 msid:0836cc8e-a7bb-47e9-affb-0599414bc56d abcdesfgh\r\n'
230
++ 'a=ssrc:2345678901 cname:peDGrDD6WsxUOki/\r\n'
231
++ 'a=ssrc:3456789012 msid:0836cc8e-a7bb-47e9-affb-0599414bc56d abcdesfgh\r\n'
232
++ 'a=ssrc:3456789012 cname:peDGrDD6WsxUOki/\r\n'
233
++ 'a=ssrc:4567890123 msid:0836cc8e-a7bb-47e9-affb-0599414bc56d abcdesfgh\r\n'
234
++ 'a=ssrc:4567890123 cname:peDGrDD6WsxUOki/\r\n'
235
++ 'a=ssrc:5678901234 msid:0836cc8e-a7bb-47e9-affb-0599414bc56d abcdesfgh\r\n'
236
++ 'a=ssrc:5678901234 cname:peDGrDD6WsxUOki/\r\n'
237
++ 'a=ssrc:6789012345 msid:0836cc8e-a7bb-47e9-affb-0599414bc56d abcdesfgh\r\n'
238
++ 'a=ssrc:6789012345 cname:peDGrDD6WsxUOki/\r\n'
239
++ 'a=ssrc-group:FID 1234567890 2345678901\r\n'
240
++ 'a=ssrc-group:FID 3456789012 4567890123\r\n'
241
++ 'a=ssrc-group:FID 5678901234 6789012345\r\n'
242
++ 'a=ssrc-group:SIM 1757014965 3456789012 5678901234\r\n'
243
++ 'a=rtcp-mux\r\n';
244
+
210 245
 // An sdp video mline with 1 video ssrc, 1 video rtx ssrc and one flexfec ssrc
211 246
 const flexFecVideoMLineSdp = ''
212 247
 + 'm=video 9 RTP/SAVPF 100 107 101 96 99 97 109\r\n'
@@ -406,6 +441,9 @@ const simulcastNoRtxSdpStr = baseSessionSdp + baseAudioMLineSdp + simulcastVideo
406 441
 // A full sdp string representing a client doing simulcast and rtx
407 442
 const simulcastRtxSdpStr = baseSessionSdp + baseAudioMLineSdp + simulcastRtxVideoMLineSdp + baseDataMLineSdp;
408 443
 
444
+// A full sdp string representing a client doing simulcast and rtx with a different track and SSRCs.
445
+const simulcastRtxSdpTrackReplaced = baseSessionSdp + baseAudioMLineSdp + simulcastRtxVideoMLineSdpReplacedTrack;
446
+
409 447
 // A full sdp string representing a client doing a single video stream
410 448
 const plainVideoSdpStr = baseSessionSdp + baseAudioMLineSdp + plainVideoMLineSdp + baseDataMLineSdp;
411 449
 
@@ -440,6 +478,10 @@ export default {
440 478
         return transform.parse(simulcastRtxSdpStr);
441 479
     },
442 480
 
481
+    get simulcastRtxSdpReplacedTrack() {
482
+        return transform.parse(simulcastRtxSdpTrackReplaced);
483
+    },
484
+
443 485
     get plainVideoSdp() {
444 486
         return transform.parse(plainVideoSdpStr);
445 487
     },

Laden…
Annuleren
Opslaan