Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Unified Diff: webrtc/call/call.cc

Issue 2793913008: Add PeerConnectionInterface::UpdateCallBitrate. (Closed)
Patch Set: add a todo about de-duplicating bitrate mask structs Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/call/call.cc
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc
index e9838d9baad0acdadde8f33ddc12bb863068cc92..814bd0dd7edb6b4342edbecf6b021e41cef6540e 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,71 @@ 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());
+
+ 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);
Taylor Brandstetter 2017/04/12 01:33:41 In general we don't assert as a result of bad inpu
Zach Stein 2017/04/18 22:54:50 Done.
+ }
+ 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;
Taylor Brandstetter 2017/04/12 01:33:42 It seems unintuitive that config_.bitrate_config i
Zach Stein 2017/04/18 22:54:50 Done.
+
+ 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);
Taylor Brandstetter 2017/04/12 01:33:42 I'm not sure the "mask" should completely override
Zach Stein 2017/04/13 00:26:36 We don't know that bitrate_config.max_bitrate_bps
Taylor Brandstetter 2017/04/13 22:16:13 The codec params also come from SDP (from "a=fmtp"
Zach Stein 2017/04/18 22:54:50 I didn't realize that the codec params also came f
+
+ if (new_masked.min_bitrate_bps != masked_bitrate_config_.min_bitrate_bps ||
+ new_masked.start_bitrate_bps !=
+ masked_bitrate_config_.start_bitrate_bps ||
Taylor Brandstetter 2017/04/12 01:33:42 Should this be the same condition as in SetBitrate
Zach Stein 2017/04/18 22:54:50 Done.
+ new_masked.max_bitrate_bps != masked_bitrate_config_.max_bitrate_bps) {
+ RTC_DCHECK_GT(new_masked.min_bitrate_bps, 0);
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698