浏览代码

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 5 年前
父节点
当前提交
2a6d3a0aea
共有 1 个文件被更改,包括 20 次插入9 次删除
  1. 20
    9
      modules/RTC/TraceablePeerConnection.js

+ 20
- 9
modules/RTC/TraceablePeerConnection.js 查看文件

2112
     }
2112
     }
2113
 
2113
 
2114
     const videoType = localVideoTrack.videoType;
2114
     const videoType = localVideoTrack.videoType;
2115
+    const planBScreenSharing = browser.usesPlanB() && videoType === VideoType.DESKTOP;
2115
 
2116
 
2116
     // Apply the maxbitrates on the video track when one of the conditions is met.
2117
     // Apply the maxbitrates on the video track when one of the conditions is met.
2117
     // 1. Max. bitrates for video are specified through videoQuality settings in config.js
2118
     // 1. Max. bitrates for video are specified through videoQuality settings in config.js
2118
     // 2. Track is a desktop track and bitrate is capped using capScreenshareBitrate option in plan-b mode.
2119
     // 2. Track is a desktop track and bitrate is capped using capScreenshareBitrate option in plan-b mode.
2119
     // 3. The client is running in Unified plan mode.
2120
     // 3. The client is running in Unified plan mode.
2120
     if (!((this.options.videoQuality && this.options.videoQuality.maxBitratesVideo)
2121
     if (!((this.options.videoQuality && this.options.videoQuality.maxBitratesVideo)
2121
-        || (browser.usesPlanB() && this.options.capScreenshareBitrate && videoType === VideoType.DESKTOP)
2122
+        || (planBScreenSharing && this.options.capScreenshareBitrate)
2122
         || browser.usesUnifiedPlan())) {
2123
         || browser.usesUnifiedPlan())) {
2123
         return Promise.resolve();
2124
         return Promise.resolve();
2124
     }
2125
     }
2139
     if (this.isSimulcastOn()) {
2140
     if (this.isSimulcastOn()) {
2140
         for (const encoding in parameters.encodings) {
2141
         for (const encoding in parameters.encodings) {
2141
             if (parameters.encodings.hasOwnProperty(encoding)) {
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
                 logger.info(`${this} Setting a max bitrate of ${bitrate} bps on layer `
2162
                 logger.info(`${this} Setting a max bitrate of ${bitrate} bps on layer `
2152
                     + `${this.tpcUtils.localStreamEncodingsConfig[encoding].rid}`);
2163
                     + `${this.tpcUtils.localStreamEncodingsConfig[encoding].rid}`);

正在加载...
取消
保存