Update RemoteBitreateEstimatorAbsSendTime to use BitrateTracker
BitrateTracker uses same implementation as RateStatistics, but provides api using Timestamp and DataRate types instead of plain numbers Bug: webrtc:13756 Change-Id: Ie37fa58ede7590f870ec4376a64e7cf2c94431d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318841 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40697}
This commit is contained in:
parent
8be04f459b
commit
85c05a8a17
@ -49,7 +49,6 @@ rtc_library("remote_bitrate_estimator") {
|
||||
"../../rtc_base:bitrate_tracker",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:logging",
|
||||
"../../rtc_base:rate_statistics",
|
||||
"../../rtc_base:rtc_numerics",
|
||||
"../../rtc_base:safe_minmax",
|
||||
"../../rtc_base:stringutils",
|
||||
|
||||
@ -44,15 +44,6 @@ constexpr int kExpectedNumberOfProbes = 3;
|
||||
constexpr double kTimestampToMs =
|
||||
1000.0 / static_cast<double>(1 << kInterArrivalShift);
|
||||
|
||||
absl::optional<DataRate> OptionalRateFromOptionalBps(
|
||||
absl::optional<int> bitrate_bps) {
|
||||
if (bitrate_bps) {
|
||||
return DataRate::BitsPerSec(*bitrate_bps);
|
||||
} else {
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
std::vector<K> Keys(const std::map<K, V>& map) {
|
||||
std::vector<K> keys;
|
||||
@ -239,8 +230,8 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacket(
|
||||
// here.
|
||||
|
||||
// Check if incoming bitrate estimate is valid, and if it needs to be reset.
|
||||
absl::optional<uint32_t> incoming_bitrate =
|
||||
incoming_bitrate_.Rate(arrival_time.ms());
|
||||
absl::optional<DataRate> incoming_bitrate =
|
||||
incoming_bitrate_.Rate(arrival_time);
|
||||
if (incoming_bitrate) {
|
||||
incoming_bitrate_initialized_ = true;
|
||||
} else if (incoming_bitrate_initialized_) {
|
||||
@ -250,7 +241,7 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacket(
|
||||
incoming_bitrate_.Reset();
|
||||
incoming_bitrate_initialized_ = false;
|
||||
}
|
||||
incoming_bitrate_.Update(payload_size.bytes(), arrival_time.ms());
|
||||
incoming_bitrate_.Update(payload_size, arrival_time);
|
||||
|
||||
if (first_packet_time_.IsInfinite()) {
|
||||
first_packet_time_ = now;
|
||||
@ -312,10 +303,10 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacket(
|
||||
remote_rate_.GetFeedbackInterval().ms()) {
|
||||
update_estimate = true;
|
||||
} else if (detector_.State() == BandwidthUsage::kBwOverusing) {
|
||||
absl::optional<uint32_t> incoming_rate =
|
||||
incoming_bitrate_.Rate(arrival_time.ms());
|
||||
if (incoming_rate && remote_rate_.TimeToReduceFurther(
|
||||
now, DataRate::BitsPerSec(*incoming_rate))) {
|
||||
absl::optional<DataRate> incoming_rate =
|
||||
incoming_bitrate_.Rate(arrival_time);
|
||||
if (incoming_rate.has_value() &&
|
||||
remote_rate_.TimeToReduceFurther(now, *incoming_rate)) {
|
||||
update_estimate = true;
|
||||
}
|
||||
}
|
||||
@ -325,9 +316,8 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacket(
|
||||
// The first overuse should immediately trigger a new estimate.
|
||||
// We also have to update the estimate immediately if we are overusing
|
||||
// and the target bitrate is too high compared to what we are receiving.
|
||||
const RateControlInput input(
|
||||
detector_.State(),
|
||||
OptionalRateFromOptionalBps(incoming_bitrate_.Rate(arrival_time.ms())));
|
||||
const RateControlInput input(detector_.State(),
|
||||
incoming_bitrate_.Rate(arrival_time));
|
||||
target_bitrate = remote_rate_.Update(input, now);
|
||||
update_estimate = remote_rate_.ValidEstimate();
|
||||
}
|
||||
|
||||
@ -30,8 +30,8 @@
|
||||
#include "modules/remote_bitrate_estimator/inter_arrival.h"
|
||||
#include "modules/remote_bitrate_estimator/overuse_detector.h"
|
||||
#include "modules/remote_bitrate_estimator/overuse_estimator.h"
|
||||
#include "rtc_base/bitrate_tracker.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/rate_statistics.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -104,7 +104,7 @@ class RemoteBitrateEstimatorAbsSendTime : public RemoteBitrateEstimator {
|
||||
std::unique_ptr<InterArrival> inter_arrival_;
|
||||
std::unique_ptr<OveruseEstimator> estimator_;
|
||||
OveruseDetector detector_;
|
||||
RateStatistics incoming_bitrate_{kBitrateWindow.ms(), 8000};
|
||||
BitrateTracker incoming_bitrate_{kBitrateWindow};
|
||||
bool incoming_bitrate_initialized_ = false;
|
||||
std::list<Probe> probes_;
|
||||
size_t total_probes_received_ = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user