blob: 19410c658a4f72624228b68c09d10b5a02321646 [file] [log] [blame]
philipel863a8262016-06-17 09:21:34 -07001/*
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"
philipel7522a282016-08-16 10:59:36 +020024#include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
philipel863a8262016-06-17 09:21:34 -070025#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
32namespace webrtc {
33
34class DelayBasedBwe : public RemoteBitrateEstimator {
35 public:
stefan5e12d362016-07-11 01:44:02 -070036 DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock);
philipel863a8262016-06-17 09:21:34 -070037 virtual ~DelayBasedBwe() {}
38
39 void IncomingPacketFeedbackVector(
40 const std::vector<PacketInfo>& packet_feedback_vector) override;
philipel7522a282016-08-16 10:59:36 +020041 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;
philipel863a8262016-06-17 09:21:34 -070045
philipel7522a282016-08-16 10:59:36 +020046 // 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;
philipel863a8262016-06-17 09:21:34 -070052 void IncomingPacket(int64_t arrival_time_ms,
53 size_t payload_size,
stefan5e12d362016-07-11 01:44:02 -070054 const RTPHeader& header) override {
55 RTC_NOTREACHED();
56 }
philipel863a8262016-06-17 09:21:34 -070057
philipel863a8262016-06-17 09:21:34 -070058 private:
philipel7522a282016-08-16 10:59:36 +020059 void IncomingPacketInfo(const PacketInfo& info);
philipel863a8262016-06-17 09:21:34 -070060
61 rtc::ThreadChecker network_thread_;
stefan5e12d362016-07-11 01:44:02 -070062 Clock* const clock_;
philipel863a8262016-06-17 09:21:34 -070063 RemoteBitrateObserver* const observer_;
64 std::unique_ptr<InterArrival> inter_arrival_;
65 std::unique_ptr<OveruseEstimator> estimator_;
66 OveruseDetector detector_;
67 RateStatistics incoming_bitrate_;
philipel863a8262016-06-17 09:21:34 -070068 int64_t first_packet_time_ms_;
69 int64_t last_update_ms_;
philipel7522a282016-08-16 10:59:36 +020070 int64_t last_seen_packet_ms_;
stefan64636dd2016-08-03 00:29:03 -070071 bool uma_recorded_;
philipel863a8262016-06-17 09:21:34 -070072
73 rtc::CriticalSection crit_;
philipel863a8262016-06-17 09:21:34 -070074 AimdRateControl remote_rate_ GUARDED_BY(&crit_);
philipel7522a282016-08-16 10:59:36 +020075 ProbeBitrateEstimator probe_bitrate_estimator_ GUARDED_BY(&crit_);
philipel863a8262016-06-17 09:21:34 -070076
77 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe);
78};
79
80} // namespace webrtc
81
82#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_