Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe.h

Issue 2234363002: Removed old probe cluster logic and logic related to ssrcs from DelayBasedBwe. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Windows WTF fix... Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ 11 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_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/congestion_controller/probe_bitrate_estimator.h"
24 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" 25 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
25 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" 26 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h"
26 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" 27 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h"
27 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" 28 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h"
28 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" 29 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h"
29 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 30 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
30 31
31 namespace webrtc { 32 namespace webrtc {
32 33
33 class DelayBasedBwe : public RemoteBitrateEstimator { 34 class DelayBasedBwe : public RemoteBitrateEstimator {
34 public: 35 public:
35 DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock); 36 DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock);
36 virtual ~DelayBasedBwe() {} 37 virtual ~DelayBasedBwe() {}
37 38
38 void IncomingPacketFeedbackVector( 39 void IncomingPacketFeedbackVector(
39 const std::vector<PacketInfo>& packet_feedback_vector) override; 40 const std::vector<PacketInfo>& packet_feedback_vector) override;
41 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
42 bool LatestEstimate(std::vector<uint32_t>* ssrcs,
43 uint32_t* bitrate_bps) const override;
44 void SetMinBitrate(int min_bitrate_bps) override;
40 45
46 // Required by RemoteBitrateEstimator but does nothing.
47 void Process() override;
48 // Required by RemoteBitrateEstimator but does nothing.
49 int64_t TimeUntilNextProcess() override;
50 // Required by RemoteBitrateEstimator but does nothing.
51 void RemoveStream(uint32_t ssrc) override;
41 void IncomingPacket(int64_t arrival_time_ms, 52 void IncomingPacket(int64_t arrival_time_ms,
42 size_t payload_size, 53 size_t payload_size,
43 const RTPHeader& header) override { 54 const RTPHeader& header) override {
44 RTC_NOTREACHED(); 55 RTC_NOTREACHED();
45 } 56 }
46 57
47 // This class relies on Process() being called periodically (at least once
48 // every other second) for streams to be timed out properly. Therefore it
49 // shouldn't be detached from the ProcessThread except if it's about to be
50 // deleted.
51 void Process() override;
52 int64_t TimeUntilNextProcess() override;
53 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
54 void RemoveStream(uint32_t ssrc) override;
55 bool LatestEstimate(std::vector<uint32_t>* ssrcs,
56 uint32_t* bitrate_bps) const override;
57 void SetMinBitrate(int min_bitrate_bps) override;
58
59 private: 58 private:
60 struct Probe { 59 void IncomingPacketInfo(const PacketInfo& info);
61 Probe(int64_t send_time_ms,
62 int64_t recv_time_ms,
63 size_t payload_size,
64 int cluster_id)
65 : send_time_ms(send_time_ms),
66 recv_time_ms(recv_time_ms),
67 payload_size(payload_size),
68 cluster_id(cluster_id) {}
69 int64_t send_time_ms;
70 int64_t recv_time_ms;
71 size_t payload_size;
72 int cluster_id;
73 };
74
75 struct Cluster {
76 Cluster()
77 : send_mean_ms(0.0f),
78 recv_mean_ms(0.0f),
79 mean_size(0),
80 count(0),
81 num_above_min_delta(0) {}
82
83 int GetSendBitrateBps() const {
84 RTC_CHECK_GT(send_mean_ms, 0.0f);
85 return mean_size * 8 * 1000 / send_mean_ms;
86 }
87
88 int GetRecvBitrateBps() const {
89 RTC_CHECK_GT(recv_mean_ms, 0.0f);
90 return mean_size * 8 * 1000 / recv_mean_ms;
91 }
92
93 float send_mean_ms;
94 float recv_mean_ms;
95 // TODO(holmer): Add some variance metric as well?
96 size_t mean_size;
97 int count;
98 int num_above_min_delta;
99 };
100
101 typedef std::map<uint32_t, int64_t> Ssrcs;
102 enum class ProbeResult { kBitrateUpdated, kNoUpdate };
103
104 static void AddCluster(std::list<Cluster>* clusters, Cluster* cluster);
105
106 void IncomingPacketInfo(int64_t arrival_time_ms,
107 uint32_t send_time_24bits,
108 size_t payload_size,
109 uint32_t ssrc,
110 int probe_cluster_id);
111
112 void ComputeClusters(std::list<Cluster>* clusters) const;
113
114 std::list<Cluster>::const_iterator FindBestProbe(
115 const std::list<Cluster>& clusters) const;
116
117 // Returns true if a probe which changed the estimate was detected.
118 ProbeResult ProcessClusters(int64_t now_ms) EXCLUSIVE_LOCKS_REQUIRED(&crit_);
119
120 bool IsBitrateImproving(int probe_bitrate_bps) const
121 EXCLUSIVE_LOCKS_REQUIRED(&crit_);
122
123 void TimeoutStreams(int64_t now_ms) EXCLUSIVE_LOCKS_REQUIRED(&crit_);
124 60
125 rtc::ThreadChecker network_thread_; 61 rtc::ThreadChecker network_thread_;
126 Clock* const clock_; 62 Clock* const clock_;
127 RemoteBitrateObserver* const observer_; 63 RemoteBitrateObserver* const observer_;
128 std::unique_ptr<InterArrival> inter_arrival_; 64 std::unique_ptr<InterArrival> inter_arrival_;
129 std::unique_ptr<OveruseEstimator> estimator_; 65 std::unique_ptr<OveruseEstimator> estimator_;
130 OveruseDetector detector_; 66 OveruseDetector detector_;
131 RateStatistics incoming_bitrate_; 67 RateStatistics incoming_bitrate_;
132 std::list<Probe> probes_;
133 size_t total_probes_received_;
134 int64_t first_packet_time_ms_; 68 int64_t first_packet_time_ms_;
135 int64_t last_update_ms_; 69 int64_t last_update_ms_;
70 int64_t last_seen_packet_ms_;
136 bool uma_recorded_; 71 bool uma_recorded_;
137 72
138 rtc::CriticalSection crit_; 73 rtc::CriticalSection crit_;
139 Ssrcs ssrcs_ GUARDED_BY(&crit_);
140 AimdRateControl remote_rate_ GUARDED_BY(&crit_); 74 AimdRateControl remote_rate_ GUARDED_BY(&crit_);
75 ProbeBitrateEstimator probe_bitrate_estimator_ GUARDED_BY(&crit_);
141 76
142 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); 77 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe);
143 }; 78 };
144 79
145 } // namespace webrtc 80 } // namespace webrtc
146 81
147 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ 82 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
OLDNEW
« no previous file with comments | « webrtc/call/bitrate_estimator_tests.cc ('k') | webrtc/modules/congestion_controller/delay_based_bwe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698