From d5af40225b7bc5fc4c1784c7410cf49766cbdbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Tue, 5 Mar 2019 08:56:48 +0100 Subject: [PATCH] Add overhead observers to MediaTransportInterface Bug: webrtc:9719 Change-Id: I18a494ac2edd52c1f61673f850e6e8abebbc5d0a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/123192 Reviewed-by: Anton Sukhanov Reviewed-by: Fredrik Solenberg Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#27019} --- api/media_transport_interface.h | 12 ++++++++++++ audio/channel_send.cc | 7 ++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/api/media_transport_interface.h b/api/media_transport_interface.h index d333bec5bf..1b5f735180 100644 --- a/api/media_transport_interface.h +++ b/api/media_transport_interface.h @@ -28,6 +28,7 @@ #include "api/transport/media/audio_transport.h" #include "api/transport/media/video_transport.h" #include "api/units/data_rate.h" +#include "common_types.h" // NOLINT(build/include) #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/network_route.h" @@ -280,8 +281,19 @@ class MediaTransportInterface { // transport overhead (ipv4/6, turn channeldata, tcp/udp, etc.). // If the transport is capable of fusing packets together, this overhead // might not be a very accurate number. + // TODO(nisse): Deprecated. virtual size_t GetAudioPacketOverhead() const; + // Corresponding observers for audio and video overhead. Before destruction, + // the observers must be unregistered by setting nullptr. + + // TODO(nisse): Should move to per-stream objects, since packetization + // overhead can vary per stream, e.g., depending on negotiated extensions. In + // addition, we should move towards reporting total overhead including all + // layers. Currently, overhead of the lower layers is reported elsewhere, + // e.g., on route change between IPv4 and IPv6. + virtual void SetAudioOverheadObserver(OverheadObserver* observer) {} + // Registers an observer for network change events. If the network route is // already established when the callback is added, |callback| will be called // immediately with the current network route. Before media transport is diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 5951b6b942..19edf3c088 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -688,11 +688,6 @@ ChannelSend::ChannelSend(Clock* clock, // RTPMediaTransport. In this case it means that overhead and bandwidth // observers should not be called when using media transport. if (!media_transport_) { - // TODO(sukhanov): Overhead observer is only needed for RTP path, because in - // media transport audio overhead is currently considered constant (see - // getter MediaTransportInterface::GetAudioPacketOverhead). In the future - // when we introduce RTP media transport we should make audio overhead - // interface consistent and work for both RTP and non-RTP implementations. configuration.overhead_observer = overhead_observer; configuration.bandwidth_callback = rtcp_observer_.get(); configuration.transport_feedback_callback = feedback_observer_proxy_.get(); @@ -725,6 +720,7 @@ ChannelSend::ChannelSend(Clock* clock, if (media_transport_) { RTC_DLOG(LS_INFO) << "Setting media_transport_ rate observers."; media_transport_->AddTargetTransferRateObserver(this); + media_transport_->SetAudioOverheadObserver(overhead_observer); } else { RTC_DLOG(LS_INFO) << "Not setting media_transport_ rate observers."; } @@ -748,6 +744,7 @@ ChannelSend::~ChannelSend() { if (media_transport_) { media_transport_->RemoveTargetTransferRateObserver(this); + media_transport_->SetAudioOverheadObserver(nullptr); } StopSend();