terelius bf2c049a12 When receiving an RTCP packet containing feedback about multiple RTP packets,
we currently check for bandwidth overuse once for every RTP packet.

This CL creates an experiment to test processing all packets in the RTCP
feedback before checking for overuse. This can be thought of as checking
for overuse per RTCP packet instead of per RTP packet.

The change is not expected to have a large impact, but enabling the
experiment will make the delay-based BWE slightly less sensitive. This means
that we'll be less likely to back down incorrectly after a brief network
transient, at the cost of sometimes missing real overuse (especially when
the network queues are short). In the latter case, the loss-based estimator
is expected to detect the overuse.

The experiment is off by default.

BUG=webrtc:7508

Review-Url: https://codereview.webrtc.org/2835573003
Cr-Commit-Position: refs/heads/master@{#17968}
2017-05-02 08:04:26 +00:00

116 lines
4.1 KiB
C++

/*
* 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>
#include <utility>
#include <vector>
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/modules/congestion_controller/median_slope_estimator.h"
#include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
#include "webrtc/modules/congestion_controller/trendline_estimator.h"
#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 {
class RtcEventLog;
class DelayBasedBwe {
public:
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;
};
DelayBasedBwe(RtcEventLog* event_log, const Clock* clock);
virtual ~DelayBasedBwe() {}
Result IncomingPacketFeedbackVector(
const std::vector<PacketFeedback>& packet_feedback_vector);
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms);
bool LatestEstimate(std::vector<uint32_t>* ssrcs,
uint32_t* bitrate_bps) const;
void SetStartBitrate(int start_bitrate_bps);
void SetMinBitrate(int min_bitrate_bps);
int64_t GetExpectedBwePeriodMs() const;
private:
// Computes a bayesian estimate of the throughput given acks containing
// the arrival time and payload size. Samples which are far from the current
// estimate or are based on few packets are given a smaller weight, as they
// are considered to be more likely to have been caused by, e.g., delay spikes
// unrelated to congestion.
class BitrateEstimator {
public:
BitrateEstimator();
void Update(int64_t now_ms, int bytes);
rtc::Optional<uint32_t> bitrate_bps() const;
private:
float UpdateWindow(int64_t now_ms, int bytes, int rate_window_ms);
int sum_;
int64_t current_win_ms_;
int64_t prev_time_ms_;
float bitrate_estimate_;
float bitrate_estimate_var_;
};
void IncomingPacketFeedback(const PacketFeedback& packet_feedback);
Result OnLongFeedbackDelay(int64_t arrival_time_ms);
Result MaybeUpdateEstimate(bool overusing);
// Updates the current remote rate estimate and returns true if a valid
// estimate exists.
bool UpdateEstimate(int64_t now_ms,
rtc::Optional<uint32_t> acked_bitrate_bps,
bool overusing,
uint32_t* target_bitrate_bps);
rtc::ThreadChecker network_thread_;
RtcEventLog* const event_log_;
const Clock* const clock_;
std::unique_ptr<InterArrival> inter_arrival_;
std::unique_ptr<TrendlineEstimator> trendline_estimator_;
OveruseDetector detector_;
BitrateEstimator receiver_incoming_bitrate_;
int64_t last_seen_packet_ms_;
bool uma_recorded_;
AimdRateControl rate_control_;
ProbeBitrateEstimator probe_bitrate_estimator_;
size_t trendline_window_size_;
double trendline_smoothing_coeff_;
double trendline_threshold_gain_;
int consecutive_delayed_feedbacks_;
uint32_t last_logged_bitrate_;
BandwidthUsage last_logged_state_;
bool in_sparse_update_experiment_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe);
};
} // namespace webrtc
#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_