From 95ca6e16922ee0f046df182c2290eedb01932cea Mon Sep 17 00:00:00 2001 From: "Piotr (Peter) Slatala" Date: Tue, 13 Nov 2018 07:57:07 -0800 Subject: [PATCH] AudioSource allows implementations to return settings So far the code assumed that there is only one implementation of AudioSourceInterface: LocalAudioSource. That is not true. This change allows custom implementations to still set options (such as audio network adaptation) on the source. Long term solution should include refactoring options so that they are passed to peer connection or call object, and not be defined on audio source. Bug: webrtc:9719 Change-Id: Ic3b92219502bc73a964adbbb9c5cd7156aa382e1 Reviewed-on: https://webrtc-review.googlesource.com/c/110681 Commit-Queue: Peter Slatala Reviewed-by: Steve Anton Reviewed-by: Niels Moller Cr-Commit-Position: refs/heads/master@{#25626} --- api/mediastreaminterface.cc | 4 ++++ api/mediastreaminterface.h | 6 ++++++ pc/localaudiosource.h | 2 +- pc/rtpsender.cc | 4 +--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/mediastreaminterface.cc b/api/mediastreaminterface.cc index e36d5cb83b..955e7e4c60 100644 --- a/api/mediastreaminterface.cc +++ b/api/mediastreaminterface.cc @@ -30,4 +30,8 @@ AudioTrackInterface::GetAudioProcessor() { return nullptr; } +const cricket::AudioOptions AudioSourceInterface::options() const { + return {}; +} + } // namespace webrtc diff --git a/api/mediastreaminterface.h b/api/mediastreaminterface.h index 30f8f71602..6d967660c5 100644 --- a/api/mediastreaminterface.h +++ b/api/mediastreaminterface.h @@ -23,6 +23,7 @@ #include #include "absl/types/optional.h" +#include "api/audio_options.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" @@ -207,6 +208,11 @@ class AudioSourceInterface : public MediaSourceInterface { // TODO(tommi): Make pure virtual. virtual void AddSink(AudioTrackSinkInterface* sink) {} virtual void RemoveSink(AudioTrackSinkInterface* sink) {} + + // Returns options for the AudioSource. + // (for some of the settings this approach is broken, e.g. setting + // audio network adaptation on the source is the wrong layer of abstraction). + virtual const cricket::AudioOptions options() const; }; // Interface of the audio processor used by the audio track to collect diff --git a/pc/localaudiosource.h b/pc/localaudiosource.h index c5f65304d0..c48f5407d4 100644 --- a/pc/localaudiosource.h +++ b/pc/localaudiosource.h @@ -29,7 +29,7 @@ class LocalAudioSource : public Notifier { SourceState state() const override { return kLive; } bool remote() const override { return false; } - virtual const cricket::AudioOptions& options() const { return options_; } + const cricket::AudioOptions options() const override { return options_; } void AddSink(AudioTrackSinkInterface* sink) override {} void RemoveSink(AudioTrackSinkInterface* sink) override {} diff --git a/pc/rtpsender.cc b/pc/rtpsender.cc index 3196641166..abd1748cea 100644 --- a/pc/rtpsender.cc +++ b/pc/rtpsender.cc @@ -405,9 +405,7 @@ void AudioRtpSender::SetAudioSend() { // options since it is also applied to all streams/channels, local or remote. if (track_->enabled() && track_->GetSource() && !track_->GetSource()->remote()) { - // TODO(xians): Remove this static_cast since we should be able to connect - // a remote audio track to a peer connection. - options = static_cast(track_->GetSource())->options(); + options = track_->GetSource()->options(); } #endif