From d6dd20c00633d9e3303c813ba303812c75783ba9 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Thu, 18 Aug 2022 10:43:54 +0200 Subject: [PATCH] Fallback to unmunged SDP for answer (#400) * Fallback to unmunged sdp for answer * changeset * fix log message --- .changeset/fifty-moles-train.md | 5 +++++ src/room/PCTransport.ts | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .changeset/fifty-moles-train.md diff --git a/.changeset/fifty-moles-train.md b/.changeset/fifty-moles-train.md new file mode 100644 index 0000000000..ebaa78d91c --- /dev/null +++ b/.changeset/fifty-moles-train.md @@ -0,0 +1,5 @@ +--- +'livekit-client': patch +--- + +Fallback to unmunged sdp for answer diff --git a/src/room/PCTransport.ts b/src/room/PCTransport.ts index 3e3beb480b..8e10ef65a7 100644 --- a/src/room/PCTransport.ts +++ b/src/room/PCTransport.ts @@ -157,8 +157,17 @@ export default class PCTransport { ensureAudioNack(media); } }); - answer.sdp = write(sdpParsed); - await this.pc.setLocalDescription(answer); + const originalSdp = answer.sdp; + try { + answer.sdp = write(sdpParsed); + await this.pc.setLocalDescription(answer); + } catch (e: unknown) { + log.warn('not able to set desired local description, falling back to unmodified answer', { + error: e, + }); + answer.sdp = originalSdp; + await this.pc.setLocalDescription(answer); + } return answer; }