瀏覽代碼

fix: Implement the encodings workaround only on Safari.

Explicitly check if all the encodings report the same scaleResolutionDownBy value before trying to ensure they match the expected values. This makes Chrome VP9 work again.
dev1
Jaya Allamsetty 4 年之前
父節點
當前提交
10e2fe3fec
共有 1 個文件被更改,包括 11 次插入14 次删除
  1. 11
    14
      modules/RTC/TPCUtils.js

+ 11
- 14
modules/RTC/TPCUtils.js 查看文件

3
 
3
 
4
 import * as MediaType from '../../service/RTC/MediaType';
4
 import * as MediaType from '../../service/RTC/MediaType';
5
 import RTCEvents from '../../service/RTC/RTCEvents';
5
 import RTCEvents from '../../service/RTC/RTCEvents';
6
-import VideoType from '../../service/RTC/VideoType';
7
 import browser from '../browser';
6
 import browser from '../browser';
8
 
7
 
9
 const logger = getLogger(__filename);
8
 const logger = getLogger(__filename);
447
      * @returns {void}
446
      * @returns {void}
448
      */
447
      */
449
     updateEncodingsResolution(parameters) {
448
     updateEncodingsResolution(parameters) {
450
-        const localVideoTrack = this.pc.getLocalVideoTrack();
451
-
452
-        // Ignore desktop and non-simulcast tracks.
453
-        if (!(parameters
454
-            && parameters.encodings
455
-            && Array.isArray(parameters.encodings)
456
-            && this.pc.isSimulcastOn()
457
-            && localVideoTrack
458
-            && localVideoTrack.videoType !== VideoType.DESKTOP)) {
449
+        if (!(browser.isSafari() && parameters.encodings && Array.isArray(parameters.encodings))) {
459
             return;
450
             return;
460
         }
451
         }
461
-
462
-        parameters.encodings.forEach((encoding, idx) => {
463
-            encoding.scaleResolutionDownBy = this.localStreamEncodingsConfig[idx].scaleResolutionDownBy;
464
-        });
452
+        const allEqualEncodings
453
+            = encodings => encodings.every(encoding => typeof encoding.scaleResolutionDownBy !== 'undefined'
454
+                && encoding.scaleResolutionDownBy === encodings[0].scaleResolutionDownBy);
455
+
456
+        // Implement the workaround only when all the encodings report the same resolution.
457
+        if (allEqualEncodings(parameters.encodings)) {
458
+            parameters.encodings.forEach((encoding, idx) => {
459
+                encoding.scaleResolutionDownBy = this.localStreamEncodingsConfig[idx].scaleResolutionDownBy;
460
+            });
461
+        }
465
     }
462
     }
466
 }
463
 }

Loading…
取消
儲存