Moved CreateBuiltinDecoderFactory out to VoEBaseImpl.
VoEBase is plumbed to optionally take an AudioDecoderFactory, or create a builtin factory if none is provided. Retained the CreateChannel interfaces in Channel and ChannelManager and added variants for injecting an AudioDecoderFactory. The "old-style" variants call CreateBuiltinAudioDecoderFactory to get a factory to use. (Just realized this means each channel uses a separate factory with the old-style calls. Probably ok.) BUG=webrtc:5805 Review-Url: https://codereview.webrtc.org/1993783002 Cr-Commit-Position: refs/heads/master@{#12961}
This commit is contained in:
parent
22e70ab1dd
commit
5f7cfa50e5
@ -229,8 +229,11 @@ class FakeWebRtcVoiceEngine
|
||||
WEBRTC_STUB(RegisterVoiceEngineObserver, (
|
||||
webrtc::VoiceEngineObserver& observer));
|
||||
WEBRTC_STUB(DeRegisterVoiceEngineObserver, ());
|
||||
WEBRTC_FUNC(Init, (webrtc::AudioDeviceModule* adm,
|
||||
webrtc::AudioProcessing* audioproc)) {
|
||||
WEBRTC_FUNC(Init,
|
||||
(webrtc::AudioDeviceModule* adm,
|
||||
webrtc::AudioProcessing* audioproc,
|
||||
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
||||
decoder_factory)) {
|
||||
inited_ = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -106,9 +106,11 @@ class MockVoiceEngine : public VoiceEngineImpl {
|
||||
// VoEBase
|
||||
MOCK_METHOD1(RegisterVoiceEngineObserver, int(VoiceEngineObserver& observer));
|
||||
MOCK_METHOD0(DeRegisterVoiceEngineObserver, int());
|
||||
MOCK_METHOD2(Init,
|
||||
int(AudioDeviceModule* external_adm,
|
||||
AudioProcessing* audioproc));
|
||||
MOCK_METHOD3(
|
||||
Init,
|
||||
int(AudioDeviceModule* external_adm,
|
||||
AudioProcessing* audioproc,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory));
|
||||
MOCK_METHOD0(audio_processing, AudioProcessing*());
|
||||
MOCK_METHOD0(Terminate, int());
|
||||
MOCK_METHOD0(CreateChannel, int());
|
||||
|
||||
@ -673,11 +673,23 @@ int32_t Channel::CreateChannel(Channel*& channel,
|
||||
uint32_t instanceId,
|
||||
RtcEventLog* const event_log,
|
||||
const Config& config) {
|
||||
return CreateChannel(channel, channelId, instanceId, event_log, config,
|
||||
CreateBuiltinAudioDecoderFactory());
|
||||
}
|
||||
|
||||
int32_t Channel::CreateChannel(
|
||||
Channel*& channel,
|
||||
int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
RtcEventLog* const event_log,
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
|
||||
"Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId,
|
||||
instanceId);
|
||||
|
||||
channel = new Channel(channelId, instanceId, event_log, config);
|
||||
channel =
|
||||
new Channel(channelId, instanceId, event_log, config, decoder_factory);
|
||||
if (channel == NULL) {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
|
||||
"Channel::CreateChannel() unable to allocate memory for"
|
||||
@ -737,7 +749,8 @@ void Channel::RecordFileEnded(int32_t id) {
|
||||
Channel::Channel(int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
RtcEventLog* const event_log,
|
||||
const Config& config)
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)
|
||||
: _instanceId(instanceId),
|
||||
_channelId(channelId),
|
||||
event_log_(event_log),
|
||||
@ -826,7 +839,7 @@ Channel::Channel(int32_t channelId,
|
||||
acm_config.neteq_config.enable_fast_accelerate =
|
||||
config.Get<NetEqFastAccelerate>().enabled;
|
||||
acm_config.neteq_config.enable_muted_state = true;
|
||||
acm_config.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
acm_config.decoder_factory = decoder_factory;
|
||||
audio_coding_.reset(AudioCodingModule::Create(acm_config));
|
||||
|
||||
_outputAudioLevel.Clear();
|
||||
|
||||
@ -175,10 +175,18 @@ class Channel
|
||||
uint32_t instanceId,
|
||||
RtcEventLog* const event_log,
|
||||
const Config& config);
|
||||
static int32_t CreateChannel(
|
||||
Channel*& channel,
|
||||
int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
RtcEventLog* const event_log,
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
Channel(int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
RtcEventLog* const event_log,
|
||||
const Config& config);
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
int32_t Init();
|
||||
int32_t SetEngineInformation(Statistics& engineStatistics,
|
||||
OutputMixer& outputMixer,
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "webrtc/voice_engine/channel_manager.h"
|
||||
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/voice_engine/channel.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -52,17 +53,30 @@ ChannelManager::ChannelManager(uint32_t instance_id, const Config& config)
|
||||
event_log_(RtcEventLog::Create(Clock::GetRealTimeClock())) {}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannel() {
|
||||
return CreateChannelInternal(config_);
|
||||
return CreateChannel(CreateBuiltinAudioDecoderFactory());
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannel(const Config& external_config) {
|
||||
return CreateChannelInternal(external_config);
|
||||
return CreateChannel(external_config, CreateBuiltinAudioDecoderFactory());
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannelInternal(const Config& config) {
|
||||
ChannelOwner ChannelManager::CreateChannel(
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
return CreateChannelInternal(config_, decoder_factory);
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannel(
|
||||
const Config& external_config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
return CreateChannelInternal(external_config, decoder_factory);
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannelInternal(
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
Channel* channel;
|
||||
Channel::CreateChannel(channel, ++last_channel_id_, instance_id_,
|
||||
event_log_.get(), config);
|
||||
event_log_.get(), config, decoder_factory);
|
||||
ChannelOwner channel_owner(channel);
|
||||
|
||||
rtc::CritScope crit(&lock_);
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/call/rtc_event_log.h"
|
||||
#include "webrtc/system_wrappers/include/atomic32.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
@ -23,6 +24,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
class Config;
|
||||
class AudioDecoderFactory;
|
||||
|
||||
namespace voe {
|
||||
|
||||
@ -101,6 +103,11 @@ class ChannelManager {
|
||||
// CreateChannel(const Config& external_config) is called.
|
||||
ChannelOwner CreateChannel();
|
||||
ChannelOwner CreateChannel(const Config& external_config);
|
||||
ChannelOwner CreateChannel(
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
ChannelOwner CreateChannel(
|
||||
const Config& external_config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
|
||||
// ChannelOwner.channel() will be NULL if channel_id is invalid or no longer
|
||||
// exists. This should be checked with ChannelOwner::IsValid().
|
||||
@ -117,7 +124,9 @@ class ChannelManager {
|
||||
|
||||
private:
|
||||
// Create a channel given a configuration, |config|.
|
||||
ChannelOwner CreateChannelInternal(const Config& config);
|
||||
ChannelOwner CreateChannelInternal(
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
|
||||
uint32_t instance_id_;
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
#ifndef WEBRTC_VOICE_ENGINE_VOE_BASE_H
|
||||
#define WEBRTC_VOICE_ENGINE_VOE_BASE_H
|
||||
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_decoder_factory.h"
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -123,11 +125,14 @@ class WEBRTC_DLLEXPORT VoEBase {
|
||||
// functionality in a separate (reference counted) module.
|
||||
// - The AudioProcessing module handles capture-side processing. VoiceEngine
|
||||
// takes ownership of this object.
|
||||
// - An AudioDecoderFactory - used to create audio decoders.
|
||||
// If NULL is passed for any of these, VoiceEngine will create its own.
|
||||
// Returns -1 in case of an error, 0 otherwise.
|
||||
// TODO(ajm): Remove default NULLs.
|
||||
virtual int Init(AudioDeviceModule* external_adm = NULL,
|
||||
AudioProcessing* audioproc = NULL) = 0;
|
||||
AudioProcessing* audioproc = NULL,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>&
|
||||
decoder_factory = nullptr) = 0;
|
||||
|
||||
// Returns NULL before Init() is called.
|
||||
virtual AudioProcessing* audio_processing() = 0;
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_impl.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
@ -211,8 +212,10 @@ int VoEBaseImpl::DeRegisterVoiceEngineObserver() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
|
||||
AudioProcessing* audioproc) {
|
||||
int VoEBaseImpl::Init(
|
||||
AudioDeviceModule* external_adm,
|
||||
AudioProcessing* audioproc,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
rtc::CritScope cs(shared_->crit_sec());
|
||||
WebRtcSpl_Init();
|
||||
if (shared_->statistics().Initialized()) {
|
||||
@ -375,6 +378,11 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (decoder_factory)
|
||||
decoder_factory_ = decoder_factory;
|
||||
else
|
||||
decoder_factory_ = CreateBuiltinAudioDecoderFactory();
|
||||
|
||||
return shared_->statistics().SetInitialized();
|
||||
}
|
||||
|
||||
@ -390,7 +398,8 @@ int VoEBaseImpl::CreateChannel() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
voe::ChannelOwner channel_owner = shared_->channel_manager().CreateChannel();
|
||||
voe::ChannelOwner channel_owner =
|
||||
shared_->channel_manager().CreateChannel(decoder_factory_);
|
||||
return InitializeChannel(&channel_owner);
|
||||
}
|
||||
|
||||
@ -401,7 +410,7 @@ int VoEBaseImpl::CreateChannel(const Config& config) {
|
||||
return -1;
|
||||
}
|
||||
voe::ChannelOwner channel_owner =
|
||||
shared_->channel_manager().CreateChannel(config);
|
||||
shared_->channel_manager().CreateChannel(config, decoder_factory_);
|
||||
return InitializeChannel(&channel_owner);
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,9 @@ class VoEBaseImpl : public VoEBase,
|
||||
int DeRegisterVoiceEngineObserver() override;
|
||||
|
||||
int Init(AudioDeviceModule* external_adm = nullptr,
|
||||
AudioProcessing* audioproc = nullptr) override;
|
||||
AudioProcessing* audioproc = nullptr,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory =
|
||||
nullptr) override;
|
||||
AudioProcessing* audio_processing() override {
|
||||
return shared_->audio_processing();
|
||||
}
|
||||
@ -143,6 +145,7 @@ class VoEBaseImpl : public VoEBase,
|
||||
int InitializeChannel(voe::ChannelOwner* channel_owner);
|
||||
VoiceEngineObserver* voiceEngineObserverPtr_;
|
||||
rtc::CriticalSection callbackCritSect_;
|
||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
||||
|
||||
AudioFrame audioFrame_;
|
||||
voe::SharedData* shared_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user