blob: 65bf5be3ec1de6e537df290b58d72eb5b4fe58ac [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/modules/include/module.h"
16#include "webrtc/modules/include/module_common_types.h"
17#include "webrtc/modules/pacing/packet_router.h"
18#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
19#include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h"
mflodman0c478b32015-10-21 15:52:16 +020020#include "webrtc/stream.h"
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000021
Stefan Holmer58c664c2016-02-08 14:31:30 +010022namespace rtc {
23struct SentPacket;
24}
25
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000026namespace webrtc {
27
mflodman0e7e2592015-11-12 21:02:42 -080028class BitrateController;
29class BitrateObserver;
Stefan Holmer58c664c2016-02-08 14:31:30 +010030class Clock;
Stefan Holmere5904162015-03-26 11:11:06 +010031class PacedSender;
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000032class ProcessThread;
andresp@webrtc.org29b22192013-05-14 12:10:58 +000033class RemoteBitrateEstimator;
Stefan Holmer58c664c2016-02-08 14:31:30 +010034class RemoteBitrateObserver;
mflodman0e7e2592015-11-12 21:02:42 -080035class TransportFeedbackObserver;
stefan@webrtc.orga50e6f02015-03-09 10:06:40 +000036
Stefan Holmer789ba922016-02-17 15:52:17 +010037class CongestionController : public CallStatsObserver, public Module {
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000038 public:
Stefan Holmer58c664c2016-02-08 14:31:30 +010039 CongestionController(Clock* clock,
Stefan Holmer58c664c2016-02-08 14:31:30 +010040 BitrateObserver* bitrate_observer,
41 RemoteBitrateObserver* remote_bitrate_observer);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010042 virtual ~CongestionController();
Stefan Holmer789ba922016-02-17 15:52:17 +010043
Stefan Holmer3842c5c2016-01-12 13:55:00 +010044 virtual void SetBweBitrates(int min_bitrate_bps,
45 int start_bitrate_bps,
46 int max_bitrate_bps);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010047 virtual void SignalNetworkState(NetworkState state);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010048 virtual BitrateController* GetBitrateController() const;
49 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
Stefan Holmer789ba922016-02-17 15:52:17 +010050 bool send_side_bwe);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010051 virtual int64_t GetPacerQueuingDelayMs() const;
Stefan Holmer789ba922016-02-17 15:52:17 +010052 virtual PacedSender* pacer() { return pacer_.get(); }
53 virtual PacketRouter* packet_router() { return &packet_router_; }
Stefan Holmer3842c5c2016-01-12 13:55:00 +010054 virtual TransportFeedbackObserver* GetTransportFeedbackObserver();
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000055
Stefan Holmer3842c5c2016-01-12 13:55:00 +010056 virtual void UpdatePacerBitrate(int bitrate_kbps,
57 int max_bitrate_kbps,
58 int min_bitrate_kbps);
stefan@webrtc.org792f1a12015-03-04 12:24:26 +000059
Stefan Holmer3842c5c2016-01-12 13:55:00 +010060 virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
stefanc1aeaf02015-10-15 07:26:07 -070061
Stefan Holmer789ba922016-02-17 15:52:17 +010062 // Implements CallStatsObserver.
63 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
64
65 // Implements Module.
66 int64_t TimeUntilNextProcess() override;
pbosa26ac922016-02-25 04:50:01 -080067 void Process() override;
Stefan Holmer789ba922016-02-17 15:52:17 +010068
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000069 private:
Stefan Holmer58c664c2016-02-08 14:31:30 +010070 Clock* const clock_;
Stefan Holmer789ba922016-02-17 15:52:17 +010071 const rtc::scoped_ptr<PacedSender> pacer_;
72 const rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
Stefan Holmer789ba922016-02-17 15:52:17 +010073 const rtc::scoped_ptr<BitrateController> bitrate_controller_;
74 PacketRouter packet_router_;
75 RemoteEstimatorProxy remote_estimator_proxy_;
76 TransportFeedbackAdapter transport_feedback_adapter_;
stefan4fbd1452015-09-28 03:57:14 -070077 int min_bitrate_bps_;
Stefan Holmer3842c5c2016-01-12 13:55:00 +010078
79 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController);
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000080};
81
82} // namespace webrtc
83
Stefan Holmer80e12072016-02-23 13:30:42 +010084#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_