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 #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" | |
22 #include "webrtc/base/rate_statistics.h" | 21 #include "webrtc/base/rate_statistics.h" |
23 #include "webrtc/base/thread_checker.h" | 22 #include "webrtc/base/thread_checker.h" |
24 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" | 23 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" |
25 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" | 24 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" |
26 #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" |
27 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" | 26 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" |
28 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" | 27 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
29 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" | 28 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" |
30 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
31 | 29 |
32 namespace webrtc { | 30 namespace webrtc { |
33 | 31 |
34 class DelayBasedBwe : public RemoteBitrateEstimator { | 32 class DelayBasedBwe { |
35 public: | 33 public: |
36 DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock); | 34 static const int64_t kStreamTimeOutMs = 2000; |
| 35 |
| 36 struct Result { |
| 37 Result() : updated(false), probe(false), target_bitrate_bps(0) {} |
| 38 Result(bool probe, uint32_t target_bitrate_bps) |
| 39 : updated(true), probe(probe), target_bitrate_bps(target_bitrate_bps) {} |
| 40 bool updated; |
| 41 bool probe; |
| 42 uint32_t target_bitrate_bps; |
| 43 }; |
| 44 |
| 45 explicit DelayBasedBwe(Clock* clock); |
37 virtual ~DelayBasedBwe() {} | 46 virtual ~DelayBasedBwe() {} |
38 | 47 |
39 void IncomingPacketFeedbackVector( | 48 Result IncomingPacketFeedbackVector( |
40 const std::vector<PacketInfo>& packet_feedback_vector) override; | 49 const std::vector<PacketInfo>& packet_feedback_vector); |
41 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; | 50 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); |
42 bool LatestEstimate(std::vector<uint32_t>* ssrcs, | 51 bool LatestEstimate(std::vector<uint32_t>* ssrcs, |
43 uint32_t* bitrate_bps) const override; | 52 uint32_t* bitrate_bps) const; |
44 void SetMinBitrate(int min_bitrate_bps) override; | 53 void SetMinBitrate(int min_bitrate_bps); |
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; | |
52 void IncomingPacket(int64_t arrival_time_ms, | |
53 size_t payload_size, | |
54 const RTPHeader& header) override { | |
55 RTC_NOTREACHED(); | |
56 } | |
57 | 54 |
58 private: | 55 private: |
59 void IncomingPacketInfo(const PacketInfo& info); | 56 Result IncomingPacketInfo(const PacketInfo& info); |
60 // Updates the current remote rate estimate and returns true if a valid | 57 // Updates the current remote rate estimate and returns true if a valid |
61 // estimate exists. | 58 // estimate exists. |
62 bool UpdateEstimate(int64_t packet_arrival_time_ms, | 59 bool UpdateEstimate(int64_t packet_arrival_time_ms, |
63 int64_t now_ms, | 60 int64_t now_ms, |
64 uint32_t* target_bitrate_bps) | 61 uint32_t* target_bitrate_bps); |
65 EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
66 | 62 |
67 rtc::ThreadChecker network_thread_; | 63 rtc::ThreadChecker network_thread_; |
68 Clock* const clock_; | 64 Clock* const clock_; |
69 RemoteBitrateObserver* const observer_; | |
70 std::unique_ptr<InterArrival> inter_arrival_; | 65 std::unique_ptr<InterArrival> inter_arrival_; |
71 std::unique_ptr<OveruseEstimator> estimator_; | 66 std::unique_ptr<OveruseEstimator> estimator_; |
72 OveruseDetector detector_; | 67 OveruseDetector detector_; |
73 RateStatistics incoming_bitrate_; | 68 RateStatistics incoming_bitrate_; |
74 int64_t last_update_ms_; | 69 int64_t last_update_ms_; |
75 int64_t last_seen_packet_ms_; | 70 int64_t last_seen_packet_ms_; |
76 bool uma_recorded_; | 71 bool uma_recorded_; |
77 | 72 AimdRateControl remote_rate_; |
78 rtc::CriticalSection crit_; | 73 ProbeBitrateEstimator probe_bitrate_estimator_; |
79 AimdRateControl remote_rate_ GUARDED_BY(&crit_); | |
80 ProbeBitrateEstimator probe_bitrate_estimator_ GUARDED_BY(&crit_); | |
81 | 74 |
82 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); | 75 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); |
83 }; | 76 }; |
84 | 77 |
85 } // namespace webrtc | 78 } // namespace webrtc |
86 | 79 |
87 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ | 80 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |
OLD | NEW |