2016-06-17 09:21:34 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2016 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
|
|
|
|
|
#define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
|
|
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "webrtc/base/checks.h"
|
|
|
|
|
#include "webrtc/base/constructormagic.h"
|
2016-09-29 04:19:38 -07:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2016-06-17 09:21:34 -07:00
|
|
|
#include "webrtc/base/rate_statistics.h"
|
|
|
|
|
#include "webrtc/base/thread_checker.h"
|
2016-08-16 10:59:36 +02:00
|
|
|
#include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
|
2016-06-17 09:21:34 -07:00
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
|
|
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
|
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h"
|
|
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h"
|
|
|
|
|
#include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h"
|
2016-09-29 04:19:38 -07:00
|
|
|
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
2016-06-17 09:21:34 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2016-09-29 04:19:38 -07:00
|
|
|
class DelayBasedBwe : public RemoteBitrateEstimator {
|
2016-06-17 09:21:34 -07:00
|
|
|
public:
|
2016-09-29 04:19:38 -07:00
|
|
|
DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock);
|
2016-06-17 09:21:34 -07:00
|
|
|
virtual ~DelayBasedBwe() {}
|
|
|
|
|
|
2016-09-29 04:19:38 -07:00
|
|
|
void IncomingPacketFeedbackVector(
|
|
|
|
|
const std::vector<PacketInfo>& packet_feedback_vector) override;
|
|
|
|
|
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
2016-08-16 10:59:36 +02:00
|
|
|
bool LatestEstimate(std::vector<uint32_t>* ssrcs,
|
2016-09-29 04:19:38 -07:00
|
|
|
uint32_t* bitrate_bps) const override;
|
|
|
|
|
void SetMinBitrate(int min_bitrate_bps) override;
|
|
|
|
|
|
|
|
|
|
// Required by RemoteBitrateEstimator but does nothing.
|
|
|
|
|
void Process() override;
|
|
|
|
|
// Required by RemoteBitrateEstimator but does nothing.
|
|
|
|
|
int64_t TimeUntilNextProcess() override;
|
|
|
|
|
// Required by RemoteBitrateEstimator but does nothing.
|
|
|
|
|
void RemoveStream(uint32_t ssrc) override;
|
|
|
|
|
void IncomingPacket(int64_t arrival_time_ms,
|
|
|
|
|
size_t payload_size,
|
|
|
|
|
const RTPHeader& header) override {
|
|
|
|
|
RTC_NOTREACHED();
|
|
|
|
|
}
|
2016-06-17 09:21:34 -07:00
|
|
|
|
|
|
|
|
private:
|
2016-09-29 04:19:38 -07:00
|
|
|
void IncomingPacketInfo(const PacketInfo& info);
|
2016-09-12 12:28:54 -07:00
|
|
|
// Updates the current remote rate estimate and returns true if a valid
|
|
|
|
|
// estimate exists.
|
|
|
|
|
bool UpdateEstimate(int64_t packet_arrival_time_ms,
|
|
|
|
|
int64_t now_ms,
|
2016-09-29 04:19:38 -07:00
|
|
|
uint32_t* target_bitrate_bps)
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
2016-06-17 09:21:34 -07:00
|
|
|
|
|
|
|
|
rtc::ThreadChecker network_thread_;
|
2016-07-11 01:44:02 -07:00
|
|
|
Clock* const clock_;
|
2016-09-29 04:19:38 -07:00
|
|
|
RemoteBitrateObserver* const observer_;
|
2016-06-17 09:21:34 -07:00
|
|
|
std::unique_ptr<InterArrival> inter_arrival_;
|
|
|
|
|
std::unique_ptr<OveruseEstimator> estimator_;
|
|
|
|
|
OveruseDetector detector_;
|
|
|
|
|
RateStatistics incoming_bitrate_;
|
|
|
|
|
int64_t last_update_ms_;
|
2016-08-16 10:59:36 +02:00
|
|
|
int64_t last_seen_packet_ms_;
|
2016-08-03 00:29:03 -07:00
|
|
|
bool uma_recorded_;
|
2016-09-29 04:19:38 -07:00
|
|
|
|
|
|
|
|
rtc::CriticalSection crit_;
|
|
|
|
|
AimdRateControl remote_rate_ GUARDED_BY(&crit_);
|
|
|
|
|
ProbeBitrateEstimator probe_bitrate_estimator_ GUARDED_BY(&crit_);
|
2016-06-17 09:21:34 -07:00
|
|
|
|
|
|
|
|
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
|