| 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/delay_based_bwe.h" | 11 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" |
| 12 | 12 |
| 13 #include <math.h> | 13 #include <math.h> |
| 14 | 14 |
| 15 #include <algorithm> | 15 #include <algorithm> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
| 19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/base/thread_annotations.h" | 20 #include "webrtc/base/thread_annotations.h" |
| 21 #include "webrtc/modules/pacing/paced_sender.h" | 21 #include "webrtc/modules/pacing/paced_sender.h" |
| 22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
| 23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 24 #include "webrtc/system_wrappers/include/metrics.h" |
| 24 #include "webrtc/typedefs.h" | 25 #include "webrtc/typedefs.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 enum { | 28 enum { |
| 28 kTimestampGroupLengthMs = 5, | 29 kTimestampGroupLengthMs = 5, |
| 29 kAbsSendTimeFraction = 18, | 30 kAbsSendTimeFraction = 18, |
| 30 kAbsSendTimeInterArrivalUpshift = 8, | 31 kAbsSendTimeInterArrivalUpshift = 8, |
| 31 kInterArrivalShift = kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift, | 32 kInterArrivalShift = kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift, |
| 32 kInitialProbingIntervalMs = 2000, | 33 kInitialProbingIntervalMs = 2000, |
| 33 kMinClusterSize = 4, | 34 kMinClusterSize = 4, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 DelayBasedBwe::DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock) | 72 DelayBasedBwe::DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock) |
| 72 : clock_(clock), | 73 : clock_(clock), |
| 73 observer_(observer), | 74 observer_(observer), |
| 74 inter_arrival_(), | 75 inter_arrival_(), |
| 75 estimator_(), | 76 estimator_(), |
| 76 detector_(OverUseDetectorOptions()), | 77 detector_(OverUseDetectorOptions()), |
| 77 incoming_bitrate_(kBitrateWindowMs, 8000), | 78 incoming_bitrate_(kBitrateWindowMs, 8000), |
| 78 total_probes_received_(0), | 79 total_probes_received_(0), |
| 79 first_packet_time_ms_(-1), | 80 first_packet_time_ms_(-1), |
| 80 last_update_ms_(-1), | 81 last_update_ms_(-1), |
| 81 ssrcs_() { | 82 uma_recorded_(false) { |
| 82 RTC_DCHECK(observer_); | 83 RTC_DCHECK(observer_); |
| 83 // NOTE! The BitrateEstimatorTest relies on this EXACT log line. | 84 // NOTE! The BitrateEstimatorTest relies on this EXACT log line. |
| 84 LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating."; | 85 LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating."; |
| 85 network_thread_.DetachFromThread(); | 86 network_thread_.DetachFromThread(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DelayBasedBwe::ComputeClusters(std::list<Cluster>* clusters) const { | 89 void DelayBasedBwe::ComputeClusters(std::list<Cluster>* clusters) const { |
| 89 Cluster current; | 90 Cluster current; |
| 90 int64_t prev_send_time = -1; | 91 int64_t prev_send_time = -1; |
| 91 int64_t prev_recv_time = -1; | 92 int64_t prev_recv_time = -1; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 bool initial_probe = !remote_rate_.ValidEstimate() && new_bitrate_bps > 0; | 190 bool initial_probe = !remote_rate_.ValidEstimate() && new_bitrate_bps > 0; |
| 190 bool bitrate_above_estimate = | 191 bool bitrate_above_estimate = |
| 191 remote_rate_.ValidEstimate() && | 192 remote_rate_.ValidEstimate() && |
| 192 new_bitrate_bps > static_cast<int>(remote_rate_.LatestEstimate()); | 193 new_bitrate_bps > static_cast<int>(remote_rate_.LatestEstimate()); |
| 193 return initial_probe || bitrate_above_estimate; | 194 return initial_probe || bitrate_above_estimate; |
| 194 } | 195 } |
| 195 | 196 |
| 196 void DelayBasedBwe::IncomingPacketFeedbackVector( | 197 void DelayBasedBwe::IncomingPacketFeedbackVector( |
| 197 const std::vector<PacketInfo>& packet_feedback_vector) { | 198 const std::vector<PacketInfo>& packet_feedback_vector) { |
| 198 RTC_DCHECK(network_thread_.CalledOnValidThread()); | 199 RTC_DCHECK(network_thread_.CalledOnValidThread()); |
| 200 if (!uma_recorded_) { |
| 201 RTC_LOGGED_HISTOGRAM_ENUMERATION(kBweTypeHistogram, |
| 202 BweNames::kSendSideTransportSeqNum, |
| 203 BweNames::kBweNamesMax); |
| 204 uma_recorded_ = true; |
| 205 } |
| 199 for (const auto& packet_info : packet_feedback_vector) { | 206 for (const auto& packet_info : packet_feedback_vector) { |
| 200 IncomingPacketInfo(packet_info.arrival_time_ms, | 207 IncomingPacketInfo(packet_info.arrival_time_ms, |
| 201 ConvertMsTo24Bits(packet_info.send_time_ms), | 208 ConvertMsTo24Bits(packet_info.send_time_ms), |
| 202 packet_info.payload_size, 0, | 209 packet_info.payload_size, 0, |
| 203 packet_info.probe_cluster_id); | 210 packet_info.probe_cluster_id); |
| 204 } | 211 } |
| 205 } | 212 } |
| 206 | 213 |
| 207 void DelayBasedBwe::IncomingPacketInfo(int64_t arrival_time_ms, | 214 void DelayBasedBwe::IncomingPacketInfo(int64_t arrival_time_ms, |
| 208 uint32_t send_time_24bits, | 215 uint32_t send_time_24bits, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 return true; | 374 return true; |
| 368 } | 375 } |
| 369 | 376 |
| 370 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 377 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { |
| 371 // Called from both the configuration thread and the network thread. Shouldn't | 378 // Called from both the configuration thread and the network thread. Shouldn't |
| 372 // be called from the network thread in the future. | 379 // be called from the network thread in the future. |
| 373 rtc::CritScope lock(&crit_); | 380 rtc::CritScope lock(&crit_); |
| 374 remote_rate_.SetMinBitrate(min_bitrate_bps); | 381 remote_rate_.SetMinBitrate(min_bitrate_bps); |
| 375 } | 382 } |
| 376 } // namespace webrtc | 383 } // namespace webrtc |
| OLD | NEW |