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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 event_log_->LogProbeResultFailure(cluster_id, kInvalidSendReceiveRatio); | 126 event_log_->LogProbeResultFailure(cluster_id, kInvalidSendReceiveRatio); |
127 return -1; | 127 return -1; |
128 } | 128 } |
129 LOG(LS_INFO) << "Probing successful" | 129 LOG(LS_INFO) << "Probing successful" |
130 << " [cluster id: " << cluster_id << "] [send: " << send_size | 130 << " [cluster id: " << cluster_id << "] [send: " << send_size |
131 << " bytes / " << send_interval_ms << " ms = " << send_bps / 1000 | 131 << " bytes / " << send_interval_ms << " ms = " << send_bps / 1000 |
132 << " kb/s]" | 132 << " kb/s]" |
133 << " [receive: " << receive_size << " bytes / " | 133 << " [receive: " << receive_size << " bytes / " |
134 << receive_interval_ms << " ms = " << receive_bps / 1000 | 134 << receive_interval_ms << " ms = " << receive_bps / 1000 |
135 << " kb/s]"; | 135 << " kb/s]"; |
| 136 |
136 float res = std::min(send_bps, receive_bps); | 137 float res = std::min(send_bps, receive_bps); |
137 if (event_log_) | 138 if (event_log_) |
138 event_log_->LogProbeResultSuccess(cluster_id, res); | 139 event_log_->LogProbeResultSuccess(cluster_id, res); |
139 return res; | 140 estimated_bitrate_bps_ = rtc::Optional<int>(std::min(send_bps, res)); |
| 141 return *estimated_bitrate_bps_; |
| 142 } |
| 143 |
| 144 rtc::Optional<int> |
| 145 ProbeBitrateEstimator::FetchAndResetLastEstimatedBitrateBps() { |
| 146 rtc::Optional<int> estimated_bitrate_bps = estimated_bitrate_bps_; |
| 147 estimated_bitrate_bps_.reset(); |
| 148 return estimated_bitrate_bps; |
140 } | 149 } |
141 | 150 |
142 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { | 151 void ProbeBitrateEstimator::EraseOldClusters(int64_t timestamp_ms) { |
143 for (auto it = clusters_.begin(); it != clusters_.end();) { | 152 for (auto it = clusters_.begin(); it != clusters_.end();) { |
144 if (it->second.last_receive_ms < timestamp_ms) { | 153 if (it->second.last_receive_ms < timestamp_ms) { |
145 it = clusters_.erase(it); | 154 it = clusters_.erase(it); |
146 } else { | 155 } else { |
147 ++it; | 156 ++it; |
148 } | 157 } |
149 } | 158 } |
150 } | 159 } |
151 } // namespace webrtc | 160 } // namespace webrtc |
OLD | NEW |