Exposing audio and video engines directly.

The audio and video engine is exposed directly rather via redundant
wrapping functions. This reduces the amount of boiler plate code.

Bug: webrtc:9883
Change-Id: I203a945ee6079397e24a378966a569cd5626ac4a
Reviewed-on: https://webrtc-review.googlesource.com/c/106683
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25673}
This commit is contained in:
Sebastian Jansson
2018-11-16 11:29:55 +01:00
committed by Commit Bot
parent eee39206a2
commit 6eb8a16dbf
6 changed files with 25 additions and 125 deletions

View File

@ -119,56 +119,6 @@ bool CompositeMediaEngine::Init() {
return true; return true;
} }
rtc::scoped_refptr<webrtc::AudioState> CompositeMediaEngine::GetAudioState()
const {
return voice().GetAudioState();
}
VoiceMediaChannel* CompositeMediaEngine::CreateChannel(
webrtc::Call* call,
const MediaConfig& config,
const AudioOptions& options,
const webrtc::CryptoOptions& crypto_options) {
return voice().CreateMediaChannel(call, config, options, crypto_options);
}
VideoMediaChannel* CompositeMediaEngine::CreateVideoChannel(
webrtc::Call* call,
const MediaConfig& config,
const VideoOptions& options,
const webrtc::CryptoOptions& crypto_options) {
return video().CreateMediaChannel(call, config, options, crypto_options);
}
const std::vector<AudioCodec>& CompositeMediaEngine::audio_send_codecs() {
return voice().send_codecs();
}
const std::vector<AudioCodec>& CompositeMediaEngine::audio_recv_codecs() {
return voice().recv_codecs();
}
RtpCapabilities CompositeMediaEngine::GetAudioCapabilities() {
return voice().GetCapabilities();
}
std::vector<VideoCodec> CompositeMediaEngine::video_codecs() {
return video().codecs();
}
RtpCapabilities CompositeMediaEngine::GetVideoCapabilities() {
return video().GetCapabilities();
}
bool CompositeMediaEngine::StartAecDump(rtc::PlatformFile file,
int64_t max_size_bytes) {
return voice().StartAecDump(file, max_size_bytes);
}
void CompositeMediaEngine::StopAecDump() {
voice().StopAecDump();
}
VoiceEngineInterface& CompositeMediaEngine::voice() { VoiceEngineInterface& CompositeMediaEngine::voice() {
return *voice_engine_.get(); return *voice_engine_.get();
} }

View File

