OLD | NEW |
---|---|
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 30 matching lines...) Expand all Loading... | |
41 ProbingResult ProbeBitrateEstimator::PacketFeedback( | 41 ProbingResult ProbeBitrateEstimator::PacketFeedback( |
42 const PacketInfo& packet_info) { | 42 const PacketInfo& packet_info) { |
43 // If this is not a probing packet or if this probing packet | 43 // If this is not a probing packet or if this probing packet |
44 // belongs to an old cluster, do nothing. | 44 // belongs to an old cluster, do nothing. |
45 if (packet_info.probe_cluster_id == PacketInfo::kNotAProbe || | 45 if (packet_info.probe_cluster_id == PacketInfo::kNotAProbe || |
46 packet_info.probe_cluster_id < last_valid_cluster_id_) { | 46 packet_info.probe_cluster_id < last_valid_cluster_id_) { |
47 return ProbingResult(); | 47 return ProbingResult(); |
48 } | 48 } |
49 | 49 |
50 AggregatedCluster* cluster = &clusters_[packet_info.probe_cluster_id]; | 50 AggregatedCluster* cluster = &clusters_[packet_info.probe_cluster_id]; |
51 | |
51 cluster->first_send_ms = | 52 cluster->first_send_ms = |
52 std::min(cluster->first_send_ms, packet_info.send_time_ms); | 53 std::min(cluster->first_send_ms, packet_info.send_time_ms); |
53 cluster->last_send_ms = | 54 cluster->last_send_ms = |
54 std::max(cluster->last_send_ms, packet_info.send_time_ms); | 55 std::max(cluster->last_send_ms, packet_info.send_time_ms); |
55 cluster->first_receive_ms = | 56 cluster->first_receive_ms = |
56 std::min(cluster->first_receive_ms, packet_info.arrival_time_ms); | 57 std::min(cluster->first_receive_ms, packet_info.arrival_time_ms); |
57 cluster->last_receive_ms = | 58 cluster->last_receive_ms = |
58 std::max(cluster->last_receive_ms, packet_info.arrival_time_ms); | 59 std::max(cluster->last_receive_ms, packet_info.arrival_time_ms); |
59 cluster->size += packet_info.payload_size * 8; | 60 cluster->size += packet_info.payload_size * 8; |
60 cluster->num_probes += 1; | 61 cluster->send_times_ms.insert(packet_info.send_time_ms); |
danilchap
2016/08/19 14:08:30
why is it needed?
| |
61 | 62 |
62 // Clean up old clusters. | 63 // Clean up old clusters. |
63 while (clusters_.size() > kMaxNumSavedClusters) | 64 while (clusters_.size() > kMaxNumSavedClusters) |
64 clusters_.erase(clusters_.begin()); | 65 clusters_.erase(clusters_.begin()); |
65 | 66 |
66 if (cluster->num_probes < kMinNumProbesValidCluster) | 67 if (cluster->send_times_ms.size() < kMinNumProbesValidCluster) |
danilchap
2016/08/19 14:08:30
If you worry two small padding packet is not enoug
| |
67 return ProbingResult(); | 68 return ProbingResult(); |
68 | 69 |
69 float send_interval_ms = cluster->last_send_ms - cluster->first_send_ms; | 70 float send_interval_ms = cluster->last_send_ms - cluster->first_send_ms; |
70 float receive_interval_ms = | 71 float receive_interval_ms = |
71 cluster->last_receive_ms - cluster->first_receive_ms; | 72 cluster->last_receive_ms - cluster->first_receive_ms; |
72 | 73 |
73 // Since the send/receive interval does not include the send/receive time of | 74 // Since the send/receive interval does not include the send/receive time of |
74 // the last/first packet we expand the interval by the average inverval | 75 // the last/first packet we expand the interval by the average inverval |
75 // between the probing packets. | 76 // between the probing packets. |
76 float interval_correction = | 77 float interval_correction = |
77 static_cast<float>(cluster->num_probes) / (cluster->num_probes - 1); | 78 static_cast<float>(cluster->send_times_ms.size()) / |
79 (cluster->send_times_ms.size() - 1); | |
78 send_interval_ms *= interval_correction; | 80 send_interval_ms *= interval_correction; |
79 receive_interval_ms *= interval_correction; | 81 receive_interval_ms *= interval_correction; |
80 | 82 |
81 if (send_interval_ms == 0 || receive_interval_ms == 0) { | 83 if (send_interval_ms == 0 || receive_interval_ms == 0) { |
82 LOG(LS_INFO) << "Probing unsuccessful, invalid send/receive interval" | 84 LOG(LS_INFO) << "Probing unsuccessful, invalid send/receive interval" |
83 << " [cluster id: " << packet_info.probe_cluster_id | 85 << " [cluster id: " << packet_info.probe_cluster_id |
84 << "] [send interval: " << send_interval_ms << " ms]" | 86 << "] [send interval: " << send_interval_ms << " ms]" |
85 << " [receive interval: " << receive_interval_ms << " ms]"; | 87 << " [receive interval: " << receive_interval_ms << " ms]"; |
86 | 88 |
87 return ProbingResult(); | 89 return ProbingResult(); |
(...skipping 23 matching lines...) Expand all Loading... | |
111 << " [cluster id: " << packet_info.probe_cluster_id | 113 << " [cluster id: " << packet_info.probe_cluster_id |
112 << "] [send: " << cluster->size << " bytes / " | 114 << "] [send: " << cluster->size << " bytes / " |
113 << send_interval_ms << " ms = " << send_bps / 1000 << " kb/s]" | 115 << send_interval_ms << " ms = " << send_bps / 1000 << " kb/s]" |
114 << " [receive: " << cluster->size << " bytes / " | 116 << " [receive: " << cluster->size << " bytes / " |
115 << receive_interval_ms << " ms = " << receive_bps / 1000 | 117 << receive_interval_ms << " ms = " << receive_bps / 1000 |
116 << " kb/s]"; | 118 << " kb/s]"; |
117 | 119 |
118 return ProbingResult(result_bps, packet_info.arrival_time_ms); | 120 return ProbingResult(result_bps, packet_info.arrival_time_ms); |
119 } | 121 } |
120 } // namespace webrtc | 122 } // namespace webrtc |
OLD | NEW |