瀏覽代碼

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,7 +130,7 @@ export class CodecSelection {
130 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 134
             session.setVideoCodecs(selectedCodec, disabledCodec);
135 135
         }
136 136
     }

+ 16
- 0
modules/RTC/TraceablePeerConnection.js 查看文件

@@ -1848,6 +1848,22 @@ TraceablePeerConnection.prototype.getConfiguredVideoCodec = function() {
1848 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 1868
  * Enables or disables simulcast for screenshare based on the frame rate requested for desktop track capture.
1853 1869
  *

Loading…
取消
儲存