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

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

Issue 2827333005: Moving overhead counting to bitrate estimators.
Patch Set: 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
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
11 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" 11 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
17 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 17 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
18 #include "webrtc/system_wrappers/include/field_trial.h"
18 19
19 namespace { 20 namespace {
20 // The minumum number of probes we need to receive feedback about in percent 21 // The minumum number of probes we need to receive feedback about in percent
21 // in order to have a valid estimate. 22 // in order to have a valid estimate.
22 constexpr int kMinReceivedProbesPercent = 80; 23 constexpr int kMinReceivedProbesPercent = 80;
23 24
24 // The minumum number of bytes we need to receive feedback about in percent 25 // The minumum number of bytes we need to receive feedback about in percent
25 // in order to have a valid estimate. 26 // in order to have a valid estimate.
26 constexpr int kMinReceivedBytesPercent = 80; 27 constexpr int kMinReceivedBytesPercent = 80;
27 28
28 // The maximum (receive rate)/(send rate) ratio for a valid estimate. 29 // The maximum (receive rate)/(send rate) ratio for a valid estimate.
29 constexpr float kValidRatio = 2.0f; 30 constexpr float kValidRatio = 2.0f;
30 31
31 // The maximum time period over which the cluster history is retained. 32 // The maximum time period over which the cluster history is retained.
32 // This is also the maximum time period beyond which a probing burst is not 33 // This is also the maximum time period beyond which a probing burst is not
33 // expected to last. 34 // expected to last.
34 constexpr int kMaxClusterHistoryMs = 1000; 35 constexpr int kMaxClusterHistoryMs = 1000;
35 36
36 // The maximum time interval between first and the last probe on a cluster 37 // The maximum time interval between first and the last probe on a cluster
37 // on the sender side as well as the receive side. 38 // on the sender side as well as the receive side.
38 constexpr int kMaxProbeIntervalMs = 1000; 39 constexpr int kMaxProbeIntervalMs = 1000;
39 } // namespace 40 } // namespace
40 41
41 namespace webrtc { 42 namespace webrtc {
42 43
43 ProbeBitrateEstimator::ProbeBitrateEstimator(RtcEventLog* event_log) 44 ProbeBitrateEstimator::ProbeBitrateEstimator(RtcEventLog* event_log)
44 : event_log_(event_log) {} 45 : event_log_(event_log),
46 send_side_bwe_with_overhead_(
47 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")) {}
45 48
46 int ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( 49 int ProbeBitrateEstimator::HandleProbeAndEstimateBitrate(
47 const PacketFeedback& packet_feedback) { 50 const PacketFeedback& packet_feedback) {
48 int cluster_id = packet_feedback.pacing_info.probe_cluster_id; 51 int cluster_id = packet_feedback.pacing_info.probe_cluster_id;
49 RTC_DCHECK_NE(cluster_id, PacedPacketInfo::kNotAProbe); 52 RTC_DCHECK_NE(cluster_id, PacedPacketInfo::kNotAProbe);
50 53
51 EraseOldClusters(packet_feedback.arrival_time_ms - kMaxClusterHistoryMs); 54 EraseOldClusters(packet_feedback.arrival_time_ms - kMaxClusterHistoryMs);
52 55
53 int payload_size_bits = packet_feedback.payload_size * 8; 56 const size_t packet_size = send_side_bwe_with_overhead_
57 ? packet_feedback.payload_size +
58 packet_feedback.rtp_headers_size +
59 packet_feedback.transport_headers_size
60 : packet_feedback.payload_size;
61 int packet_size_bits = packet_size * 8;
62
54 AggregatedCluster* cluster = &clusters_[cluster_id]; 63 AggregatedCluster* cluster = &clusters_[cluster_id];
55 64
56 if (packet_feedback.send_time_ms < cluster->first_send_ms) { 65 if (packet_feedback.send_time_ms < cluster->first_send_ms) {
57 cluster->first_send_ms = packet_feedback.send_time_ms; 66 cluster->first_send_ms = packet_feedback.send_time_ms;
58 } 67 }
59 if (packet_feedback.send_time_ms > cluster->last_send_ms) { 68 if (packet_feedback.send_time_ms > cluster->last_send_ms) {
60 cluster->last_send_ms = packet_feedback.send_time_ms; 69 cluster->last_send_ms = packet_feedback.send_time_ms;
61 cluster->size_last_send = payload_size_bits; 70 cluster->size_last_send = packet_size_bits;
62 } 71 }
63 if (packet_feedback.arrival_time_ms < cluster->first_receive_ms) { 72 if (packet_feedback.arrival_time_ms < cluster->first_receive_ms) {
64 cluster->first_receive_ms = packet_feedback.arrival_time_ms; 73 cluster->first_receive_ms = packet_feedback.arrival_time_ms;
65 cluster->size_first_receive = payload_size_bits; 74 cluster->size_first_receive = packet_size_bits;
66 } 75 }
67 if (packet_feedback.arrival_time_ms > cluster->last_receive_ms) { 76 if (packet_feedback.arrival_time_ms > cluster->last_receive_ms) {
68 cluster->last_receive_ms = packet_feedback.arrival_time_ms; 77 cluster->last_receive_ms = packet_feedback.arrival_time_ms;
69 } 78 }
70 cluster->size_total += payload_size_bits; 79 cluster->size_total += packet_size_bits;
71 cluster->num_probes += 1; 80 cluster->num_probes += 1;
72 81
73 RTC_DCHECK_GT(packet_feedback.pacing_info.probe_cluster_min_probes, 0); 82 RTC_DCHECK_GT(packet_feedback.pacing_info.probe_cluster_min_probes, 0);
74 RTC_DCHECK_GT(packet_feedback.pacing_info.probe_cluster_min_bytes, 0); 83 RTC_DCHECK_GT(packet_feedback.pacing_info.probe_cluster_min_bytes, 0);
75 84
76 int min_probes = packet_feedback.pacing_info.probe_cluster_min_probes * 85 int min_probes = packet_feedback.pacing_info.probe_cluster_min_probes *
77 kMinReceivedProbesPercent / 100; 86 kMinReceivedProbesPercent / 100;
78 int min_bytes = packet_feedback.pacing_info.probe_cluster_min_bytes * 87 int min_bytes = packet_feedback.pacing_info.probe_cluster_min_bytes *
79 kMinReceivedBytesPercent / 100; 88 kMinReceivedBytesPercent / 100;
80 if (cluster->num_probes < min_probes || cluster->size_total < min_bytes * 8) 89 if (cluster->num_probes < min_probes || cluster->size_total < min_bytes * 8)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { 160 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) {
152 for (auto it = clusters_.begin(); it != clusters_.end();) { 161 for (auto it = clusters_.begin(); it != clusters_.end();) {
153 if (it->second.last_receive_ms < timestamp_ms) { 162 if (it->second.last_receive_ms < timestamp_ms) {
154 it = clusters_.erase(it); 163 it = clusters_.erase(it);
155 } else { 164 } else {
156 ++it; 165 ++it;
157 } 166 }
158 } 167 }
159 } 168 }
160 } // namespace webrtc 169 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698