blob: 8c8972dd3ac18fee63321d07101a5fbf457f8e7e [file] [log] [blame]
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +00001/*
2 * Copyright (c) 2012 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
Stefan Holmer80e12072016-02-23 13:30:42 +010011#ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
12#define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000013
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000014#include "webrtc/base/scoped_ptr.h"
Stefan Holmer789ba922016-02-17 15:52:17 +010015#include "webrtc/base/thread_checker.h"
16#include "webrtc/modules/include/module.h"
17#include "webrtc/modules/include/module_common_types.h"
18#include "webrtc/modules/pacing/packet_router.h"
19#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
20#include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h"
mflodman0c478b32015-10-21 15:52:16 +020021#include "webrtc/stream.h"
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000022
Stefan Holmer58c664c2016-02-08 14:31:30 +010023namespace rtc {
24struct SentPacket;
25}
26
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000027namespace webrtc {
28
mflodman0e7e2592015-11-12 21:02:42 -080029class BitrateController;
30class BitrateObserver;
Stefan Holmer58c664c2016-02-08 14:31:30 +010031class Clock;
Stefan Holmere5904162015-03-26 11:11:06 +010032class PacedSender;
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000033class ProcessThread;
andresp@webrtc.org29b22192013-05-14 12:10:58 +000034class RemoteBitrateEstimator;
Stefan Holmer58c664c2016-02-08 14:31:30 +010035class RemoteBitrateObserver;
mflodman0e7e2592015-11-12 21:02:42 -080036class TransportFeedbackObserver;
stefan@webrtc.orga50e6f02015-03-09 10:06:40 +000037
Stefan Holmer789ba922016-02-17 15:52:17 +010038class CongestionController : public CallStatsObserver, public Module {
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000039 public:
Stefan Holmer58c664c2016-02-08 14:31:30 +010040 CongestionController(Clock* clock,
Stefan Holmer58c664c2016-02-08 14:31:30 +010041 BitrateObserver* bitrate_observer,
42 RemoteBitrateObserver* remote_bitrate_observer);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010043 virtual ~CongestionController();
Stefan Holmer789ba922016-02-17 15:52:17 +010044
Stefan Holmer3842c5c2016-01-12 13:55:00 +010045 virtual void SetBweBitrates(int min_bitrate_bps,
46 int start_bitrate_bps,
47 int max_bitrate_bps);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010048 virtual void SignalNetworkState(NetworkState state);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010049 virtual BitrateController* GetBitrateController() const;
50 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
Stefan Holmer789ba922016-02-17 15:52:17 +010051 bool send_side_bwe);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010052 virtual int64_t GetPacerQueuingDelayMs() const;
Stefan Holmer789ba922016-02-17 15:52:17 +010053 virtual PacedSender* pacer() { return pacer_.get(); }
54 virtual PacketRouter* packet_router() { return &packet_router_; }
Stefan Holmer3842c5c2016-01-12 13:55:00 +010055 virtual TransportFeedbackObserver* GetTransportFeedbackObserver();
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000056
Stefan Holmer3842c5c2016-01-12 13:55:00 +010057 virtual void UpdatePacerBitrate(int bitrate_kbps,
58 int max_bitrate_kbps,
59 int min_bitrate_kbps);
stefan@webrtc.org792f1a12015-03-04 12:24:26 +000060
Stefan Holmer3842c5c2016-01-12 13:55:00 +010061 virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
stefanc1aeaf02015-10-15 07:26:07 -070062
Stefan Holmer789ba922016-02-17 15:52:17 +010063 // Implements CallStatsObserver.
64 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
65
66 // Implements Module.
67 int64_t TimeUntilNextProcess() override;
68 int32_t Process() override;
69
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000070 private:
Stefan Holmer58c664c2016-02-08 14:31:30 +010071 Clock* const clock_;
Stefan Holmer789ba922016-02-17 15:52:17 +010072 rtc::ThreadChecker config_thread_checker_;
73 const rtc::scoped_ptr<PacedSender> pacer_;
74 const rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
75 const rtc::scoped_ptr<ProcessThread> pacer_thread_;
76 const rtc::scoped_ptr<BitrateController> bitrate_controller_;
77 PacketRouter packet_router_;
78 RemoteEstimatorProxy remote_estimator_proxy_;
79 TransportFeedbackAdapter transport_feedback_adapter_;
stefan4fbd1452015-09-28 03:57:14 -070080 int min_bitrate_bps_;
Stefan Holmer3842c5c2016-01-12 13:55:00 +010081
82 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController);
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000083};
84
85} // namespace webrtc
86
Stefan Holmer80e12072016-02-23 13:30:42 +010087#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_