diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-11-04 20:16:45 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-11-04 20:16:45 +0300 |
commit | 6d288ad8d8f740cf587f925d1dab9326a1fa7b0a (patch) | |
tree | cf0949172c30fc667581c4bbe6196ea77e625b61 /src/utils/webrtc | |
parent | 951db802e2b01c152b389c2d5cbf6b920ecb503d (diff) |
Ignore preference for H.264 when simulcast is used
When "prefer_h264" is set the SDP is modified to place H.264 as the
preferred codec. However, this change in the SDP clashes with the
changes done to enable simulcast with Chromium and sometimes causes
creating the offer to fail. Given that preferring H.264 has no effect
when the HPB is used (as only VP8 is supported in that case) and that
simulcast can be enabled only with the HPB now "prefer_h264" is ignored
when simulcast is used.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src/utils/webrtc')
-rw-r--r-- | src/utils/webrtc/simplewebrtc/peer.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/utils/webrtc/simplewebrtc/peer.js b/src/utils/webrtc/simplewebrtc/peer.js index 15eb870db..7ba22b5d5 100644 --- a/src/utils/webrtc/simplewebrtc/peer.js +++ b/src/utils/webrtc/simplewebrtc/peer.js @@ -150,16 +150,29 @@ function Peer(options) { util.inherits(Peer, WildEmitter) /** - * + * @param {object} signaling the connection/signaling object */ -function shouldPreferH264() { +function shouldPreferH264(signaling) { + let preferH264 + try { - return initialState.loadState('spreed', 'prefer_h264') + preferH264 = initialState.loadState('spreed', 'prefer_h264') } catch (exception) { // If the state can not be loaded an exception is thrown console.warn('Could not find initial state for H.264 preference') return false } + + if (!preferH264) { + return false + } + + if (signaling.hasFeature('simulcast')) { + console.warn('Ignoring preference for H.264, as it can not be used with simulcast') + return false + } + + return true } /** @@ -457,7 +470,7 @@ Peer.prototype.offer = function(options) { } } this.pc.createOffer(options).then(function(offer) { - if (shouldPreferH264()) { + if (shouldPreferH264(this.parent.config.connection)) { console.debug('Preferring hardware codec H.264 as per global configuration') offer = preferH264VideoCodecIfAvailable(offer) } @@ -502,7 +515,7 @@ Peer.prototype.handleOffer = function(offer) { Peer.prototype.answer = function() { this.pc.createAnswer().then(function(answer) { - if (shouldPreferH264()) { + if (shouldPreferH264(this.parent.config.connection)) { console.debug('Preferring hardware codec H.264 as per global configuration') answer = preferH264VideoCodecIfAvailable(answer) } |