2012-04-19 12:13:52 +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.
|
|
|
|
|
*
|
|
|
|
|
* Usage: this class will register multiple RtcpBitrateObserver's one at each
|
|
|
|
|
* RTCP module. It will aggregate the results and run one bandwidth estimation
|
|
|
|
|
* and push the result to the encoders via BitrateObserver(s).
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
|
|
|
|
|
#define MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2017-08-20 09:19:58 -07:00
|
|
|
#include <map>
|
|
|
|
|
|
2018-07-02 09:25:25 +02:00
|
|
|
#include "modules/congestion_controller/goog_cc/delay_based_bwe.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/include/module.h"
|
|
|
|
|
#include "modules/pacing/paced_sender.h"
|
|
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2012-04-19 12:13:52 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-11-05 12:02:15 -08:00
|
|
|
class RtcEventLog;
|
2015-03-04 12:24:26 +00:00
|
|
|
|
2016-05-11 06:01:13 -07:00
|
|
|
// Deprecated
|
|
|
|
|
// TODO(perkj): Remove BitrateObserver when no implementations use it.
|
2012-04-19 12:13:52 +00:00
|
|
|
class BitrateObserver {
|
2015-03-04 12:24:26 +00:00
|
|
|
// Observer class for bitrate changes announced due to change in bandwidth
|
|
|
|
|
// estimate or due to bitrate allocation changes. Fraction loss and rtt is
|
|
|
|
|
// also part of this callback to allow the obsevrer to optimize its settings
|
|
|
|
|
// for different types of network environments. The bitrate does not include
|
|
|
|
|
// packet headers and is measured in bits per second.
|
2012-04-19 12:13:52 +00:00
|
|
|
public:
|
2015-03-04 12:24:26 +00:00
|
|
|
virtual void OnNetworkChanged(uint32_t bitrate_bps,
|
2014-12-08 19:46:23 +00:00
|
|
|
uint8_t fraction_loss, // 0 - 255.
|
2015-03-04 12:24:26 +00:00
|
|
|
int64_t rtt_ms) = 0;
|
2017-08-20 09:19:58 -07:00
|
|
|
// TODO(gnish): Merge these two into one function.
|
|
|
|
|
virtual void OnNetworkChanged(uint32_t bitrate_for_encoder_bps,
|
|
|
|
|
uint32_t bitrate_for_pacer_bps,
|
|
|
|
|
bool in_probe_rtt,
|
|
|
|
|
int64_t target_set_time,
|
|
|
|
|
uint64_t congestion_window) {}
|
|
|
|
|
virtual void OnBytesAcked(size_t bytes) {}
|
2018-07-18 15:37:01 +02:00
|
|
|
virtual size_t pacer_queue_size_in_bytes();
|
2012-04-19 12:13:52 +00:00
|
|
|
virtual ~BitrateObserver() {}
|
|
|
|
|
};
|
|
|
|
|
|
2017-08-20 09:19:58 -07:00
|
|
|
class BitrateController : public Module, public RtcpBandwidthObserver {
|
2015-03-04 12:24:26 +00:00
|
|
|
// This class collects feedback from all streams sent to a peer (via
|
|
|
|
|
// RTCPBandwidthObservers). It does one aggregated send side bandwidth
|
|
|
|
|
// estimation and divide the available bitrate between all its registered
|
|
|
|
|
// BitrateObservers.
|
2012-04-19 12:13:52 +00:00
|
|
|
public:
|
2016-05-11 06:01:13 -07:00
|
|
|
static const int kDefaultStartBitratebps = 300000;
|
2015-03-04 12:24:26 +00:00
|
|
|
|
2016-05-11 06:01:13 -07:00
|
|
|
// Deprecated:
|
|
|
|
|
// TODO(perkj): BitrateObserver has been deprecated and is not used in WebRTC.
|
|
|
|
|
// Remove this method once other other projects does not use it.
|
2017-03-09 07:09:31 -08:00
|
|
|
static BitrateController* CreateBitrateController(const Clock* clock,
|
2016-07-04 07:06:55 -07:00
|
|
|
BitrateObserver* observer,
|
|
|
|
|
RtcEventLog* event_log);
|
|
|
|
|
|
2017-03-09 07:09:31 -08:00
|
|
|
static BitrateController* CreateBitrateController(const Clock* clock,
|
2016-07-04 07:06:55 -07:00
|
|
|
RtcEventLog* event_log);
|
2016-05-11 06:01:13 -07:00
|
|
|
|
2018-07-18 15:37:01 +02:00
|
|
|
~BitrateController() override {}
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2017-11-15 17:22:16 +01:00
|
|
|
// Deprecated, use raw pointer to BitrateController instance instead.
|
2017-06-12 16:29:45 +02:00
|
|
|
// Creates RtcpBandwidthObserver caller responsible to delete.
|
2017-11-15 17:22:16 +01:00
|
|
|
RTC_DEPRECATED virtual RtcpBandwidthObserver*
|
|
|
|
|
CreateRtcpBandwidthObserver() = 0;
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2016-04-28 15:52:49 +02:00
|
|
|
// Deprecated
|
2015-03-04 12:24:26 +00:00
|
|
|
virtual void SetStartBitrate(int start_bitrate_bps) = 0;
|
2016-04-28 15:52:49 +02:00
|
|
|
// Deprecated
|
2015-03-04 12:24:26 +00:00
|
|
|
virtual void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) = 0;
|
2016-04-28 15:52:49 +02:00
|
|
|
virtual void SetBitrates(int start_bitrate_bps,
|
|
|
|
|
int min_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps) = 0;
|
2015-03-04 12:24:26 +00:00
|
|
|
|
2016-06-24 11:03:55 -07:00
|
|
|
virtual void ResetBitrates(int bitrate_bps,
|
|
|
|
|
int min_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps) = 0;
|
|
|
|
|
|
2016-09-30 10:06:51 +02:00
|
|
|
virtual void OnDelayBasedBweResult(const DelayBasedBwe::Result& result) = 0;
|
|
|
|
|
|
2012-11-13 15:02:13 +00:00
|
|
|
// Gets the available payload bandwidth in bits per second. Note that
|
|
|
|
|
// this bandwidth excludes packet headers.
|
2012-04-23 08:32:47 +00:00
|
|
|
virtual bool AvailableBandwidth(uint32_t* bandwidth) const = 0;
|
|
|
|
|
|
2016-05-11 06:01:13 -07:00
|
|
|
virtual bool GetNetworkParameters(uint32_t* bitrate,
|
|
|
|
|
uint8_t* fraction_loss,
|
|
|
|
|
int64_t* rtt) = 0;
|
2012-04-19 12:13:52 +00:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
|