瀏覽代碼

fix(TPCUtils): Re-use the existing recv-only transceiver for secondary video tracks.

Fixes cases where SS fails in multi-stream mode with p2p->jvb->p2p switching.
dev1
Jaya Allamsetty 2 年之前
父節點
當前提交
62b0e5c426
共有 2 個檔案被更改,包括 24 行新增11 行删除
  1. 13
    7
      modules/RTC/TPCUtils.js
  2. 11
    4
      modules/xmpp/JingleSessionPC.js

+ 13
- 7
modules/RTC/TPCUtils.js 查看文件

@@ -376,7 +376,10 @@ export class TPCUtils {
376 376
             transceiver = this.pc.peerconnection.getTransceivers().find(
377 377
                 t => t.receiver.track.kind === mediaType
378 378
                 && t.direction === MediaDirection.RECVONLY
379
-                && t.currentDirection === MediaDirection.INACTIVE);
379
+
380
+                // Re-use any existing recvonly transceiver (if available) for p2p case.
381
+                && ((this.pc.isP2P && t.currentDirection === MediaDirection.RECVONLY)
382
+                    || t.currentDirection === MediaDirection.INACTIVE));
380 383
 
381 384
         // For mute/unmute operations, find the transceiver based on the track index in the source name if present,
382 385
         // otherwise it is assumed to be the first local track that was added to the peerconnection.
@@ -387,17 +390,20 @@ export class TPCUtils {
387 390
             if (sourceName) {
388 391
                 const trackIndex = Number(sourceName.split('-')[1].substring(1));
389 392
 
390
-                if (trackIndex) {
391
-                    transceiver = this.pc.isP2P
392
-                        ? this.pc.peerconnection.getTransceivers()
393
-                            .filter(t => t.receiver.track.kind === mediaType)[trackIndex]
394
-                        : this.pc.peerconnection.getTransceivers()
393
+                if (this.pc.isP2P) {
394
+                    transceiver = this.pc.peerconnection.getTransceivers()
395
+                        .filter(t => t.receiver.track.kind === mediaType)[trackIndex];
396
+                } else if (oldTrack) {
397
+                    const transceiverMid = this.pc._localTrackTransceiverMids.get(oldTrack.rtcId);
398
+
399
+                    transceiver = this.pc.peerconnection.getTransceivers().find(t => t.mid === transceiverMid);
400
+                } else if (trackIndex) {
401
+                    transceiver = this.pc.peerconnection.getTransceivers()
395 402
                             .filter(t => t.receiver.track.kind === mediaType
396 403
                                 && t.direction !== MediaDirection.RECVONLY)[trackIndex];
397 404
                 }
398 405
             }
399 406
         }
400
-
401 407
         if (!transceiver) {
402 408
             return Promise.reject(new Error('replace track failed'));
403 409
         }

+ 11
- 4
modules/xmpp/JingleSessionPC.js 查看文件

@@ -636,7 +636,6 @@ export default class JingleSessionPC extends JingleSession {
636 636
             const remoteDescription = this.peerconnection.remoteDescription;
637 637
 
638 638
             if (this.usesUnifiedPlan
639
-                && !this.isP2P
640 639
                 && state === 'stable'
641 640
                 && remoteDescription
642 641
                 && typeof remoteDescription.sdp === 'string') {
@@ -2122,10 +2121,18 @@ export default class JingleSessionPC extends JingleSession {
2122 2121
         const workFunction = finishedCallback => {
2123 2122
             const oldLocalSDP = new SDP(this.peerconnection.localDescription.sdp);
2124 2123
             const remoteSdp = new SDP(this.peerconnection.peerconnection.remoteDescription.sdp);
2125
-
2126
-            // Add transceivers by adding a new mline in the remote description for each track.
2124
+            const recvOnlyTransceiver = this.peerconnection.peerconnection.getTransceivers()
2125
+                    .find(t => t.receiver.track.kind === MediaType.VIDEO
2126
+                        && t.direction === MediaDirection.RECVONLY
2127
+                        && t.currentDirection === MediaDirection.RECVONLY);
2128
+
2129
+            // Add transceivers by adding a new mline in the remote description for each track. Do not create a new
2130
+            // m-line if a recv-only transceiver exists in the p2p case. The new track will be attached to the
2131
+            // existing one in that case.
2127 2132
             for (const track of localTracks) {
2128
-                remoteSdp.addMlineForNewLocalSource(track.getType());
2133
+                if (!this.isP2P || !recvOnlyTransceiver) {
2134
+                    remoteSdp.addMlineForNewLocalSource(track.getType());
2135
+                }
2129 2136
             }
2130 2137
 
2131 2138
             const remoteDescription = new RTCSessionDescription({

Loading…
取消
儲存