Avoid exposing RemoteBitrateEstimator in ReceiveSideCongestionController

Making RemoteBitrateEstimator to be ReceiveSideCC implementation detail allows code to be cleaner.

Bug: None
Change-Id: I1d3327c44b364c6c2a1005391cf1dc468e0cc8ce
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266482
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37305}
This commit is contained in:
Danil Chapovalov 2022-06-22 10:11:00 +02:00 committed by WebRTC LUCI CQ
parent 1d848e1c2e
commit 0ed3a2b6cb
4 changed files with 32 additions and 20 deletions

View File

@ -898,9 +898,7 @@ void Call::DestroyAudioReceiveStream(
audio_receive_stream->UnregisterFromTransport();
uint32_t ssrc = audio_receive_stream->remote_ssrc();
receive_side_cc_
.GetRemoteBitrateEstimator(UseSendSideBwe(audio_receive_stream))
->RemoveStream(ssrc);
receive_side_cc_.RemoveStream(ssrc);
audio_receive_streams_.erase(audio_receive_stream);
@ -1086,9 +1084,7 @@ void Call::DestroyVideoReceiveStream(
video_receive_streams_.erase(receive_stream_impl);
ConfigureSync(receive_stream_impl->sync_group());
receive_side_cc_
.GetRemoteBitrateEstimator(UseSendSideBwe(receive_stream_impl))
->RemoveStream(receive_stream_impl->remote_ssrc());
receive_side_cc_.RemoveStream(receive_stream_impl->remote_ssrc());
UpdateAggregateNetworkState();
delete receive_stream_impl;
@ -1132,9 +1128,7 @@ void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) {
// Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be
// destroyed.
receive_side_cc_
.GetRemoteBitrateEstimator(UseSendSideBwe(receive_stream_impl))
->RemoveStream(ssrc);
receive_side_cc_.RemoveStream(ssrc);
delete receive_stream_impl;
}
@ -1165,11 +1159,7 @@ Call::Stats Call::GetStats() const {
stats.rtt_ms = call_stats_->LastProcessedRtt();
// Fetch available send/receive bitrates.
std::vector<unsigned int> ssrcs;
uint32_t recv_bandwidth = 0;
receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate(
&ssrcs, &recv_bandwidth);
stats.recv_bandwidth_bps = recv_bandwidth;
stats.recv_bandwidth_bps = receive_side_cc_.LatestReceiveSideEstimate().bps();
stats.send_bandwidth_bps =
last_bandwidth_bps_.load(std::memory_order_relaxed);
stats.max_padding_bitrate_bps =

View File

@ -48,9 +48,10 @@ class ReceiveSideCongestionController : public CallStatsObserver {
void SetSendPeriodicFeedback(bool send_periodic_feedback);
// TODO(nisse): Delete these methods, design a more specific interface.
virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(bool send_side_bwe);
virtual const RemoteBitrateEstimator* GetRemoteBitrateEstimator(
bool send_side_bwe) const;
[[deprecated]] virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
bool send_side_bwe);
[[deprecated]] virtual const RemoteBitrateEstimator*
GetRemoteBitrateEstimator(bool send_side_bwe) const;
// Implements CallStatsObserver.
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
@ -64,6 +65,14 @@ class ReceiveSideCongestionController : public CallStatsObserver {
void SetTransportOverhead(DataSize overhead_per_packet);
// Returns latest receive side bandwidth estimation.
// Returns zero if receive side bandwidth estimation is unavailable.
DataRate LatestReceiveSideEstimate() const;
// Removes stream from receive side bandwidth estimation.
// Noop if receive side bwe is not used or stream doesn't participate in it.
void RemoveStream(uint32_t ssrc);
[[deprecated]] int64_t TimeUntilNextProcess();
[[deprecated]] void Process();

View File

@ -167,6 +167,20 @@ ReceiveSideCongestionController::GetRemoteBitrateEstimator(
}
}
DataRate ReceiveSideCongestionController::LatestReceiveSideEstimate() const {
std::vector<uint32_t> unused_ssrcs;
uint32_t bitrate_bps = 0;
if (remote_bitrate_estimator_.LatestEstimate(&unused_ssrcs, &bitrate_bps)) {
return DataRate::BitsPerSec(bitrate_bps);
} else {
return DataRate::Zero();
}
}
void ReceiveSideCongestionController::RemoveStream(uint32_t ssrc) {
remote_bitrate_estimator_.RemoveStream(ssrc);
}
void ReceiveSideCongestionController::OnRttUpdate(int64_t avg_rtt_ms,
int64_t max_rtt_ms) {
remote_bitrate_estimator_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);

View File

@ -26,7 +26,6 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
&clock,
absl::bind_front(&PacketRouter::SendCombinedRtcpPacket, &packet_router),
absl::bind_front(&PacketRouter::SendRemb, &packet_router), nullptr);
RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true);
RTPHeader header;
header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]);
i += sizeof(uint32_t);
@ -43,11 +42,11 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
header.extension.transportSequenceNumber =
ByteReader<uint16_t>::ReadBigEndian(&data[i]);
i += sizeof(uint16_t);
rbe->IncomingPacket(arrival_time_ms, payload_size, header);
cc.OnReceivedPacket(arrival_time_ms, payload_size, header);
clock.AdvanceTimeMilliseconds(5);
arrival_time_ms += ByteReader<uint8_t>::ReadBigEndian(&data[i]);
i += sizeof(uint8_t);
cc.MaybeProcess();
}
rbe->Process();
}
} // namespace webrtc