From 4a4a6bd1a59047500577d33172ed9f8cd51c75f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 21 Oct 2026 12:04:10 +0200 Subject: [PATCH] Workaround to avoid "Failed to execute 'setHeaderExtensionsToNegotiate'" # Details - Fixes #394 - Related libwebrtc ticket: https://issues.webrtc.org/issues/576082210 --- src/handlers/ortc/utils.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/handlers/ortc/utils.ts b/src/handlers/ortc/utils.ts index 33c98c67..ddf897e8 100644 --- a/src/handlers/ortc/utils.ts +++ b/src/handlers/ortc/utils.ts @@ -7,6 +7,17 @@ import type { const logger = new Logger('ortc/utils'); +/** + * RTP header extensions that are mandatory to negotiate (since BUNDLE is always + * offered) and hence cannot be disabled via the RTP header extension control + * API. + * + * @see https://www.rfc-editor.org/rfc/rfc8834#name-header-extensions + */ +const MandatoryRtpExtensionUris: Set = new Set([ + 'urn:ietf:params:rtp-hdrext:sdes:mid', +]); + /** * This function adds RTCP NACK support for OPUS codec in given capabilities. */ @@ -75,7 +86,12 @@ export function applyForcedRtpExtensions( const uri = extenCap.uri as RtpHeaderExtensionUri; const enabled: boolean | undefined = forcedRtpExtensions[uri]; - if (enabled === true) { + // NOTE: This is a workaround to avoid a potential bug in libwebrtc: + // - https://github.com/versatica/mediasoup-client/issues/394 + // - https://issues.webrtc.org/issues/576082210 + if (MandatoryRtpExtensionUris.has(uri)) { + extenCap.direction = 'sendrecv'; + } else if (enabled === true) { extenCap.direction = 'sendrecv'; } else if (enabled === false) { extenCap.direction = 'stopped';