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

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe.cc

Issue 2404253004: Rename variables to reflect that DelayBasedBwe lives on the send side rather than receive side. (Closed)
Patch Set: Created 4 years, 2 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/congestion_controller/delay_based_bwe.h ('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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 26 matching lines...) Expand all
37 constexpr uint32_t kFixedSsrc = 0; 37 constexpr uint32_t kFixedSsrc = 0;
38 } // namespace 38 } // namespace
39 39
40 namespace webrtc { 40 namespace webrtc {
41 41
42 DelayBasedBwe::DelayBasedBwe(Clock* clock) 42 DelayBasedBwe::DelayBasedBwe(Clock* clock)
43 : clock_(clock), 43 : clock_(clock),
44 inter_arrival_(), 44 inter_arrival_(),
45 estimator_(), 45 estimator_(),
46 detector_(OverUseDetectorOptions()), 46 detector_(OverUseDetectorOptions()),
47 incoming_bitrate_(kBitrateWindowMs, 8000), 47 receiver_incoming_bitrate_(kBitrateWindowMs, 8000),
48 last_update_ms_(-1), 48 last_update_ms_(-1),
49 last_seen_packet_ms_(-1), 49 last_seen_packet_ms_(-1),
50 uma_recorded_(false) { 50 uma_recorded_(false) {
51 network_thread_.DetachFromThread(); 51 network_thread_.DetachFromThread();
52 } 52 }
53 53
54 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( 54 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector(
55 const std::vector<PacketInfo>& packet_feedback_vector) { 55 const std::vector<PacketInfo>& packet_feedback_vector) {
56 RTC_DCHECK(network_thread_.CalledOnValidThread()); 56 RTC_DCHECK(network_thread_.CalledOnValidThread());
57 if (!uma_recorded_) { 57 if (!uma_recorded_) {
58 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, 58 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram,
59 BweNames::kSendSideTransportSeqNum, 59 BweNames::kSendSideTransportSeqNum,
60 BweNames::kBweNamesMax); 60 BweNames::kBweNamesMax);
61 uma_recorded_ = true; 61 uma_recorded_ = true;
62 } 62 }
63 Result aggregated_result; 63 Result aggregated_result;
64 for (const auto& packet_info : packet_feedback_vector) { 64 for (const auto& packet_info : packet_feedback_vector) {
65 Result result = IncomingPacketInfo(packet_info); 65 Result result = IncomingPacketInfo(packet_info);
66 if (result.updated) 66 if (result.updated)
67 aggregated_result = result; 67 aggregated_result = result;
68 } 68 }
69 return aggregated_result; 69 return aggregated_result;
70 } 70 }
71 71
72 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketInfo( 72 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketInfo(
73 const PacketInfo& info) { 73 const PacketInfo& info) {
74 int64_t now_ms = clock_->TimeInMilliseconds(); 74 int64_t now_ms = clock_->TimeInMilliseconds();
75 75
76 incoming_bitrate_.Update(info.payload_size, info.arrival_time_ms); 76 receiver_incoming_bitrate_.Update(info.payload_size, info.arrival_time_ms);
77 Result result; 77 Result result;
78 // Reset if the stream has timed out. 78 // Reset if the stream has timed out.
79 if (last_seen_packet_ms_ == -1 || 79 if (last_seen_packet_ms_ == -1 ||
80 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { 80 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) {
81 inter_arrival_.reset( 81 inter_arrival_.reset(
82 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000, 82 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000,
83 kTimestampToMs, true)); 83 kTimestampToMs, true));
84 estimator_.reset(new OveruseEstimator(OverUseDetectorOptions())); 84 estimator_.reset(new OveruseEstimator(OverUseDetectorOptions()));
85 } 85 }
86 last_seen_packet_ms_ = now_ms; 86 last_seen_packet_ms_ = now_ms;
(...skipping 22 matching lines...) Expand all
109 } 109 }
110 110
111 int probing_bps = 0; 111 int probing_bps = 0;
112 if (info.probe_cluster_id != PacketInfo::kNotAProbe) { 112 if (info.probe_cluster_id != PacketInfo::kNotAProbe) {
113 probing_bps = probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(info); 113 probing_bps = probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(info);
114 } 114 }
115 115
116 // Currently overusing the bandwidth. 116 // Currently overusing the bandwidth.
117 if (detector_.State() == kBwOverusing) { 117 if (detector_.State() == kBwOverusing) {
118 rtc::Optional<uint32_t> incoming_rate = 118 rtc::Optional<uint32_t> incoming_rate =
119 incoming_bitrate_.Rate(info.arrival_time_ms); 119 receiver_incoming_bitrate_.Rate(info.arrival_time_ms);
120 if (incoming_rate && 120 if (incoming_rate &&
121 remote_rate_.TimeToReduceFurther(now_ms, *incoming_rate)) { 121 rate_control_.TimeToReduceFurther(now_ms, *incoming_rate)) {
122 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms, 122 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms,
123 &result.target_bitrate_bps); 123 &result.target_bitrate_bps);
124 } 124 }
125 } else if (probing_bps > 0) { 125 } else if (probing_bps > 0) {
126 // No overuse, but probing measured a bitrate. 126 // No overuse, but probing measured a bitrate.
127 remote_rate_.SetEstimate(probing_bps, info.arrival_time_ms); 127 rate_control_.SetEstimate(probing_bps, info.arrival_time_ms);
128 result.probe = true; 128 result.probe = true;
129 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms, 129 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms,
130 &result.target_bitrate_bps); 130 &result.target_bitrate_bps);
131 } 131 }
132 rtc::Optional<uint32_t> incoming_rate = 132 rtc::Optional<uint32_t> incoming_rate =
133 incoming_bitrate_.Rate(info.arrival_time_ms); 133 receiver_incoming_bitrate_.Rate(info.arrival_time_ms);
stefan-webrtc 2016/10/15 05:21:37 This seems to be unused. Feel free to remove.
terelius 2016/10/18 12:39:57 Will do in a follow-up CL.
134 if (!result.updated && 134 if (!result.updated &&
135 (last_update_ms_ == -1 || 135 (last_update_ms_ == -1 ||
136 now_ms - last_update_ms_ > remote_rate_.GetFeedbackInterval())) { 136 now_ms - last_update_ms_ > rate_control_.GetFeedbackInterval())) {
137 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms, 137 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms,
138 &result.target_bitrate_bps); 138 &result.target_bitrate_bps);
139 } 139 }
140 if (result.updated) 140 if (result.updated)
141 last_update_ms_ = now_ms; 141 last_update_ms_ = now_ms;
142 142
143 return result; 143 return result;
144 } 144 }
145 145
146 bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms, 146 bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms,
147 int64_t now_ms, 147 int64_t now_ms,
148 uint32_t* target_bitrate_bps) { 148 uint32_t* target_bitrate_bps) {
149 // The first overuse should immediately trigger a new estimate. 149 // The first overuse should immediately trigger a new estimate.
150 // We also have to update the estimate immediately if we are overusing 150 // We also have to update the estimate immediately if we are overusing
151 // and the target bitrate is too high compared to what we are receiving. 151 // and the target bitrate is too high compared to what we are receiving.
152 const RateControlInput input(detector_.State(), 152 const RateControlInput input(detector_.State(),
153 incoming_bitrate_.Rate(arrival_time_ms), 153 receiver_incoming_bitrate_.Rate(arrival_time_ms),
154 estimator_->var_noise()); 154 estimator_->var_noise());
155 remote_rate_.Update(&input, now_ms); 155 rate_control_.Update(&input, now_ms);
156 *target_bitrate_bps = remote_rate_.UpdateBandwidthEstimate(now_ms); 156 *target_bitrate_bps = rate_control_.UpdateBandwidthEstimate(now_ms);
157 return remote_rate_.ValidEstimate(); 157 return rate_control_.ValidEstimate();
158 } 158 }
159 159
160 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 160 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
161 remote_rate_.SetRtt(avg_rtt_ms); 161 rate_control_.SetRtt(avg_rtt_ms);
162 } 162 }
163 163
164 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs, 164 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs,
165 uint32_t* bitrate_bps) const { 165 uint32_t* bitrate_bps) const {
166 // Currently accessed from both the process thread (see 166 // Currently accessed from both the process thread (see
167 // ModuleRtpRtcpImpl::Process()) and the configuration thread (see 167 // ModuleRtpRtcpImpl::Process()) and the configuration thread (see
168 // Call::GetStats()). Should in the future only be accessed from a single 168 // Call::GetStats()). Should in the future only be accessed from a single
169 // thread. 169 // thread.
170 RTC_DCHECK(ssrcs); 170 RTC_DCHECK(ssrcs);
171 RTC_DCHECK(bitrate_bps); 171 RTC_DCHECK(bitrate_bps);
172 if (!remote_rate_.ValidEstimate()) 172 if (!rate_control_.ValidEstimate())
173 return false; 173 return false;
174 174
175 *ssrcs = {kFixedSsrc}; 175 *ssrcs = {kFixedSsrc};
176 *bitrate_bps = remote_rate_.LatestEstimate(); 176 *bitrate_bps = rate_control_.LatestEstimate();
177 return true; 177 return true;
178 } 178 }
179 179
180 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { 180 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) {
181 // Called from both the configuration thread and the network thread. Shouldn't 181 // Called from both the configuration thread and the network thread. Shouldn't
182 // be called from the network thread in the future. 182 // be called from the network thread in the future.
183 remote_rate_.SetMinBitrate(min_bitrate_bps); 183 rate_control_.SetMinBitrate(min_bitrate_bps);
184 } 184 }
185 } // namespace webrtc 185 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/delay_based_bwe.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698