Browse Source

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 years ago
parent
commit
6afb0a563d
2 changed files with 17 additions and 1 deletions
  1. 1
    1
      modules/RTC/CodecSelection.js
  2. 16
    0
      modules/RTC/TraceablePeerConnection.js

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

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 View File

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…
Cancel
Save