2012-03-05 17:12:41 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-02-23 13:30:42 +01:00
|
|
|
#ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
|
|
|
|
|
#define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
|
2012-03-05 17:12:41 +00:00
|
|
|
|
2016-04-27 01:19:58 -07:00
|
|
|
#include <memory>
|
2017-03-21 06:41:12 -07:00
|
|
|
#include <utility>
|
2017-01-24 02:53:38 -08:00
|
|
|
#include <vector>
|
2016-04-27 01:19:58 -07:00
|
|
|
|
2016-04-26 08:14:39 -07:00
|
|
|
#include "webrtc/base/constructormagic.h"
|
2017-01-24 02:53:38 -08:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2017-03-15 12:40:25 +01:00
|
|
|
#include "webrtc/base/networkroute.h"
|
2017-03-09 06:40:08 -08:00
|
|
|
#include "webrtc/base/thread_checker.h"
|
2016-05-01 20:18:34 -07:00
|
|
|
#include "webrtc/common_types.h"
|
2017-03-09 06:40:08 -08:00
|
|
|
#include "webrtc/modules/congestion_controller/delay_based_bwe.h"
|
2017-03-21 06:41:12 -07:00
|
|
|
#include "webrtc/modules/congestion_controller/include/receive_side_congestion_controller.h"
|
|
|
|
|
#include "webrtc/modules/congestion_controller/include/send_side_congestion_controller.h"
|
2016-09-30 10:06:51 +02:00
|
|
|
#include "webrtc/modules/congestion_controller/transport_feedback_adapter.h"
|
2016-02-17 15:52:17 +01:00
|
|
|
#include "webrtc/modules/include/module.h"
|
|
|
|
|
#include "webrtc/modules/include/module_common_types.h"
|
2016-05-11 06:01:13 -07:00
|
|
|
#include "webrtc/modules/pacing/paced_sender.h"
|
2017-03-09 06:40:08 -08:00
|
|
|
#include "webrtc/modules/pacing/packet_router.h"
|
2012-03-05 17:12:41 +00:00
|
|
|
|
2016-02-08 14:31:30 +01:00
|
|
|
namespace rtc {
|
|
|
|
|
struct SentPacket;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-05 17:12:41 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-11-12 21:02:42 -08:00
|
|
|
class BitrateController;
|
2016-02-08 14:31:30 +01:00
|
|
|
class Clock;
|
2016-09-12 12:28:54 -07:00
|
|
|
class ProbeController;
|
2016-07-13 09:11:28 -07:00
|
|
|
class RateLimiter;
|
2013-05-14 12:10:58 +00:00
|
|
|
class RemoteBitrateEstimator;
|
2016-02-08 14:31:30 +01:00
|
|
|
class RemoteBitrateObserver;
|
2016-07-04 07:06:55 -07:00
|
|
|
class RtcEventLog;
|
2015-03-09 10:06:40 +00:00
|
|
|
|
2017-03-09 06:40:08 -08:00
|
|
|
class CongestionController : public CallStatsObserver,
|
|
|
|
|
public Module,
|
|
|
|
|
public TransportFeedbackObserver {
|
2012-03-05 17:12:41 +00:00
|
|
|
public:
|
2017-03-21 06:41:12 -07:00
|
|
|
using Observer = SendSideCongestionController::Observer;
|
|
|
|
|
|
2017-03-09 07:09:31 -08:00
|
|
|
CongestionController(const Clock* clock,
|
2016-11-30 03:35:20 -08:00
|
|
|
Observer* observer,
|
|
|
|
|
RemoteBitrateObserver* remote_bitrate_observer,
|
|
|
|
|
RtcEventLog* event_log,
|
2017-03-21 06:41:12 -07:00
|
|
|
PacketRouter* packet_router)
|
|
|
|
|
: send_side_cc_(clock, observer, event_log, packet_router),
|
|
|
|
|
receive_side_cc_(clock, remote_bitrate_observer, packet_router) {}
|
2017-03-09 07:09:31 -08:00
|
|
|
CongestionController(const Clock* clock,
|
2016-05-11 06:01:13 -07:00
|
|
|
Observer* observer,
|
|
|
|
|
RemoteBitrateObserver* remote_bitrate_observer,
|
2016-07-04 07:06:55 -07:00
|
|
|
RtcEventLog* event_log,
|
2016-11-30 03:35:20 -08:00
|
|
|
PacketRouter* packet_router,
|
2017-03-21 06:41:12 -07:00
|
|
|
std::unique_ptr<PacedSender> pacer)
|
|
|
|
|
: send_side_cc_(clock, observer, event_log, std::move(pacer)),
|
|
|
|
|
receive_side_cc_(clock, remote_bitrate_observer, packet_router) {}
|
|
|
|
|
|
|
|
|
|
virtual ~CongestionController() {}
|
2016-02-17 15:52:17 +01:00
|
|
|
|
2016-12-21 06:37:18 -08:00
|
|
|
virtual void OnReceivedPacket(int64_t arrival_time_ms,
|
|
|
|
|
size_t payload_size,
|
|
|
|
|
const RTPHeader& header);
|
|
|
|
|
|
2016-01-12 13:55:00 +01:00
|
|
|
virtual void SetBweBitrates(int min_bitrate_bps,
|
|
|
|
|
int start_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps);
|
2016-06-24 11:03:55 -07:00
|
|
|
// Resets both the BWE state and the bitrate estimator. Note the first
|
|
|
|
|
// argument is the bitrate_bps.
|
2017-03-15 12:40:25 +01:00
|
|
|
virtual void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route,
|
|
|
|
|
int bitrate_bps,
|
|
|
|
|
int min_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps);
|
2016-01-12 13:55:00 +01:00
|
|
|
virtual void SignalNetworkState(NetworkState state);
|
2017-01-10 08:58:32 -08:00
|
|
|
virtual void SetTransportOverhead(size_t transport_overhead_bytes_per_packet);
|
|
|
|
|
|
2016-01-12 13:55:00 +01:00
|
|
|
virtual BitrateController* GetBitrateController() const;
|
|
|
|
|
virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
|
2016-02-17 15:52:17 +01:00
|
|
|
bool send_side_bwe);
|
2016-01-12 13:55:00 +01:00
|
|
|
virtual int64_t GetPacerQueuingDelayMs() const;
|
2016-12-08 06:24:28 -08:00
|
|
|
// TODO(nisse): Delete this accessor function. The pacer should be
|
2017-03-27 05:36:15 -07:00
|
|
|
// internal to the congestion controller. Currently needed by Call,
|
|
|
|
|
// to register the pacer module on the right thread.
|
2017-03-21 06:41:12 -07:00
|
|
|
virtual PacedSender* pacer() { return send_side_cc_.pacer(); }
|
2017-03-27 05:36:15 -07:00
|
|
|
// TODO(nisse): Delete this method, as soon as downstream projects
|
|
|
|
|
// are updated.
|
2017-03-09 11:45:55 -08:00
|
|
|
virtual TransportFeedbackObserver* GetTransportFeedbackObserver() {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2016-07-13 09:11:28 -07:00
|
|
|
RateLimiter* GetRetransmissionRateLimiter();
|
2016-11-28 13:11:13 -08:00
|
|
|
void EnablePeriodicAlrProbing(bool enable);
|
2012-04-27 05:25:53 +00:00
|
|
|
|
2016-06-15 00:47:53 -07:00
|
|
|
// SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
|
|
|
|
|
// settings.
|
|
|
|
|
// |min_send_bitrate_bps| is the total minimum send bitrate required by all
|
|
|
|
|
// sending streams. This is the minimum bitrate the PacedSender will use.
|
|
|
|
|
// Note that CongestionController::OnNetworkChanged can still be called with
|
|
|
|
|
// a lower bitrate estimate.
|
|
|
|
|
// |max_padding_bitrate_bps| is the max bitrate the send streams request for
|
|
|
|
|
// padding. This can be higher than the current network estimate and tells
|
|
|
|
|
// the PacedSender how much it should max pad unless there is real packets to
|
|
|
|
|
// send.
|
|
|
|
|
void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
|
|
|
|
|
int max_padding_bitrate_bps);
|
2015-03-04 12:24:26 +00:00
|
|
|
|
2016-01-12 13:55:00 +01:00
|
|
|
virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
|
2015-10-15 07:26:07 -07:00
|
|
|
|
2016-02-17 15:52:17 +01:00
|
|
|
// Implements CallStatsObserver.
|
|
|
|
|
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
2015-10-21 13:24:28 +02:00
|
|
|
|
2016-02-17 15:52:17 +01:00
|
|
|
// Implements Module.
|
|
|
|
|
int64_t TimeUntilNextProcess() override;
|
2016-02-25 04:50:01 -08:00
|
|
|
void Process() override;
|
2015-03-26 11:11:06 +01:00
|
|
|
|
2017-03-09 06:40:08 -08:00
|
|
|
// Implements TransportFeedbackObserver.
|
2017-03-23 11:04:48 -07:00
|
|
|
void AddPacket(uint32_t ssrc,
|
|
|
|
|
uint16_t sequence_number,
|
2017-03-09 06:40:08 -08:00
|
|
|
size_t length,
|
|
|
|
|
const PacedPacketInfo& pacing_info) override;
|
|
|
|
|
void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override;
|
|
|
|
|
std::vector<PacketFeedback> GetTransportFeedbackVector() const override;
|
|
|
|
|
|
2016-02-17 15:52:17 +01:00
|
|
|
private:
|
2017-03-21 06:41:12 -07:00
|
|
|
SendSideCongestionController send_side_cc_;
|
|
|
|
|
ReceiveSideCongestionController receive_side_cc_;
|
2016-01-12 13:55:00 +01:00
|
|
|
|
|
|
|
|
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController);
|
2012-03-05 17:12:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2016-02-23 13:30:42 +01:00
|
|
|
#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
|