Bläddra i källkod

fix(TPC) Avoid applying constraints on desktop tracks if not needed. (#2246)

* fix(TPC) Avoid applying constraints on desktop tracks if not needed.
Ignore sender constraints if the client is already sending video of the requested resolution. For desktop tracks, max resolution will be the height of the window being captured irrespective of the height being requested by the peer. Therfore, check if the configured resolution is equal to the track height for all requested heights > 0.
Fixes an issue where the track addition fails because of setParameters failing on the video track. This is only seen the torture tests because this is very timing specific.

* squash: check correct scaleResolutionDownBy value for p2p conn.
master
Jaya Allamsetty 2 år sedan
förälder
incheckning
05edc9b599
Inget konto är kopplat till bidragsgivarens mejladress
2 ändrade filer med 26 tillägg och 9 borttagningar
  1. 8
    3
      modules/RTC/TPCUtils.js
  2. 18
    6
      modules/RTC/TraceablePeerConnection.js

+ 8
- 3
modules/RTC/TPCUtils.js Visa fil

@@ -373,9 +373,14 @@ export class TPCUtils {
373 373
         if (!parameters?.encodings?.length) {
374 374
             return maxHeight;
375 375
         }
376
-        for (const encoding of parameters.encodings) {
377
-            if (encoding.active) {
378
-                maxHeight = Math.max(maxHeight, height / encoding.scaleResolutionDownBy);
376
+        for (const encoding in parameters.encodings) {
377
+            if (parameters.encodings[encoding].active) {
378
+                const scaleResolutionDownBy
379
+                    = this.pc.isSimulcastOn()
380
+                        ? this._getVideoStreamEncodings(localVideoTrack.getVideoType())[encoding].scaleResolutionDownBy
381
+                        : parameters.encodings[encoding].scaleResolutionDownBy;
382
+
383
+                maxHeight = Math.max(maxHeight, height / scaleResolutionDownBy);
379 384
             }
380 385
         }
381 386
 

+ 18
- 6
modules/RTC/TraceablePeerConnection.js Visa fil

@@ -2560,21 +2560,33 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
2560 2560
     if (frameHeight < 0) {
2561 2561
         throw new Error(`Invalid frameHeight: ${frameHeight}`);
2562 2562
     }
2563
+    if (!localVideoTrack) {
2564
+        throw new Error('Local video track is missing');
2565
+    }
2563 2566
     const sourceName = localVideoTrack.getSourceName();
2564 2567
 
2565
-    this._senderMaxHeights.set(sourceName, frameHeight);
2568
+    // Ignore sender constraints if the media on the peerconnection is suspended (jvb conn when p2p is currently active)
2569
+    // or if the video track is muted.
2570
+    if (!this.videoTransferActive || localVideoTrack.isMuted()) {
2571
+        this._senderMaxHeights.set(sourceName, frameHeight);
2566 2572
 
2567
-    // Ignore sender constraints for the following cases -
2568
-    // 1. If the media on the peerconnection is suspended (jvb conn when p2p is currently active).
2569
-    // 2. If the client is already sending video of the requested resolution.
2570
-    if (!this.videoTransferActive || this.tpcUtils.getConfiguredEncodeResolution(localVideoTrack) === frameHeight) {
2571 2573
         return Promise.resolve();
2572 2574
     }
2573 2575
 
2574
-    if (!localVideoTrack || localVideoTrack.isMuted()) {
2576
+    const configuredResolution = this.tpcUtils.getConfiguredEncodeResolution(localVideoTrack);
2577
+
2578
+    // Ignore sender constraints if the client is already sending video of the requested resolution. Note that for
2579
+    // screensharing sources, the max resolution will be the height of the window being captured irrespective of the
2580
+    // height being requested by the peer.
2581
+    if ((localVideoTrack.getVideoType() === VideoType.CAMERA && configuredResolution === frameHeight)
2582
+        || (localVideoTrack.getVideoType() === VideoType.DESKTOP
2583
+            && frameHeight > 0
2584
+            && configuredResolution === localVideoTrack.getTrack()?.getSettings()?.height)) {
2575 2585
         return Promise.resolve();
2576 2586
     }
2577 2587
 
2588
+    this._senderMaxHeights.set(sourceName, frameHeight);
2589
+
2578 2590
     return this._updateVideoSenderParameters(this._updateVideoSenderEncodings(frameHeight, localVideoTrack));
2579 2591
 };
2580 2592
 

Laddar…
Avbryt
Spara