diff --git a/media/base/fakemediaengine.cc b/media/base/fakemediaengine.cc index b2557a98a7..55e38c6c4f 100644 --- a/media/base/fakemediaengine.cc +++ b/media/base/fakemediaengine.cc @@ -464,7 +464,7 @@ void FakeVoiceEngine::Init() {} rtc::scoped_refptr FakeVoiceEngine::GetAudioState() const { return rtc::scoped_refptr(); } -VoiceMediaChannel* FakeVoiceEngine::CreateChannel( +VoiceMediaChannel* FakeVoiceEngine::CreateMediaChannel( webrtc::Call* call, const MediaConfig& config, const AudioOptions& options, @@ -519,7 +519,7 @@ bool FakeVideoEngine::SetOptions(const VideoOptions& options) { options_ = options; return true; } -VideoMediaChannel* FakeVideoEngine::CreateChannel( +VideoMediaChannel* FakeVideoEngine::CreateMediaChannel( webrtc::Call* call, const MediaConfig& config, const VideoOptions& options, diff --git a/media/base/fakemediaengine.h b/media/base/fakemediaengine.h index 32f6123616..4821ad4395 100644 --- a/media/base/fakemediaengine.h +++ b/media/base/fakemediaengine.h @@ -494,28 +494,29 @@ class FakeDataMediaChannel : public RtpHelper { int max_bps_; }; -class FakeVoiceEngine { +class FakeVoiceEngine : public VoiceEngineInterface { public: FakeVoiceEngine(); - RtpCapabilities GetCapabilities() const; - void Init(); - rtc::scoped_refptr GetAudioState() const; + RtpCapabilities GetCapabilities() const override; + void Init() override; + rtc::scoped_refptr GetAudioState() const override; - VoiceMediaChannel* CreateChannel(webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options); + VoiceMediaChannel* CreateMediaChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options) override; FakeVoiceMediaChannel* GetChannel(size_t index); void UnregisterChannel(VoiceMediaChannel* channel); // TODO(ossu): For proper testing, These should either individually settable // or the voice engine should reference mockable factories. - const std::vector& send_codecs() const; - const std::vector& recv_codecs() const; + const std::vector& send_codecs() const override; + const std::vector& recv_codecs() const override; void SetCodecs(const std::vector& codecs); int GetInputLevel(); - bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes); - void StopAecDump(); + bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override; + void StopAecDump() override; bool StartRtcEventLog(rtc::PlatformFile file, int64_t max_size_bytes); void StopRtcEventLog(); @@ -527,18 +528,19 @@ class FakeVoiceEngine { friend class FakeMediaEngine; }; -class FakeVideoEngine { +class FakeVideoEngine : public VideoEngineInterface { public: FakeVideoEngine(); - RtpCapabilities GetCapabilities() const; + RtpCapabilities GetCapabilities() const override; bool SetOptions(const VideoOptions& options); - VideoMediaChannel* CreateChannel(webrtc::Call* call, - const MediaConfig& config, - const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options); + VideoMediaChannel* CreateMediaChannel( + webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options) override; FakeVideoMediaChannel* GetChannel(size_t index); void UnregisterChannel(VideoMediaChannel* channel); - std::vector codecs() const; + std::vector codecs() const override; void SetCodecs(const std::vector codecs); bool SetCapture(bool capture); diff --git a/media/base/mediaengine.h b/media/base/mediaengine.h index 62f43f9949..eede3af624 100644 --- a/media/base/mediaengine.h +++ b/media/base/mediaengine.h @@ -49,6 +49,58 @@ struct RtpCapabilities { std::vector header_extensions; }; +class VoiceEngineInterface { + public: + VoiceEngineInterface() = default; + virtual ~VoiceEngineInterface() = default; + RTC_DISALLOW_COPY_AND_ASSIGN(VoiceEngineInterface); + + // Initialization + // Starts the engine. + virtual void Init() = 0; + + // TODO(solenberg): Remove once VoE API refactoring is done. + virtual rtc::scoped_refptr GetAudioState() const = 0; + + // MediaChannel creation + // Creates a voice media channel. Returns NULL on failure. + virtual VoiceMediaChannel* CreateMediaChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options) = 0; + + virtual const std::vector& send_codecs() const = 0; + virtual const std::vector& recv_codecs() const = 0; + virtual RtpCapabilities GetCapabilities() const = 0; + + // Starts AEC dump using existing file, a maximum file size in bytes can be + // specified. Logging is stopped just before the size limit is exceeded. + // If max_size_bytes is set to a value <= 0, no limit will be used. + virtual bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) = 0; + + // Stops recording AEC dump. + virtual void StopAecDump() = 0; +}; + +class VideoEngineInterface { + public: + VideoEngineInterface() = default; + virtual ~VideoEngineInterface() = default; + RTC_DISALLOW_COPY_AND_ASSIGN(VideoEngineInterface); + + // Creates a video media channel, paired with the specified voice channel. + // Returns NULL on failure. + virtual VideoMediaChannel* CreateMediaChannel( + webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options) = 0; + + virtual std::vector codecs() const = 0; + virtual RtpCapabilities GetCapabilities() const = 0; +}; + // MediaEngineInterface is an abstraction of a media engine which can be // subclassed to support different media componentry backends. // It supports voice and video operations in the same class to facilitate @@ -119,14 +171,14 @@ class CompositeMediaEngine : public MediaEngineInterface { const MediaConfig& config, const AudioOptions& options, const webrtc::CryptoOptions& crypto_options) { - return voice().CreateChannel(call, config, options, crypto_options); + return voice().CreateMediaChannel(call, config, options, crypto_options); } virtual VideoMediaChannel* CreateVideoChannel( webrtc::Call* call, const MediaConfig& config, const VideoOptions& options, const webrtc::CryptoOptions& crypto_options) { - return video().CreateChannel(call, config, options, crypto_options); + return video().CreateMediaChannel(call, config, options, crypto_options); } virtual const std::vector& audio_send_codecs() { diff --git a/media/engine/nullwebrtcvideoengine.h b/media/engine/nullwebrtcvideoengine.h index ae519b6cea..62326dd4dd 100644 --- a/media/engine/nullwebrtcvideoengine.h +++ b/media/engine/nullwebrtcvideoengine.h @@ -30,17 +30,19 @@ class WebRtcVideoEncoderFactory; // Video engine implementation that does nothing and can be used in // CompositeMediaEngine. -class NullWebRtcVideoEngine { +class NullWebRtcVideoEngine : public VideoEngineInterface { public: - std::vector codecs() const { return std::vector(); } + std::vector codecs() const override { + return std::vector(); + } - RtpCapabilities GetCapabilities() const { return RtpCapabilities(); } + RtpCapabilities GetCapabilities() const override { return RtpCapabilities(); } - VideoMediaChannel* CreateChannel( + VideoMediaChannel* CreateMediaChannel( webrtc::Call* call, const MediaConfig& config, const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options) { + const webrtc::CryptoOptions& crypto_options) override { return nullptr; } }; diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc index 9e54b2b368..e55e0e5ef6 100644 --- a/media/engine/webrtcvideoengine.cc +++ b/media/engine/webrtcvideoengine.cc @@ -464,17 +464,16 @@ WebRtcVideoEngine::~WebRtcVideoEngine() { RTC_LOG(LS_INFO) << "WebRtcVideoEngine::~WebRtcVideoEngine"; } -WebRtcVideoChannel* WebRtcVideoEngine::CreateChannel( +VideoMediaChannel* WebRtcVideoEngine::CreateMediaChannel( webrtc::Call* call, const MediaConfig& config, const VideoOptions& options, const webrtc::CryptoOptions& crypto_options) { - RTC_LOG(LS_INFO) << "CreateChannel. Options: " << options.ToString(); + RTC_LOG(LS_INFO) << "CreateMediaChannel. Options: " << options.ToString(); return new WebRtcVideoChannel(call, config, options, crypto_options, encoder_factory_.get(), decoder_factory_.get(), bitrate_allocator_factory_.get()); } - std::vector WebRtcVideoEngine::codecs() const { return AssignPayloadTypesAndDefaultCodecs(encoder_factory_.get()); } diff --git a/media/engine/webrtcvideoengine.h b/media/engine/webrtcvideoengine.h index 25d9532421..9ecf13f342 100644 --- a/media/engine/webrtcvideoengine.h +++ b/media/engine/webrtcvideoengine.h @@ -79,7 +79,7 @@ class DefaultUnsignalledSsrcHandler : public UnsignalledSsrcHandler { }; // WebRtcVideoEngine is used for the new native WebRTC Video API (webrtc:1667). -class WebRtcVideoEngine { +class WebRtcVideoEngine : public VideoEngineInterface { public: #if defined(USE_BUILTIN_SW_CODECS) // Internal SW video codecs will be added on top of the external codecs. @@ -98,16 +98,16 @@ class WebRtcVideoEngine { std::unique_ptr video_bitrate_allocator_factory); - virtual ~WebRtcVideoEngine(); + ~WebRtcVideoEngine() override; - WebRtcVideoChannel* CreateChannel( + VideoMediaChannel* CreateMediaChannel( webrtc::Call* call, const MediaConfig& config, const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options); + const webrtc::CryptoOptions& crypto_options) override; - std::vector codecs() const; - RtpCapabilities GetCapabilities() const; + std::vector codecs() const override; + RtpCapabilities GetCapabilities() const override; private: const std::unique_ptr decoder_factory_; diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc index 93fcd4f749..cf16214c1b 100644 --- a/media/engine/webrtcvideoengine_unittest.cc +++ b/media/engine/webrtcvideoengine_unittest.cc @@ -457,7 +457,7 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) { TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) { encoder_factory_->AddSupportedVideoCodecType("VP8"); - std::unique_ptr channel(engine_.CreateChannel( + std::unique_ptr channel(engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); @@ -471,7 +471,7 @@ TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) { TEST_F(WebRtcVideoEngineTest, GetStatsWithoutSendCodecsSetDoesNotCrash) { encoder_factory_->AddSupportedVideoCodecType("VP8"); - std::unique_ptr channel(engine_.CreateChannel( + std::unique_ptr channel(engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); VideoMediaInfo info; @@ -681,7 +681,7 @@ cricket::VideoCodec WebRtcVideoEngineTest::GetEngineCodec( VideoMediaChannel* WebRtcVideoEngineTest::SetSendParamsWithAllSupportedCodecs() { - VideoMediaChannel* channel = engine_.CreateChannel( + VideoMediaChannel* channel = engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()); cricket::VideoSendParameters parameters; // We need to look up the codec in the engine to get the correct payload type. @@ -701,7 +701,7 @@ WebRtcVideoEngineTest::SetSendParamsWithAllSupportedCodecs() { VideoMediaChannel* WebRtcVideoEngineTest::SetRecvParamsWithSupportedCodecs( const std::vector& codecs) { - VideoMediaChannel* channel = engine_.CreateChannel( + VideoMediaChannel* channel = engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()); cricket::VideoRecvParameters parameters; parameters.codecs = codecs; @@ -756,7 +756,7 @@ TEST_F(WebRtcVideoEngineTest, ChannelWithH264CanChangeToVp8) { EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capturer.GetSupportedFormats()->front())); - std::unique_ptr channel(engine_.CreateChannel( + std::unique_ptr channel(engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); cricket::VideoSendParameters parameters; parameters.codecs.push_back(GetEngineCodec("H264")); @@ -785,7 +785,7 @@ TEST_F(WebRtcVideoEngineTest, encoder_factory_->AddSupportedVideoCodecType("VP8"); encoder_factory_->AddSupportedVideoCodecType("H264"); - std::unique_ptr channel(engine_.CreateChannel( + std::unique_ptr channel(engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); cricket::VideoSendParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); @@ -820,7 +820,7 @@ TEST_F(WebRtcVideoEngineTest, encoder_factory_->AddSupportedVideoCodecType("VP8"); encoder_factory_->AddSupportedVideoCodecType("H264"); - std::unique_ptr channel(engine_.CreateChannel( + std::unique_ptr channel(engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); cricket::VideoSendParameters parameters; parameters.codecs.push_back(GetEngineCodec("H264")); @@ -852,7 +852,7 @@ TEST_F(WebRtcVideoEngineTest, SimulcastEnabledForH264BehindFieldTrial) { "WebRTC-H264Simulcast/Enabled/"); encoder_factory_->AddSupportedVideoCodecType("H264"); - std::unique_ptr channel(engine_.CreateChannel( + std::unique_ptr channel(engine_.CreateMediaChannel( call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); cricket::VideoSendParameters parameters; parameters.codecs.push_back(GetEngineCodec("H264")); @@ -1124,7 +1124,7 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { // Create send channel. const int send_ssrc = 123; - std::unique_ptr send_channel(engine.CreateChannel( + std::unique_ptr send_channel(engine.CreateMediaChannel( call.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); cricket::VideoSendParameters send_parameters; send_parameters.codecs.push_back(engine_codecs.at(0)); @@ -1145,7 +1145,7 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { // Create recv channel. const int recv_ssrc = 321; - std::unique_ptr recv_channel(engine.CreateChannel( + std::unique_ptr recv_channel(engine.CreateMediaChannel( call.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); cricket::VideoRecvParameters recv_parameters; recv_parameters.codecs.push_back(engine_codecs.at(0)); @@ -1191,7 +1191,7 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, NullDecoder) { // Create recv channel. const int recv_ssrc = 321; - std::unique_ptr recv_channel(engine.CreateChannel( + std::unique_ptr recv_channel(engine.CreateMediaChannel( call.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions())); cricket::VideoRecvParameters recv_parameters; recv_parameters.codecs.push_back(engine.codecs().front()); @@ -1281,9 +1281,10 @@ class WebRtcVideoChannelBaseTest : public testing::Test { // needs to be disabled, otherwise, tests which check the size of received // frames become flaky. media_config.video.enable_cpu_adaptation = false; - channel_.reset(engine_.CreateChannel(call_.get(), media_config, - cricket::VideoOptions(), - webrtc::CryptoOptions())); + channel_.reset( + static_cast(engine_.CreateMediaChannel( + call_.get(), media_config, cricket::VideoOptions(), + webrtc::CryptoOptions()))); channel_->OnReadyToSend(true); EXPECT_TRUE(channel_.get() != NULL); network_interface_.SetDestination(channel_.get()); @@ -2039,9 +2040,9 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest { #endif fake_call_.reset(new FakeCall()); - channel_.reset(engine_.CreateChannel(fake_call_.get(), GetMediaConfig(), - VideoOptions(), - webrtc::CryptoOptions())); + channel_.reset(engine_.CreateMediaChannel(fake_call_.get(), + GetMediaConfig(), VideoOptions(), + webrtc::CryptoOptions())); channel_->OnReadyToSend(true); last_ssrc_ = 123; send_parameters_.codecs = engine_.codecs(); @@ -2884,7 +2885,7 @@ TEST_F(WebRtcVideoChannelTest, SetMediaConfigSuspendBelowMinBitrate) { MediaConfig media_config = GetMediaConfig(); media_config.video.suspend_below_min_bitrate = true; - channel_.reset(engine_.CreateChannel( + channel_.reset(engine_.CreateMediaChannel( fake_call_.get(), media_config, VideoOptions(), webrtc::CryptoOptions())); channel_->OnReadyToSend(true); @@ -2894,7 +2895,7 @@ TEST_F(WebRtcVideoChannelTest, SetMediaConfigSuspendBelowMinBitrate) { EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); media_config.video.suspend_below_min_bitrate = false; - channel_.reset(engine_.CreateChannel( + channel_.reset(engine_.CreateMediaChannel( fake_call_.get(), media_config, VideoOptions(), webrtc::CryptoOptions())); channel_->OnReadyToSend(true); @@ -3235,7 +3236,7 @@ TEST_F(WebRtcVideoChannelTest, AdaptsOnOveruseAndChangeResolution) { parameters.codecs.push_back(codec); MediaConfig media_config = GetMediaConfig(); - channel_.reset(engine_.CreateChannel( + channel_.reset(engine_.CreateMediaChannel( fake_call_.get(), media_config, VideoOptions(), webrtc::CryptoOptions())); channel_->OnReadyToSend(true); ASSERT_TRUE(channel_->SetSendParameters(parameters)); @@ -3316,7 +3317,7 @@ TEST_F(WebRtcVideoChannelTest, PreviousAdaptationDoesNotApplyToScreenshare) { MediaConfig media_config = GetMediaConfig(); media_config.video.enable_cpu_adaptation = true; - channel_.reset(engine_.CreateChannel( + channel_.reset(engine_.CreateMediaChannel( fake_call_.get(), media_config, VideoOptions(), webrtc::CryptoOptions())); channel_->OnReadyToSend(true); ASSERT_TRUE(channel_->SetSendParameters(parameters)); @@ -3390,7 +3391,7 @@ void WebRtcVideoChannelTest::TestDegradationPreference( MediaConfig media_config = GetMediaConfig(); media_config.video.enable_cpu_adaptation = true; - channel_.reset(engine_.CreateChannel( + channel_.reset(engine_.CreateMediaChannel( fake_call_.get(), media_config, VideoOptions(), webrtc::CryptoOptions())); channel_->OnReadyToSend(true); @@ -3425,7 +3426,7 @@ void WebRtcVideoChannelTest::TestCpuAdaptation(bool enable_overuse, if (enable_overuse) { media_config.video.enable_cpu_adaptation = true; } - channel_.reset(engine_.CreateChannel( + channel_.reset(engine_.CreateMediaChannel( fake_call_.get(), media_config, VideoOptions(), webrtc::CryptoOptions())); channel_->OnReadyToSend(true); @@ -4608,8 +4609,9 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) { std::unique_ptr channel; webrtc::RtpParameters parameters; - channel.reset(static_cast(engine_.CreateChannel( - call_.get(), config, VideoOptions(), webrtc::CryptoOptions()))); + channel.reset( + static_cast(engine_.CreateMediaChannel( + call_.get(), config, VideoOptions(), webrtc::CryptoOptions()))); channel->SetInterface(network_interface.get(), /*media_transport=*/nullptr); // Default value when DSCP is disabled should be DSCP_DEFAULT. EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); @@ -4617,8 +4619,9 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) { // Default value when DSCP is enabled is also DSCP_DEFAULT, until it is set // through rtp parameters. config.enable_dscp = true; - channel.reset(static_cast(engine_.CreateChannel( - call_.get(), config, VideoOptions(), webrtc::CryptoOptions()))); + channel.reset( + static_cast(engine_.CreateMediaChannel( + call_.get(), config, VideoOptions(), webrtc::CryptoOptions()))); channel->SetInterface(network_interface.get(), /*media_transport=*/nullptr); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); @@ -4649,8 +4652,9 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) { // Verify that setting the option to false resets the // DiffServCodePoint. config.enable_dscp = false; - channel.reset(static_cast(engine_.CreateChannel( - call_.get(), config, VideoOptions(), webrtc::CryptoOptions()))); + channel.reset( + static_cast(engine_.CreateMediaChannel( + call_.get(), config, VideoOptions(), webrtc::CryptoOptions()))); channel->SetInterface(network_interface.get(), /*media_transport=*/nullptr); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); } @@ -6791,9 +6795,9 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test { void SetUp() override { encoder_factory_->AddSupportedVideoCodecType("VP8"); - channel_.reset(engine_.CreateChannel(&fake_call_, GetMediaConfig(), - VideoOptions(), - webrtc::CryptoOptions())); + channel_.reset(engine_.CreateMediaChannel(&fake_call_, GetMediaConfig(), + VideoOptions(), + webrtc::CryptoOptions())); channel_->OnReadyToSend(true); last_ssrc_ = 123; } diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc index 5c96668a4d..9ec7a0c014 100644 --- a/media/engine/webrtcvoiceengine.cc +++ b/media/engine/webrtcvoiceengine.cc @@ -298,7 +298,7 @@ rtc::scoped_refptr WebRtcVoiceEngine::GetAudioState() return audio_state_; } -VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel( +VoiceMediaChannel* WebRtcVoiceEngine::CreateMediaChannel( webrtc::Call* call, const MediaConfig& config, const AudioOptions& options, diff --git a/media/engine/webrtcvoiceengine.h b/media/engine/webrtcvoiceengine.h index 7a5343e55d..3ea5082300 100644 --- a/media/engine/webrtcvoiceengine.h +++ b/media/engine/webrtcvoiceengine.h @@ -40,7 +40,7 @@ class WebRtcVoiceMediaChannel; // WebRtcVoiceEngine is a class to be used with CompositeMediaEngine. // It uses the WebRtc VoiceEngine library for audio handling. -class WebRtcVoiceEngine final { +class WebRtcVoiceEngine final : public VoiceEngineInterface { friend class WebRtcVoiceMediaChannel; public: @@ -50,20 +50,21 @@ class WebRtcVoiceEngine final { const rtc::scoped_refptr& decoder_factory, rtc::scoped_refptr audio_mixer, rtc::scoped_refptr audio_processing); - ~WebRtcVoiceEngine(); + ~WebRtcVoiceEngine() override; // Does initialization that needs to occur on the worker thread. - void Init(); + void Init() override; - rtc::scoped_refptr GetAudioState() const; - VoiceMediaChannel* CreateChannel(webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options); + rtc::scoped_refptr GetAudioState() const override; + VoiceMediaChannel* CreateMediaChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options) override; - const std::vector& send_codecs() const; - const std::vector& recv_codecs() const; - RtpCapabilities GetCapabilities() const; + const std::vector& send_codecs() const override; + const std::vector& recv_codecs() const override; + RtpCapabilities GetCapabilities() const override; // For tracking WebRtc channels. Needed because we have to pause them // all when switching devices. @@ -75,10 +76,10 @@ class WebRtcVoiceEngine final { // 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 // used. - bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes); + bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override; // Stops AEC dump. - void StopAecDump(); + void StopAecDump() override; const webrtc::AudioProcessing::Config GetApmConfigForTest() const { return apm()->GetConfig(); diff --git a/media/engine/webrtcvoiceengine_unittest.cc b/media/engine/webrtcvoiceengine_unittest.cc index e24f18524a..76f05202b9 100644 --- a/media/engine/webrtcvoiceengine_unittest.cc +++ b/media/engine/webrtcvoiceengine_unittest.cc @@ -211,9 +211,9 @@ class WebRtcVoiceEngineTestFake : public testing::Test { bool SetupChannel() { EXPECT_CALL(*apm_, SetExtraOptions(testing::_)); - channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), - cricket::AudioOptions(), - webrtc::CryptoOptions()); + channel_ = engine_->CreateMediaChannel(&call_, cricket::MediaConfig(), + cricket::AudioOptions(), + webrtc::CryptoOptions()); return (channel_ != nullptr); } @@ -761,7 +761,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { }; // Tests that we can create and destroy a channel. -TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) { +TEST_F(WebRtcVoiceEngineTestFake, CreateMediaChannel) { EXPECT_TRUE(SetupChannel()); } @@ -2976,13 +2976,15 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(10); std::unique_ptr channel1( - static_cast(engine_->CreateChannel( - &call_, cricket::MediaConfig(), cricket::AudioOptions(), - webrtc::CryptoOptions()))); + static_cast( + engine_->CreateMediaChannel(&call_, cricket::MediaConfig(), + cricket::AudioOptions(), + webrtc::CryptoOptions()))); std::unique_ptr channel2( - static_cast(engine_->CreateChannel( - &call_, cricket::MediaConfig(), cricket::AudioOptions(), - webrtc::CryptoOptions()))); + static_cast( + engine_->CreateMediaChannel(&call_, cricket::MediaConfig(), + cricket::AudioOptions(), + webrtc::CryptoOptions()))); // Have to add a stream to make SetSend work. cricket::StreamParams stream1; @@ -3090,17 +3092,17 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { .WillRepeatedly(SaveArg<0>(&apm_config)); EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(3); - channel.reset( - static_cast(engine_->CreateChannel( - &call_, config, cricket::AudioOptions(), webrtc::CryptoOptions()))); + channel.reset(static_cast( + engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(), + webrtc::CryptoOptions()))); channel->SetInterface(&network_interface, /*media_transport=*/nullptr); // Default value when DSCP is disabled should be DSCP_DEFAULT. EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); config.enable_dscp = true; - channel.reset( - static_cast(engine_->CreateChannel( - &call_, config, cricket::AudioOptions(), webrtc::CryptoOptions()))); + channel.reset(static_cast( + engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(), + webrtc::CryptoOptions()))); channel->SetInterface(&network_interface, /*media_transport=*/nullptr); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); @@ -3131,9 +3133,9 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { // Verify that setting the option to false resets the // DiffServCodePoint. config.enable_dscp = false; - channel.reset( - static_cast(engine_->CreateChannel( - &call_, config, cricket::AudioOptions(), webrtc::CryptoOptions()))); + channel.reset(static_cast( + engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(), + webrtc::CryptoOptions()))); channel->SetInterface(&network_interface, /*media_transport=*/nullptr); // Default value when DSCP is disabled should be DSCP_DEFAULT. EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); @@ -3461,9 +3463,9 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) { webrtc::RtcEventLogNullImpl event_log; std::unique_ptr call( webrtc::Call::Create(webrtc::Call::Config(&event_log))); - cricket::VoiceMediaChannel* channel = - engine.CreateChannel(call.get(), cricket::MediaConfig(), - cricket::AudioOptions(), webrtc::CryptoOptions()); + cricket::VoiceMediaChannel* channel = engine.CreateMediaChannel( + call.get(), cricket::MediaConfig(), cricket::AudioOptions(), + webrtc::CryptoOptions()); EXPECT_TRUE(channel != nullptr); delete channel; } @@ -3485,9 +3487,9 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { webrtc::RtcEventLogNullImpl event_log; std::unique_ptr call( webrtc::Call::Create(webrtc::Call::Config(&event_log))); - cricket::VoiceMediaChannel* channel = - engine.CreateChannel(call.get(), cricket::MediaConfig(), - cricket::AudioOptions(), webrtc::CryptoOptions()); + cricket::VoiceMediaChannel* channel = engine.CreateMediaChannel( + call.get(), cricket::MediaConfig(), cricket::AudioOptions(), + webrtc::CryptoOptions()); EXPECT_TRUE(channel != nullptr); delete channel; } @@ -3556,9 +3558,9 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) { cricket::VoiceMediaChannel* channels[32]; size_t num_channels = 0; while (num_channels < arraysize(channels)) { - cricket::VoiceMediaChannel* channel = - engine.CreateChannel(call.get(), cricket::MediaConfig(), - cricket::AudioOptions(), webrtc::CryptoOptions()); + cricket::VoiceMediaChannel* channel = engine.CreateMediaChannel( + call.get(), cricket::MediaConfig(), cricket::AudioOptions(), + webrtc::CryptoOptions()); if (!channel) break; channels[num_channels++] = channel;