Procházet zdrojové kódy

fix(TPC): maxBitratesVideo break screenshare

In Chrome, if 'maxBitratesVideo' options are specified
and 'capScreenshareBitrate' is disabled, then simulcast is enabled
for screenshare. Chrome in plan B, does not send screen stream if
'maxBitrate' are set and simulcast is enabled.
dev1
Paweł Domas před 5 roky
rodič
revize
2a6d3a0aea
1 změnil soubory, kde provedl 20 přidání a 9 odebrání
  1. 20
    9
      modules/RTC/TraceablePeerConnection.js

+ 20
- 9
modules/RTC/TraceablePeerConnection.js Zobrazit soubor

@@ -2112,13 +2112,14 @@ TraceablePeerConnection.prototype.setMaxBitRate = function() {
2112 2112
     }
2113 2113
 
2114 2114
     const videoType = localVideoTrack.videoType;
2115
+    const planBScreenSharing = browser.usesPlanB() && videoType === VideoType.DESKTOP;
2115 2116
 
2116 2117
     // Apply the maxbitrates on the video track when one of the conditions is met.
2117 2118
     // 1. Max. bitrates for video are specified through videoQuality settings in config.js
2118 2119
     // 2. Track is a desktop track and bitrate is capped using capScreenshareBitrate option in plan-b mode.
2119 2120
     // 3. The client is running in Unified plan mode.
2120 2121
     if (!((this.options.videoQuality && this.options.videoQuality.maxBitratesVideo)
2121
-        || (browser.usesPlanB() && this.options.capScreenshareBitrate && videoType === VideoType.DESKTOP)
2122
+        || (planBScreenSharing && this.options.capScreenshareBitrate)
2122 2123
         || browser.usesUnifiedPlan())) {
2123 2124
         return Promise.resolve();
2124 2125
     }
@@ -2139,14 +2140,24 @@ TraceablePeerConnection.prototype.setMaxBitRate = function() {
2139 2140
     if (this.isSimulcastOn()) {
2140 2141
         for (const encoding in parameters.encodings) {
2141 2142
             if (parameters.encodings.hasOwnProperty(encoding)) {
2142
-                // On chromium, set a max bitrate of 500 Kbps for screenshare when
2143
-                // capScreenshareBitrate is enabled through config.js and presenter
2144
-                // is not turned on.
2145
-                const bitrate = browser.usesPlanB()
2146
-                    && videoType === VideoType.DESKTOP
2147
-                    && this.options.capScreenshareBitrate
2148
-                    ? presenterEnabled ? this.videoBitrates.high : DESKSTOP_SHARE_RATE
2149
-                    : this.tpcUtils.localStreamEncodingsConfig[encoding].maxBitrate;
2143
+                let bitrate;
2144
+
2145
+                if (planBScreenSharing) {
2146
+                    // On chromium, set a max bitrate of 500 Kbps for screenshare when capScreenshareBitrate
2147
+                    // is enabled through config.js and presenter is not turned on.
2148
+                    // FIXME the top 'isSimulcastOn' condition is confusing for screensharing, because
2149
+                    // if capScreenshareBitrate option is enabled then the simulcast is turned off
2150
+                    bitrate = this.options.capScreenshareBitrate
2151
+                        ? presenterEnabled ? this.videoBitrates.high : DESKSTOP_SHARE_RATE
2152
+
2153
+                        // Remove the bitrate config if not capScreenshareBitrate:
2154
+                        // When switching from camera to desktop and videoQuality.maxBitratesVideo were set,
2155
+                        // then the 'maxBitrate' setting must be cleared, because if simulcast is enabled for screen
2156
+                        // and maxBitrates are set then Chrome will not send the screen stream (plan B).
2157
+                        : undefined;
2158
+                } else {
2159
+                    bitrate = this.tpcUtils.localStreamEncodingsConfig[encoding].maxBitrate;
2160
+                }
2150 2161
 
2151 2162
                 logger.info(`${this} Setting a max bitrate of ${bitrate} bps on layer `
2152 2163
                     + `${this.tpcUtils.localStreamEncodingsConfig[encoding].rid}`);

Načítá se…
Zrušit
Uložit