| 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 |
| 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 | 17 |
| 18 namespace { | 18 namespace { |
| 19 // The minumum number of probes we need for a valid cluster. | 19 // The minumum number of probes we need to receive feedback about in percent |
| 20 constexpr int kMinNumProbesValidCluster = 4; | 20 // in order to have a valid estimate. |
| 21 constexpr int kMinReceivedProbesPercent = 80; |
| 22 |
| 23 // The minumum number of bytes we need to receive feedback about in percent |
| 24 // in order to have a valid estimate. |
| 25 constexpr int kMinReceivedBytesPercent = 80; |
| 21 | 26 |
| 22 // The maximum (receive rate)/(send rate) ratio for a valid estimate. | 27 // The maximum (receive rate)/(send rate) ratio for a valid estimate. |
| 23 constexpr float kValidRatio = 2.0f; | 28 constexpr float kValidRatio = 2.0f; |
| 24 | 29 |
| 25 // The maximum time period over which the cluster history is retained. | 30 // The maximum time period over which the cluster history is retained. |
| 26 // This is also the maximum time period beyond which a probing burst is not | 31 // This is also the maximum time period beyond which a probing burst is not |
| 27 // expected to last. | 32 // expected to last. |
| 28 constexpr int kMaxClusterHistoryMs = 1000; | 33 constexpr int kMaxClusterHistoryMs = 1000; |
| 29 | 34 |
| 30 // The maximum time interval between first and the last probe on a cluster | 35 // The maximum time interval between first and the last probe on a cluster |
| (...skipping 25 matching lines...) Expand all Loading... |
| 56 if (packet_feedback.arrival_time_ms < cluster->first_receive_ms) { | 61 if (packet_feedback.arrival_time_ms < cluster->first_receive_ms) { |
| 57 cluster->first_receive_ms = packet_feedback.arrival_time_ms; | 62 cluster->first_receive_ms = packet_feedback.arrival_time_ms; |
| 58 cluster->size_first_receive = payload_size_bits; | 63 cluster->size_first_receive = payload_size_bits; |
| 59 } | 64 } |
| 60 if (packet_feedback.arrival_time_ms > cluster->last_receive_ms) { | 65 if (packet_feedback.arrival_time_ms > cluster->last_receive_ms) { |
| 61 cluster->last_receive_ms = packet_feedback.arrival_time_ms; | 66 cluster->last_receive_ms = packet_feedback.arrival_time_ms; |
| 62 } | 67 } |
| 63 cluster->size_total += payload_size_bits; | 68 cluster->size_total += payload_size_bits; |
| 64 cluster->num_probes += 1; | 69 cluster->num_probes += 1; |
| 65 | 70 |
| 66 if (cluster->num_probes < kMinNumProbesValidCluster) | 71 RTC_DCHECK_GT(packet_feedback.pacing_info.probe_cluster_min_probes, 0); |
| 72 RTC_DCHECK_GT(packet_feedback.pacing_info.probe_cluster_min_bytes, 0); |
| 73 |
| 74 int min_probes = packet_feedback.pacing_info.probe_cluster_min_probes * |
| 75 kMinReceivedProbesPercent / 100; |
| 76 int min_bytes = packet_feedback.pacing_info.probe_cluster_min_bytes * |
| 77 kMinReceivedBytesPercent / 100; |
| 78 if (cluster->num_probes < min_probes || cluster->size_total < min_bytes * 8) |
| 67 return -1; | 79 return -1; |
| 68 | 80 |
| 69 float send_interval_ms = cluster->last_send_ms - cluster->first_send_ms; | 81 float send_interval_ms = cluster->last_send_ms - cluster->first_send_ms; |
| 70 float receive_interval_ms = | 82 float receive_interval_ms = |
| 71 cluster->last_receive_ms - cluster->first_receive_ms; | 83 cluster->last_receive_ms - cluster->first_receive_ms; |
| 72 | 84 |
| 73 if (send_interval_ms <= 0 || send_interval_ms > kMaxProbeIntervalMs || | 85 if (send_interval_ms <= 0 || send_interval_ms > kMaxProbeIntervalMs || |
| 74 receive_interval_ms <= 0 || receive_interval_ms > kMaxProbeIntervalMs) { | 86 receive_interval_ms <= 0 || receive_interval_ms > kMaxProbeIntervalMs) { |
| 75 LOG(LS_INFO) << "Probing unsuccessful, invalid send/receive interval" | 87 LOG(LS_INFO) << "Probing unsuccessful, invalid send/receive interval" |
| 76 << " [cluster id: " << cluster_id | 88 << " [cluster id: " << cluster_id |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { | 131 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { |
| 120 for (auto it = clusters_.begin(); it != clusters_.end();) { | 132 for (auto it = clusters_.begin(); it != clusters_.end();) { |
| 121 if (it->second.last_receive_ms < timestamp_ms) { | 133 if (it->second.last_receive_ms < timestamp_ms) { |
| 122 it = clusters_.erase(it); | 134 it = clusters_.erase(it); |
| 123 } else { | 135 } else { |
| 124 ++it; | 136 ++it; |
| 125 } | 137 } |
| 126 } | 138 } |
| 127 } | 139 } |
| 128 } // namespace webrtc | 140 } // namespace webrtc |
| OLD | NEW |