Преглед изворни кода

fix(codec-selection) Check if disabled is already removed from sdp.

This should avoid unnecessary renegotiations if disabledCodec setting is present in config.js and should improve time to receive media when joining big calls.
master
Jaya Allamsetty пре 2 година
родитељ
комит
6afb0a563d
2 измењених фајлова са 17 додато и 1 уклоњено
  1. 1
    1
      modules/RTC/CodecSelection.js
  2. 16
    0
      modules/RTC/TraceablePeerConnection.js

+ 1
- 1
modules/RTC/CodecSelection.js Прегледај датотеку

130
                     ?? nonPreferredCodecs.find(codec => this._isCodecSupported(codec));
130
                     ?? nonPreferredCodecs.find(codec => this._isCodecSupported(codec));
131
             }
131
             }
132
         }
132
         }
133
-        if (selectedCodec !== currentCodec || disabledCodec) {
133
+        if (selectedCodec !== currentCodec || !session?.peerconnection.isVideoCodecDisabled(disabledCodec)) {
134
             session.setVideoCodecs(selectedCodec, disabledCodec);
134
             session.setVideoCodecs(selectedCodec, disabledCodec);
135
         }
135
         }
136
     }
136
     }

+ 16
- 0
modules/RTC/TraceablePeerConnection.js Прегледај датотеку

1848
     return defaultCodec;
1848
     return defaultCodec;
1849
 };
1849
 };
1850
 
1850
 
1851
+/**
1852
+ * Checks if the client has negotiated not to receive video encoded using the given codec, i.e., the codec has been
1853
+ * removed from the local description.
1854
+ */
1855
+TraceablePeerConnection.prototype.isVideoCodecDisabled = function(codec) {
1856
+    const sdp = this.peerconnection.localDescription?.sdp;
1857
+
1858
+    if (!sdp) {
1859
+        return false;
1860
+    }
1861
+    const parsedSdp = transform.parse(sdp);
1862
+    const mLine = parsedSdp.media.find(m => m.type === MediaType.VIDEO);
1863
+
1864
+    return !mLine.rtp.find(r => r.codec === codec);
1865
+};
1866
+
1851
 /**
1867
 /**
1852
  * Enables or disables simulcast for screenshare based on the frame rate requested for desktop track capture.
1868
  * Enables or disables simulcast for screenshare based on the frame rate requested for desktop track capture.
1853
  *
1869
  *

Loading…
Откажи
Сачувај