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

feat: Add the ability to configure max. bitrates for VP9.

The max bitrate for VP9 is enforced by adding the b=AS:<limit> line in the SDP since there is no way to configure the max. bitrates for the individual SVC streams using RTCRtpSender.setParameters.
dev1
Jaya Allamsetty преди 4 години
родител
ревизия
21d5178775
променени са 2 файла, в които са добавени 19 реда и са изтрити 4 реда
  1. 1
    1
      modules/RTC/TPCUtils.js
  2. 18
    3
      modules/RTC/TraceablePeerConnection.js

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

@@ -26,7 +26,7 @@ export class TPCUtils {
26 26
      */
27 27
     constructor(peerconnection, videoBitrates) {
28 28
         this.pc = peerconnection;
29
-        this.videoBitrates = videoBitrates;
29
+        this.videoBitrates = videoBitrates.VP8 || videoBitrates;
30 30
 
31 31
         /**
32 32
          * The startup configuration for the stream encodings that are applicable to

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

@@ -1521,6 +1521,21 @@ TraceablePeerConnection.prototype._mungeCodecOrder = function(description) {
1521 1521
         if (this.codecPreference.mimeType === CodecMimeType.H264 && browser.isReactNative() && this.isP2P) {
1522 1522
             SDPUtil.stripCodec(mLine, this.codecPreference.mimeType, true /* high profile */);
1523 1523
         }
1524
+
1525
+        // Set the max bitrate here on the SDP so that the configured max. bitrate is effective
1526
+        // as soon as the browser switches to VP9.
1527
+        if (this.codecPreference.mimeType === CodecMimeType.VP9) {
1528
+            const bitrates = Object.values(this.videoBitrates.VP9 || this.videoBitrates);
1529
+            const localVideoTrack = this.getLocalVideoTrack();
1530
+            const isSharingScreen = localVideoTrack && localVideoTrack.videoType === VideoType.DESKTOP;
1531
+
1532
+            // Use only the HD bitrate for now as there is no API available yet for configuring
1533
+            // the bitrates on the individual SVC layers.
1534
+            mLine.bandwidth = [ {
1535
+                type: 'AS',
1536
+                limit: isSharingScreen ? HD_BITRATE : Math.floor(bitrates[2] / 1000)
1537
+            } ];
1538
+        }
1524 1539
     } else {
1525 1540
         SDPUtil.stripCodec(mLine, this.codecPreference.mimeType);
1526 1541
     }
@@ -2119,9 +2134,9 @@ TraceablePeerConnection.prototype.setSenderVideoDegradationPreference = function
2119 2134
  * @returns {Promise<void>}
2120 2135
  */
2121 2136
 TraceablePeerConnection.prototype.setMaxBitRate = function() {
2122
-    if (!this.peerconnection.getSenders) {
2123
-        logger.debug('Browser doesn\'t support RTCRtpSender');
2124
-
2137
+    // For VP9, max bitrate is configured by setting b=AS value in SDP. Browsers do
2138
+    // not yet support setting max bitrates for individual VP9 SVC layers.
2139
+    if (this.getConfiguredVideoCodec() === CodecMimeType.VP9 || !window.RTCRtpSender) {
2125 2140
         return Promise.resolve();
2126 2141
     }
2127 2142
     const localVideoTrack = this.getLocalVideoTrack();

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