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}
This commit is contained in:
Sebastian Jansson 2018-11-16 10:40:36 +01:00 committed by Commit Bot
parent 2681523793
commit 84848f26b5
10 changed files with 173 additions and 111 deletions

View File

@ -464,7 +464,7 @@ void FakeVoiceEngine::Init() {}
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 @@ 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,

View File

@ -494,28 +494,29 @@ class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
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 @@ 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<VideoCodec> codecs() const;
std::vector<VideoCodec> codecs() const override;
void SetCodecs(const std::vector<VideoCodec> codecs);
bool SetCapture(bool capture);

View File

@ -49,6 +49,58 @@ struct RtpCapabilities {
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 @@ 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<AudioCodec>& audio_send_codecs() {

View File

@ -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<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;
}
};

View File

@ -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<VideoCodec> WebRtcVideoEngine::codecs() const {
return AssignPayloadTypesAndDefaultCodecs(encoder_factory_.get());
}

View File

@ -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<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_;

View File

@ -457,7 +457,7 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) {
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, SetSendFailsBeforeSettingCodecs) {
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 @@ 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<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 @@ TEST_F(WebRtcVideoEngineTest, ChannelWithH264CanChangeToVp8) {
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 @@ TEST_F(WebRtcVideoEngineTest,
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 @@ TEST_F(WebRtcVideoEngineTest,
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 @@ TEST_F(WebRtcVideoEngineTest, SimulcastEnabledForH264BehindFieldTrial) {
"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 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
// 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 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
// 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 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, NullDecoder) {
// 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 @@ 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<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 @@ 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<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 @@ 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<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 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) {
// 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 @@ 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;
}

View File

@ -298,7 +298,7 @@ rtc::scoped_refptr<webrtc::AudioState> WebRtcVoiceEngine::GetAudioState()
return audio_state_;
}
VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel(
VoiceMediaChannel* WebRtcVoiceEngine::CreateMediaChannel(
webrtc::Call* call,
const MediaConfig& config,
const AudioOptions& options,

View File

@ -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<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 @@ 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();

View File

@ -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<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 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
.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 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
// 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 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) {
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 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) {
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 @@ 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;