Browse Source

fix(TPC) Set maxbitrates via b=AS line on the remote SDP as well.

This fixes an issue where the bitrates for screenshare were much higher than before for VP9 causing the JVB to suspend SS streams more often.
dev1
Jaya Allamsetty 2 years ago
parent
commit
6d5ca18be6

+ 9
- 5
modules/RTC/TraceablePeerConnection.js View File

2359
  * Sets the max bitrates on the video m-lines when VP9 is the selected codec.
2359
  * Sets the max bitrates on the video m-lines when VP9 is the selected codec.
2360
  *
2360
  *
2361
  * @param {RTCSessionDescription} description - The local description that needs to be munged.
2361
  * @param {RTCSessionDescription} description - The local description that needs to be munged.
2362
+ * @param {boolean} isLocalSdp - Whether the max bitrate (via b=AS line in SDP) is set on local SDP.
2362
  * @returns RTCSessionDescription
2363
  * @returns RTCSessionDescription
2363
  */
2364
  */
2364
-TraceablePeerConnection.prototype._setVp9MaxBitrates = function(description) {
2365
+TraceablePeerConnection.prototype._setVp9MaxBitrates = function(description, isLocalSdp = false) {
2365
     if (!this.codecPreference) {
2366
     if (!this.codecPreference) {
2366
         return description;
2367
         return description;
2367
     }
2368
     }
2368
 
2369
 
2369
     const parsedSdp = transform.parse(description.sdp);
2370
     const parsedSdp = transform.parse(description.sdp);
2371
+
2372
+    // Find all the m-lines associated with the local sources.
2373
+    const direction = isLocalSdp ? MediaDirection.RECVONLY : MediaDirection.SENDONLY;
2370
     const mLines = FeatureFlags.isMultiStreamSupportEnabled()
2374
     const mLines = FeatureFlags.isMultiStreamSupportEnabled()
2371
-        ? parsedSdp.media.filter(m => m.type === MediaType.VIDEO && m.direction !== MediaDirection.RECVONLY)
2375
+        ? parsedSdp.media.filter(m => m.type === MediaType.VIDEO && m.direction !== direction)
2372
         : [ parsedSdp.media.find(m => m.type === MediaType.VIDEO) ];
2376
         : [ parsedSdp.media.find(m => m.type === MediaType.VIDEO) ];
2373
 
2377
 
2374
     // Find the mid associated with the desktop track so that bitrates can be configured accordingly on the
2378
     // Find the mid associated with the desktop track so that bitrates can be configured accordingly on the
2393
     };
2397
     };
2394
 
2398
 
2395
     for (const mLine of mLines) {
2399
     for (const mLine of mLines) {
2396
-        if (this.codecPreference.mimeType === CodecMimeType.VP9
2397
-            && this.getConfiguredVideoCodec() === CodecMimeType.VP9) {
2400
+        if (this.codecPreference.mimeType === CodecMimeType.VP9) {
2398
             const bitrates = this.tpcUtils.videoBitrates.VP9 || this.tpcUtils.videoBitrates;
2401
             const bitrates = this.tpcUtils.videoBitrates.VP9 || this.tpcUtils.videoBitrates;
2399
             const hdBitrate = bitrates.high ? bitrates.high : HD_BITRATE;
2402
             const hdBitrate = bitrates.high ? bitrates.high : HD_BITRATE;
2400
             const mid = mLine.mid;
2403
             const mid = mLine.mid;
2470
 
2473
 
2471
     // Munge the order of the codecs based on the preferences set through config.js.
2474
     // Munge the order of the codecs based on the preferences set through config.js.
2472
     localDescription = this._mungeCodecOrder(localDescription);
2475
     localDescription = this._mungeCodecOrder(localDescription);
2473
-    localDescription = this._setVp9MaxBitrates(localDescription);
2476
+    localDescription = this._setVp9MaxBitrates(localDescription, true);
2474
 
2477
 
2475
     this.trace('setLocalDescription::postTransform', dumpSDP(localDescription));
2478
     this.trace('setLocalDescription::postTransform', dumpSDP(localDescription));
2476
 
2479
 
2564
 
2567
 
2565
     // Munge the order of the codecs based on the preferences set through config.js.
2568
     // Munge the order of the codecs based on the preferences set through config.js.
2566
     remoteDescription = this._mungeCodecOrder(remoteDescription);
2569
     remoteDescription = this._mungeCodecOrder(remoteDescription);
2570
+    remoteDescription = this._setVp9MaxBitrates(remoteDescription);
2567
     this.trace('setRemoteDescription::postTransform (munge codec order)', dumpSDP(remoteDescription));
2571
     this.trace('setRemoteDescription::postTransform (munge codec order)', dumpSDP(remoteDescription));
2568
 
2572
 
2569
     return new Promise((resolve, reject) => {
2573
     return new Promise((resolve, reject) => {

+ 2
- 1
types/auto/modules/RTC/TraceablePeerConnection.d.ts View File

656
      * Sets the max bitrates on the video m-lines when VP9 is the selected codec.
656
      * Sets the max bitrates on the video m-lines when VP9 is the selected codec.
657
      *
657
      *
658
      * @param {RTCSessionDescription} description - The local description that needs to be munged.
658
      * @param {RTCSessionDescription} description - The local description that needs to be munged.
659
+     * @param {boolean} isLocalSdp - Whether the max bitrate (via b=AS line in SDP) is set on local SDP.
659
      * @returns RTCSessionDescription
660
      * @returns RTCSessionDescription
660
      */
661
      */
661
-    _setVp9MaxBitrates(description: RTCSessionDescription): RTCSessionDescription;
662
+    _setVp9MaxBitrates(description: RTCSessionDescription, isLocalSdp?: boolean): RTCSessionDescription;
662
     /**
663
     /**
663
      * Configures the stream encodings depending on the video type and the bitrates configured.
664
      * Configures the stream encodings depending on the video type and the bitrates configured.
664
      *
665
      *

Loading…
Cancel
Save