Adds interfaces for audio and video engines.
This makes the currently implicit interfaces explicit and
prepares for making CompositeMediaEngine non-templated.
Bug: webrtc:9883
Change-Id: I57452acc9ada60a801f6d624894440a942c12ded
Reviewed-on: https://webrtc-review.googlesource.com/c/106940
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25667}
diff --git a/media/base/fakemediaengine.cc b/media/base/fakemediaengine.cc
index b2557a9..55e38c6 100644
--- a/media/base/fakemediaengine.cc
+++ b/media/base/fakemediaengine.cc
@@ -464,7 +464,7 @@
rtc::scoped_refptr<webrtc::AudioState> FakeVoiceEngine::GetAudioState() const {
return rtc::scoped_refptr<webrtc::AudioState>();
}
-VoiceMediaChannel* FakeVoiceEngine::CreateChannel(
+VoiceMediaChannel* FakeVoiceEngine::CreateMediaChannel(
webrtc::Call* call,
const MediaConfig& config,
const AudioOptions& options,
@@ -519,7 +519,7 @@
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 32f6123..4821ad4 100644
--- a/media/base/fakemediaengine.h
+++ b/media/base/fakemediaengine.h
@@ -494,28 +494,29 @@
int max_bps_;
};
-class FakeVoiceEngine {
+class FakeVoiceEngine : public VoiceEngineInterface {
public:
FakeVoiceEngine();
- RtpCapabilities GetCapabilities() const;
- void Init();
- rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const;
+ RtpCapabilities GetCapabilities() const override;
+ void Init() override;
+ rtc::scoped_refptr<webrtc::AudioState> 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<AudioCodec>& send_codecs() const;
- const std::vector<AudioCodec>& recv_codecs() const;
+ const std::vector<AudioCodec>& send_codecs() const override;
+ const std::vector<AudioCodec>& recv_codecs() const override;
void SetCodecs(const std::vector<AudioCodec>& 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 @@
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<VideoCodec> codecs() const;
+ std::vector<VideoCodec> codecs() const override;
void SetCodecs(const std::vector<VideoCodec> codecs);
bool SetCapture(bool capture);
diff --git a/media/base/mediaengine.h b/media/base/mediaengine.h
index 62f43f9..eede3af 100644
--- a/media/base/mediaengine.h
+++ b/media/base/mediaengine.h
@@ -49,6 +49,58 @@
std::vector<webrtc::RtpExtension> 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<webrtc::AudioState> 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<AudioCodec>& send_codecs() const = 0;
+ virtual const std::vector<AudioCodec>& 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<VideoCodec> 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 @@
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<AudioCodec>& audio_send_codecs() {
diff --git a/media/engine/nullwebrtcvideoengine.h b/media/engine/nullwebrtcvideoengine.h
index ae519b6..62326dd 100644
--- a/media/engine/nullwebrtcvideoengine.h
+++ b/media/engine/nullwebrtcvideoengine.h
@@ -30,17 +30,19 @@
// Video engine implementation that does nothing and can be used in
// CompositeMediaEngine.
-class NullWebRtcVideoEngine {
+class NullWebRtcVideoEngine : public VideoEngineInterface {
public:
- std::vector<VideoCodec> codecs() const { return std::vector<VideoCodec>(); }
+ std::vector<VideoCodec> codecs() const override {
+ return std::vector<VideoCodec>();
+ }
- 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 9e54b2b..e55e0e5 100644
--- a/media/engine/webrtcvideoengine.cc
+++ b/media/engine/webrtcvideoengine.cc
@@ -464,17 +464,16 @@
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<VideoCodec> WebRtcVideoEngine::codecs() const {
return AssignPayloadTypesAndDefaultCodecs(encoder_factory_.get());
}
diff --git a/media/engine/webrtcvideoengine.h b/media/engine/webrtcvideoengine.h
index 25d9532..9ecf13f 100644
--- a/media/engine/webrtcvideoengine.h
+++ b/media/engine/webrtcvideoengine.h
@@ -79,7 +79,7 @@
};
// 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 @@
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
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<VideoCodec> codecs() const;
- RtpCapabilities GetCapabilities() const;
+ std::vector<VideoCodec> codecs() const override;
+ RtpCapabilities GetCapabilities() const override;
private:
const std::unique_ptr<webrtc::VideoDecoderFactory> decoder_factory_;
diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc
index 93fcd4f..cf16214 100644
--- a/media/engine/webrtcvideoengine_unittest.cc
+++ b/media/engine/webrtcvideoengine_unittest.cc
@@ -457,7 +457,7 @@
TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) {
encoder_factory_->AddSupportedVideoCodecType("VP8");
- std::unique_ptr<VideoMediaChannel> channel(engine_.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> channel(engine_.CreateMediaChannel(
call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()));
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
@@ -471,7 +471,7 @@
TEST_F(WebRtcVideoEngineTest, GetStatsWithoutSendCodecsSetDoesNotCrash) {
encoder_factory_->AddSupportedVideoCodecType("VP8");
- std::unique_ptr<VideoMediaChannel> channel(engine_.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> channel(engine_.CreateMediaChannel(
call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()));
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
VideoMediaInfo info;
@@ -681,7 +681,7 @@
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 @@
VideoMediaChannel* WebRtcVideoEngineTest::SetRecvParamsWithSupportedCodecs(
const std::vector<VideoCodec>& 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 @@
EXPECT_EQ(cricket::CS_RUNNING,
capturer.Start(capturer.GetSupportedFormats()->front()));
- std::unique_ptr<VideoMediaChannel> channel(engine_.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> channel(engine_.CreateMediaChannel(
call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()));
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(GetEngineCodec("H264"));
@@ -785,7 +785,7 @@
encoder_factory_->AddSupportedVideoCodecType("VP8");
encoder_factory_->AddSupportedVideoCodecType("H264");
- std::unique_ptr<VideoMediaChannel> channel(engine_.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> channel(engine_.CreateMediaChannel(
call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()));
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(GetEngineCodec("VP8"));
@@ -820,7 +820,7 @@
encoder_factory_->AddSupportedVideoCodecType("VP8");
encoder_factory_->AddSupportedVideoCodecType("H264");
- std::unique_ptr<VideoMediaChannel> channel(engine_.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> channel(engine_.CreateMediaChannel(
call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()));
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(GetEngineCodec("H264"));
@@ -852,7 +852,7 @@
"WebRTC-H264Simulcast/Enabled/");
encoder_factory_->AddSupportedVideoCodecType("H264");
- std::unique_ptr<VideoMediaChannel> channel(engine_.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> channel(engine_.CreateMediaChannel(
call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions()));
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(GetEngineCodec("H264"));
@@ -1124,7 +1124,7 @@
// Create send channel.
const int send_ssrc = 123;
- std::unique_ptr<VideoMediaChannel> send_channel(engine.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> 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 @@
// Create recv channel.
const int recv_ssrc = 321;
- std::unique_ptr<VideoMediaChannel> recv_channel(engine.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> 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 @@
// Create recv channel.
const int recv_ssrc = 321;
- std::unique_ptr<VideoMediaChannel> recv_channel(engine.CreateChannel(
+ std::unique_ptr<VideoMediaChannel> 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 @@
// 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<cricket::WebRtcVideoChannel*>(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 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
std::unique_ptr<cricket::WebRtcVideoChannel> channel;
webrtc::RtpParameters parameters;
- channel.reset(static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateChannel(
- call_.get(), config, VideoOptions(), webrtc::CryptoOptions())));
+ channel.reset(
+ static_cast<cricket::WebRtcVideoChannel*>(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 @@
// 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<cricket::WebRtcVideoChannel*>(engine_.CreateChannel(
- call_.get(), config, VideoOptions(), webrtc::CryptoOptions())));
+ channel.reset(
+ static_cast<cricket::WebRtcVideoChannel*>(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 @@
// Verify that setting the option to false resets the
// DiffServCodePoint.
config.enable_dscp = false;
- channel.reset(static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateChannel(
- call_.get(), config, VideoOptions(), webrtc::CryptoOptions())));
+ channel.reset(
+ static_cast<cricket::WebRtcVideoChannel*>(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 @@
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 5c96668..9ec7a0c 100644
--- a/media/engine/webrtcvoiceengine.cc
+++ b/media/engine/webrtcvoiceengine.cc
@@ -298,7 +298,7 @@
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 7a5343e..3ea5082 100644
--- a/media/engine/webrtcvoiceengine.h
+++ b/media/engine/webrtcvoiceengine.h
@@ -40,7 +40,7 @@
// 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 @@
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory,
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing);
- ~WebRtcVoiceEngine();
+ ~WebRtcVoiceEngine() override;
// Does initialization that needs to occur on the worker thread.
- void Init();
+ void Init() override;
- rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const;
- VoiceMediaChannel* CreateChannel(webrtc::Call* call,
- const MediaConfig& config,
- const AudioOptions& options,
- const webrtc::CryptoOptions& crypto_options);
+ rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const override;
+ VoiceMediaChannel* CreateMediaChannel(
+ webrtc::Call* call,
+ const MediaConfig& config,
+ const AudioOptions& options,
+ const webrtc::CryptoOptions& crypto_options) override;
- const std::vector<AudioCodec>& send_codecs() const;
- const std::vector<AudioCodec>& recv_codecs() const;
- RtpCapabilities GetCapabilities() const;
+ const std::vector<AudioCodec>& send_codecs() const override;
+ const std::vector<AudioCodec>& 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 @@
// 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 e24f185..76f0520 100644
--- a/media/engine/webrtcvoiceengine_unittest.cc
+++ b/media/engine/webrtcvoiceengine_unittest.cc
@@ -211,9 +211,9 @@
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 @@
};
// Tests that we can create and destroy a channel.
-TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) {
+TEST_F(WebRtcVoiceEngineTestFake, CreateMediaChannel) {
EXPECT_TRUE(SetupChannel());
}
@@ -2976,13 +2976,15 @@
EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(10);
std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel1(
- static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
- &call_, cricket::MediaConfig(), cricket::AudioOptions(),
- webrtc::CryptoOptions())));
+ static_cast<cricket::WebRtcVoiceMediaChannel*>(
+ engine_->CreateMediaChannel(&call_, cricket::MediaConfig(),
+ cricket::AudioOptions(),
+ webrtc::CryptoOptions())));
std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel2(
- static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
- &call_, cricket::MediaConfig(), cricket::AudioOptions(),
- webrtc::CryptoOptions())));
+ static_cast<cricket::WebRtcVoiceMediaChannel*>(
+ 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 @@
.WillRepeatedly(SaveArg<0>(&apm_config));
EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(3);
- channel.reset(
- static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
- &call_, config, cricket::AudioOptions(), webrtc::CryptoOptions())));
+ channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>(
+ 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<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
- &call_, config, cricket::AudioOptions(), webrtc::CryptoOptions())));
+ channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>(
+ 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 @@
// Verify that setting the option to false resets the
// DiffServCodePoint.
config.enable_dscp = false;
- channel.reset(
- static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
- &call_, config, cricket::AudioOptions(), webrtc::CryptoOptions())));
+ channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>(
+ 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 @@
webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> 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 @@
webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> 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 @@
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;