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

Side by Side Diff: webrtc/modules/pacing/bitrate_prober.cc

Issue 2650393002: Improve bitrate probing for the audio-only case. (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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 } 58 }
59 59
60 bool BitrateProber::IsProbing() const { 60 bool BitrateProber::IsProbing() const {
61 return probing_state_ == ProbingState::kActive; 61 return probing_state_ == ProbingState::kActive;
62 } 62 }
63 63
64 void BitrateProber::OnIncomingPacket(size_t packet_size) { 64 void BitrateProber::OnIncomingPacket(size_t packet_size) {
65 // Don't initialize probing unless we have something large enough to start 65 // Don't initialize probing unless we have something large enough to start
66 // probing. 66 // probing.
67 if (probing_state_ == ProbingState::kInactive && 67 const size_t kMinProbePacketSize = 200;
philipel 2017/01/25 13:39:37 Move to anonymous namespace.
68 !clusters_.empty() && 68 if (probing_state_ == ProbingState::kInactive && !clusters_.empty() &&
69 packet_size >= PacedSender::kMinProbePacketSize) { 69 packet_size >=
70 std::min<size_t>(RecommendedMinProbeSize(), kMinProbePacketSize)) {
70 // Send next probe right away. 71 // Send next probe right away.
71 next_probe_time_ms_ = -1; 72 next_probe_time_ms_ = -1;
72 probing_state_ = ProbingState::kActive; 73 probing_state_ = ProbingState::kActive;
73 } 74 }
74 } 75 }
75 76
76 void BitrateProber::CreateProbeCluster(int bitrate_bps) { 77 void BitrateProber::CreateProbeCluster(int bitrate_bps) {
77 RTC_DCHECK(probing_state_ != ProbingState::kDisabled); 78 RTC_DCHECK(probing_state_ != ProbingState::kDisabled);
78 ProbeCluster cluster; 79 ProbeCluster cluster;
79 cluster.min_probes = kMinProbePacketsSent; 80 cluster.min_probes = kMinProbePacketsSent;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 RTC_DCHECK(!clusters_.empty()); 130 RTC_DCHECK(!clusters_.empty());
130 RTC_DCHECK(ProbingState::kActive == probing_state_); 131 RTC_DCHECK(ProbingState::kActive == probing_state_);
131 return clusters_.front().id; 132 return clusters_.front().id;
132 } 133 }
133 134
134 // Probe size is recommended based on the probe bitrate required. We choose 135 // Probe size is recommended based on the probe bitrate required. We choose
135 // a minimum of twice |kMinProbeDeltaMs| interval to allow scheduling to be 136 // a minimum of twice |kMinProbeDeltaMs| interval to allow scheduling to be
136 // feasible. 137 // feasible.
137 size_t BitrateProber::RecommendedMinProbeSize() const { 138 size_t BitrateProber::RecommendedMinProbeSize() const {
138 RTC_DCHECK(!clusters_.empty()); 139 RTC_DCHECK(!clusters_.empty());
139 return clusters_.front().bitrate_bps * 2 * kMinProbeDeltaMs / (8 * 1000); 140 return clusters_.front().bitrate_bps * 3 * kMinProbeDeltaMs / (8 * 1000);
140 } 141 }
141 142
142 void BitrateProber::ProbeSent(int64_t now_ms, size_t bytes) { 143 void BitrateProber::ProbeSent(int64_t now_ms, size_t bytes) {
143 RTC_DCHECK(probing_state_ == ProbingState::kActive); 144 RTC_DCHECK(probing_state_ == ProbingState::kActive);
144 RTC_DCHECK_GT(bytes, 0); 145 RTC_DCHECK_GT(bytes, 0);
145 146
146 if (!clusters_.empty()) { 147 if (!clusters_.empty()) {
147 ProbeCluster* cluster = &clusters_.front(); 148 ProbeCluster* cluster = &clusters_.front();
148 if (cluster->sent_probes == 0) { 149 if (cluster->sent_probes == 0) {
149 RTC_DCHECK_EQ(cluster->time_started_ms, -1); 150 RTC_DCHECK_EQ(cluster->time_started_ms, -1);
(...skipping 17 matching lines...) Expand all
167 168
168 // Compute the time delta from the cluster start to ensure probe bitrate stays 169 // Compute the time delta from the cluster start to ensure probe bitrate stays
169 // close to the target bitrate. Result is in milliseconds. 170 // close to the target bitrate. Result is in milliseconds.
170 int64_t delta_ms = (8000ll * cluster.sent_bytes + cluster.bitrate_bps / 2) / 171 int64_t delta_ms = (8000ll * cluster.sent_bytes + cluster.bitrate_bps / 2) /
171 cluster.bitrate_bps; 172 cluster.bitrate_bps;
172 return cluster.time_started_ms + delta_ms; 173 return cluster.time_started_ms + delta_ms;
173 } 174 }
174 175
175 176
176 } // namespace webrtc 177 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/alr_detector_unittest.cc ('k') | webrtc/modules/pacing/bitrate_prober_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698