Browse Source

fix: getting right resolution for mobile web (#2356)

release-8443
Gabriel Borlea 2 years ago
parent
commit
c3a086f86d
No account linked to committer's email address

+ 3
- 3
modules/RTC/JitsiLocalTrack.js View File

@@ -102,7 +102,7 @@ export default class JitsiLocalTrack extends JitsiTrack {
102 102
 
103 103
         // Get the resolution from the track itself because it cannot be
104 104
         // certain which resolution webrtc has fallen back to using.
105
-        this.resolution = track.getSettings().height;
105
+        this.resolution = this.getHeight();
106 106
         this.maxEnabledResolution = resolution;
107 107
 
108 108
         // Cache the constraints of the track in case of any this track
@@ -112,8 +112,8 @@ export default class JitsiLocalTrack extends JitsiTrack {
112 112
         // Safari returns an empty constraints object, construct the constraints using getSettings.
113 113
         if (!Object.keys(this._constraints).length && videoType === VideoType.CAMERA) {
114 114
             this._constraints = {
115
-                height: track.getSettings().height,
116
-                width: track.getSettings().width
115
+                height: track.getHeight(),
116
+                width: track.getWidth()
117 117
             };
118 118
         }
119 119
 

+ 14
- 0
modules/RTC/JitsiTrack.js View File

@@ -378,6 +378,20 @@ export default class JitsiTrack extends EventEmitter {
378 378
         return this.videoType;
379 379
     }
380 380
 
381
+    /**
382
+     * Returns the height of the track in normalized landscape format.
383
+     */
384
+    getHeight() {
385
+        return Math.min(this.track.getSettings().height, this.track.getSettings().width);
386
+    }
387
+
388
+    /**
389
+     * Returns the width of the track in normalized landscape format.
390
+     */
391
+    getWidth() {
392
+        return Math.max(this.track.getSettings().height, this.track.getSettings().width);
393
+    }
394
+
381 395
     /**
382 396
      * Checks whether the MediaStream is active/not ended.
383 397
      * When there is no check for active we don't have information and so

+ 2
- 4
modules/RTC/TPCUtils.js View File

@@ -307,8 +307,7 @@ export class TPCUtils {
307 307
      * @returns {Array<boolean>}
308 308
      */
309 309
     calculateEncodingsActiveState(localVideoTrack, newHeight) {
310
-        const localTrack = localVideoTrack.getTrack();
311
-        const { height } = localTrack.getSettings();
310
+        const height = localVideoTrack.getHeight();
312 311
         const videoStreamEncodings = this._getVideoStreamEncodings(localVideoTrack.getVideoType());
313 312
         const encodingsState = videoStreamEncodings
314 313
         .map(encoding => height / encoding.scaleResolutionDownBy)
@@ -384,8 +383,7 @@ export class TPCUtils {
384 383
      * @returns {number|null} The max encoded resolution for the given video track.
385 384
      */
386 385
     getConfiguredEncodeResolution(localVideoTrack) {
387
-        const localTrack = localVideoTrack.getTrack();
388
-        const { height } = localTrack.getSettings();
386
+        const height = localVideoTrack.getHeight();
389 387
         const videoSender = this.pc.findSenderForTrack(localVideoTrack.getTrack());
390 388
         let maxHeight = 0;
391 389
 

+ 1
- 1
modules/RTC/TraceablePeerConnection.js View File

@@ -2677,7 +2677,7 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
2677 2677
     if ((localVideoTrack.getVideoType() === VideoType.CAMERA && configuredResolution === frameHeight)
2678 2678
         || (localVideoTrack.getVideoType() === VideoType.DESKTOP
2679 2679
             && frameHeight > 0
2680
-            && configuredResolution === localVideoTrack.getTrack()?.getSettings()?.height)) {
2680
+            && configuredResolution === localVideoTrack.getHeight())) {
2681 2681
         return Promise.resolve();
2682 2682
     }
2683 2683
 

Loading…
Cancel
Save