Преглед на файлове

fix(FF): Don't add recvonly SSRC in session-accept

tags/v0.0.2
Hristo Terezov преди 3 години
родител
ревизия
4cb919e024
променени са 3 файла, в които са добавени 67 реда и са изтрити 3 реда
  1. 39
    1
      modules/RTC/TraceablePeerConnection.js
  2. 23
    2
      modules/sdp/LocalSdpMunger.js
  3. 5
    0
      types/auto/modules/RTC/TraceablePeerConnection.d.ts

+ 39
- 1
modules/RTC/TraceablePeerConnection.js Целия файл

@@ -256,6 +256,19 @@ export default function TraceablePeerConnection(
256 256
     this._usesTransceiverCodecPreferences
257 257
         && logger.info('Using RTCRtpTransceiver#setCodecPreferences for codec selection');
258 258
 
259
+    // We currently need these flags only for FF and that's why we are updating them only for unified plan.
260
+    if (this._usesUnifiedPlan) {
261
+        /**
262
+         * Indicates whether an audio track has ever been added to the peer connection.
263
+         */
264
+        this._hasHadAudioTrack = false;
265
+
266
+        /**
267
+         * Indicates whether a video track has ever been added to the peer connection.
268
+         */
269
+        this._hasHadAudioTrack = false;
270
+    }
271
+
259 272
     /**
260 273
      * @type {number} The max number of stats to keep in this.stats. Limit to
261 274
      * 300 values, i.e. 5 minutes; set to 0 to disable
@@ -1672,6 +1685,13 @@ TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false
1672 1685
         logger.debug(`${this} TPC.addTrack using unified plan`);
1673 1686
         try {
1674 1687
             this.tpcUtils.addTrack(track, isInitiator);
1688
+            if (track) {
1689
+                if (track.isAudioTrack()) {
1690
+                    this._hasHadAudioTrack = true;
1691
+                } else {
1692
+                    this._hasHadVideoTrack = true;
1693
+                }
1694
+            }
1675 1695
         } catch (error) {
1676 1696
             logger.error(`${this} Adding track=${track} failed: ${error?.message}`);
1677 1697
 
@@ -1753,7 +1773,17 @@ TraceablePeerConnection.prototype.addTrackUnmute = function(track) {
1753 1773
     }
1754 1774
 
1755 1775
     if (this._usesUnifiedPlan) {
1756
-        return this.tpcUtils.replaceTrack(null, track).then(() => false);
1776
+        return this.tpcUtils.replaceTrack(null, track).then(() => {
1777
+            if (track) {
1778
+                if (track.isAudioTrack()) {
1779
+                    this._hasHadAudioTrack = true;
1780
+                } else {
1781
+                    this._hasHadVideoTrack = true;
1782
+                }
1783
+            }
1784
+
1785
+            return false;
1786
+        });
1757 1787
     }
1758 1788
 
1759 1789
     this._addStream(webRtcStream);
@@ -1985,6 +2015,14 @@ TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
1985 2015
 
1986 2016
         return promise
1987 2017
             .then(transceiver => {
2018
+                if (newTrack) {
2019
+                    if (newTrack.isAudioTrack()) {
2020
+                        this._hasHadAudioTrack = true;
2021
+                    } else {
2022
+                        this._hasHadVideoTrack = true;
2023
+                    }
2024
+                }
2025
+
1988 2026
                 oldTrack && this.localTracks.delete(oldTrack.rtcId);
1989 2027
                 newTrack && this.localTracks.set(newTrack.rtcId, newTrack);
1990 2028
 

+ 23
- 2
modules/sdp/LocalSdpMunger.js Целия файл

@@ -4,6 +4,7 @@ import { MediaDirection } from '../../service/RTC/MediaDirection';
4 4
 import { MediaType } from '../../service/RTC/MediaType';
5 5
 import { getSourceNameForJitsiTrack } from '../../service/RTC/SignalingLayer';
6 6
 import { VideoType } from '../../service/RTC/VideoType';
7
+import browser from '../browser';
7 8
 import FeatureFlags from '../flags/FeatureFlags';
8 9
 
9 10
 import { SdpTransformWrap } from './SdpTransformUtil';
@@ -245,8 +246,28 @@ export default class LocalSdpMunger {
245 246
             return;
246 247
         }
247 248
 
248
-        // Add the msid attribute if it is missing when the direction is sendrecv/sendonly. Firefox doesn't produce a
249
-        // a=ssrc line with msid attribute for p2p connection.
249
+        const mediaDirection = mediaSection.mLine?.direction;
250
+
251
+        // On FF when the user has started muted create answer will generate a recv only SSRC. We don't want to signal
252
+        // this SSRC in order to reduce the load of the xmpp server for large calls. Therefore the SSRC needs to be
253
+        // removed from the SDP.
254
+        //
255
+        // For all other use cases (when the user has had media but then the user has stopped it) we want to keep the
256
+        // receive only SSRCs in the SDP. Otherwise source-remove will be triggered and the next time the user add a
257
+        // track we will reuse the SSRCs and send source-add with the same SSRCs. This is problematic because of issues
258
+        // on Chrome and FF (https://bugzilla.mozilla.org/show_bug.cgi?id=1768729) when removing and then adding the
259
+        // same SSRC in the remote sdp the remote track is not rendered.
260
+        if (browser.isFirefox()
261
+            && (mediaDirection === MediaDirection.RECVONLY || mediaDirection === MediaDirection.INACTIVE)
262
+            && (
263
+                (mediaType === MediaType.VIDEO && !this.tpc._hadVideoAdded)
264
+                || (mediaType === MediaType.AUDIO && !this.tpc._hadAudioAdded)
265
+            )
266
+        ) {
267
+            mediaSection.ssrcs = undefined;
268
+            mediaSection.ssrcGroups = undefined;
269
+        }
270
+
250 271
         const msidLine = mediaSection.mLine?.msid;
251 272
         const trackId = msidLine && msidLine.split(' ')[1];
252 273
         const sources = [ ...new Set(mediaSection.mLine?.ssrcs?.map(s => s.id)) ];

+ 5
- 0
types/auto/modules/RTC/TraceablePeerConnection.d.ts Целия файл

@@ -229,6 +229,10 @@ export default class TraceablePeerConnection {
229 229
      * munging for codec selection.
230 230
      */
231 231
     _usesTransceiverCodecPreferences: boolean;
232
+    /**
233
+     * Indicates whether an audio track has ever been added to the peer connection.
234
+     */
235
+    _hasHadAudioTrack: boolean;
232 236
     /**
233 237
      * @type {number} The max number of stats to keep in this.stats. Limit to
234 238
      * 300 values, i.e. 5 minutes; set to 0 to disable
@@ -495,6 +499,7 @@ export default class TraceablePeerConnection {
495 499
      * @returns {Promise<void>} - resolved when done.
496 500
      */
497 501
     addTrack(track: any, isInitiator?: boolean): Promise<void>;
502
+    _hasHadVideoTrack: boolean;
498 503
     /**
499 504
      * Adds local track as part of the unmute operation.
500 505
      * @param {JitsiLocalTrack} track the track to be added as part of the unmute operation.

Loading…
Отказ
Запис