Skip to content

Commit df9bfa9

Browse files
authored
fix(RTC): Strip sdes:mid header extension from remote SDP on Firefox
1 parent 5076104 commit df9bfa9

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

modules/RTC/TPCUtils.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,31 @@ export class TPCUtils {
333333
&& !browser.isWebKitBased();
334334
}
335335

336+
/**
337+
* Removes the sdes:mid RTP header extension from the remote SDP for Firefox. Opting into sdes:mid negotiation
338+
* was enabled on Chrome to fix SSRC demuxing issues (https://issues.webrtc.org/issues/502130956), but Firefox
339+
* does not handle the sdes:mid header extension well, causing audio/video SSRC demuxing failures.
340+
*
341+
* @param {SessionDescription} parsedSdp - The parsed SDP that needs to be munged.
342+
* @returns {SessionDescription} The munged SDP.
343+
* @internal
344+
*/
345+
_stripSdesMid(parsedSdp: SessionDescription): SessionDescription {
346+
if (!browser.isFirefox()) {
347+
return parsedSdp;
348+
}
349+
350+
const mungedSdp = parsedSdp;
351+
352+
for (const mLine of mungedSdp.media) {
353+
if (mLine.ext) {
354+
mLine.ext = mLine.ext.filter(ext => ext.uri !== 'urn:ietf:params:rtp-hdrext:sdes:mid');
355+
}
356+
}
357+
358+
return mungedSdp;
359+
}
360+
336361
/**
337362
* Returns the calculated active state of the stream encodings based on the frame height requested for the send
338363
* stream. All the encodings that have a resolution lower than the frame height requested will be enabled.

modules/RTC/TraceablePeerConnection.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,14 +913,18 @@ export default class TraceablePeerConnection {
913913
* @param {boolean} isLocal - Whether the description is local or remote.
914914
* @returns {RTCSessionDescription} - The munged description.
915915
*/
916-
private _mungeDescription(description: RTCSessionDescription, _isLocal: boolean = true): RTCSessionDescription {
916+
private _mungeDescription(description: RTCSessionDescription, isLocal: boolean = true): RTCSessionDescription {
917917
this.trace('RTCSessionDescription::preTransform', TraceablePeerConnection.dumpSDP(description));
918918
let mungedSdp = transform.parse(description?.sdp);
919919
const audioQuality = this.audioQualityLocal;
920920

921921
mungedSdp = this.tpcUtils.mungeOpus(mungedSdp, audioQuality);
922922
mungedSdp = this.tpcUtils.mungeCodecOrder(mungedSdp);
923923
mungedSdp = this.tpcUtils.setMaxBitrates(mungedSdp, true);
924+
925+
if (!isLocal) {
926+
mungedSdp = this.tpcUtils._stripSdesMid(mungedSdp);
927+
}
924928
const mungedDescription = new RTCSessionDescription({
925929
sdp: transform.write(mungedSdp),
926930
type: description.type

0 commit comments

Comments
 (0)