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 <memory>
|
2016-10-27 17:19:20 +02:00
|
|
|
#include <utility>
|
2016-06-17 09:21:34 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "webrtc/base/checks.h"
|
|
|
|
|
#include "webrtc/base/constructormagic.h"
|
2017-06-16 05:02:05 -07:00
|
|
|
#include "webrtc/base/race_checker.h"
|
2016-12-09 05:50:01 -08:00
|
|
|
#include "webrtc/modules/congestion_controller/median_slope_estimator.h"
|
2016-08-16 10:59:36 +02:00
|
|
|
#include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
|
2016-11-17 03:48:18 -08:00
|
|
|
#include "webrtc/modules/congestion_controller/trendline_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"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2017-02-17 03:38:28 -08:00
|
|
|
class RtcEventLog;
|
|
|
|
|
|
2016-09-30 10:06:51 +02:00
|
|
|
class DelayBasedBwe {
|
2016-06-17 09:21:34 -07:00
|
|
|
public:
|
2016-09-30 10:06:51 +02:00
|
|
|
static const int64_t kStreamTimeOutMs = 2000;
|
|
|
|
|
|
|
|
|
|
struct Result {
|
|
|
|
|
Result() : updated(false), probe(false), target_bitrate_bps(0) {}
|
|
|
|
|
Result(bool probe, uint32_t target_bitrate_bps)
|
|
|
|
|
: updated(true), probe(probe), target_bitrate_bps(target_bitrate_bps) {}
|
|
|
|
|
bool updated;
|
|
|
|
|
bool probe;
|
|
|
|
|
uint32_t target_bitrate_bps;
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-09 07:09:31 -08:00
|
|
|
DelayBasedBwe(RtcEventLog* event_log, const Clock* clock);
|
2017-05-31 02:24:52 -07:00
|
|
|
virtual ~DelayBasedBwe();
|
2016-06-17 09:21:34 -07:00
|
|
|
|
2016-09-30 10:06:51 +02:00
|
|
|
Result IncomingPacketFeedbackVector(
|
2017-06-11 23:57:17 -07:00
|
|
|
const std::vector<PacketFeedback>& packet_feedback_vector,
|
|
|
|
|
rtc::Optional<uint32_t> acked_bitrate_bps);
|
2016-09-30 10:06:51 +02:00
|
|
|
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms);
|
2016-08-16 10:59:36 +02:00
|
|
|
bool LatestEstimate(std::vector<uint32_t>* ssrcs,
|
2016-09-30 10:06:51 +02:00
|
|
|
uint32_t* bitrate_bps) const;
|
2017-01-27 06:43:18 -08:00
|
|
|
void SetStartBitrate(int start_bitrate_bps);
|
2016-09-30 10:06:51 +02:00
|
|
|
void SetMinBitrate(int min_bitrate_bps);
|
2017-04-19 09:15:04 -07:00
|
|
|
int64_t GetExpectedBwePeriodMs() const;
|
2016-06-17 09:21:34 -07:00
|
|
|
|
|
|
|
|
private:
|
2017-04-20 10:10:10 -07:00
|
|
|
void IncomingPacketFeedback(const PacketFeedback& packet_feedback);
|
2017-02-13 09:08:22 -08:00
|
|
|
Result OnLongFeedbackDelay(int64_t arrival_time_ms);
|
2017-04-20 10:10:10 -07:00
|
|
|
|
2017-06-11 23:57:17 -07:00
|
|
|
Result MaybeUpdateEstimate(bool overusing,
|
|
|
|
|
rtc::Optional<uint32_t> acked_bitrate_bps);
|
2016-09-12 12:28:54 -07:00
|
|
|
// Updates the current remote rate estimate and returns true if a valid
|
|
|
|
|
// estimate exists.
|
2017-04-20 10:10:10 -07:00
|
|
|
bool UpdateEstimate(int64_t now_ms,
|
2016-10-27 17:19:20 +02:00
|
|
|
rtc::Optional<uint32_t> acked_bitrate_bps,
|
2017-04-20 10:10:10 -07:00
|
|
|
bool overusing,
|
2016-09-30 10:06:51 +02:00
|
|
|
uint32_t* target_bitrate_bps);
|
2016-06-17 09:21:34 -07:00
|
|
|
|
2017-06-16 05:02:05 -07:00
|
|
|
rtc::RaceChecker network_race_;
|
2017-02-17 03:38:28 -08:00
|
|
|
RtcEventLog* const event_log_;
|
2017-03-09 07:09:31 -08:00
|
|
|
const Clock* const clock_;
|
2016-06-17 09:21:34 -07:00
|
|
|
std::unique_ptr<InterArrival> inter_arrival_;
|
2016-11-17 03:48:18 -08:00
|
|
|
std::unique_ptr<TrendlineEstimator> trendline_estimator_;
|
2016-06-17 09:21:34 -07:00
|
|
|
OveruseDetector detector_;
|
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-10-18 05:55:30 -07:00
|
|
|
AimdRateControl rate_control_;
|
2016-09-30 10:06:51 +02:00
|
|
|
ProbeBitrateEstimator probe_bitrate_estimator_;
|
2016-11-17 03:48:18 -08:00
|
|
|
size_t trendline_window_size_;
|
|
|
|
|
double trendline_smoothing_coeff_;
|
|
|
|
|
double trendline_threshold_gain_;
|
2017-02-13 09:08:22 -08:00
|
|
|
int consecutive_delayed_feedbacks_;
|
2017-02-17 03:38:28 -08:00
|
|
|
uint32_t last_logged_bitrate_;
|
|
|
|
|
BandwidthUsage last_logged_state_;
|
2017-05-02 01:04:26 -07:00
|
|
|
bool in_sparse_update_experiment_;
|
2016-06-17 09:21:34 -07:00
|
|
|
|
|
|
|
|
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
|