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

Side by Side Diff: webrtc/call/bitrate_allocator.cc

Issue 2703393002: Revert of Fixes a bug where a video stream can get stuck in the suspended state. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « webrtc/call/bitrate_allocator.h ('k') | webrtc/call/bitrate_allocator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 * 9 *
10 */ 10 */
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer) 48 BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer)
49 : limit_observer_(limit_observer), 49 : limit_observer_(limit_observer),
50 bitrate_observer_configs_(), 50 bitrate_observer_configs_(),
51 last_bitrate_bps_(0), 51 last_bitrate_bps_(0),
52 last_non_zero_bitrate_bps_(kDefaultBitrateBps), 52 last_non_zero_bitrate_bps_(kDefaultBitrateBps),
53 last_fraction_loss_(0), 53 last_fraction_loss_(0),
54 last_rtt_(0), 54 last_rtt_(0),
55 num_pause_events_(0), 55 num_pause_events_(0),
56 clock_(Clock::GetRealTimeClock()), 56 clock_(Clock::GetRealTimeClock()),
57 last_bwe_log_time_(0), 57 last_bwe_log_time_(0) {
58 total_requested_padding_bitrate_(0),
59 total_requested_min_bitrate_(0) {
60 sequenced_checker_.Detach(); 58 sequenced_checker_.Detach();
61 } 59 }
62 60
63 BitrateAllocator::~BitrateAllocator() { 61 BitrateAllocator::~BitrateAllocator() {
64 RTC_HISTOGRAM_COUNTS_100("WebRTC.Call.NumberOfPauseEvents", 62 RTC_HISTOGRAM_COUNTS_100("WebRTC.Call.NumberOfPauseEvents",
65 num_pause_events_); 63 num_pause_events_);
66 } 64 }
67 65
68 void BitrateAllocator::OnNetworkChanged(uint32_t target_bitrate_bps, 66 void BitrateAllocator::OnNetworkChanged(uint32_t target_bitrate_bps,
69 uint8_t fraction_loss, 67 uint8_t fraction_loss,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 << ", configured min bitrate " << config.min_bitrate_bps 108 << ", configured min bitrate " << config.min_bitrate_bps
111 << ", current allocation " << allocated_bitrate 109 << ", current allocation " << allocated_bitrate
112 << " and protection bitrate " << protection_bitrate; 110 << " and protection bitrate " << protection_bitrate;
113 } 111 }
114 112
115 // Only update the media ratio if the observer got an allocation. 113 // Only update the media ratio if the observer got an allocation.
116 if (allocated_bitrate > 0) 114 if (allocated_bitrate > 0)
117 config.media_ratio = MediaRatio(allocated_bitrate, protection_bitrate); 115 config.media_ratio = MediaRatio(allocated_bitrate, protection_bitrate);
118 config.allocated_bitrate_bps = allocated_bitrate; 116 config.allocated_bitrate_bps = allocated_bitrate;
119 } 117 }
120 UpdateAllocationLimits();
121 } 118 }
122 119
123 void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer, 120 void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
124 uint32_t min_bitrate_bps, 121 uint32_t min_bitrate_bps,
125 uint32_t max_bitrate_bps, 122 uint32_t max_bitrate_bps,
126 uint32_t pad_up_bitrate_bps, 123 uint32_t pad_up_bitrate_bps,
127 bool enforce_min_bitrate) { 124 bool enforce_min_bitrate) {
128 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); 125 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
129 auto it = FindObserverConfig(observer); 126 auto it = FindObserverConfig(observer);
130 127
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 160 }
164 UpdateAllocationLimits(); 161 UpdateAllocationLimits();
165 } 162 }
166 163
167 void BitrateAllocator::UpdateAllocationLimits() { 164 void BitrateAllocator::UpdateAllocationLimits() {
168 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); 165 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
169 uint32_t total_requested_padding_bitrate = 0; 166 uint32_t total_requested_padding_bitrate = 0;
170 uint32_t total_requested_min_bitrate = 0; 167 uint32_t total_requested_min_bitrate = 0;
171 168
172 for (const auto& config : bitrate_observer_configs_) { 169 for (const auto& config : bitrate_observer_configs_) {
173 uint32_t stream_padding = config.pad_up_bitrate_bps;
174 if (config.enforce_min_bitrate) { 170 if (config.enforce_min_bitrate) {
175 total_requested_min_bitrate += config.min_bitrate_bps; 171 total_requested_min_bitrate += config.min_bitrate_bps;
176 } else if (config.allocated_bitrate_bps == 0) {
177 stream_padding =
178 std::max(MinBitrateWithHysteresis(config), stream_padding);
179 } 172 }
180 total_requested_padding_bitrate += stream_padding; 173 total_requested_padding_bitrate += config.pad_up_bitrate_bps;
181 } 174 }
182 175
183 if (total_requested_padding_bitrate == total_requested_padding_bitrate_ &&
184 total_requested_min_bitrate == total_requested_min_bitrate_) {
185 return;
186 }
187
188 total_requested_min_bitrate_ = total_requested_min_bitrate;
189 total_requested_padding_bitrate_ = total_requested_padding_bitrate;
190
191 LOG(LS_INFO) << "UpdateAllocationLimits : total_requested_min_bitrate: " 176 LOG(LS_INFO) << "UpdateAllocationLimits : total_requested_min_bitrate: "
192 << total_requested_min_bitrate 177 << total_requested_min_bitrate
193 << "bps, total_requested_padding_bitrate: " 178 << "bps, total_requested_padding_bitrate: "
194 << total_requested_padding_bitrate << "bps"; 179 << total_requested_padding_bitrate << "bps";
195 limit_observer_->OnAllocationLimitsChanged(total_requested_min_bitrate, 180 limit_observer_->OnAllocationLimitsChanged(total_requested_min_bitrate,
196 total_requested_padding_bitrate); 181 total_requested_padding_bitrate);
197 } 182 }
198 183
199 void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) { 184 void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) {
200 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); 185 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 uint32_t sum_min_bitrates) { 409 uint32_t sum_min_bitrates) {
425 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); 410 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
426 if (bitrate < sum_min_bitrates) 411 if (bitrate < sum_min_bitrates)
427 return false; 412 return false;
428 413
429 uint32_t extra_bitrate_per_observer = 414 uint32_t extra_bitrate_per_observer =
430 (bitrate - sum_min_bitrates) / 415 (bitrate - sum_min_bitrates) /
431 static_cast<uint32_t>(bitrate_observer_configs_.size()); 416 static_cast<uint32_t>(bitrate_observer_configs_.size());
432 for (const auto& observer_config : bitrate_observer_configs_) { 417 for (const auto& observer_config : bitrate_observer_configs_) {
433 if (observer_config.min_bitrate_bps + extra_bitrate_per_observer < 418 if (observer_config.min_bitrate_bps + extra_bitrate_per_observer <
434 MinBitrateWithHysteresis(observer_config)) { 419 MinBitrateWithHysteresis(observer_config))
435 return false; 420 return false;
436 }
437 } 421 }
438 return true; 422 return true;
439 } 423 }
440 } // namespace webrtc 424 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/bitrate_allocator.h ('k') | webrtc/call/bitrate_allocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698