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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc

Issue 2800633004: Resolve dependency between rtc_event_log_api and remote_bitrate_estimator (Closed)
Patch Set: Rebased 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc ('k') | no next file » | 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (estimator->inter_arrival.ComputeDeltas( 118 if (estimator->inter_arrival.ComputeDeltas(
119 rtp_timestamp, arrival_time_ms, now_ms, payload_size, 119 rtp_timestamp, arrival_time_ms, now_ms, payload_size,
120 &timestamp_delta, &time_delta, &size_delta)) { 120 &timestamp_delta, &time_delta, &size_delta)) {
121 double timestamp_delta_ms = timestamp_delta * kTimestampToMs; 121 double timestamp_delta_ms = timestamp_delta * kTimestampToMs;
122 estimator->estimator.Update(time_delta, timestamp_delta_ms, size_delta, 122 estimator->estimator.Update(time_delta, timestamp_delta_ms, size_delta,
123 estimator->detector.State(), now_ms); 123 estimator->detector.State(), now_ms);
124 estimator->detector.Detect(estimator->estimator.offset(), 124 estimator->detector.Detect(estimator->estimator.offset(),
125 timestamp_delta_ms, 125 timestamp_delta_ms,
126 estimator->estimator.num_of_deltas(), now_ms); 126 estimator->estimator.num_of_deltas(), now_ms);
127 } 127 }
128 if (estimator->detector.State() == kBwOverusing) { 128 if (estimator->detector.State() == BandwidthUsage::kBwOverusing) {
129 rtc::Optional<uint32_t> incoming_bitrate_bps = 129 rtc::Optional<uint32_t> incoming_bitrate_bps =
130 incoming_bitrate_.Rate(now_ms); 130 incoming_bitrate_.Rate(now_ms);
131 if (incoming_bitrate_bps && 131 if (incoming_bitrate_bps &&
132 (prior_state != kBwOverusing || 132 (prior_state != BandwidthUsage::kBwOverusing ||
133 GetRemoteRate()->TimeToReduceFurther(now_ms, *incoming_bitrate_bps))) { 133 GetRemoteRate()->TimeToReduceFurther(now_ms, *incoming_bitrate_bps))) {
134 // The first overuse should immediately trigger a new estimate. 134 // The first overuse should immediately trigger a new estimate.
135 // We also have to update the estimate immediately if we are overusing 135 // We also have to update the estimate immediately if we are overusing
136 // and the target bitrate is too high compared to what we are receiving. 136 // and the target bitrate is too high compared to what we are receiving.
137 UpdateEstimate(now_ms); 137 UpdateEstimate(now_ms);
138 } 138 }
139 } 139 }
140 } 140 }
141 141
142 void RemoteBitrateEstimatorSingleStream::Process() { 142 void RemoteBitrateEstimatorSingleStream::Process() {
143 { 143 {
144 rtc::CritScope cs(&crit_sect_); 144 rtc::CritScope cs(&crit_sect_);
145 UpdateEstimate(clock_->TimeInMilliseconds()); 145 UpdateEstimate(clock_->TimeInMilliseconds());
146 } 146 }
147 last_process_time_ = clock_->TimeInMilliseconds(); 147 last_process_time_ = clock_->TimeInMilliseconds();
148 } 148 }
149 149
150 int64_t RemoteBitrateEstimatorSingleStream::TimeUntilNextProcess() { 150 int64_t RemoteBitrateEstimatorSingleStream::TimeUntilNextProcess() {
151 if (last_process_time_ < 0) { 151 if (last_process_time_ < 0) {
152 return 0; 152 return 0;
153 } 153 }
154 rtc::CritScope cs_(&crit_sect_); 154 rtc::CritScope cs_(&crit_sect_);
155 RTC_DCHECK_GT(process_interval_ms_, 0); 155 RTC_DCHECK_GT(process_interval_ms_, 0);
156 return last_process_time_ + process_interval_ms_ - 156 return last_process_time_ + process_interval_ms_ -
157 clock_->TimeInMilliseconds(); 157 clock_->TimeInMilliseconds();
158 } 158 }
159 159
160 void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) { 160 void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
161 BandwidthUsage bw_state = kBwNormal; 161 BandwidthUsage bw_state = BandwidthUsage::kBwNormal;
162 double sum_var_noise = 0.0; 162 double sum_var_noise = 0.0;
163 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.begin(); 163 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.begin();
164 while (it != overuse_detectors_.end()) { 164 while (it != overuse_detectors_.end()) {
165 const int64_t time_of_last_received_packet = 165 const int64_t time_of_last_received_packet =
166 it->second->last_packet_time_ms; 166 it->second->last_packet_time_ms;
167 if (time_of_last_received_packet >= 0 && 167 if (time_of_last_received_packet >= 0 &&
168 now_ms - time_of_last_received_packet > kStreamTimeOutMs) { 168 now_ms - time_of_last_received_packet > kStreamTimeOutMs) {
169 // This over-use detector hasn't received packets for |kStreamTimeOutMs| 169 // This over-use detector hasn't received packets for |kStreamTimeOutMs|
170 // milliseconds and is considered stale. 170 // milliseconds and is considered stale.
171 delete it->second; 171 delete it->second;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 remote_rate_.reset(new AimdRateControl()); 249 remote_rate_.reset(new AimdRateControl());
250 return remote_rate_.get(); 250 return remote_rate_.get();
251 } 251 }
252 252
253 void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) { 253 void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) {
254 rtc::CritScope cs(&crit_sect_); 254 rtc::CritScope cs(&crit_sect_);
255 remote_rate_->SetMinBitrate(min_bitrate_bps); 255 remote_rate_->SetMinBitrate(min_bitrate_bps);
256 } 256 }
257 257
258 } // namespace webrtc 258 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698