Bläddra i källkod

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 år sedan
förälder
incheckning
62b0e5c426
2 ändrade filer med 24 tillägg och 11 borttagningar
  1. 13
    7
      modules/RTC/TPCUtils.js
  2. 11
    4
      modules/xmpp/JingleSessionPC.js

+ 13
- 7
modules/RTC/TPCUtils.js Visa fil

376
             transceiver = this.pc.peerconnection.getTransceivers().find(
376
             transceiver = this.pc.peerconnection.getTransceivers().find(
377
                 t => t.receiver.track.kind === mediaType
377
                 t => t.receiver.track.kind === mediaType
378
                 && t.direction === MediaDirection.RECVONLY
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
         // For mute/unmute operations, find the transceiver based on the track index in the source name if present,
384
         // For mute/unmute operations, find the transceiver based on the track index in the source name if present,
382
         // otherwise it is assumed to be the first local track that was added to the peerconnection.
385
         // otherwise it is assumed to be the first local track that was added to the peerconnection.
387
             if (sourceName) {
390
             if (sourceName) {
388
                 const trackIndex = Number(sourceName.split('-')[1].substring(1));
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
                             .filter(t => t.receiver.track.kind === mediaType
402
                             .filter(t => t.receiver.track.kind === mediaType
396
                                 && t.direction !== MediaDirection.RECVONLY)[trackIndex];
403
                                 && t.direction !== MediaDirection.RECVONLY)[trackIndex];
397
                 }
404
                 }
398
             }
405
             }
399
         }
406
         }
400
-
401
         if (!transceiver) {
407
         if (!transceiver) {
402
             return Promise.reject(new Error('replace track failed'));
408
             return Promise.reject(new Error('replace track failed'));
403
         }
409
         }

+ 11
- 4
modules/xmpp/JingleSessionPC.js Visa fil

636
             const remoteDescription = this.peerconnection.remoteDescription;
636
             const remoteDescription = this.peerconnection.remoteDescription;
637
 
637
 
638
             if (this.usesUnifiedPlan
638
             if (this.usesUnifiedPlan
639
-                && !this.isP2P
640
                 && state === 'stable'
639
                 && state === 'stable'
641
                 && remoteDescription
640
                 && remoteDescription
642
                 && typeof remoteDescription.sdp === 'string') {
641
                 && typeof remoteDescription.sdp === 'string') {
2122
         const workFunction = finishedCallback => {
2121
         const workFunction = finishedCallback => {
2123
             const oldLocalSDP = new SDP(this.peerconnection.localDescription.sdp);
2122
             const oldLocalSDP = new SDP(this.peerconnection.localDescription.sdp);
2124
             const remoteSdp = new SDP(this.peerconnection.peerconnection.remoteDescription.sdp);
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
             for (const track of localTracks) {
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
             const remoteDescription = new RTCSessionDescription({
2138
             const remoteDescription = new RTCSessionDescription({

Laddar…
Avbryt
Spara