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>
|
2012-04-19 12:13:52 +00:00
|
|
|
|
2015-02-26 14:34:55 +00:00
|
|
|
#include "webrtc/base/scoped_ptr.h"
|
2013-07-16 12:54:53 +00:00
|
|
|
#include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h"
|
|
|
|
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
2012-04-19 12:13:52 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class BitrateControllerImpl : public BitrateController {
|
|
|
|
|
public:
|
2015-03-04 12:24:26 +00:00
|
|
|
BitrateControllerImpl(Clock* clock, BitrateObserver* observer);
|
2014-03-21 14:00:51 +00:00
|
|
|
virtual ~BitrateControllerImpl();
|
|
|
|
|
|
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
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void SetStartBitrate(int start_bitrate_bps) override;
|
|
|
|
|
void SetMinMaxBitrate(int min_bitrate_bps,
|
2015-03-04 12:24:26 +00:00
|
|
|
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
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int64_t TimeUntilNextProcess() override;
|
|
|
|
|
int32_t 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.
|
2014-12-08 19:46:23 +00:00
|
|
|
void OnReceivedEstimatedBitrate(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
|
|
|
|
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-01-12 21:51:21 +00:00
|
|
|
int64_t rtt)
|
2014-03-21 14:00:51 +00:00
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(*critsect_);
|
|
|
|
|
|
2014-03-26 21:00:21 +00:00
|
|
|
// Used by process thread.
|
|
|
|
|
Clock* clock_;
|
2015-03-04 12:24:26 +00:00
|
|
|
BitrateObserver* observer_;
|
2014-12-08 19:46:23 +00:00
|
|
|
int64_t last_bitrate_update_ms_;
|
2014-03-26 21:00:21 +00:00
|
|
|
|
2012-04-19 12:13:52 +00:00
|
|
|
CriticalSectionWrapper* critsect_;
|
2014-03-21 14:00:51 +00:00
|
|
|
SendSideBandwidthEstimation bandwidth_estimation_ GUARDED_BY(*critsect_);
|
2014-03-26 21:00:21 +00:00
|
|
|
uint32_t reserved_bitrate_bps_ GUARDED_BY(*critsect_);
|
|
|
|
|
|
|
|
|
|
uint32_t last_bitrate_bps_ GUARDED_BY(*critsect_);
|
2014-03-21 16:51:01 +00:00
|
|
|
uint8_t last_fraction_loss_ GUARDED_BY(*critsect_);
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t last_rtt_ms_ GUARDED_BY(*critsect_);
|
2014-03-26 14:32:47 +00:00
|
|
|
uint32_t last_reserved_bitrate_bps_ GUARDED_BY(*critsect_);
|
|
|
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(BitrateControllerImpl);
|
2012-04-19 12:13:52 +00:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
#endif // WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
|