@ -111,37 +111,10 @@ class MediaEngineInterface {
// Initialization // Initialization
// Starts the engine. // Starts the engine.
virtual bool Init() = 0; virtual bool Init() = 0;
// TODO(solenberg): Remove once VoE API refactoring is done. virtual VoiceEngineInterface& voice() = 0;
virtual rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const = 0; virtual VideoEngineInterface& video() = 0;
virtual const VoiceEngineInterface& voice() const = 0;
// MediaChannel creation virtual const VideoEngineInterface& video() const = 0;
// Creates a voice media channel. Returns NULL on failure.
virtual VoiceMediaChannel* CreateChannel(
webrtc::Call* call,
const MediaConfig& config,
const AudioOptions& options,
const webrtc::CryptoOptions& crypto_options) = 0;
// Creates a video media channel, paired with the specified voice channel.
// Returns NULL on failure.
virtual VideoMediaChannel* CreateVideoChannel(
webrtc::Call* call,
const MediaConfig& config,
const VideoOptions& options,
const webrtc::CryptoOptions& crypto_options) = 0;
virtual const std::vector<AudioCodec>& audio_send_codecs() = 0;
virtual const std::vector<AudioCodec>& audio_recv_codecs() = 0;
virtual RtpCapabilities GetAudioCapabilities() = 0;
virtual std::vector<VideoCodec> video_codecs() = 0;
virtual RtpCapabilities GetVideoCapabilities() = 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;
}; };
// CompositeMediaEngine constructs a MediaEngine from separate // CompositeMediaEngine constructs a MediaEngine from separate
@ -153,34 +126,10 @@ class CompositeMediaEngine : public MediaEngineInterface {
~CompositeMediaEngine() override; ~CompositeMediaEngine() override;
bool Init() override; bool Init() override;
rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const override; VoiceEngineInterface& voice() override;
VoiceMediaChannel* CreateChannel( VideoEngineInterface& video() override;
webrtc::Call* call, const VoiceEngineInterface& voice() const override;
const MediaConfig& config, const VideoEngineInterface& video() const override;
const AudioOptions& options,
const webrtc::CryptoOptions& crypto_options) override;
VideoMediaChannel* CreateVideoChannel(
webrtc::Call* call,
const MediaConfig& config,
const VideoOptions& options,
const webrtc::CryptoOptions& crypto_options) override;
const std::vector<AudioCodec>& audio_send_codecs() override;
const std::vector<AudioCodec>& audio_recv_codecs() override;
RtpCapabilities GetAudioCapabilities() override;
std::vector<VideoCodec> video_codecs() override;
RtpCapabilities GetVideoCapabilities() override;
bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override;
void StopAecDump() override;
protected:
VoiceEngineInterface& voice();
VideoEngineInterface& video();
const VoiceEngineInterface& voice() const;
const VideoEngineInterface& video() const;
private: private:
std::unique_ptr<VoiceEngineInterface> voice_engine_; std::unique_ptr<VoiceEngineInterface> voice_engine_;

View File

@ -66,7 +66,7 @@ void ChannelManager::GetSupportedAudioSendCodecs(
if (!media_engine_) { if (!media_engine_) {
return; return;
} }
*codecs = media_engine_->audio_send_codecs(); *codecs = media_engine_->voice().send_codecs();
} }
void ChannelManager::GetSupportedAudioReceiveCodecs( void ChannelManager::GetSupportedAudioReceiveCodecs(
@ -74,7 +74,7 @@ void ChannelManager::GetSupportedAudioReceiveCodecs(
if (!media_engine_) { if (!media_engine_) {
return; return;
} }
*codecs = media_engine_->audio_recv_codecs(); *codecs = media_engine_->voice().recv_codecs();
} }
void ChannelManager::GetSupportedAudioRtpHeaderExtensions( void ChannelManager::GetSupportedAudioRtpHeaderExtensions(
@ -82,7 +82,7 @@ void ChannelManager::GetSupportedAudioRtpHeaderExtensions(
if (!media_engine_) { if (!media_engine_) {
return; return;
} }
*ext = media_engine_->GetAudioCapabilities().header_extensions; *ext = media_engine_->voice().GetCapabilities().header_extensions;
} }
void ChannelManager::GetSupportedVideoCodecs( void ChannelManager::GetSupportedVideoCodecs(
@ -92,7 +92,7 @@ void ChannelManager::GetSupportedVideoCodecs(
} }
codecs->clear(); codecs->clear();
std::vector<VideoCodec> video_codecs = media_engine_->video_codecs(); std::vector<VideoCodec> video_codecs = media_engine_->video().codecs();
for (const auto& video_codec : video_codecs) { for (const auto& video_codec : video_codecs) {
if (!enable_rtx_ && if (!enable_rtx_ &&
absl::EqualsIgnoreCase(kRtxCodecName, video_codec.name)) { absl::EqualsIgnoreCase(kRtxCodecName, video_codec.name)) {
@ -107,7 +107,7 @@ void ChannelManager::GetSupportedVideoRtpHeaderExtensions(
if (!media_engine_) { if (!media_engine_) {
return; return;
} }
*ext = media_engine_->GetVideoCapabilities().header_extensions; *ext = media_engine_->video().GetCapabilities().header_extensions;
} }
void ChannelManager::GetSupportedDataCodecs( void ChannelManager::GetSupportedDataCodecs(
@ -177,8 +177,8 @@ VoiceChannel* ChannelManager::CreateVoiceChannel(
return nullptr; return nullptr;
} }
VoiceMediaChannel* media_channel = VoiceMediaChannel* media_channel = media_engine_->voice().CreateMediaChannel(
media_engine_->CreateChannel(call, media_config, options, crypto_options); call, media_config, options, crypto_options);
if (!media_channel) { if (!media_channel) {
return nullptr; return nullptr;
} }
@ -244,7 +244,7 @@ VideoChannel* ChannelManager::CreateVideoChannel(
return nullptr; return nullptr;
} }
VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel( VideoMediaChannel* media_channel = media_engine_->video().CreateMediaChannel(
call, media_config, options, crypto_options); call, media_config, options, crypto_options);
if (!media_channel) { if (!media_channel) {
return nullptr; return nullptr;
@ -349,13 +349,13 @@ void ChannelManager::DestroyRtpDataChannel(RtpDataChannel* data_channel) {
bool ChannelManager::StartAecDump(rtc::PlatformFile file, bool ChannelManager::StartAecDump(rtc::PlatformFile file,
int64_t max_size_bytes) { int64_t max_size_bytes) {
return worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { return worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] {
return media_engine_->StartAecDump(file, max_size_bytes); return media_engine_->voice().StartAecDump(file, max_size_bytes);
}); });
} }
void ChannelManager::StopAecDump() { void ChannelManager::StopAecDump() {
worker_thread_->Invoke<void>(RTC_FROM_HERE, worker_thread_->Invoke<void>(RTC_FROM_HERE,
[&] { media_engine_->StopAecDump(); }); [&] { media_engine_->voice().StopAecDump(); });
} }
} // namespace cricket } // namespace cricket

View File

@ -1717,7 +1717,7 @@ void PeerConnection::GetStats(
break; break;
} }
} }
// If there is no |internal_sender| then |selector| is either null or does not // If there is no |internal_sender| then |selector| is either null or does not
// belong to the PeerConnection (in Plan B, senders can be removed from the // belong to the PeerConnection (in Plan B, senders can be removed from the
// PeerConnection). This means that "all the stats objects representing the // PeerConnection). This means that "all the stats objects representing the
// selector" is an empty set. Invoking GetStatsReport() with a null selector // selector" is an empty set. Invoking GetStatsReport() with a null selector
@ -1745,7 +1745,7 @@ void PeerConnection::GetStats(
break; break;
} }
} }
// If there is no |internal_receiver| then |selector| is either null or does // If there is no |internal_receiver| then |selector| is either null or does
// not belong to the PeerConnection (in Plan B, receivers can be removed from // not belong to the PeerConnection (in Plan B, receivers can be removed from
// the PeerConnection). This means that "all the stats objects representing // the PeerConnection). This means that "all the stats objects representing
// the selector" is an empty set. Invoking GetStatsReport() with a null // the selector" is an empty set. Invoking GetStatsReport() with a null
@ -3254,7 +3254,7 @@ void PeerConnection::SetAudioPlayout(bool playout) {
return; return;
} }
auto audio_state = auto audio_state =
factory_->channel_manager()->media_engine()->GetAudioState(); factory_->channel_manager()->media_engine()->voice().GetAudioState();
audio_state->SetPlayout(playout); audio_state->SetPlayout(playout);
} }
@ -3266,7 +3266,7 @@ void PeerConnection::SetAudioRecording(bool recording) {
return; return;
} }
auto audio_state = auto audio_state =
factory_->channel_manager()->media_engine()->GetAudioState(); factory_->channel_manager()->media_engine()->voice().GetAudioState();
audio_state->SetRecording(recording); audio_state->SetRecording(recording);
} }

