From ff97631e3c7460c97909d67b5ff171003cb968eb Mon Sep 17 00:00:00 2001 From: solenberg Date: Wed, 30 Mar 2016 23:28:51 -0700 Subject: [PATCH] - Add temporary VoEBase::audio_device_module() method. - Remove WVoE::SetAudioDeviceModule() - the ADM is now supplied in ctor. - Remove WVoE::Init() and WVoE::Terminate(). - Remove MediaEngineInterface::Terminate(). BUG=webrtc:4690 Review URL: https://codereview.webrtc.org/1830213002 Cr-Commit-Position: refs/heads/master@{#12173} --- webrtc/media/base/fakemediaengine.h | 7 +- webrtc/media/base/mediaengine.h | 13 +- webrtc/media/engine/fakewebrtcvoiceengine.h | 27 +- .../engine/nullwebrtcvideoengine_unittest.cc | 8 +- webrtc/media/engine/webrtcmediaengine.cc | 8 +- .../engine/webrtcvideoengine2_unittest.cc | 1 + webrtc/media/engine/webrtcvoiceengine.cc | 119 ++---- webrtc/media/engine/webrtcvoiceengine.h | 23 +- .../engine/webrtcvoiceengine_unittest.cc | 341 +++++++++--------- webrtc/pc/channelmanager.cc | 3 +- webrtc/voice_engine/channel_proxy.h | 3 + webrtc/voice_engine/include/voe_base.h | 4 + webrtc/voice_engine/voe_base_impl.h | 3 + 13 files changed, 253 insertions(+), 307 deletions(-) diff --git a/webrtc/media/base/fakemediaengine.h b/webrtc/media/base/fakemediaengine.h index 6feaf8e989..d6d653991c 100644 --- a/webrtc/media/base/fakemediaengine.h +++ b/webrtc/media/base/fakemediaengine.h @@ -696,14 +696,12 @@ class FakeBaseEngine { class FakeVoiceEngine : public FakeBaseEngine { public: - FakeVoiceEngine() + explicit FakeVoiceEngine(webrtc::AudioDeviceModule* adm) : output_volume_(-1) { // Add a fake audio codec. Note that the name must not be "" as there are // sanity checks against that. codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0)); } - bool Init(rtc::Thread* worker_thread) { return true; } - void Terminate() {} rtc::scoped_refptr GetAudioState() const { return rtc::scoped_refptr(); } @@ -810,7 +808,8 @@ class FakeVideoEngine : public FakeBaseEngine { class FakeMediaEngine : public CompositeMediaEngine { public: - FakeMediaEngine() {} + FakeMediaEngine() : + CompositeMediaEngine(nullptr) {} virtual ~FakeMediaEngine() {} void SetAudioCodecs(const std::vector& codecs) { diff --git a/webrtc/media/base/mediaengine.h b/webrtc/media/base/mediaengine.h index 001eb1ff88..4c7d62a1e4 100644 --- a/webrtc/media/base/mediaengine.h +++ b/webrtc/media/base/mediaengine.h @@ -33,6 +33,7 @@ #endif namespace webrtc { +class AudioDeviceModule; class Call; } @@ -54,9 +55,7 @@ class MediaEngineInterface { // Initialization // Starts the engine. - virtual bool Init(rtc::Thread* worker_thread) = 0; - // Shuts down the engine. - virtual void Terminate() = 0; + virtual bool Init() = 0; // TODO(solenberg): Remove once VoE API refactoring is done. virtual rtc::scoped_refptr GetAudioState() const = 0; @@ -125,16 +124,12 @@ class MediaEngineFactory { template class CompositeMediaEngine : public MediaEngineInterface { public: + explicit CompositeMediaEngine(webrtc::AudioDeviceModule* adm) : voice_(adm) {} virtual ~CompositeMediaEngine() {} - virtual bool Init(rtc::Thread* worker_thread) { - if (!voice_.Init(worker_thread)) - return false; + virtual bool Init() { video_.Init(); return true; } - virtual void Terminate() { - voice_.Terminate(); - } virtual rtc::scoped_refptr GetAudioState() const { return voice_.GetAudioState(); diff --git a/webrtc/media/engine/fakewebrtcvoiceengine.h b/webrtc/media/engine/fakewebrtcvoiceengine.h index e0e70d90ae..cc0375e7c7 100644 --- a/webrtc/media/engine/fakewebrtcvoiceengine.h +++ b/webrtc/media/engine/fakewebrtcvoiceengine.h @@ -25,6 +25,7 @@ #include "webrtc/media/engine/fakewebrtccommon.h" #include "webrtc/media/engine/webrtcvoe.h" #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" +#include "webrtc/modules/audio_device/include/fake_audio_device.h" #include "webrtc/modules/audio_processing/include/audio_processing.h" namespace cricket { @@ -118,6 +119,26 @@ class FakeAudioProcessing : public webrtc::AudioProcessing { bool experimental_ns_enabled_; }; +// TODO(solenberg): Swap this for a proper mock of the ADM. +class FakeAudioDeviceModule : public webrtc::FakeAudioDeviceModule { + public: + ~FakeAudioDeviceModule() override { + RTC_DCHECK_EQ(0, ref_count_); + } + int32_t AddRef() const override { + ref_count_++; + return ref_count_; + } + int32_t Release() const override { + RTC_DCHECK_LT(0, ref_count_); + ref_count_--; + return ref_count_; + } + + private: + mutable int32_t ref_count_ = 0; +}; + class FakeWebRtcVoiceEngine : public webrtc::VoEAudioProcessing, public webrtc::VoEBase, public webrtc::VoECodec, @@ -193,7 +214,7 @@ class FakeWebRtcVoiceEngine playout_sample_rate_(-1) { memset(&agc_config_, 0, sizeof(agc_config_)); } - ~FakeWebRtcVoiceEngine() { + ~FakeWebRtcVoiceEngine() override { RTC_CHECK(channels_.empty()); } @@ -306,6 +327,9 @@ class FakeWebRtcVoiceEngine webrtc::AudioProcessing* audio_processing() override { return &audio_processing_; } + webrtc::AudioDeviceModule* audio_device_module() override { + return &audio_device_module_; + } WEBRTC_FUNC(CreateChannel, ()) { webrtc::Config empty_config; return AddChannel(empty_config); @@ -775,6 +799,7 @@ class FakeWebRtcVoiceEngine int recording_sample_rate_; int playout_sample_rate_; FakeAudioProcessing audio_processing_; + FakeAudioDeviceModule audio_device_module_; }; } // namespace cricket diff --git a/webrtc/media/engine/nullwebrtcvideoengine_unittest.cc b/webrtc/media/engine/nullwebrtcvideoengine_unittest.cc index cf5f5076e0..31a2754e19 100644 --- a/webrtc/media/engine/nullwebrtcvideoengine_unittest.cc +++ b/webrtc/media/engine/nullwebrtcvideoengine_unittest.cc @@ -20,8 +20,8 @@ class WebRtcMediaEngineNullVideo public: WebRtcMediaEngineNullVideo(webrtc::AudioDeviceModule* adm, WebRtcVideoEncoderFactory* encoder_factory, - WebRtcVideoDecoderFactory* decoder_factory) { - voice_.SetAudioDeviceModule(adm); + WebRtcVideoDecoderFactory* decoder_factory) + : CompositeMediaEngine(adm) { video_.SetExternalDecoderFactory(decoder_factory); video_.SetExternalEncoderFactory(encoder_factory); } @@ -31,9 +31,7 @@ class WebRtcMediaEngineNullVideo // required by CompositeMediaEngine. TEST(NullWebRtcVideoEngineTest, CheckInterface) { WebRtcMediaEngineNullVideo engine(nullptr, nullptr, nullptr); - - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); - engine.Terminate(); + EXPECT_TRUE(engine.Init()); } } // namespace cricket diff --git a/webrtc/media/engine/webrtcmediaengine.cc b/webrtc/media/engine/webrtcmediaengine.cc index 0643de6d4d..45652d0128 100644 --- a/webrtc/media/engine/webrtcmediaengine.cc +++ b/webrtc/media/engine/webrtcmediaengine.cc @@ -30,8 +30,12 @@ class WebRtcMediaEngine2 public: WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm, WebRtcVideoEncoderFactory* encoder_factory, - WebRtcVideoDecoderFactory* decoder_factory) { - voice_.SetAudioDeviceModule(adm); + WebRtcVideoDecoderFactory* decoder_factory) +#ifdef HAVE_WEBRTC_VIDEO + : CompositeMediaEngine(adm) { +#else + : CompositeMediaEngine(adm) { +#endif video_.SetExternalDecoderFactory(decoder_factory); video_.SetExternalEncoderFactory(encoder_factory); } diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc index e8800ba66f..a8d743e1d5 100644 --- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc +++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc @@ -102,6 +102,7 @@ class WebRtcVideoEngine2Test : public ::testing::Test { const char* field_trials) : override_field_trials_(field_trials), call_(webrtc::Call::Create(webrtc::Call::Config())), + voice_engine_(nullptr), engine_() { std::vector engine_codecs = engine_.codecs(); RTC_DCHECK(!engine_codecs.empty()); diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc index 6fe3d86fd9..21094fde4d 100644 --- a/webrtc/media/engine/webrtcvoiceengine.cc +++ b/webrtc/media/engine/webrtcvoiceengine.cc @@ -249,7 +249,6 @@ class WebRtcVoiceCodecs final { // TODO(solenberg): Do this filtering once off-line, add a simple AudioCodec // list and add a test which verifies VoE supports the listed codecs. static std::vector SupportedCodecs() { - LOG(LS_INFO) << "WebRtc VoiceEngine codecs:"; std::vector result; for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { // Change the sample rate of G722 to 8000 to match SDP. @@ -276,7 +275,6 @@ class WebRtcVoiceCodecs final { pref->payload_type, voe_codec.plname, voe_codec.plfreq, voe_codec.rate, voe_codec.channels, static_cast(arraysize(kCodecPrefs)) - (pref - kCodecPrefs)); - LOG(LS_INFO) << ToString(codec); if (IsCodec(codec, kIsacCodecName)) { // Indicate auto-bitrate in signaling. codec.bitrate = 0; @@ -300,7 +298,7 @@ class WebRtcVoiceCodecs final { } result.push_back(codec); } else { - LOG(LS_WARNING) << "Unexpected codec: " << ToString(voe_codec); + LOG(LS_INFO) << "[Unused] " << ToString(voe_codec); } } // Make sure they are in local preference order. @@ -515,74 +513,46 @@ bool WebRtcVoiceEngine::ToCodecInst(const AudioCodec& in, return WebRtcVoiceCodecs::ToCodecInst(in, out); } -WebRtcVoiceEngine::WebRtcVoiceEngine() - : voe_wrapper_(new VoEWrapper()), - audio_state_(webrtc::AudioState::Create(MakeAudioStateConfig(voe()))) { - Construct(); +WebRtcVoiceEngine::WebRtcVoiceEngine(webrtc::AudioDeviceModule* adm) + : WebRtcVoiceEngine(adm, new VoEWrapper()) { + audio_state_ = webrtc::AudioState::Create(MakeAudioStateConfig(voe())); } -WebRtcVoiceEngine::WebRtcVoiceEngine(VoEWrapper* voe_wrapper) - : voe_wrapper_(voe_wrapper) { - Construct(); -} - -void WebRtcVoiceEngine::Construct() { +WebRtcVoiceEngine::WebRtcVoiceEngine(webrtc::AudioDeviceModule* adm, + VoEWrapper* voe_wrapper) + : adm_(adm), voe_wrapper_(voe_wrapper) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - LOG(LS_VERBOSE) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; + LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; + RTC_DCHECK(voe_wrapper); signal_thread_checker_.DetachFromThread(); - std::memset(&default_agc_config_, 0, sizeof(default_agc_config_)); - voe_config_.Set(new webrtc::VoicePacing(true)); - - webrtc::Trace::set_level_filter(kDefaultTraceFilter); - webrtc::Trace::SetTraceCallback(this); // Load our audio codec list. + LOG(LS_INFO) << "Supported codecs in order of preference:"; codecs_ = WebRtcVoiceCodecs::SupportedCodecs(); -} - -WebRtcVoiceEngine::~WebRtcVoiceEngine() { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - LOG(LS_VERBOSE) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; - if (adm_) { - voe_wrapper_.reset(); - adm_->Release(); - adm_ = NULL; + for (const AudioCodec& codec : codecs_) { + LOG(LS_INFO) << ToString(codec); } - webrtc::Trace::SetTraceCallback(nullptr); -} -bool WebRtcVoiceEngine::Init(rtc::Thread* worker_thread) { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - RTC_DCHECK(worker_thread == rtc::Thread::Current()); - LOG(LS_INFO) << "WebRtcVoiceEngine::Init"; - bool res = InitInternal(); - if (res) { - LOG(LS_INFO) << "WebRtcVoiceEngine::Init Done!"; - } else { - LOG(LS_ERROR) << "WebRtcVoiceEngine::Init failed"; - Terminate(); - } - return res; -} + voe_config_.Set(new webrtc::VoicePacing(true)); -bool WebRtcVoiceEngine::InitInternal() { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - // Temporarily turn logging level up for the Init call. + // Temporarily turn logging level up for the Init() call. + webrtc::Trace::SetTraceCallback(this); webrtc::Trace::set_level_filter(kElevatedTraceFilter); LOG(LS_INFO) << webrtc::VoiceEngine::GetVersionString(); - if (voe_wrapper_->base()->Init(adm_) == -1) { - LOG_RTCERR0_EX(Init, voe_wrapper_->error()); - return false; - } + RTC_CHECK_EQ(0, voe_wrapper_->base()->Init(adm_.get())); webrtc::Trace::set_level_filter(kDefaultTraceFilter); + // No ADM supplied? Get the default one from VoE. + if (!adm_) { + adm_ = voe_wrapper_->base()->audio_device_module(); + } + RTC_DCHECK(adm_); + // Save the default AGC configuration settings. This must happen before // calling ApplyOptions or the default will be overwritten. - if (voe_wrapper_->processing()->GetAgcConfig(default_agc_config_) == -1) { - LOG_RTCERR0(GetAgcConfig); - return false; - } + int error = voe_wrapper_->processing()->GetAgcConfig(default_agc_config_); + RTC_DCHECK_EQ(0, error); // Set default engine options. { @@ -600,31 +570,19 @@ bool WebRtcVoiceEngine::InitInternal() { options.extended_filter_aec = rtc::Optional(false); options.delay_agnostic_aec = rtc::Optional(false); options.experimental_ns = rtc::Optional(false); - if (!ApplyOptions(options)) { - return false; - } - } - - // Print our codec list again for the call diagnostic log. - LOG(LS_INFO) << "WebRtc VoiceEngine codecs:"; - for (const AudioCodec& codec : codecs_) { - LOG(LS_INFO) << ToString(codec); + bool error = ApplyOptions(options); + RTC_DCHECK(error); } SetDefaultDevices(); - - initialized_ = true; - return true; } -void WebRtcVoiceEngine::Terminate() { +WebRtcVoiceEngine::~WebRtcVoiceEngine() { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - LOG(LS_INFO) << "WebRtcVoiceEngine::Terminate"; - initialized_ = false; - + LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; StopAecDump(); - voe_wrapper_->base()->Terminate(); + webrtc::Trace::SetTraceCallback(nullptr); } rtc::scoped_refptr @@ -643,7 +601,7 @@ VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel( bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - LOG(LS_INFO) << "ApplyOptions: " << options_in.ToString(); + LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: " << options_in.ToString(); AudioOptions options = options_in; // The options are modified below. // kEcConference is AEC with high suppression. @@ -1048,23 +1006,6 @@ bool WebRtcVoiceEngine::AdjustAgcLevel(int delta) { return true; } -bool WebRtcVoiceEngine::SetAudioDeviceModule(webrtc::AudioDeviceModule* adm) { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - if (initialized_) { - LOG(LS_WARNING) << "SetAudioDeviceModule can not be called after Init."; - return false; - } - if (adm_) { - adm_->Release(); - adm_ = NULL; - } - if (adm) { - adm_ = adm; - adm_->AddRef(); - } - return true; -} - bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); diff --git a/webrtc/media/engine/webrtcvoiceengine.h b/webrtc/media/engine/webrtcvoiceengine.h index c9798cbc95..396e3bbb8c 100644 --- a/webrtc/media/engine/webrtcvoiceengine.h +++ b/webrtc/media/engine/webrtcvoiceengine.h @@ -19,6 +19,7 @@ #include "webrtc/audio_state.h" #include "webrtc/base/buffer.h" #include "webrtc/base/networkroute.h" +#include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/base/stream.h" #include "webrtc/base/thread_checker.h" #include "webrtc/call.h" @@ -44,12 +45,10 @@ class WebRtcVoiceEngine final : public webrtc::TraceCallback { // Exposed for the WVoE/MC unit test. static bool ToCodecInst(const AudioCodec& in, webrtc::CodecInst* out); - WebRtcVoiceEngine(); + explicit WebRtcVoiceEngine(webrtc::AudioDeviceModule* adm); // Dependency injection for testing. - explicit WebRtcVoiceEngine(VoEWrapper* voe_wrapper); - ~WebRtcVoiceEngine(); - bool Init(rtc::Thread* worker_thread); - void Terminate(); + WebRtcVoiceEngine(webrtc::AudioDeviceModule* adm, VoEWrapper* voe_wrapper); + ~WebRtcVoiceEngine() override; rtc::scoped_refptr GetAudioState() const; VoiceMediaChannel* CreateChannel(webrtc::Call* call, @@ -76,9 +75,6 @@ class WebRtcVoiceEngine final : public webrtc::TraceCallback { VoEWrapper* voe() { return voe_wrapper_.get(); } int GetLastEngineError(); - // Set the external ADM. This can only be called before Init. - bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm); - // Starts AEC dump using an existing file. A maximum file size in bytes can be // specified. When the maximum file size is reached, logging is stopped and // the file is closed. If max_size_bytes is set to <= 0, no limit will be @@ -96,8 +92,6 @@ class WebRtcVoiceEngine final : public webrtc::TraceCallback { void StopRtcEventLog(); private: - void Construct(); - bool InitInternal(); // Every option that is "set" will be applied. Every option not "set" will be // ignored. This allows us to selectively turn on and off different options // easily at any time. @@ -113,15 +107,14 @@ class WebRtcVoiceEngine final : public webrtc::TraceCallback { rtc::ThreadChecker signal_thread_checker_; rtc::ThreadChecker worker_thread_checker_; + // The audio device manager. + rtc::scoped_refptr adm_; // The primary instance of WebRtc VoiceEngine. std::unique_ptr voe_wrapper_; rtc::scoped_refptr audio_state_; - // The external audio device manager - webrtc::AudioDeviceModule* adm_ = nullptr; std::vector codecs_; std::vector channels_; webrtc::Config voe_config_; - bool initialized_ = false; bool is_dumping_aec_ = false; webrtc::AgcConfig default_agc_config_; @@ -133,7 +126,7 @@ class WebRtcVoiceEngine final : public webrtc::TraceCallback { rtc::Optional delay_agnostic_aec_; rtc::Optional experimental_ns_; - RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcVoiceEngine); + RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceEngine); }; // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses @@ -157,8 +150,6 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel, bool PausePlayout(); bool ResumePlayout(); void SetSend(bool send) override; - bool PauseSend(); - bool ResumeSend(); bool SetAudioSend(uint32_t ssrc, bool enable, const AudioOptions* options, diff --git a/webrtc/media/engine/webrtcvoiceengine_unittest.cc b/webrtc/media/engine/webrtcvoiceengine_unittest.cc index 30be07d213..97773b7134 100644 --- a/webrtc/media/engine/webrtcvoiceengine_unittest.cc +++ b/webrtc/media/engine/webrtcvoiceengine_unittest.cc @@ -59,6 +59,17 @@ class FakeVoEWrapper : public cricket::VoEWrapper { }; } // namespace +// Tests that our stub library "works". +TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { + cricket::FakeWebRtcVoiceEngine voe; + EXPECT_FALSE(voe.IsInited()); + { + cricket::WebRtcVoiceEngine engine(nullptr, new FakeVoEWrapper(&voe)); + EXPECT_TRUE(voe.IsInited()); + } + EXPECT_FALSE(voe.IsInited()); +} + class FakeAudioSink : public webrtc::AudioSinkInterface { public: void OnData(const Data& audio) override {} @@ -74,29 +85,25 @@ class WebRtcVoiceEngineTestFake : public testing::Test { explicit WebRtcVoiceEngineTestFake(const char* field_trials) : call_(webrtc::Call::Config()), - engine_(new FakeVoEWrapper(&voe_)), - channel_(nullptr), + engine_(nullptr, new FakeVoEWrapper(&voe_)), override_field_trials_(field_trials) { send_parameters_.codecs.push_back(kPcmuCodec); recv_parameters_.codecs.push_back(kPcmuCodec); } - bool SetupEngine() { - if (!engine_.Init(rtc::Thread::Current())) { - return false; - } + bool SetupChannel() { channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), cricket::AudioOptions()); return (channel_ != nullptr); } - bool SetupEngineWithRecvStream() { - if (!SetupEngine()) { + bool SetupRecvStream() { + if (!SetupChannel()) { return false; } return channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc1)); } - bool SetupEngineWithSendStream() { - if (!SetupEngine()) { + bool SetupSendStream() { + if (!SetupChannel()) { return false; } if (!channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc1))) { @@ -105,7 +112,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { return channel_->SetAudioSend(kSsrc1, true, nullptr, &fake_source_); } void SetupForMultiSendStream() { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); // Remove stream added in Setup. EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1)); @@ -118,7 +125,6 @@ class WebRtcVoiceEngineTestFake : public testing::Test { } void TearDown() override { delete channel_; - engine_.Terminate(); } const cricket::FakeAudioSendStream& GetSendStream(uint32_t ssrc) { @@ -142,10 +148,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { } void TestInsertDtmf(uint32_t ssrc, bool caller) { - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), - cricket::AudioOptions()); - EXPECT_TRUE(channel_ != nullptr); + EXPECT_TRUE(SetupChannel()); if (caller) { // If this is a caller, local description will be applied and add the // send stream. @@ -204,7 +207,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { } void TestSetSendRtpHeaderExtensions(const std::string& ext) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); // Ensure extensions are off by default. EXPECT_EQ(0u, GetSendStreamConfig(kSsrc1).rtp.extensions.size()); @@ -246,7 +249,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { } void TestSetRecvRtpHeaderExtensions(const std::string& ext) { - EXPECT_TRUE(SetupEngineWithRecvStream()); + EXPECT_TRUE(SetupRecvStream()); // Ensure extensions are off by default. EXPECT_EQ(0u, GetRecvStreamConfig(kSsrc1).rtp.extensions.size()); @@ -401,7 +404,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { cricket::FakeCall call_; cricket::FakeWebRtcVoiceEngine voe_; cricket::WebRtcVoiceEngine engine_; - cricket::VoiceMediaChannel* channel_; + cricket::VoiceMediaChannel* channel_ = nullptr; cricket::AudioSendParameters send_parameters_; cricket::AudioRecvParameters recv_parameters_; FakeAudioSource fake_source_; @@ -410,21 +413,9 @@ class WebRtcVoiceEngineTestFake : public testing::Test { webrtc::test::ScopedFieldTrials override_field_trials_; }; -// Tests that our stub library "works". -TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { - EXPECT_FALSE(voe_.IsInited()); - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - EXPECT_TRUE(voe_.IsInited()); - engine_.Terminate(); - EXPECT_FALSE(voe_.IsInited()); -} - // Tests that we can create and destroy a channel. TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) { - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), - cricket::AudioOptions()); - EXPECT_TRUE(channel_ != nullptr); + EXPECT_TRUE(SetupChannel()); } // Tests that the list of supported codecs is created properly and ordered @@ -494,7 +485,7 @@ TEST_F(WebRtcVoiceEngineTestFake, FindCodec) { // Test that we set our inbound codecs properly, including changing PT. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -521,7 +512,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { // Test that we fail to set an unknown inbound codec. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(cricket::AudioCodec(127, "XYZ", 32000, 0, 1, 0)); @@ -530,7 +521,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { // Test that we fail if we have duplicate types in the inbound list. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsDuplicatePayloadType) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kCn16000Codec); @@ -540,7 +531,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsDuplicatePayloadType) { // Test that we can decode OPUS without stereo parameters. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -562,7 +553,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { // Test that we can decode OPUS with stereo = 0. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -585,7 +576,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { // Test that we can decode OPUS with stereo = 1. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -607,7 +598,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { // Test that changes to recv codecs are applied to all streams. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -634,7 +625,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { } TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { - EXPECT_TRUE(SetupEngineWithRecvStream()); + EXPECT_TRUE(SetupRecvStream()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs[0].id = 106; // collide with existing telephone-event @@ -652,7 +643,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { // Test that we can apply the same set of codecs again while playing. TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { - EXPECT_TRUE(SetupEngineWithRecvStream()); + EXPECT_TRUE(SetupRecvStream()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kCn16000Codec); @@ -669,7 +660,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { // Test that we can add a codec while playing. TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { - EXPECT_TRUE(SetupEngineWithRecvStream()); + EXPECT_TRUE(SetupRecvStream()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kCn16000Codec); @@ -686,7 +677,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { } TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); // Test that when autobw is enabled, bitrate is kept as the default // value. autobw is enabled for the following tests because the target @@ -703,7 +694,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { } TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); // Test that the bitrate of a multi-rate codec is always the maximum. @@ -717,7 +708,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { } TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); // Test that we can only set a maximum bitrate for a fixed-rate codec // if it's bigger than the fixed rate. @@ -733,7 +724,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { } TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); const int kDesiredBitrate = 128000; cricket::AudioSendParameters parameters; parameters.codecs = engine_.codecs(); @@ -753,7 +744,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { // Bitrate is ignored if it is higher than the fixed bitrate. // Bitrate less then the fixed bitrate is an error. TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); // PCMU, default bitrate == 64000. EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); @@ -775,7 +766,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { // Test that we apply codecs properly. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -800,7 +791,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried // to apply. TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -817,7 +808,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { // Verify that G722 is set with 16000 samples per second to WebRTC. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kG722CodecSdp); @@ -831,7 +822,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { // Test that if clockrate is not 48000 for opus, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); parameters.codecs[0].bitrate = 0; @@ -841,7 +832,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { // Test that if channels=0 for opus, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); parameters.codecs[0].bitrate = 0; @@ -851,7 +842,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { // Test that if channels=0 for opus, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); parameters.codecs[0].bitrate = 0; @@ -862,7 +853,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { // Test that if channel is 1 for opus and there's no stereo, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); parameters.codecs[0].bitrate = 0; @@ -872,7 +863,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { // Test that if channel is 1 for opus and stereo=0, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); parameters.codecs[0].bitrate = 0; @@ -883,7 +874,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { // Test that if channel is 1 for opus and stereo=1, we fail. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); parameters.codecs[0].bitrate = 0; @@ -895,7 +886,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { // Test that with bitrate=0 and no stereo, // channels and bitrate are 1 and 32000. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -911,7 +902,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { // Test that with bitrate=0 and stereo=0, // channels and bitrate are 1 and 32000. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -928,7 +919,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { // Test that with bitrate=invalid and stereo=0, // channels and bitrate are 1 and 32000. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -954,7 +945,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { // Test that with bitrate=0 and stereo=1, // channels and bitrate are 2 and 64000. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -971,7 +962,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { // Test that with bitrate=invalid and stereo=1, // channels and bitrate are 2 and 64000. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -997,7 +988,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { // Test that with bitrate=N and stereo unset, // channels and bitrate are 1 and N. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1015,7 +1006,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { // Test that with bitrate=N and stereo=0, // channels and bitrate are 1 and N. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1032,7 +1023,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { // Test that with bitrate=N and without any parameters, // channels and bitrate are 1 and N. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1048,7 +1039,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { // Test that with bitrate=N and stereo=1, // channels and bitrate are 2 and N. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1066,7 +1057,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { // Also test that the "maxaveragebitrate" can't be set to values outside the // range of 6000 and 510000 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1093,7 +1084,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { // Test that we can enable NACK with opus as caller. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1107,7 +1098,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { // Test that we can enable NACK with opus as callee. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { - EXPECT_TRUE(SetupEngineWithRecvStream()); + EXPECT_TRUE(SetupRecvStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1125,7 +1116,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { // Test that we can enable NACK on receive streams. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num1 = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); int channel_num2 = voe_.GetLastChannel(); @@ -1143,7 +1134,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { // Test that we can disable NACK. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1161,7 +1152,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { // Test that we can disable NACK on receive streams. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num1 = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); int channel_num2 = voe_.GetLastChannel(); @@ -1183,7 +1174,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { // Test that NACK is enabled on a new receive stream. TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); @@ -1204,7 +1195,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { // Test that without useinbandfec, Opus FEC is off. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1214,7 +1205,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { // Test that with useinbandfec=0, Opus FEC is off. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1231,7 +1222,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { // Test that with useinbandfec=1, Opus FEC is on. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1248,7 +1239,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { // Test that with useinbandfec=1, stereo=1, Opus FEC is on. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1266,7 +1257,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { // Test that with non-Opus, codec FEC is off. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); @@ -1276,7 +1267,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { // Test the with non-Opus, even if useinbandfec=1, FEC is off. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); @@ -1287,7 +1278,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { // Test that Opus FEC status can be changed. TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1299,7 +1290,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { } TEST_F(WebRtcVoiceEngineTestFake, TransportCcCanBeEnabledAndDisabled) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::AudioSendParameters send_parameters; send_parameters.codecs.push_back(kOpusCodec); EXPECT_TRUE(send_parameters.codecs[0].feedback_params.params().empty()); @@ -1323,7 +1314,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TransportCcCanBeEnabledAndDisabled) { // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1345,7 +1336,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode. TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1367,7 +1358,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode. TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1389,7 +1380,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode. TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1411,7 +1402,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { // Test 24000 < maxplaybackrate triggers Opus full band mode. TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1433,7 +1424,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { // Test Opus that without maxplaybackrate, default playback rate is used. TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1444,7 +1435,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { // Test the with non-Opus, maxplaybackrate has no effect. TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); @@ -1455,7 +1446,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { // Test maxplaybackrate can be set on two streams. TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1478,7 +1469,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { // Test that with usedtx=0, Opus DTX is off. TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1489,7 +1480,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { // Test that with usedtx=1, Opus DTX is on. TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1501,7 +1492,7 @@ TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { // Test that usedtx=1 works with stereo Opus. TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1514,7 +1505,7 @@ TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { // Test that usedtx=1 does not work with non Opus. TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); @@ -1525,7 +1516,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { // Test that we can switch back and forth between Opus and ISAC with CN. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters opus_parameters; opus_parameters.codecs.push_back(kOpusCodec); @@ -1552,7 +1543,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { // Test that we handle various ways of specifying bitrate. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); // bitrate == 32000 @@ -1602,7 +1593,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { // Test that we could set packet size specified in kCodecParamPTime. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kOpusCodec); @@ -1637,7 +1628,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { // Test that we fail if no codecs are specified. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; EXPECT_FALSE(channel_->SetSendParameters(parameters)); } @@ -1645,7 +1636,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { // Test that we can set send codecs even with telephone-event codec as the first // one on the list. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kTelephoneEventCodec); @@ -1663,7 +1654,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { // Test that payload type range is limited for telephone-event codec. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kTelephoneEventCodec); parameters.codecs.push_back(kIsacCodec); @@ -1685,7 +1676,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { // Test that we can set send codecs even with CN codec as the first // one on the list. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kCn16000Codec); @@ -1703,7 +1694,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { // Test that we set VAD and DTMF types correctly as caller. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); @@ -1730,11 +1721,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { // Test that we set VAD and DTMF types correctly as callee. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), - cricket::AudioOptions()); - EXPECT_TRUE(channel_ != nullptr); - + EXPECT_TRUE(SetupChannel()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -1765,7 +1752,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { // Test that we only apply VAD if we have a CN codec that matches the // send codec clockrate. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; // Set ISAC(16K) and CN(16K). VAD should be activated. @@ -1801,7 +1788,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { // Test that we perform case-insensitive matching of codec names. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kIsacCodec); @@ -1828,7 +1815,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { // Test that we set up RED correctly as caller. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); @@ -1848,11 +1835,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { // Test that we set up RED correctly as callee. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) { - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), - cricket::AudioOptions()); - EXPECT_TRUE(channel_ != nullptr); - + EXPECT_TRUE(SetupChannel()); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); parameters.codecs.push_back(kIsacCodec); @@ -1874,7 +1857,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) { // Test that we set up RED correctly if params are omitted. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); @@ -1893,7 +1876,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { // Test that we ignore RED if the parameters aren't named the way we expect. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); @@ -1912,7 +1895,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { // Test that we ignore RED if it uses different primary/secondary encoding. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); @@ -1931,7 +1914,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { // Test that we ignore RED if it uses more than 2 encodings. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); @@ -1950,7 +1933,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { // Test that we ignore RED if it has bogus codec ids. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); @@ -1969,7 +1952,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { // Test that we ignore RED if it refers to a codec that is not present. TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num = voe_.GetLastChannel(); cricket::AudioSendParameters parameters; parameters.codecs.push_back(kRedCodec); @@ -2025,7 +2008,7 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { // Test that we can create a channel and start sending on it. TEST_F(WebRtcVoiceEngineTestFake, Send) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); channel_->SetSend(true); EXPECT_TRUE(GetSendStream(kSsrc1).IsSending()); @@ -2036,7 +2019,7 @@ TEST_F(WebRtcVoiceEngineTestFake, Send) { // Test that a channel will send if and only if it has a source and is enabled // for sending. TEST_F(WebRtcVoiceEngineTestFake, SendStateWithAndWithoutSource) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); channel_->SetSend(true); @@ -2049,7 +2032,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SendStateWithAndWithoutSource) { // Test that we can create a channel and start playing out on it. TEST_F(WebRtcVoiceEngineTestFake, Playout) { - EXPECT_TRUE(SetupEngineWithRecvStream()); + EXPECT_TRUE(SetupRecvStream()); int channel_num = voe_.GetLastChannel(); EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); EXPECT_TRUE(channel_->SetPlayout(true)); @@ -2208,7 +2191,7 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { // Test that we can add and remove receive streams, and do proper send/playout. // We can receive on multiple streams while sending one stream. TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); int channel_num1 = voe_.GetLastChannel(); // Start playout without a receive stream. @@ -2260,7 +2243,7 @@ TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { // Test that we can create a channel configured for Codian bridges, // and start sending on it. TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioOptions options_adjust_agc; options_adjust_agc.adjust_agc_delta = rtc::Optional(-10); webrtc::AgcConfig agc_config; @@ -2278,7 +2261,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { } TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); webrtc::AgcConfig agc_config; EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); EXPECT_EQ(0, agc_config.targetLeveldBOv); @@ -2302,7 +2285,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { } TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); send_parameters_.options.recording_sample_rate = rtc::Optional(48000); send_parameters_.options.playout_sample_rate = rtc::Optional(44100); @@ -2316,17 +2299,17 @@ TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { } // Test that we can set the outgoing SSRC properly. -// SSRC is set in SetupEngine by calling AddSendStream. +// SSRC is set in SetupSendStream() by calling AddSendStream. TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); } TEST_F(WebRtcVoiceEngineTestFake, GetStats) { // Setup. We need send codec to be set to get all stats. - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); SetAudioSendStreamStats(); - // SetupEngineWithSendStream adds a send stream with kSsrc1, so the receive + // SetupSendStream adds a send stream with kSsrc1, so the receive // stream has to use a different SSRC. EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc2))); @@ -2377,9 +2360,9 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStats) { } // Test that we can set the outgoing SSRC properly with multiple streams. -// SSRC is set in SetupEngine by calling AddSendStream. +// SSRC is set in SetupSendStream() by calling AddSendStream. TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); EXPECT_TRUE(channel_->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrc2))); @@ -2389,10 +2372,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { // Test that the local SSRC is the same on sending and receiving channels if the // receive channel is created before the send channel. TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), - cricket::AudioOptions()); - + EXPECT_TRUE(SetupChannel()); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); int receive_channel_num = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddSendStream( @@ -2404,7 +2384,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { // Test that we can properly receive packets. TEST_F(WebRtcVoiceEngineTestFake, Recv) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); int channel_num = voe_.GetLastChannel(); @@ -2413,7 +2393,7 @@ TEST_F(WebRtcVoiceEngineTestFake, Recv) { // Test that we can properly receive packets on multiple streams. TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); int channel_num1 = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); @@ -2458,7 +2438,7 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { // Test that receiving on an unsignalled stream works (default channel will be // created). TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignalled) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); int channel_num = voe_.GetLastChannel(); EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, sizeof(kPcmuFrame))); @@ -2468,7 +2448,7 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignalled) { // created), and that packets will be forwarded to the default channel // regardless of their SSRCs. TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignalledWithSsrcSwitch) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); char packet[sizeof(kPcmuFrame)]; memcpy(packet, kPcmuFrame, sizeof(kPcmuFrame)); @@ -2488,7 +2468,7 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignalledWithSsrcSwitch) { // Test that a default channel is created even after a signalled stream has been // added, and that this stream will get any packets for unknown SSRCs. TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignalledAfterSignalled) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); char packet[sizeof(kPcmuFrame)]; memcpy(packet, kPcmuFrame, sizeof(kPcmuFrame)); @@ -2515,21 +2495,21 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvUnsignalledAfterSignalled) { // Test that we properly handle failures to add a receive stream. TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamFail) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); voe_.set_fail_create_channel(true); EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); } // Test that we properly handle failures to add a send stream. TEST_F(WebRtcVoiceEngineTestFake, AddSendStreamFail) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); voe_.set_fail_create_channel(true); EXPECT_FALSE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); } // Test that AddRecvStream creates new stream. TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream) { - EXPECT_TRUE(SetupEngineWithRecvStream()); + EXPECT_TRUE(SetupRecvStream()); int channel_num = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); EXPECT_NE(channel_num, voe_.GetLastChannel()); @@ -2538,7 +2518,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream) { // Test that after adding a recv stream, we do not decode more codecs than // those previously passed into SetRecvCodecs. TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::AudioRecvParameters parameters; parameters.codecs.push_back(kIsacCodec); parameters.codecs.push_back(kPcmuCodec); @@ -2556,7 +2536,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { // Test that we properly clean up any streams that were added, even if // not explicitly removed. TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); @@ -2567,12 +2547,12 @@ TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { } TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0))); } TEST_F(WebRtcVoiceEngineTestFake, TestNoLeakingWhenAddRecvStreamFail) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); // Manually delete channel to simulate a failure. int channel = voe_.GetLastChannel(); @@ -2606,7 +2586,7 @@ TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { } TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); channel_->SetSend(true); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); @@ -2618,7 +2598,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { } TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); bool ec_enabled; webrtc::EcModes ec_mode; @@ -2774,7 +2754,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { } TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); bool ec_enabled; webrtc::EcModes ec_mode; @@ -2806,7 +2786,6 @@ TEST_F(WebRtcVoiceEngineTestFake, InitDoesNotOverwriteDefaultAgcConfig) { set_config.digitalCompressionGaindB = 9; set_config.limiterEnable = true; EXPECT_EQ(0, voe_.SetAgcConfig(set_config)); - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); webrtc::AgcConfig config = {0}; EXPECT_EQ(0, voe_.GetAgcConfig(config)); @@ -2817,7 +2796,7 @@ TEST_F(WebRtcVoiceEngineTestFake, InitDoesNotOverwriteDefaultAgcConfig) { } TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); std::unique_ptr channel1( static_cast(engine_.CreateChannel( &call_, cricket::MediaConfig(), cricket::AudioOptions()))); @@ -2918,7 +2897,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { // This test verifies DSCP settings are properly applied on voice media channel. TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::FakeNetworkInterface network_interface; cricket::MediaConfig config; std::unique_ptr channel; @@ -2945,7 +2924,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { } TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelId) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); EXPECT_EQ(-1, media_channel->GetReceiveChannelId(0)); @@ -2961,7 +2940,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelId) { } TEST_F(WebRtcVoiceEngineTestFake, TestGetSendChannelId) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); EXPECT_EQ(-1, media_channel->GetSendChannelId(0)); @@ -2977,7 +2956,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TestGetSendChannelId) { } TEST_F(WebRtcVoiceEngineTestFake, SetOutputVolume) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); EXPECT_FALSE(channel_->SetOutputVolume(kSsrc2, 0.5)); cricket::StreamParams stream; stream.ssrcs.push_back(kSsrc2); @@ -2990,7 +2969,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOutputVolume) { } TEST_F(WebRtcVoiceEngineTestFake, SetOutputVolumeDefaultRecvStream) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); EXPECT_TRUE(channel_->SetOutputVolume(0, 2)); DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); int channel_id = voe_.GetLastChannel(); @@ -3006,7 +2985,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { const uint32_t kAudioSsrc = 123; const std::string kSyncLabel = "AvSyncLabel"; - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); sp.sync_label = kSyncLabel; // Creating two channels to make sure that sync label is set properly for both @@ -3033,7 +3012,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { ssrcs.push_back(223); ssrcs.push_back(224); - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); @@ -3090,7 +3069,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { }; rtc::CopyOnWriteBuffer kRtcpPacket(kRtcp, sizeof(kRtcp)); - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); @@ -3110,7 +3089,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { // All receive channels should be associated with the first send channel, // since they do not send RTCP SR. TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); int default_channel = voe_.GetLastChannel(); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); @@ -3126,7 +3105,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel) { } TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { - EXPECT_TRUE(SetupEngineWithSendStream()); + EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); @@ -3148,7 +3127,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { } TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSink) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); std::unique_ptr fake_sink_1(new FakeAudioSink()); std::unique_ptr fake_sink_2(new FakeAudioSink()); @@ -3168,7 +3147,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSink) { } TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSinkDefaultRecvStream) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); std::unique_ptr fake_sink_1(new FakeAudioSink()); std::unique_ptr fake_sink_2(new FakeAudioSink()); @@ -3196,7 +3175,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSinkDefaultRecvStream) { // Test that, just like the video channel, the voice channel communicates the // network state to the call. TEST_F(WebRtcVoiceEngineTestFake, OnReadyToSendSignalsNetworkState) { - EXPECT_TRUE(SetupEngine()); + EXPECT_TRUE(SetupChannel()); EXPECT_EQ(webrtc::kNetworkUp, call_.GetNetworkState(webrtc::MediaType::AUDIO)); @@ -3218,19 +3197,27 @@ TEST_F(WebRtcVoiceEngineTestFake, OnReadyToSendSignalsNetworkState) { // Tests that the library initializes and shuts down properly. TEST(WebRtcVoiceEngineTest, StartupShutdown) { - cricket::WebRtcVoiceEngine engine; - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + cricket::WebRtcVoiceEngine engine(nullptr); std::unique_ptr call( webrtc::Call::Create(webrtc::Call::Config())); cricket::VoiceMediaChannel* channel = engine.CreateChannel( call.get(), cricket::MediaConfig(), cricket::AudioOptions()); EXPECT_TRUE(channel != nullptr); delete channel; - engine.Terminate(); +} - // Reinit to catch regression where VoiceEngineObserver reference is lost - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); - engine.Terminate(); +// Tests that reference counting on the external ADM is correct. +TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternADM) { + cricket::FakeAudioDeviceModule adm; + { + cricket::WebRtcVoiceEngine engine(&adm); + std::unique_ptr call( + webrtc::Call::Create(webrtc::Call::Config())); + cricket::VoiceMediaChannel* channel = engine.CreateChannel( + call.get(), cricket::MediaConfig(), cricket::AudioOptions()); + EXPECT_TRUE(channel != nullptr); + delete channel; + } } // Tests that the library is configured with the codecs we want. @@ -3288,7 +3275,7 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { cricket::AudioCodec(0, "", 0, 5000, 1, 0), nullptr)); // Verify the payload id of common audio codecs, including CN, ISAC, and G722. - cricket::WebRtcVoiceEngine engine; + cricket::WebRtcVoiceEngine engine(nullptr); for (std::vector::const_iterator it = engine.codecs().begin(); it != engine.codecs().end(); ++it) { if (it->name == "CN" && it->clockrate == 16000) { @@ -3315,13 +3302,11 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { EXPECT_EQ("1", it->params.find("useinbandfec")->second); } } - engine.Terminate(); } // Tests that VoE supports at least 32 channels TEST(WebRtcVoiceEngineTest, Has32Channels) { - cricket::WebRtcVoiceEngine engine; - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + cricket::WebRtcVoiceEngine engine(nullptr); std::unique_ptr call( webrtc::Call::Create(webrtc::Call::Config())); @@ -3341,13 +3326,11 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) { while (num_channels > 0) { delete channels[--num_channels]; } - engine.Terminate(); } // Test that we set our preferred codecs properly. TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { - cricket::WebRtcVoiceEngine engine; - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + cricket::WebRtcVoiceEngine engine(nullptr); std::unique_ptr call( webrtc::Call::Create(webrtc::Call::Config())); cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc index 996a2633f2..f59a3df9c7 100644 --- a/webrtc/pc/channelmanager.cc +++ b/webrtc/pc/channelmanager.cc @@ -174,7 +174,7 @@ bool ChannelManager::Init() { bool ChannelManager::InitMediaEngine_w() { ASSERT(worker_thread_ == rtc::Thread::Current()); - return (media_engine_->Init(worker_thread_)); + return media_engine_->Init(); } void ChannelManager::Terminate() { @@ -200,7 +200,6 @@ void ChannelManager::Terminate_w() { while (!voice_channels_.empty()) { DestroyVoiceChannel_w(voice_channels_.back()); } - media_engine_->Terminate(); } VoiceChannel* ChannelManager::CreateVoiceChannel( diff --git a/webrtc/voice_engine/channel_proxy.h b/webrtc/voice_engine/channel_proxy.h index dec726cb23..344769e1a9 100644 --- a/webrtc/voice_engine/channel_proxy.h +++ b/webrtc/voice_engine/channel_proxy.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_ #define WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_ +#include "webrtc/base/constructormagic.h" #include "webrtc/base/thread_checker.h" #include "webrtc/voice_engine/channel_manager.h" #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" @@ -77,6 +78,8 @@ class ChannelProxy { rtc::ThreadChecker thread_checker_; ChannelOwner channel_owner_; + + RTC_DISALLOW_COPY_AND_ASSIGN(ChannelProxy); }; } // namespace voe } // namespace webrtc diff --git a/webrtc/voice_engine/include/voe_base.h b/webrtc/voice_engine/include/voe_base.h index 3d07fa78ff..4001b94577 100644 --- a/webrtc/voice_engine/include/voe_base.h +++ b/webrtc/voice_engine/include/voe_base.h @@ -132,6 +132,10 @@ class WEBRTC_DLLEXPORT VoEBase { // Returns NULL before Init() is called. virtual AudioProcessing* audio_processing() = 0; + // This method is WIP - DO NOT USE! + // Returns NULL before Init() is called. + virtual AudioDeviceModule* audio_device_module() = 0; + // Terminates all VoiceEngine functions and releases allocated resources. // Returns 0. virtual int Terminate() = 0; diff --git a/webrtc/voice_engine/voe_base_impl.h b/webrtc/voice_engine/voe_base_impl.h index 9fc18ad666..ec18c59786 100644 --- a/webrtc/voice_engine/voe_base_impl.h +++ b/webrtc/voice_engine/voe_base_impl.h @@ -33,6 +33,9 @@ class VoEBaseImpl : public VoEBase, AudioProcessing* audio_processing() override { return shared_->audio_processing(); } + AudioDeviceModule* audio_device_module() override { + return shared_->audio_device(); + } int Terminate() override; int CreateChannel() override;