ソースを参照

fix(TPC): Do not configure encodings on chromium immediately after replace track.

Avoid configuring the encodings on chromium immediately after replace track since the encoding params are read-only until the renegotation is done.
release-8443
Jaya Allamsetty 4年前
コミット
59e67c5b93
2個のファイルの変更30行の追加16行の削除
  1. 21
    10
      modules/RTC/TPCUtils.js
  2. 9
    6
      modules/sdp/LocalSdpMunger.js

+ 21
- 10
modules/RTC/TPCUtils.js ファイルの表示

@@ -79,12 +79,19 @@ export class TPCUtils {
79 79
     _findTransceiver(mediaType, localTrack = null) {
80 80
         let transceiver = null;
81 81
 
82
-        if (localTrack) {
83
-            transceiver = this.pc.peerconnection.getTransceivers()
84
-                .find(t => t.sender?.track?.id === localTrack.getTrackId());
85
-        } else if (mediaType) {
82
+        // Check if the local track has been removed from the peerconnection already.
83
+        const trackRemoved = !localTrack
84
+            || (localTrack
85
+                && browser.doesVideoMuteByStreamRemove()
86
+                && localTrack.isVideoTrack()
87
+                && localTrack.isMuted());
88
+
89
+        if (trackRemoved) {
86 90
             transceiver = this.pc.peerconnection.getTransceivers()
87 91
                 .find(t => t.receiver?.track?.kind === mediaType);
92
+        } else if (localTrack) {
93
+            transceiver = this.pc.peerconnection.getTransceivers()
94
+                .find(t => t.sender?.track?.id === localTrack.getTrackId());
88 95
         }
89 96
 
90 97
         return transceiver;
@@ -328,9 +335,7 @@ export class TPCUtils {
328 335
                 return Promise.resolve();
329 336
             }
330 337
 
331
-            const transceiver = oldTrack.isVideoTrack() && browser.doesVideoMuteByStreamRemove && oldTrack.isMuted()
332
-                ? this._findTransceiver(mediaType)
333
-                : this._findTransceiver(mediaType, oldTrack);
338
+            const transceiver = this._findTransceiver(mediaType, oldTrack);
334 339
             const track = newTrack.getTrack();
335 340
 
336 341
             if (!transceiver) {
@@ -368,7 +373,6 @@ export class TPCUtils {
368 373
                 });
369 374
         } else if (newTrack && !oldTrack) {
370 375
             return this.addTrackUnmute(newTrack)
371
-                .then(() => this.setEncodings(newTrack))
372 376
                 .then(() => {
373 377
                     const mediaType = newTrack.getType();
374 378
                     const transceiver = this._findTransceiver(mediaType, newTrack);
@@ -379,8 +383,15 @@ export class TPCUtils {
379 383
                         transceiver.direction = TransceiverDirection.SENDRECV;
380 384
                     }
381 385
 
382
-                    // Add the new track to the list of local tracks.
383
-                    this.pc.localTracks.set(newTrack.rtcId, newTrack);
386
+                    // Avoid configuring the encodings on chromium since the encoding params are read-only
387
+                    // until the renegotation is done after the track is replaced on the sender.
388
+                    const promise = browser.isChromiumBased() ? Promise.resolve() : this.setEncodings(newTrack);
389
+
390
+                    return promise
391
+                        .then(() => {
392
+                            // Add the new track to the list of local tracks.
393
+                            this.pc.localTracks.set(newTrack.rtcId, newTrack);
394
+                        });
384 395
                 });
385 396
         }
386 397
 

+ 9
- 6
modules/sdp/LocalSdpMunger.js ファイルの表示

@@ -239,13 +239,16 @@ export default class LocalSdpMunger {
239 239
             for (const source of sources) {
240 240
                 const msidExists = mediaSection.ssrcs
241 241
                     .find(ssrc => ssrc.id === source && ssrc.attribute === 'msid');
242
-                const generatedMsid = this._generateMsidAttribute(mediaSection.mLine?.type, trackId);
243 242
 
244
-                !msidExists && generatedMsid && mediaSection.ssrcs.push({
245
-                    id: source,
246
-                    attribute: 'msid',
247
-                    value: generatedMsid
248
-                });
243
+                if (!msidExists) {
244
+                    const generatedMsid = this._generateMsidAttribute(mediaSection.mLine?.type, trackId);
245
+
246
+                    mediaSection.ssrcs.push({
247
+                        id: source,
248
+                        attribute: 'msid',
249
+                        value: generatedMsid
250
+                    });
251
+                }
249 252
             }
250 253
         }
251 254
     }

読み込み中…
キャンセル
保存