Просмотр исходного кода

fix(RTC): Fix capture resolution for Safari desktop tracks.

The browser returns height as 0 at track creation time. Fixes an issue where Safari's screenshare shows as black.
release-8443
Jaya Allamsetty 1 год назад
Родитель
Сommit
c7495280e4

+ 13
- 0
modules/RTC/JitsiLocalTrack.js Просмотреть файл

@@ -667,6 +667,19 @@ export default class JitsiLocalTrack extends JitsiTrack {
667 667
         return undefined;
668 668
     }
669 669
 
670
+    /**
671
+     * Returns the capture resolution of the video track.
672
+     *
673
+     * @returns {Number}
674
+     */
675
+    getCaptureResolution() {
676
+        if (this.videoType === VideoType.CAMERA || !browser.isWebKitBased()) {
677
+            return this.resolution;
678
+        }
679
+
680
+        return this.getHeight();
681
+    }
682
+
670 683
     /**
671 684
      * Returns device id associated with track.
672 685
      *

+ 8
- 0
modules/RTC/MockClasses.js Просмотреть файл

@@ -329,6 +329,14 @@ export class MockJitsiLocalTrack {
329 329
         return this.track.height;
330 330
     }
331 331
 
332
+    /**
333
+     * Returns the capture resolution.
334
+     * @returns {number}
335
+     */
336
+    getCaptureResolution() {
337
+        return this.getHeight();
338
+    }
339
+
332 340
     /**
333 341
      * Returns track.
334 342
      * @returns {MockTrack}

+ 4
- 4
modules/RTC/TPCUtils.js Просмотреть файл

@@ -84,7 +84,7 @@ export class TPCUtils {
84 84
      */
85 85
     _calculateActiveEncodingParams(localVideoTrack, codec, newHeight) {
86 86
         const codecBitrates = this.codecSettings[codec].maxBitratesVideo;
87
-        const trackCaptureHeight = localVideoTrack.resolution;
87
+        const trackCaptureHeight = localVideoTrack.getCaptureResolution();
88 88
         const effectiveNewHeight = newHeight > trackCaptureHeight ? trackCaptureHeight : newHeight;
89 89
         const desktopShareBitrate = this.pc.options?.videoQuality?.desktopbitrate || codecBitrates.ssHigh;
90 90
         const isScreenshare = localVideoTrack.getVideoType() === VideoType.DESKTOP;
@@ -177,7 +177,7 @@ export class TPCUtils {
177 177
      * @param {String} codec
178 178
      */
179 179
     _getVideoStreamEncodings(localTrack, codec) {
180
-        const captureResolution = localTrack.resolution;
180
+        const captureResolution = localTrack.getCaptureResolution();
181 181
         const codecBitrates = this.codecSettings[codec].maxBitratesVideo;
182 182
         const videoType = localTrack.getVideoType();
183 183
         let effectiveScaleFactors = SIM_LAYERS.map(sim => sim.scaleFactor);
@@ -360,7 +360,7 @@ export class TPCUtils {
360 360
      * @returns {Array<boolean>}
361 361
      */
362 362
     calculateEncodingsActiveState(localVideoTrack, codec, newHeight) {
363
-        const height = localVideoTrack.resolution;
363
+        const height = localVideoTrack.getCaptureResolution();
364 364
         const videoStreamEncodings = this._getVideoStreamEncodings(localVideoTrack, codec);
365 365
         const encodingsState = videoStreamEncodings
366 366
         .map(encoding => height / encoding.scaleResolutionDownBy)
@@ -543,7 +543,7 @@ export class TPCUtils {
543 543
      * @returns {number|null} The max encoded resolution for the given video track.
544 544
      */
545 545
     getConfiguredEncodeResolution(localVideoTrack, codec) {
546
-        const height = localVideoTrack.resolution;
546
+        const height = localVideoTrack.getCaptureResolution();
547 547
         const videoSender = this.pc.findSenderForTrack(localVideoTrack.getTrack());
548 548
         let maxHeight = 0;
549 549
 

+ 2
- 2
modules/RTC/TraceablePeerConnection.js Просмотреть файл

@@ -2062,7 +2062,7 @@ TraceablePeerConnection.prototype._setMaxBitrates = function(description, isLoca
2062 2062
             if (localTrack.getVideoType() === VideoType.DESKTOP) {
2063 2063
                 maxBitrate = codecScalabilityModeSettings.maxBitratesVideo.ssHigh;
2064 2064
             } else {
2065
-                const { level } = VIDEO_QUALITY_LEVELS.find(lvl => lvl.height <= localTrack.resolution);
2065
+                const { level } = VIDEO_QUALITY_LEVELS.find(lvl => lvl.height <= localTrack.getCaptureResolution());
2066 2066
 
2067 2067
                 maxBitrate = codecScalabilityModeSettings.maxBitratesVideo[level];
2068 2068
             }
@@ -2240,7 +2240,7 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
2240 2240
     if ((localVideoTrack.getVideoType() === VideoType.CAMERA && configuredResolution === frameHeight)
2241 2241
         || (localVideoTrack.getVideoType() === VideoType.DESKTOP
2242 2242
             && frameHeight > 0
2243
-            && configuredResolution === localVideoTrack.resolution)) {
2243
+            && configuredResolution === localVideoTrack.getCaptureResolution())) {
2244 2244
         return Promise.resolve();
2245 2245
     }
2246 2246
 

Загрузка…
Отмена
Сохранить