mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 14:20:45 +01:00

This time the class is added but only used if the field trial "WebRTC-Bwe-NewInterArrivalDelta/Enabled/" is enabled. Original cl description: This cl copies modules/remote_bitrate_estimator/inter_arrival.x to inter_arrival.h and interrival_delta.cc in goog_cc but modified to use webrtc::Timestamp and webrtc::Timedelta in order to avoid having to use 24 bit time repressentation. patchset 1 is a pure revert of the revert https://webrtc-review.googlesource.com/c/src/+/196343 patchset 2 contains a modification to allow running it behind an experiment. Bug: webrtc:12269 Change-Id: Ide80e9f5243362799a2cc1f0fcf7e613e707d851 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196502 Commit-Queue: Per Kjellander <perkj@webrtc.org> Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32784}
136 lines
4.8 KiB
C++
136 lines
4.8 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 MODULES_CONGESTION_CONTROLLER_GOOG_CC_DELAY_BASED_BWE_H_
|
|
#define MODULES_CONGESTION_CONTROLLER_GOOG_CC_DELAY_BASED_BWE_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "api/network_state_predictor.h"
|
|
#include "api/transport/network_types.h"
|
|
#include "api/transport/webrtc_key_value_config.h"
|
|
#include "modules/congestion_controller/goog_cc/delay_increase_detector_interface.h"
|
|
#include "modules/congestion_controller/goog_cc/inter_arrival_delta.h"
|
|
#include "modules/congestion_controller/goog_cc/probe_bitrate_estimator.h"
|
|
#include "modules/remote_bitrate_estimator/aimd_rate_control.h"
|
|
#include "modules/remote_bitrate_estimator/inter_arrival.h"
|
|
#include "rtc_base/experiments/struct_parameters_parser.h"
|
|
#include "rtc_base/race_checker.h"
|
|
|
|
namespace webrtc {
|
|
class RtcEventLog;
|
|
|
|
struct BweSeparateAudioPacketsSettings {
|
|
static constexpr char kKey[] = "WebRTC-Bwe-SeparateAudioPackets";
|
|
|
|
BweSeparateAudioPacketsSettings() = default;
|
|
explicit BweSeparateAudioPacketsSettings(
|
|
const WebRtcKeyValueConfig* key_value_config);
|
|
|
|
bool enabled = false;
|
|
int packet_threshold = 10;
|
|
TimeDelta time_threshold = TimeDelta::Seconds(1);
|
|
|
|
std::unique_ptr<StructParametersParser> Parser();
|
|
};
|
|
|
|
class DelayBasedBwe {
|
|
public:
|
|
struct Result {
|
|
Result();
|
|
~Result() = default;
|
|
bool updated;
|
|
bool probe;
|
|
DataRate target_bitrate = DataRate::Zero();
|
|
bool recovered_from_overuse;
|
|
bool backoff_in_alr;
|
|
};
|
|
|
|
explicit DelayBasedBwe(const WebRtcKeyValueConfig* key_value_config,
|
|
RtcEventLog* event_log,
|
|
NetworkStatePredictor* network_state_predictor);
|
|
|
|
DelayBasedBwe() = delete;
|
|
DelayBasedBwe(const DelayBasedBwe&) = delete;
|
|
DelayBasedBwe& operator=(const DelayBasedBwe&) = delete;
|
|
|
|
virtual ~DelayBasedBwe();
|
|
|
|
Result IncomingPacketFeedbackVector(
|
|
const TransportPacketsFeedback& msg,
|
|
absl::optional<DataRate> acked_bitrate,
|
|
absl::optional<DataRate> probe_bitrate,
|
|
absl::optional<NetworkStateEstimate> network_estimate,
|
|
bool in_alr);
|
|
void OnRttUpdate(TimeDelta avg_rtt);
|
|
bool LatestEstimate(std::vector<uint32_t>* ssrcs, DataRate* bitrate) const;
|
|
void SetStartBitrate(DataRate start_bitrate);
|
|
void SetMinBitrate(DataRate min_bitrate);
|
|
TimeDelta GetExpectedBwePeriod() const;
|
|
void SetAlrLimitedBackoffExperiment(bool enabled);
|
|
DataRate TriggerOveruse(Timestamp at_time,
|
|
absl::optional<DataRate> link_capacity);
|
|
DataRate last_estimate() const { return prev_bitrate_; }
|
|
|
|
private:
|
|
friend class GoogCcStatePrinter;
|
|
void IncomingPacketFeedback(const PacketResult& packet_feedback,
|
|
Timestamp at_time);
|
|
Result MaybeUpdateEstimate(
|
|
absl::optional<DataRate> acked_bitrate,
|
|
absl::optional<DataRate> probe_bitrate,
|
|
absl::optional<NetworkStateEstimate> state_estimate,
|
|
bool recovered_from_overuse,
|
|
bool in_alr,
|
|
Timestamp at_time);
|
|
// Updates the current remote rate estimate and returns true if a valid
|
|
// estimate exists.
|
|
bool UpdateEstimate(Timestamp at_time,
|
|
absl::optional<DataRate> acked_bitrate,
|
|
DataRate* target_rate);
|
|
|
|
rtc::RaceChecker network_race_;
|
|
RtcEventLog* const event_log_;
|
|
const WebRtcKeyValueConfig* const key_value_config_;
|
|
|
|
// Alternatively, run two separate overuse detectors for audio and video,
|
|
// and fall back to the audio one if we haven't seen a video packet in a
|
|
// while.
|
|
BweSeparateAudioPacketsSettings separate_audio_;
|
|
int64_t audio_packets_since_last_video_;
|
|
Timestamp last_video_packet_recv_time_;
|
|
|
|
NetworkStatePredictor* network_state_predictor_;
|
|
std::unique_ptr<InterArrival> video_inter_arrival_;
|
|
std::unique_ptr<InterArrivalDelta> video_inter_arrival_delta_;
|
|
std::unique_ptr<DelayIncreaseDetectorInterface> video_delay_detector_;
|
|
std::unique_ptr<InterArrival> audio_inter_arrival_;
|
|
std::unique_ptr<InterArrivalDelta> audio_inter_arrival_delta_;
|
|
std::unique_ptr<DelayIncreaseDetectorInterface> audio_delay_detector_;
|
|
DelayIncreaseDetectorInterface* active_delay_detector_;
|
|
|
|
Timestamp last_seen_packet_;
|
|
bool uma_recorded_;
|
|
AimdRateControl rate_control_;
|
|
DataRate prev_bitrate_;
|
|
bool has_once_detected_overuse_;
|
|
BandwidthUsage prev_state_;
|
|
const bool use_new_inter_arrival_delta_;
|
|
bool alr_limited_backoff_enabled_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_CONGESTION_CONTROLLER_GOOG_CC_DELAY_BASED_BWE_H_
|