philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |
| 12 | #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |
| 13 | |
| 14 | #include <list> |
| 15 | #include <map> |
| 16 | #include <memory> |
| 17 | #include <vector> |
| 18 | |
| 19 | #include "webrtc/base/checks.h" |
| 20 | #include "webrtc/base/constructormagic.h" |
| 21 | #include "webrtc/base/criticalsection.h" |
| 22 | #include "webrtc/base/rate_statistics.h" |
| 23 | #include "webrtc/base/thread_checker.h" |
philipel | 7522a28 | 2016-08-16 10:59:36 +0200 | [diff] [blame] | 24 | #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 25 | #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" |
| 26 | #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
| 27 | #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" |
| 28 | #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
| 29 | #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" |
| 30 | #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 31 | |
| 32 | namespace webrtc { |
| 33 | |
| 34 | class DelayBasedBwe : public RemoteBitrateEstimator { |
| 35 | public: |
stefan | 5e12d36 | 2016-07-11 01:44:02 -0700 | [diff] [blame] | 36 | DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock); |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 37 | virtual ~DelayBasedBwe() {} |
| 38 | |
| 39 | void IncomingPacketFeedbackVector( |
| 40 | const std::vector<PacketInfo>& packet_feedback_vector) override; |
philipel | 7522a28 | 2016-08-16 10:59:36 +0200 | [diff] [blame] | 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; |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 45 | |
philipel | 7522a28 | 2016-08-16 10:59:36 +0200 | [diff] [blame] | 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; |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 52 | void IncomingPacket(int64_t arrival_time_ms, |
| 53 | size_t payload_size, |
stefan | 5e12d36 | 2016-07-11 01:44:02 -0700 | [diff] [blame] | 54 | const RTPHeader& header) override { |
| 55 | RTC_NOTREACHED(); |
| 56 | } |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 57 | |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 58 | private: |
philipel | 7522a28 | 2016-08-16 10:59:36 +0200 | [diff] [blame] | 59 | void IncomingPacketInfo(const PacketInfo& info); |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 60 | |
| 61 | rtc::ThreadChecker network_thread_; |
stefan | 5e12d36 | 2016-07-11 01:44:02 -0700 | [diff] [blame] | 62 | Clock* const clock_; |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 63 | RemoteBitrateObserver* const observer_; |
| 64 | std::unique_ptr<InterArrival> inter_arrival_; |
| 65 | std::unique_ptr<OveruseEstimator> estimator_; |
| 66 | OveruseDetector detector_; |
| 67 | RateStatistics incoming_bitrate_; |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 68 | int64_t first_packet_time_ms_; |
| 69 | int64_t last_update_ms_; |
philipel | 7522a28 | 2016-08-16 10:59:36 +0200 | [diff] [blame] | 70 | int64_t last_seen_packet_ms_; |
stefan | 64636dd | 2016-08-03 00:29:03 -0700 | [diff] [blame] | 71 | bool uma_recorded_; |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 72 | |
| 73 | rtc::CriticalSection crit_; |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 74 | AimdRateControl remote_rate_ GUARDED_BY(&crit_); |
philipel | 7522a28 | 2016-08-16 10:59:36 +0200 | [diff] [blame] | 75 | ProbeBitrateEstimator probe_bitrate_estimator_ GUARDED_BY(&crit_); |
philipel | 863a826 | 2016-06-17 09:21:34 -0700 | [diff] [blame] | 76 | |
| 77 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); |
| 78 | }; |
| 79 | |
| 80 | } // namespace webrtc |
| 81 | |
| 82 | #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |