Reland "Reland "Using units in SendSideBandwidthEstimation.""
This reverts commit a4de9c8b04ce9f7b1c4be639edd6cc4d3a9f07a1.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Revert "Reland "Using units in SendSideBandwidthEstimation.""
>
> This reverts commit e2cb26cb4fa2a3ce7c12636225ba9c720d7c7e56.
>
> Reason for revert: <INSERT REASONING HERE>
>
> Original change's description:
> > Reland "Using units in SendSideBandwidthEstimation."
> >
> > This reverts commit 917e5967a597fa8d6e6cae9ffccb21e3d35d553b.
> >
> > Reason for revert: Handling downstream use case.
> >
> > Original change's description:
> > > Revert "Using units in SendSideBandwidthEstimation."
> > >
> > > This reverts commit 35b5e5f3b0dc409bf571b3609860ad5bb8e00c29.
> > >
> > > Reason for revert: Breaks downstream project
> > >
> > > Original change's description:
> > > > Using units in SendSideBandwidthEstimation.
> > > >
> > > > This CL moves SendSideBandwidthEstimation to use the unit types
> > > > DataRate, TimeDelta and Timestamp. This prepares for upcoming changes.
> > > >
> > > > Bug: webrtc:9718
> > > > Change-Id: If10e329920dda037b53055ff3352ae7f8d7e32b8
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/104021
> > > > Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> > > > Reviewed-by: Björn Terelius <terelius@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#25029}
> > >
> > > TBR=terelius@webrtc.org,srte@webrtc.org
> > >
> > > No-Try: True
> > > Bug: webrtc:9718
> > > Change-Id: Iaf470f1eec9911ee6fc7c1b4f5db9675d89d3780
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/104480
> > > Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
> > > Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#25035}
> >
> > TBR=oprypin@webrtc.org,terelius@webrtc.org,srte@webrtc.org
> >
> > Change-Id: I0940791fcd1e196598b0f0a2ec779c49931ee5df
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: webrtc:9718
> > Reviewed-on: https://webrtc-review.googlesource.com/c/104520
> > Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> > Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#25036}
>
> TBR=oprypin@webrtc.org,terelius@webrtc.org,srte@webrtc.org
>
> Change-Id: I6628771c79fc78dfd856649ae92232e95df63495
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9718
> Reviewed-on: https://webrtc-review.googlesource.com/c/104540
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25037}
TBR=oprypin@webrtc.org,terelius@webrtc.org,srte@webrtc.org
Change-Id: If5473859cea725420afce11b6683fa0c70a29b0a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9718
Reviewed-on: https://webrtc-review.googlesource.com/c/104501
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25039}
diff --git a/modules/bitrate_controller/bitrate_controller_impl.cc b/modules/bitrate_controller/bitrate_controller_impl.cc
index 9b816f6..86b016c 100644
--- a/modules/bitrate_controller/bitrate_controller_impl.cc
+++ b/modules/bitrate_controller/bitrate_controller_impl.cc
@@ -20,7 +20,18 @@
#include "rtc_base/logging.h"
namespace webrtc {
-
+namespace {
+absl::optional<DataRate> ToOptionalDataRate(int send_bitrate_bps) {
+ if (send_bitrate_bps > 0)
+ return DataRate::bps(send_bitrate_bps);
+ return absl::nullopt;
+}
+DataRate MaxRate(int max_bitrate_bps) {
+ if (max_bitrate_bps == -1)
+ return DataRate::Infinity();
+ return DataRate::bps(max_bitrate_bps);
+}
+} // namespace
class BitrateControllerImpl::RtcpBandwidthObserverImpl
: public RtcpBandwidthObserver {
public:
@@ -80,7 +91,9 @@
void BitrateControllerImpl::SetStartBitrate(int start_bitrate_bps) {
{
rtc::CritScope cs(&critsect_);
- bandwidth_estimation_.SetSendBitrate(start_bitrate_bps);
+ bandwidth_estimation_.SetSendBitrate(
+ DataRate::bps(start_bitrate_bps),
+ Timestamp::ms(clock_->TimeInMilliseconds()));
}
MaybeTriggerOnNetworkChanged();
}
@@ -89,7 +102,8 @@
int max_bitrate_bps) {
{
rtc::CritScope cs(&critsect_);
- bandwidth_estimation_.SetMinMaxBitrate(min_bitrate_bps, max_bitrate_bps);
+ bandwidth_estimation_.SetMinMaxBitrate(DataRate::bps(min_bitrate_bps),
+ DataRate::bps(max_bitrate_bps));
}
MaybeTriggerOnNetworkChanged();
}
@@ -99,8 +113,9 @@
int max_bitrate_bps) {
{
rtc::CritScope cs(&critsect_);
- bandwidth_estimation_.SetBitrates(start_bitrate_bps, min_bitrate_bps,
- max_bitrate_bps);
+ bandwidth_estimation_.SetBitrates(
+ ToOptionalDataRate(start_bitrate_bps), DataRate::bps(min_bitrate_bps),
+ MaxRate(max_bitrate_bps), Timestamp::ms(clock_->TimeInMilliseconds()));
}
MaybeTriggerOnNetworkChanged();
}
@@ -111,8 +126,9 @@
{
rtc::CritScope cs(&critsect_);
bandwidth_estimation_ = SendSideBandwidthEstimation(event_log_);
- bandwidth_estimation_.SetBitrates(bitrate_bps, min_bitrate_bps,
- max_bitrate_bps);
+ bandwidth_estimation_.SetBitrates(
+ ToOptionalDataRate(bitrate_bps), DataRate::bps(min_bitrate_bps),
+ MaxRate(max_bitrate_bps), Timestamp::ms(clock_->TimeInMilliseconds()));
}
MaybeTriggerOnNetworkChanged();
}
@@ -121,8 +137,8 @@
void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) {
{
rtc::CritScope cs(&critsect_);
- bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(),
- bitrate);
+ bandwidth_estimation_.UpdateReceiverEstimate(
+ Timestamp::ms(clock_->TimeInMilliseconds()), DataRate::bps(bitrate));
BWE_TEST_LOGGING_PLOT(1, "REMB_kbps", clock_->TimeInMilliseconds(),
bitrate / 1000);
}
@@ -136,12 +152,15 @@
{
rtc::CritScope cs(&critsect_);
if (result.probe) {
- bandwidth_estimation_.SetSendBitrate(result.target_bitrate_bps);
+ bandwidth_estimation_.SetSendBitrate(
+ DataRate::bps(result.target_bitrate_bps),
+ Timestamp::ms(clock_->TimeInMilliseconds()));
}
// Since SetSendBitrate now resets the delay-based estimate, we have to call
// UpdateDelayBasedEstimate after SetSendBitrate.
- bandwidth_estimation_.UpdateDelayBasedEstimate(clock_->TimeInMilliseconds(),
- result.target_bitrate_bps);
+ bandwidth_estimation_.UpdateDelayBasedEstimate(
+ Timestamp::ms(clock_->TimeInMilliseconds()),
+ DataRate::bps(result.target_bitrate_bps));
}
MaybeTriggerOnNetworkChanged();
}
@@ -158,7 +177,8 @@
void BitrateControllerImpl::Process() {
{
rtc::CritScope cs(&critsect_);
- bandwidth_estimation_.UpdateEstimate(clock_->TimeInMilliseconds());
+ bandwidth_estimation_.UpdateEstimate(
+ Timestamp::ms(clock_->TimeInMilliseconds()));
}
MaybeTriggerOnNetworkChanged();
last_bitrate_update_ms_ = clock_->TimeInMilliseconds();
@@ -213,8 +233,9 @@
RTC_DCHECK_GE(total_number_of_packets, 0);
- bandwidth_estimation_.UpdateReceiverBlock(fraction_lost_aggregate, rtt,
- total_number_of_packets, now_ms);
+ bandwidth_estimation_.UpdateReceiverBlock(
+ fraction_lost_aggregate, TimeDelta::ms(rtt), total_number_of_packets,
+ Timestamp::ms(now_ms));
}
MaybeTriggerOnNetworkChanged();
}