Fix inconsistency with x-goog-max-bitrate and maxBitrate.
In the past, only encodings.size() == 1 was considered singlecast. But
it's possible to have singlecast via {active,inactive,inactive} too so
this condition should be updated.
This CL ignores x-goog-max-bitrate if maxBitrate was specified on *any*
encoding. This fixes the case of {active,inactive,inactive} resolving
the singlecast inconsistency, but it also takes things one step further
and ignores x-goog-max-bitrate in simulcast cases as well (if any
active encoding has a maxBitrate), as it is not clear why simulcast
should behave differently from singlecast with regards to this flag.
Bug: webrtc:15390
Change-Id: If89a488249239a6bd10fdd56c599ccd2e6ec26fc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/313540
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40494}
This commit is contained in:
parent
96137813f7
commit
875cd32eac
@ -2036,14 +2036,17 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig(
|
||||
int stream_max_bitrate = parameters_.max_bitrate_bps;
|
||||
// The codec max bitrate comes from the "x-google-max-bitrate" parameter
|
||||
// attribute set in the SDP for a specific codec. It only has an effect if
|
||||
// max bitrate is not specified via "b=AS" and doesn't apply in singlecast
|
||||
// if the encoding has a max bitrate.
|
||||
// max bitrate is not specified through other means.
|
||||
bool encodings_has_max_bitrate = false;
|
||||
for (const auto& encoding : rtp_parameters_.encodings) {
|
||||
if (encoding.active && encoding.max_bitrate_bps.value_or(0) > 0) {
|
||||
encodings_has_max_bitrate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int codec_max_bitrate_kbps;
|
||||
bool is_single_encoding_with_max_bitrate =
|
||||
rtp_parameters_.encodings.size() == 1 &&
|
||||
rtp_parameters_.encodings[0].max_bitrate_bps.value_or(0) > 0;
|
||||
if (codec.GetParam(kCodecParamMaxBitrate, &codec_max_bitrate_kbps) &&
|
||||
stream_max_bitrate == -1 && !is_single_encoding_with_max_bitrate) {
|
||||
stream_max_bitrate == -1 && !encodings_has_max_bitrate) {
|
||||
stream_max_bitrate = codec_max_bitrate_kbps * 1000;
|
||||
}
|
||||
encoder_config.max_bitrate_bps = stream_max_bitrate;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user