소스 검색

fix(TPC): Ensure encodings resolutions match configured values.

On every call to RTCRtpSender.setParameters(), ensure that the resolution configured for the encoding matches that of the value configured on the RTCRtpSender when the source was added to the peerconnection. This should prevent us from overriding the default values if the browser returns erroneous values when RTCRtpSender.getParameters is used for getting the encodings info. This fixes the issue on recent versions of Safari where the 'scaleResolutionDownBy' value comes back as 1 for all encodings even though the encoding resolution is different from the stream capture resolution.
dev1
Jaya Allamsetty 5 년 전
부모
커밋
1958efd5d7
2개의 변경된 파일21개의 추가작업 그리고 0개의 파일을 삭제
  1. 18
    0
      modules/RTC/TPCUtils.js
  2. 3
    0
      modules/RTC/TraceablePeerConnection.js

+ 18
- 0
modules/RTC/TPCUtils.js 파일 보기

@@ -436,4 +436,22 @@ export class TPCUtils {
436 436
     setVideoTransferActive(active) {
437 437
         this.setMediaTransferActive(MediaType.VIDEO, active);
438 438
     }
439
+
440
+    /**
441
+     * Ensures that the resolution of the stream encodings are consistent with the values
442
+     * that were configured on the RTCRtpSender when the source was added to the peerconnection.
443
+     * This should prevent us from overriding the default values if the browser returns
444
+     * erroneous values when RTCRtpSender.getParameters is used for getting the encodings info.
445
+     * @param {Object} parameters - the RTCRtpEncodingParameters obtained from the browser.
446
+     * @returns {void}
447
+     */
448
+    updateEncodingsResolution(parameters) {
449
+        if (!(parameters && parameters.encodings && Array.isArray(parameters.encodings))) {
450
+            return;
451
+        }
452
+
453
+        parameters.encodings.forEach((encoding, idx) => {
454
+            encoding.scaleResolutionDownBy = this.localStreamEncodingsConfig[idx].scaleResolutionDownBy;
455
+        });
456
+    }
439 457
 }

+ 3
- 0
modules/RTC/TraceablePeerConnection.js 파일 보기

@@ -2086,6 +2086,7 @@ TraceablePeerConnection.prototype.setSenderVideoDegradationPreference = function
2086 2086
             parameters.encodings[encoding].degradationPreference = preference;
2087 2087
         }
2088 2088
     }
2089
+    this.tpcUtils.updateEncodingsResolution(parameters);
2089 2090
 
2090 2091
     return videoSender.setParameters(parameters);
2091 2092
 };
@@ -2183,6 +2184,7 @@ TraceablePeerConnection.prototype.setMaxBitRate = function() {
2183 2184
         }
2184 2185
         parameters.encodings[0].maxBitrate = bitrate;
2185 2186
     }
2187
+    this.tpcUtils.updateEncodingsResolution(parameters);
2186 2188
 
2187 2189
     return videoSender.setParameters(parameters);
2188 2190
 };
@@ -2323,6 +2325,7 @@ TraceablePeerConnection.prototype.setSenderVideoConstraint = function(frameHeigh
2323 2325
                 parameters.encodings[encoding].active = encodingsEnabledState[encoding];
2324 2326
             }
2325 2327
         }
2328
+        this.tpcUtils.updateEncodingsResolution(parameters);
2326 2329
     } else if (newHeight > 0) {
2327 2330
         parameters.encodings[0].scaleResolutionDownBy = localVideoTrack.resolution >= newHeight
2328 2331
             ? Math.floor(localVideoTrack.resolution / newHeight)

Loading…
취소
저장