blob: b77c46faa3b48ab06d01c575ae98d05e8a206389 [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
mflodman0c478b32015-10-21 15:52:16 +020011#ifndef WEBRTC_CALL_CONGESTION_CONTROLLER_H_
12#define WEBRTC_CALL_CONGESTION_CONTROLLER_H_
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000013
stefan@webrtc.orga50e6f02015-03-09 10:06:40 +000014#include <vector>
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000015
pbosd6fc47e2015-07-23 06:58:33 -070016#include "webrtc/base/criticalsection.h"
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000017#include "webrtc/base/scoped_ptr.h"
stefanc1aeaf02015-10-15 07:26:07 -070018#include "webrtc/base/socket.h"
mflodman0c478b32015-10-21 15:52:16 +020019#include "webrtc/stream.h"
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000020
21namespace webrtc {
22
mflodman0e7e2592015-11-12 21:02:42 -080023class BitrateController;
24class BitrateObserver;
mflodman@webrtc.org7c894b72012-11-26 12:40:15 +000025class CallStats;
andresp@webrtc.org7707d062013-05-13 10:50:50 +000026class Config;
Stefan Holmere5904162015-03-26 11:11:06 +010027class PacedSender;
28class PacketRouter;
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000029class ProcessThread;
andresp@webrtc.org29b22192013-05-14 12:10:58 +000030class RemoteBitrateEstimator;
sprangef165ee2015-09-22 05:10:52 -070031class RemoteEstimatorProxy;
mflodmane3787022015-10-21 13:24:28 +020032class RtpRtcp;
Peter Boström7083e112015-09-22 16:28:51 +020033class SendStatisticsProxy;
sprangef165ee2015-09-22 05:10:52 -070034class TransportFeedbackAdapter;
mflodman0e7e2592015-11-12 21:02:42 -080035class TransportFeedbackObserver;
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000036class ViEEncoder;
37class VieRemb;
stefan@webrtc.orga50e6f02015-03-09 10:06:40 +000038
mflodman0e7e2592015-11-12 21:02:42 -080039class CongestionController {
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000040 public:
mflodman0e7e2592015-11-12 21:02:42 -080041 CongestionController(ProcessThread* process_thread, CallStats* call_stats,
42 BitrateObserver* bitrate_observer);
Stefan Holmer3842c5c2016-01-12 13:55:00 +010043 virtual ~CongestionController();
44 virtual void AddEncoder(ViEEncoder* encoder);
45 virtual void RemoveEncoder(ViEEncoder* encoder);
46 virtual void SetBweBitrates(int min_bitrate_bps,
47 int start_bitrate_bps,
48 int max_bitrate_bps);
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000049
Stefan Holmer3842c5c2016-01-12 13:55:00 +010050 virtual void SetChannelRembStatus(bool sender,
51 bool receiver,
52 RtpRtcp* rtp_module);
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000053
Stefan Holmer3842c5c2016-01-12 13:55:00 +010054 virtual void SignalNetworkState(NetworkState state);
stefan457a61d2015-10-14 03:12:59 -070055
Stefan Holmer3842c5c2016-01-12 13:55:00 +010056 virtual BitrateController* GetBitrateController() const;
57 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
58 bool send_side_bwe) const;
59 virtual int64_t GetPacerQueuingDelayMs() const;
60 virtual PacedSender* pacer() const { return pacer_.get(); }
61 virtual PacketRouter* packet_router() const { return packet_router_.get(); }
62 virtual TransportFeedbackObserver* GetTransportFeedbackObserver();
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000063
Stefan Holmer3842c5c2016-01-12 13:55:00 +010064 virtual void UpdatePacerBitrate(int bitrate_kbps,
65 int max_bitrate_kbps,
66 int min_bitrate_kbps);
stefan@webrtc.org792f1a12015-03-04 12:24:26 +000067
Stefan Holmer3842c5c2016-01-12 13:55:00 +010068 virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
stefanc1aeaf02015-10-15 07:26:07 -070069
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000070 private:
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000071 rtc::scoped_ptr<VieRemb> remb_;
Stefan Holmere5904162015-03-26 11:11:06 +010072 rtc::scoped_ptr<PacketRouter> packet_router_;
73 rtc::scoped_ptr<PacedSender> pacer_;
Erik Språng6b8d3552015-09-24 15:06:57 +020074 rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
75 rtc::scoped_ptr<RemoteEstimatorProxy> remote_estimator_proxy_;
mflodman949c2f02015-10-16 02:31:11 -070076
77 mutable rtc::CriticalSection encoder_crit_;
78 std::vector<ViEEncoder*> encoders_ GUARDED_BY(encoder_crit_);
Stefan Holmere5904162015-03-26 11:11:06 +010079
mflodman@webrtc.orgaeff4f32013-04-22 12:41:57 +000080 // Registered at construct time and assumed to outlive this class.
sprang5e023eb2015-09-14 06:42:43 -070081 ProcessThread* const process_thread_;
mflodmane3787022015-10-21 13:24:28 +020082 CallStats* const call_stats_;
83
Stefan Holmere5904162015-03-26 11:11:06 +010084 rtc::scoped_ptr<ProcessThread> pacer_thread_;
85
86 rtc::scoped_ptr<BitrateController> bitrate_controller_;
Erik Språng6b8d3552015-09-24 15:06:57 +020087 rtc::scoped_ptr<TransportFeedbackAdapter> transport_feedback_adapter_;
stefan4fbd1452015-09-28 03:57:14 -070088 int min_bitrate_bps_;
Stefan Holmer3842c5c2016-01-12 13:55:00 +010089
90 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController);
mflodman@webrtc.org9ec883e2012-03-05 17:12:41 +000091};
92
93} // namespace webrtc
94
mflodman0c478b32015-10-21 15:52:16 +020095#endif // WEBRTC_CALL_CONGESTION_CONTROLLER_H_