| 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 19 matching lines...) Expand all Loading... |
| 30 // The maximum time interval between first and the last probe on a cluster | 30 // The maximum time interval between first and the last probe on a cluster |
| 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 PacketFeedback& packet_feedback) { |
| 41 int cluster_id = packet_info.pacing_info.probe_cluster_id; | 41 int cluster_id = packet_feedback.pacing_info.probe_cluster_id; |
| 42 RTC_DCHECK_NE(cluster_id, PacedPacketInfo::kNotAProbe); | 42 RTC_DCHECK_NE(cluster_id, PacedPacketInfo::kNotAProbe); |
| 43 | 43 |
| 44 EraseOldClusters(packet_info.arrival_time_ms - kMaxClusterHistoryMs); | 44 EraseOldClusters(packet_feedback.arrival_time_ms - kMaxClusterHistoryMs); |
| 45 | 45 |
| 46 int payload_size_bits = packet_info.payload_size * 8; | 46 int payload_size_bits = packet_feedback.payload_size * 8; |
| 47 AggregatedCluster* cluster = &clusters_[cluster_id]; | 47 AggregatedCluster* cluster = &clusters_[cluster_id]; |
| 48 | 48 |
| 49 if (packet_info.send_time_ms < cluster->first_send_ms) { | 49 if (packet_feedback.send_time_ms < cluster->first_send_ms) { |
| 50 cluster->first_send_ms = packet_info.send_time_ms; | 50 cluster->first_send_ms = packet_feedback.send_time_ms; |
| 51 } | 51 } |
| 52 if (packet_info.send_time_ms > cluster->last_send_ms) { | 52 if (packet_feedback.send_time_ms > cluster->last_send_ms) { |
| 53 cluster->last_send_ms = packet_info.send_time_ms; | 53 cluster->last_send_ms = packet_feedback.send_time_ms; |
| 54 cluster->size_last_send = payload_size_bits; | 54 cluster->size_last_send = payload_size_bits; |
| 55 } | 55 } |
| 56 if (packet_info.arrival_time_ms < cluster->first_receive_ms) { | 56 if (packet_feedback.arrival_time_ms < cluster->first_receive_ms) { |
| 57 cluster->first_receive_ms = packet_info.arrival_time_ms; | 57 cluster->first_receive_ms = packet_feedback.arrival_time_ms; |
| 58 cluster->size_first_receive = payload_size_bits; | 58 cluster->size_first_receive = payload_size_bits; |
| 59 } | 59 } |
| 60 if (packet_info.arrival_time_ms > cluster->last_receive_ms) { | 60 if (packet_feedback.arrival_time_ms > cluster->last_receive_ms) { |
| 61 cluster->last_receive_ms = packet_info.arrival_time_ms; | 61 cluster->last_receive_ms = packet_feedback.arrival_time_ms; |
| 62 } | 62 } |
| 63 cluster->size_total += payload_size_bits; | 63 cluster->size_total += payload_size_bits; |
| 64 cluster->num_probes += 1; | 64 cluster->num_probes += 1; |
| 65 | 65 |
| 66 if (cluster->num_probes < kMinNumProbesValidCluster) | 66 if (cluster->num_probes < kMinNumProbesValidCluster) |
| 67 return -1; | 67 return -1; |
| 68 | 68 |
| 69 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; |
| 70 float receive_interval_ms = | 70 float receive_interval_ms = |
| 71 cluster->last_receive_ms - cluster->first_receive_ms; | 71 cluster->last_receive_ms - cluster->first_receive_ms; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { | 119 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { |
| 120 for (auto it = clusters_.begin(); it != clusters_.end();) { | 120 for (auto it = clusters_.begin(); it != clusters_.end();) { |
| 121 if (it->second.last_receive_ms < timestamp_ms) { | 121 if (it->second.last_receive_ms < timestamp_ms) { |
| 122 it = clusters_.erase(it); | 122 it = clusters_.erase(it); |
| 123 } else { | 123 } else { |
| 124 ++it; | 124 ++it; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } // namespace webrtc | 128 } // namespace webrtc |
| OLD | NEW |