| Index: webrtc/call/call.cc
|
| diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc
|
| index e9838d9baad0acdadde8f33ddc12bb863068cc92..4aa880e3002ca7468a38608441076ca1e6cf1040 100644
|
| --- a/webrtc/call/call.cc
|
| +++ b/webrtc/call/call.cc
|
| @@ -180,6 +180,13 @@ class Call : public webrtc::Call,
|
| void SetBitrateConfig(
|
| const webrtc::Call::Config::BitrateConfig& bitrate_config) override;
|
|
|
| + void SetBitrateConfigMask(
|
| + const webrtc::Call::Config::BitrateConfigMask& bitrate_config) override;
|
| +
|
| + // Updates the cached |masked_bitrate_config_| struct and updates the
|
| + // congestion controller if the masked config changed.
|
| + void UpdateMaskedBitrateConfig();
|
| +
|
| void SignalChannelNetworkState(MediaType media, NetworkState state) override;
|
|
|
| void OnTransportOverheadChanged(MediaType media,
|
| @@ -321,6 +328,14 @@ class Call : public webrtc::Call,
|
| // and deleted before any other members.
|
| rtc::TaskQueue worker_queue_;
|
|
|
| + // The mask is kept so it can be re-applied if SetBitrateConfig is called.
|
| + Config::BitrateConfigMask bitrate_config_mask_;
|
| +
|
| + // This is the BitrateConfig given to the congestion controller. We cache it
|
| + // here to avoid resets in the congestion controller when nothing has actually
|
| + // changed.
|
| + Config::BitrateConfig masked_bitrate_config_;
|
| +
|
| RTC_DISALLOW_COPY_AND_ASSIGN(Call);
|
| };
|
| } // namespace internal
|
| @@ -374,7 +389,8 @@ Call::Call(const Call::Config& config,
|
| receive_side_cc_(clock_, &remb_, transport_send_->packet_router()),
|
| video_send_delay_stats_(new SendDelayStats(clock_)),
|
| start_ms_(clock_->TimeInMilliseconds()),
|
| - worker_queue_("call_worker_queue") {
|
| + worker_queue_("call_worker_queue"),
|
| + masked_bitrate_config_(config.bitrate_config) {
|
| RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
| RTC_DCHECK(config.event_log != nullptr);
|
| RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
|
| @@ -897,9 +913,11 @@ void Call::SetBitrateConfig(
|
| const webrtc::Call::Config::BitrateConfig& bitrate_config) {
|
| TRACE_EVENT0("webrtc", "Call::SetBitrateConfig");
|
| RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
| +
|
| RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0);
|
| if (bitrate_config.max_bitrate_bps != -1)
|
| RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0);
|
| +
|
| if (config_.bitrate_config.min_bitrate_bps ==
|
| bitrate_config.min_bitrate_bps &&
|
| (bitrate_config.start_bitrate_bps <= 0 ||
|
| @@ -910,16 +928,74 @@ void Call::SetBitrateConfig(
|
| // Nothing new to set, early abort to avoid encoder reconfigurations.
|
| return;
|
| }
|
| +
|
| config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps;
|
| // Start bitrate of -1 means we should keep the old bitrate, which there is
|
| // no point in remembering for the future.
|
| if (bitrate_config.start_bitrate_bps > 0)
|
| config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps;
|
| config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps;
|
| +
|
| RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0);
|
| - transport_send_->send_side_cc()->SetBweBitrates(
|
| - bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps,
|
| +
|
| + UpdateMaskedBitrateConfig();
|
| +}
|
| +
|
| +void Call::SetBitrateConfigMask(
|
| + const webrtc::Call::Config::BitrateConfigMask& mask) {
|
| + TRACE_EVENT0("webrtc", "Call::UpdateBitrateConfig");
|
| + RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
| +
|
| + // TODO(zstein): this validation belongs in PeerConnection::SetBitrate, which
|
| + // should return an RTCError instead of using DCHECK
|
| + const bool has_min = static_cast<bool>(mask.min_bitrate_bps);
|
| + const bool has_start = static_cast<bool>(mask.start_bitrate_bps);
|
| + const bool has_max = static_cast<bool>(mask.max_bitrate_bps);
|
| + if (has_min) {
|
| + RTC_DCHECK_GE(*mask.min_bitrate_bps, 0);
|
| + }
|
| + if (has_start) {
|
| + RTC_DCHECK_GE(*mask.start_bitrate_bps, has_min ? *mask.min_bitrate_bps : 0);
|
| + }
|
| + if (has_max) {
|
| + RTC_DCHECK_GE(*mask.max_bitrate_bps,
|
| + has_start ? *mask.start_bitrate_bps
|
| + : (has_min ? *mask.min_bitrate_bps : 0));
|
| + }
|
| +
|
| + bitrate_config_mask_ = mask;
|
| +
|
| + UpdateMaskedBitrateConfig();
|
| +}
|
| +
|
| +void Call::UpdateMaskedBitrateConfig() {
|
| + Config::BitrateConfig new_masked;
|
| + const Config::BitrateConfig& bitrate_config = config_.bitrate_config;
|
| +
|
| + new_masked.min_bitrate_bps = bitrate_config_mask_.min_bitrate_bps.value_or(
|
| + bitrate_config.min_bitrate_bps);
|
| + new_masked.start_bitrate_bps =
|
| + bitrate_config_mask_.start_bitrate_bps.value_or(
|
| + bitrate_config.start_bitrate_bps);
|
| + new_masked.max_bitrate_bps = bitrate_config_mask_.max_bitrate_bps.value_or(
|
| bitrate_config.max_bitrate_bps);
|
| +
|
| + if (new_masked.min_bitrate_bps != masked_bitrate_config_.min_bitrate_bps ||
|
| + new_masked.start_bitrate_bps !=
|
| + masked_bitrate_config_.start_bitrate_bps ||
|
| + new_masked.max_bitrate_bps != masked_bitrate_config_.max_bitrate_bps) {
|
| + RTC_DCHECK_GT(new_masked.min_bitrate_bps, 0);
|
| + // TODO(zstein): start_bitrate might be <= 0 if it wasn't set in the mask
|
| + RTC_DCHECK_GT(new_masked.start_bitrate_bps, new_masked.min_bitrate_bps);
|
| + RTC_DCHECK(new_masked.max_bitrate_bps == -1 ||
|
| + new_masked.max_bitrate_bps > new_masked.start_bitrate_bps);
|
| +
|
| + masked_bitrate_config_ = new_masked;
|
| + transport_send_->send_side_cc()->SetBweBitrates(
|
| + masked_bitrate_config_.min_bitrate_bps,
|
| + masked_bitrate_config_.start_bitrate_bps,
|
| + masked_bitrate_config_.max_bitrate_bps);
|
| + }
|
| }
|
|
|
| void Call::SignalChannelNetworkState(MediaType media, NetworkState state) {
|
|
|