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 encoder via VideoEncoderCallback.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
|
|
|
|
|
#define WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
|
|
|
|
|
|
2013-07-16 12:54:53 +00:00
|
|
|
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2012-08-13 16:13:09 +00:00
|
|
|
#include <list>
|
2013-10-21 14:00:01 +00:00
|
|
|
#include <utility>
|
2016-09-12 12:28:54 -07:00
|
|
|
#include <vector>
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2016-04-26 08:14:39 -07:00
|
|
|
#include "webrtc/base/constructormagic.h"
|
2015-08-03 04:38:41 -07:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2013-07-16 12:54:53 +00:00
|
|
|
#include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h"
|
2012-04-19 12:13:52 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class BitrateControllerImpl : public BitrateController {
|
|
|
|
|
public:
|
2016-05-11 06:01:13 -07:00
|
|
|
// TODO(perkj): BitrateObserver has been deprecated and is not used in WebRTC.
|
|
|
|
|
// |observer| is left for project that is not yet updated.
|
2017-03-09 07:09:31 -08:00
|
|
|
BitrateControllerImpl(const Clock* clock,
|
2016-07-04 07:06:55 -07:00
|
|
|
BitrateObserver* observer,
|
|
|
|
|
RtcEventLog* event_log);
|
2015-03-26 11:11:06 +01:00
|
|
|
virtual ~BitrateControllerImpl() {}
|
2014-03-21 14:00:51 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool AvailableBandwidth(uint32_t* bandwidth) const override;
|
2014-03-21 14:00:51 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
RtcpBandwidthObserver* CreateRtcpBandwidthObserver() override;
|
2014-03-21 14:00:51 +00:00
|
|
|
|
2016-04-28 15:52:49 +02:00
|
|
|
// Deprecated
|
2015-03-04 12:58:35 +00:00
|
|
|
void SetStartBitrate(int start_bitrate_bps) override;
|
2016-04-28 15:52:49 +02:00
|
|
|
// Deprecated
|
2016-01-20 07:13:58 -08:00
|
|
|
void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) override;
|
|
|
|
|
|
2016-04-28 15:52:49 +02:00
|
|
|
void SetBitrates(int start_bitrate_bps,
|
|
|
|
|
int min_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps) override;
|
|
|
|
|
|
2016-06-24 11:03:55 -07:00
|
|
|
void ResetBitrates(int bitrate_bps,
|
|
|
|
|
int min_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps) override;
|
|
|
|
|
|
2014-03-21 14:00:51 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void SetReservedBitrate(uint32_t reserved_bitrate_bps) override;
|
2014-03-21 14:00:51 +00:00
|
|
|
|
2016-05-11 06:01:13 -07:00
|
|
|
// Returns true if the parameters have changed since the last call.
|
|
|
|
|
bool GetNetworkParameters(uint32_t* bitrate,
|
|
|
|
|
uint8_t* fraction_loss,
|
|
|
|
|
int64_t* rtt) override;
|
|
|
|
|
|
2016-09-30 10:06:51 +02:00
|
|
|
void OnDelayBasedBweResult(const DelayBasedBwe::Result& result) override;
|
2016-08-24 02:45:35 -07:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int64_t TimeUntilNextProcess() override;
|
2016-02-25 04:50:01 -08:00
|
|
|
void Process() override;
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2014-03-21 14:00:51 +00:00
|
|
|
private:
|
|
|
|
|
class RtcpBandwidthObserverImpl;
|
2012-04-19 12:13:52 +00:00
|
|
|
|
|
|
|
|
// Called by BitrateObserver's direct from the RTCP module.
|
2016-09-12 12:28:54 -07:00
|
|
|
void OnReceiverEstimatedBitrate(uint32_t bitrate);
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2014-12-08 19:46:23 +00:00
|
|
|
void OnReceivedRtcpReceiverReport(uint8_t fraction_loss,
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t rtt,
|
2014-12-08 19:46:23 +00:00
|
|
|
int number_of_packets,
|
|
|
|
|
int64_t now_ms);
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2016-05-11 06:01:13 -07:00
|
|
|
// Deprecated
|
2015-03-04 12:24:26 +00:00
|
|
|
void MaybeTriggerOnNetworkChanged();
|
2014-03-21 16:51:01 +00:00
|
|
|
|
2014-12-08 19:46:23 +00:00
|
|
|
void OnNetworkChanged(uint32_t bitrate,
|
|
|
|
|
uint8_t fraction_loss, // 0 - 255.
|
2015-08-03 04:38:41 -07:00
|
|
|
int64_t rtt) EXCLUSIVE_LOCKS_REQUIRED(critsect_);
|
2014-03-21 14:00:51 +00:00
|
|
|
|
2014-03-26 21:00:21 +00:00
|
|
|
// Used by process thread.
|
2017-03-09 07:09:31 -08:00
|
|
|
const Clock* const clock_;
|
2016-05-11 06:01:13 -07:00
|
|
|
BitrateObserver* const observer_;
|
2014-12-08 19:46:23 +00:00
|
|
|
int64_t last_bitrate_update_ms_;
|
2016-07-04 07:06:55 -07:00
|
|
|
RtcEventLog* const event_log_;
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2016-01-25 03:52:44 -08:00
|
|
|
rtc::CriticalSection critsect_;
|
2015-08-03 04:38:41 -07:00
|
|
|
SendSideBandwidthEstimation bandwidth_estimation_ GUARDED_BY(critsect_);
|
|
|
|
|
uint32_t reserved_bitrate_bps_ GUARDED_BY(critsect_);
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2015-08-03 04:38:41 -07:00
|
|
|
uint32_t last_bitrate_bps_ GUARDED_BY(critsect_);
|
|
|
|
|
uint8_t last_fraction_loss_ GUARDED_BY(critsect_);
|
|
|
|
|
int64_t last_rtt_ms_ GUARDED_BY(critsect_);
|
|
|
|
|
uint32_t last_reserved_bitrate_bps_ GUARDED_BY(critsect_);
|
2014-03-26 14:32:47 +00:00
|
|
|
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(BitrateControllerImpl);
|
2012-04-19 12:13:52 +00:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
#endif // WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
|