Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 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 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_BITRATE_ESTIMATOR_ABS_SEN D_TIME_H_ | 11 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BITRATE_PROBING_H_ |
| 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_BITRATE_ESTIMATOR_ABS_SEN D_TIME_H_ | 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BITRATE_PROBING_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <map> | 15 #include <map> |
| 16 #include <memory> | 16 #include <memory> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
| 20 #include "webrtc/base/constructormagic.h" | 20 #include "webrtc/base/constructormagic.h" |
| 21 #include "webrtc/base/criticalsection.h" | 21 #include "webrtc/base/criticalsection.h" |
| 22 #include "webrtc/base/rate_statistics.h" | 22 #include "webrtc/base/rate_statistics.h" |
| 23 #include "webrtc/base/thread_checker.h" | 23 #include "webrtc/base/thread_checker.h" |
| 24 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" | 24 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" |
| 25 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" |
| 26 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" | 26 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" |
| 27 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" | 27 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
| 28 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" | 28 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" |
| 29 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 29 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 30 | 30 |
| 31 namespace webrtc { | 31 namespace webrtc { |
| 32 | 32 |
| 33 struct Probe { | 33 struct Probe { |
|
danilchap
2016/06/03 14:11:45
that make two webrtc::Probe structures with differ
philipel
2016/06/03 14:54:55
Good point, moved Probe and Cluster into DelayBase
| |
| 34 Probe(int64_t send_time_ms, int64_t recv_time_ms, size_t payload_size) | 34 Probe(int64_t send_time_ms, |
| 35 int64_t recv_time_ms, | |
| 36 size_t payload_size, | |
| 37 int probe_cluster_id) | |
| 35 : send_time_ms(send_time_ms), | 38 : send_time_ms(send_time_ms), |
| 36 recv_time_ms(recv_time_ms), | 39 recv_time_ms(recv_time_ms), |
| 37 payload_size(payload_size) {} | 40 payload_size(payload_size), |
| 41 probe_cluster_id(probe_cluster_id) {} | |
| 38 int64_t send_time_ms; | 42 int64_t send_time_ms; |
| 39 int64_t recv_time_ms; | 43 int64_t recv_time_ms; |
| 40 size_t payload_size; | 44 size_t payload_size; |
| 45 int probe_cluster_id; | |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 struct Cluster { | 48 struct Cluster { |
| 44 Cluster() | 49 Cluster() |
| 45 : send_mean_ms(0.0f), | 50 : send_mean_ms(0.0f), |
| 46 recv_mean_ms(0.0f), | 51 recv_mean_ms(0.0f), |
| 47 mean_size(0), | 52 mean_size(0), |
| 48 count(0), | 53 count(0), |
| 49 num_above_min_delta(0) {} | 54 num_above_min_delta(0) {} |
| 50 | 55 |
| 51 int GetSendBitrateBps() const { | 56 int GetSendBitrateBps() const { |
| 52 RTC_CHECK_GT(send_mean_ms, 0.0f); | 57 RTC_CHECK_GT(send_mean_ms, 0.0f); |
| 53 return mean_size * 8 * 1000 / send_mean_ms; | 58 return mean_size * 8 * 1000 / send_mean_ms; |
| 54 } | 59 } |
| 55 | 60 |
| 56 int GetRecvBitrateBps() const { | 61 int GetRecvBitrateBps() const { |
| 57 RTC_CHECK_GT(recv_mean_ms, 0.0f); | 62 RTC_CHECK_GT(recv_mean_ms, 0.0f); |
| 58 return mean_size * 8 * 1000 / recv_mean_ms; | 63 return mean_size * 8 * 1000 / recv_mean_ms; |
| 59 } | 64 } |
| 60 | 65 |
| 61 float send_mean_ms; | 66 float send_mean_ms; |
| 62 float recv_mean_ms; | 67 float recv_mean_ms; |
| 63 // TODO(holmer): Add some variance metric as well? | 68 // TODO(holmer): Add some variance metric as well? |
| 64 size_t mean_size; | 69 size_t mean_size; |
| 65 int count; | 70 int count; |
| 66 int num_above_min_delta; | 71 int num_above_min_delta; |
| 67 }; | 72 }; |
| 68 | 73 |
| 69 class RemoteBitrateEstimatorAbsSendTime : public RemoteBitrateEstimator { | 74 class DelayBasedProbingEstimator : public RemoteBitrateEstimator { |
| 70 public: | 75 public: |
| 71 explicit RemoteBitrateEstimatorAbsSendTime(RemoteBitrateObserver* observer); | 76 explicit DelayBasedProbingEstimator(RemoteBitrateObserver* observer); |
| 72 virtual ~RemoteBitrateEstimatorAbsSendTime() {} | 77 virtual ~DelayBasedProbingEstimator() {} |
| 73 | 78 |
| 74 void IncomingPacketFeedbackVector( | 79 void IncomingPacketFeedbackVector( |
| 75 const std::vector<PacketInfo>& packet_feedback_vector) override; | 80 const std::vector<PacketInfo>& packet_feedback_vector) override; |
| 76 | 81 |
| 77 void IncomingPacket(int64_t arrival_time_ms, | 82 void IncomingPacket(int64_t arrival_time_ms, |
| 78 size_t payload_size, | 83 size_t payload_size, |
| 79 const RTPHeader& header, | 84 const RTPHeader& header, |
| 80 bool was_paced) override; | 85 bool was_paced) override; |
| 81 // This class relies on Process() being called periodically (at least once | 86 // This class relies on Process() being called periodically (at least once |
| 82 // every other second) for streams to be timed out properly. Therefore it | 87 // every other second) for streams to be timed out properly. Therefore it |
| 83 // shouldn't be detached from the ProcessThread except if it's about to be | 88 // shouldn't be detached from the ProcessThread except if it's about to be |
| 84 // deleted. | 89 // deleted. |
| 85 void Process() override; | 90 void Process() override; |
| 86 int64_t TimeUntilNextProcess() override; | 91 int64_t TimeUntilNextProcess() override; |
| 87 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; | 92 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 88 void RemoveStream(uint32_t ssrc) override; | 93 void RemoveStream(uint32_t ssrc) override; |
| 89 bool LatestEstimate(std::vector<uint32_t>* ssrcs, | 94 bool LatestEstimate(std::vector<uint32_t>* ssrcs, |
| 90 uint32_t* bitrate_bps) const override; | 95 uint32_t* bitrate_bps) const override; |
| 91 void SetMinBitrate(int min_bitrate_bps) override; | 96 void SetMinBitrate(int min_bitrate_bps) override; |
| 92 | 97 |
| 93 private: | 98 private: |
| 94 typedef std::map<uint32_t, int64_t> Ssrcs; | 99 typedef std::map<uint32_t, int64_t> Ssrcs; |
| 95 enum class ProbeResult { kBitrateUpdated, kNoUpdate }; | 100 enum class ProbeResult { kBitrateUpdated, kNoUpdate }; |
| 96 | 101 |
| 97 static bool IsWithinClusterBounds(int send_delta_ms, | |
| 98 const Cluster& cluster_aggregate); | |
| 99 | |
| 100 static void AddCluster(std::list<Cluster>* clusters, Cluster* cluster); | 102 static void AddCluster(std::list<Cluster>* clusters, Cluster* cluster); |
| 101 | 103 |
| 102 void IncomingPacketInfo(int64_t arrival_time_ms, | 104 void IncomingPacketInfo(int64_t arrival_time_ms, |
| 103 uint32_t send_time_24bits, | 105 uint32_t send_time_24bits, |
| 104 size_t payload_size, | 106 size_t payload_size, |
| 105 uint32_t ssrc, | 107 uint32_t ssrc, |
| 106 bool was_paced); | 108 bool was_paced, |
| 109 int probe_cluster_id); | |
| 107 | 110 |
| 108 void ComputeClusters(std::list<Cluster>* clusters) const; | 111 void ComputeClusters(std::list<Cluster>* clusters) const; |
| 109 | 112 |
| 110 std::list<Cluster>::const_iterator FindBestProbe( | 113 std::list<Cluster>::const_iterator FindBestProbe( |
| 111 const std::list<Cluster>& clusters) const; | 114 const std::list<Cluster>& clusters) const; |
| 112 | 115 |
| 113 // Returns true if a probe which changed the estimate was detected. | 116 // Returns true if a probe which changed the estimate was detected. |
| 114 ProbeResult ProcessClusters(int64_t now_ms) EXCLUSIVE_LOCKS_REQUIRED(&crit_); | 117 ProbeResult ProcessClusters(int64_t now_ms) EXCLUSIVE_LOCKS_REQUIRED(&crit_); |
| 115 | 118 |
| 116 bool IsBitrateImproving(int probe_bitrate_bps) const | 119 bool IsBitrateImproving(int probe_bitrate_bps) const |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 128 std::vector<int64_t> recent_update_time_ms_; | 131 std::vector<int64_t> recent_update_time_ms_; |
| 129 std::list<Probe> probes_; | 132 std::list<Probe> probes_; |
| 130 size_t total_probes_received_; | 133 size_t total_probes_received_; |
| 131 int64_t first_packet_time_ms_; | 134 int64_t first_packet_time_ms_; |
| 132 int64_t last_update_ms_; | 135 int64_t last_update_ms_; |
| 133 | 136 |
| 134 rtc::CriticalSection crit_; | 137 rtc::CriticalSection crit_; |
| 135 Ssrcs ssrcs_ GUARDED_BY(&crit_); | 138 Ssrcs ssrcs_ GUARDED_BY(&crit_); |
| 136 AimdRateControl remote_rate_ GUARDED_BY(&crit_); | 139 AimdRateControl remote_rate_ GUARDED_BY(&crit_); |
| 137 | 140 |
| 138 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RemoteBitrateEstimatorAbsSendTime); | 141 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedProbingEstimator); |
| 139 }; | 142 }; |
| 140 | 143 |
| 141 } // namespace webrtc | 144 } // namespace webrtc |
| 142 | 145 |
| 143 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_BITRATE_ESTIMATOR_ABS_ SEND_TIME_H_ | 146 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BITRATE_PROBING_H_ |
| OLD | NEW |