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

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

Issue 2708873003: Propagate packet pacing information to SendTimeHistory. (Closed)
Patch Set: TransportFeedbackAdapterTest fix. 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) 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 20 matching lines...) Expand all
31 // on the sender side as well as the receive side. 31 // on the sender side as well as the receive side.
32 constexpr int kMaxProbeIntervalMs = 1000; 32 constexpr int kMaxProbeIntervalMs = 1000;
33 } // namespace 33 } // namespace
34 34
35 namespace webrtc { 35 namespace webrtc {
36 36
37 ProbeBitrateEstimator::ProbeBitrateEstimator() {} 37 ProbeBitrateEstimator::ProbeBitrateEstimator() {}
38 38
39 int ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( 39 int ProbeBitrateEstimator::HandleProbeAndEstimateBitrate(
40 const PacketInfo& packet_info) { 40 const PacketInfo& packet_info) {
41 RTC_DCHECK_NE(packet_info.probe_cluster_id, PacedPacketInfo::kNotAProbe); 41 int cluster_id = packet_info.pacing_info.probe_cluster_id;
42 RTC_DCHECK_NE(cluster_id, PacedPacketInfo::kNotAProbe);
42 43
43 EraseOldClusters(packet_info.arrival_time_ms - kMaxClusterHistoryMs); 44 EraseOldClusters(packet_info.arrival_time_ms - kMaxClusterHistoryMs);
44 45
45 int payload_size_bits = packet_info.payload_size * 8; 46 int payload_size_bits = packet_info.payload_size * 8;
46 AggregatedCluster* cluster = &clusters_[packet_info.probe_cluster_id]; 47 AggregatedCluster* cluster = &clusters_[cluster_id];
47 48
48 if (packet_info.send_time_ms < cluster->first_send_ms) { 49 if (packet_info.send_time_ms < cluster->first_send_ms) {
49 cluster->first_send_ms = packet_info.send_time_ms; 50 cluster->first_send_ms = packet_info.send_time_ms;
50 } 51 }
51 if (packet_info.send_time_ms > cluster->last_send_ms) { 52 if (packet_info.send_time_ms > cluster->last_send_ms) {
52 cluster->last_send_ms = packet_info.send_time_ms; 53 cluster->last_send_ms = packet_info.send_time_ms;
53 cluster->size_last_send = payload_size_bits; 54 cluster->size_last_send = payload_size_bits;
54 } 55 }
55 if (packet_info.arrival_time_ms < cluster->first_receive_ms) { 56 if (packet_info.arrival_time_ms < cluster->first_receive_ms) {
56 cluster->first_receive_ms = packet_info.arrival_time_ms; 57 cluster->first_receive_ms = packet_info.arrival_time_ms;
57 cluster->size_first_receive = payload_size_bits; 58 cluster->size_first_receive = payload_size_bits;
58 } 59 }
59 if (packet_info.arrival_time_ms > cluster->last_receive_ms) { 60 if (packet_info.arrival_time_ms > cluster->last_receive_ms) {
60 cluster->last_receive_ms = packet_info.arrival_time_ms; 61 cluster->last_receive_ms = packet_info.arrival_time_ms;
61 } 62 }
62 cluster->size_total += payload_size_bits; 63 cluster->size_total += payload_size_bits;
63 cluster->num_probes += 1; 64 cluster->num_probes += 1;
64 65
65 if (cluster->num_probes < kMinNumProbesValidCluster) 66 if (cluster->num_probes < kMinNumProbesValidCluster)
66 return -1; 67 return -1;
67 68
68 float send_interval_ms = cluster->last_send_ms - cluster->first_send_ms; 69 float send_interval_ms = cluster->last_send_ms - cluster->first_send_ms;
69 float receive_interval_ms = 70 float receive_interval_ms =
70 cluster->last_receive_ms - cluster->first_receive_ms; 71 cluster->last_receive_ms - cluster->first_receive_ms;
71 72
72 if (send_interval_ms <= 0 || send_interval_ms > kMaxProbeIntervalMs || 73 if (send_interval_ms <= 0 || send_interval_ms > kMaxProbeIntervalMs ||
73 receive_interval_ms <= 0 || receive_interval_ms > kMaxProbeIntervalMs) { 74 receive_interval_ms <= 0 || receive_interval_ms > kMaxProbeIntervalMs) {
74 LOG(LS_INFO) << "Probing unsuccessful, invalid send/receive interval" 75 LOG(LS_INFO) << "Probing unsuccessful, invalid send/receive interval"
75 << " [cluster id: " << packet_info.probe_cluster_id 76 << " [cluster id: " << cluster_id
76 << "] [send interval: " << send_interval_ms << " ms]" 77 << "] [send interval: " << send_interval_ms << " ms]"
77 << " [receive interval: " << receive_interval_ms << " ms]"; 78 << " [receive interval: " << receive_interval_ms << " ms]";
78 return -1; 79 return -1;
79 } 80 }
80 // Since the |send_interval_ms| does not include the time it takes to actually 81 // Since the |send_interval_ms| does not include the time it takes to actually
81 // send the last packet the size of the last sent packet should not be 82 // send the last packet the size of the last sent packet should not be
82 // included when calculating the send bitrate. 83 // included when calculating the send bitrate.
83 RTC_DCHECK_GT(cluster->size_total, cluster->size_last_send); 84 RTC_DCHECK_GT(cluster->size_total, cluster->size_last_send);
84 float send_size = cluster->size_total - cluster->size_last_send; 85 float send_size = cluster->size_total - cluster->size_last_send;
85 float send_bps = send_size / send_interval_ms * 1000; 86 float send_bps = send_size / send_interval_ms * 1000;
86 87
87 // Since the |receive_interval_ms| does not include the time it takes to 88 // Since the |receive_interval_ms| does not include the time it takes to
88 // actually receive the first packet the size of the first received packet 89 // actually receive the first packet the size of the first received packet
89 // should not be included when calculating the receive bitrate. 90 // should not be included when calculating the receive bitrate.
90 RTC_DCHECK_GT(cluster->size_total, cluster->size_first_receive); 91 RTC_DCHECK_GT(cluster->size_total, cluster->size_first_receive);
91 float receive_size = cluster->size_total - cluster->size_first_receive; 92 float receive_size = cluster->size_total - cluster->size_first_receive;
92 float receive_bps = receive_size / receive_interval_ms * 1000; 93 float receive_bps = receive_size / receive_interval_ms * 1000;
93 94
94 float ratio = receive_bps / send_bps; 95 float ratio = receive_bps / send_bps;
95 if (ratio > kValidRatio) { 96 if (ratio > kValidRatio) {
96 LOG(LS_INFO) << "Probing unsuccessful, receive/send ratio too high" 97 LOG(LS_INFO) << "Probing unsuccessful, receive/send ratio too high"
97 << " [cluster id: " << packet_info.probe_cluster_id 98 << " [cluster id: " << cluster_id << "] [send: " << send_size
98 << "] [send: " << send_size << " bytes / " << send_interval_ms 99 << " bytes / " << send_interval_ms
99 << " ms = " << send_bps / 1000 << " kb/s]" 100 << " ms = " << send_bps / 1000 << " kb/s]"
100 << " [receive: " << receive_size << " bytes / " 101 << " [receive: " << receive_size << " bytes / "
101 << receive_interval_ms << " ms = " << receive_bps / 1000 102 << receive_interval_ms << " ms = " << receive_bps / 1000
102 << " kb/s]" 103 << " kb/s]"
103 << " [ratio: " << receive_bps / 1000 << " / " 104 << " [ratio: " << receive_bps / 1000 << " / "
104 << send_bps / 1000 << " = " << ratio << " > kValidRatio (" 105 << send_bps / 1000 << " = " << ratio << " > kValidRatio ("
105 << kValidRatio << ")]"; 106 << kValidRatio << ")]";
106 return -1; 107 return -1;
107 } 108 }
108 LOG(LS_INFO) << "Probing successful" 109 LOG(LS_INFO) << "Probing successful"
109 << " [cluster id: " << packet_info.probe_cluster_id 110 << " [cluster id: " << cluster_id << "] [send: " << send_size
110 << "] [send: " << send_size << " bytes / " << send_interval_ms 111 << " bytes / " << send_interval_ms << " ms = " << send_bps / 1000
111 << " ms = " << send_bps / 1000 << " kb/s]" 112 << " kb/s]"
112 << " [receive: " << receive_size << " bytes / " 113 << " [receive: " << receive_size << " bytes / "
113 << receive_interval_ms << " ms = " << receive_bps / 1000 114 << receive_interval_ms << " ms = " << receive_bps / 1000
114 << " kb/s]"; 115 << " kb/s]";
115 return std::min(send_bps, receive_bps); 116 return std::min(send_bps, receive_bps);
116 } 117 }
117 118
118 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { 119 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) {
119 for (auto it = clusters_.begin(); it != clusters_.end();) { 120 for (auto it = clusters_.begin(); it != clusters_.end();) {
120 if (it->second.last_receive_ms < timestamp_ms) { 121 if (it->second.last_receive_ms < timestamp_ms) {
121 it = clusters_.erase(it); 122 it = clusters_.erase(it);
122 } else { 123 } else {
123 ++it; 124 ++it;
124 } 125 }
125 } 126 }
126 } 127 }
127 } // namespace webrtc 128 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698