From 2598f4d2458475c6579d2cd6afd10de0fb1f0c86 Mon Sep 17 00:00:00 2001 From: Huang Rui1 Date: Thu, 18 Mar 2021 22:31:03 +0800 Subject: [PATCH] Enhance the judgement of sdp semantics. Signed-off-by: Huang Rui1 --- src/sdk/p2p/peerconnection-channel.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sdk/p2p/peerconnection-channel.js b/src/sdk/p2p/peerconnection-channel.js index e3a4b90a..b4468161 100644 --- a/src/sdk/p2p/peerconnection-channel.js +++ b/src/sdk/p2p/peerconnection-channel.js @@ -646,14 +646,22 @@ class P2PPeerConnectionChannel extends EventDispatcher { const pc = new RTCPeerConnection({ sdpSemantics: 'unified-plan', }); - return (pc.getConfiguration() && pc.getConfiguration().sdpSemantics === - 'plan-b'); + if (typeof pc.getConfiguration === "undefined") { + return false; + } + return pc.getConfiguration().sdpSemantics === 'unified-plan'; } _createPeerConnection() { const pcConfiguration = this._config.rtcConfiguration || {}; if (Utils.isChrome()) { - pcConfiguration.sdpSemantics = 'unified-plan'; + if (this._isUnifiedPlan()) { + Logger.info("Set sdpSemantics: unified-plan"); + pcConfiguration.sdpSemantics = 'unified-plan'; + } else { + Logger.info("Set sdpSemantics: plan-b"); + pcConfiguration.sdpSemantics = 'plan-b'; + } } this._pc = new RTCPeerConnection(pcConfiguration); // Firefox 59 implemented addTransceiver. However, mid in SDP will differ from track's ID in this case. And transceiver's mid is null.