View File

@ -704,7 +704,7 @@ void AddComfortNoiseCodecsToSend(cricket::FakeMediaEngine* media_engine) {
const cricket::AudioCodec kComfortNoiseCodec8k(102, "CN", 8000, 0, 1); const cricket::AudioCodec kComfortNoiseCodec8k(102, "CN", 8000, 0, 1);
const cricket::AudioCodec kComfortNoiseCodec16k(103, "CN", 16000, 0, 1); const cricket::AudioCodec kComfortNoiseCodec16k(103, "CN", 16000, 0, 1);
auto codecs = media_engine->audio_send_codecs(); auto codecs = media_engine->voice().send_codecs();
codecs.push_back(kComfortNoiseCodec8k); codecs.push_back(kComfortNoiseCodec8k);
codecs.push_back(kComfortNoiseCodec16k); codecs.push_back(kComfortNoiseCodec16k);
media_engine->SetAudioCodecs(codecs); media_engine->SetAudioCodecs(codecs);

View File

@ -470,7 +470,8 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
if (!channel_manager_->media_engine() || !call_factory_) { if (!channel_manager_->media_engine() || !call_factory_) {
return nullptr; return nullptr;
} }
call_config.audio_state = channel_manager_->media_engine()->GetAudioState(); call_config.audio_state =
channel_manager_->media_engine()->voice().GetAudioState();
call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;