blob: 7f181500658b8b68c26b947fe8f7a850b67bf464 [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
kwiberg84be5112016-04-27 01:19:58 -070014#include <memory>
15
kwiberg4485ffb2016-04-26 08:14:39 -070016#include "webrtc/base/constructormagic.h"
terelius52d4e6b2016-04-26 09:31:59 -070017#include "webrtc/base/scoped_ptr.h"
Stefan Holmer789ba922016-02-17 15:52:17 +010018#include "webrtc/modules/include/module.h"
19#include "webrtc/modules/include/module_common_types.h"
20#include "webrtc/modules/pacing/packet_router.h"
21#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
22#include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h"
mflodman0c478b32015-10-21 15:52:16 +020023#include "webrtc/stream.h"
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000024
Stefan Holmer58c664c2016-02-08 14:31:30 +010025namespace rtc {
26struct SentPacket;
27}
28
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000029namespace webrtc {
30
mflodman0e7e2592015-11-12 21:02:42 -080031class BitrateController;
32class BitrateObserver;
Stefan Holmer58c664c2016-02-08 14:31:30 +010033class Clock;
Stefan Holmere5904162015-03-26 11:11:06 +010034class PacedSender;
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000035class ProcessThread;
andresp@webrtc.org29b22192013-05-14 12:10:58 +000036class RemoteBitrateEstimator;
Stefan Holmer58c664c2016-02-08 14:31:30 +010037class RemoteBitrateObserver;
mflodman0e7e2592015-11-12 21:02:42 -080038class TransportFeedbackObserver;
stefan@webrtc.orga50e6f02015-03-09 10:06:40 +000039
Stefan Holmer789ba922016-02-17 15:52:17 +010040class CongestionController : public CallStatsObserver, public Module {
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000041 public:
Stefan Holmer58c664c2016-02-08 14:31:30 +010042 CongestionController(Clock* clock,
Stefan Holmer58c664c2016-02-08 14:31:30 +010043 BitrateObserver* bitrate_observer,
44 RemoteBitrateObserver* remote_bitrate_observer);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010045 virtual ~CongestionController();
Stefan Holmer789ba922016-02-17 15:52:17 +010046
Stefan Holmer3842c5c2016-01-12 13:55:00 +010047 virtual void SetBweBitrates(int min_bitrate_bps,
48 int start_bitrate_bps,
49 int max_bitrate_bps);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010050 virtual void SignalNetworkState(NetworkState state);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010051 virtual BitrateController* GetBitrateController() const;
52 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
Stefan Holmer789ba922016-02-17 15:52:17 +010053 bool send_side_bwe);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010054 virtual int64_t GetPacerQueuingDelayMs() const;
Stefan Holmer789ba922016-02-17 15:52:17 +010055 virtual PacedSender* pacer() { return pacer_.get(); }
56 virtual PacketRouter* packet_router() { return &packet_router_; }
Stefan Holmer3842c5c2016-01-12 13:55:00 +010057 virtual TransportFeedbackObserver* GetTransportFeedbackObserver();
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000058
Stefan Holmer3842c5c2016-01-12 13:55:00 +010059 virtual void UpdatePacerBitrate(int bitrate_kbps,
60 int max_bitrate_kbps,
61 int min_bitrate_kbps);
stefan@webrtc.org792f1a12015-03-04 12:24:26 +000062
Stefan Holmer3842c5c2016-01-12 13:55:00 +010063 virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
stefanc1aeaf02015-10-15 07:26:07 -070064
Stefan Holmer789ba922016-02-17 15:52:17 +010065 // Implements CallStatsObserver.
66 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
67
68 // Implements Module.
69 int64_t TimeUntilNextProcess() override;
pbosa26ac922016-02-25 04:50:01 -080070 void Process() override;
Stefan Holmer789ba922016-02-17 15:52:17 +010071
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000072 private:
Stefan Holmer58c664c2016-02-08 14:31:30 +010073 Clock* const clock_;
kwiberg84be5112016-04-27 01:19:58 -070074 const std::unique_ptr<PacedSender> pacer_;
75 const std::unique_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
76 const std::unique_ptr<BitrateController> bitrate_controller_;
Stefan Holmer789ba922016-02-17 15:52:17 +010077 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_