This issue is related to
https://chromereviews.googleplex.com/9908014/ I was thinking about shipping ACM2 from the signal repository. There seems to be too many changes in one CL. BUG= R=andrew@webrtc.org, turaj@webrtc.org, xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2171004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4733 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -1017,6 +1017,20 @@ class AudioCodingModule: public Module {
|
|||||||
virtual std::vector<uint16_t> GetNackList(int round_trip_time_ms) const = 0;
|
virtual std::vector<uint16_t> GetNackList(int round_trip_time_ms) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AudioCodingModuleFactory {
|
||||||
|
AudioCodingModuleFactory() {}
|
||||||
|
virtual ~AudioCodingModuleFactory() {}
|
||||||
|
|
||||||
|
virtual AudioCodingModule* Create(int id) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NewAudioCodingModuleFactory : AudioCodingModuleFactory {
|
||||||
|
NewAudioCodingModuleFactory() {}
|
||||||
|
virtual ~NewAudioCodingModuleFactory() {}
|
||||||
|
|
||||||
|
virtual AudioCodingModule* Create(int id) const;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_H_
|
||||||
|
|||||||
@@ -98,4 +98,14 @@ bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioCodingModule* AudioCodingModuleFactory::Create(int id) const {
|
||||||
|
return new AudioCodingModuleImpl(static_cast<int32_t>(id),
|
||||||
|
Clock::GetRealTimeClock());
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const {
|
||||||
|
// TODO(minyue): return new AudioCodingModuleImpl (new version).
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "webrtc/voice_engine/channel.h"
|
#include "webrtc/voice_engine/channel.h"
|
||||||
|
|
||||||
|
#include "webrtc/common.h"
|
||||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||||
#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
|
#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
|
||||||
@@ -816,13 +817,14 @@ Channel::NeededFrequency(int32_t id)
|
|||||||
int32_t
|
int32_t
|
||||||
Channel::CreateChannel(Channel*& channel,
|
Channel::CreateChannel(Channel*& channel,
|
||||||
int32_t channelId,
|
int32_t channelId,
|
||||||
uint32_t instanceId)
|
uint32_t instanceId,
|
||||||
|
const Config& config)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId,channelId),
|
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId,channelId),
|
||||||
"Channel::CreateChannel(channelId=%d, instanceId=%d)",
|
"Channel::CreateChannel(channelId=%d, instanceId=%d)",
|
||||||
channelId, instanceId);
|
channelId, instanceId);
|
||||||
|
|
||||||
channel = new Channel(channelId, instanceId);
|
channel = new Channel(channelId, instanceId, config);
|
||||||
if (channel == NULL)
|
if (channel == NULL)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceMemory, kTraceVoice,
|
WEBRTC_TRACE(kTraceMemory, kTraceVoice,
|
||||||
@@ -900,7 +902,8 @@ Channel::RecordFileEnded(int32_t id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Channel::Channel(int32_t channelId,
|
Channel::Channel(int32_t channelId,
|
||||||
uint32_t instanceId) :
|
uint32_t instanceId,
|
||||||
|
const Config& config) :
|
||||||
_fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_instanceId(instanceId),
|
_instanceId(instanceId),
|
||||||
@@ -915,7 +918,7 @@ Channel::Channel(int32_t channelId,
|
|||||||
VoEModuleId(instanceId, channelId), Clock::GetRealTimeClock(), this,
|
VoEModuleId(instanceId, channelId), Clock::GetRealTimeClock(), this,
|
||||||
this, this, rtp_payload_registry_.get())),
|
this, this, rtp_payload_registry_.get())),
|
||||||
telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()),
|
telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()),
|
||||||
_audioCodingModule(*AudioCodingModule::Create(
|
_audioCodingModule(*config.Get<AudioCodingModuleFactory>().Create(
|
||||||
VoEModuleId(instanceId, channelId))),
|
VoEModuleId(instanceId, channelId))),
|
||||||
_rtpDumpIn(*RtpDump::CreateRtpDump()),
|
_rtpDumpIn(*RtpDump::CreateRtpDump()),
|
||||||
_rtpDumpOut(*RtpDump::CreateRtpDump()),
|
_rtpDumpOut(*RtpDump::CreateRtpDump()),
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
namespace webrtc
|
namespace webrtc
|
||||||
{
|
{
|
||||||
class AudioDeviceModule;
|
class AudioDeviceModule;
|
||||||
|
class Config;
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class FileWrapper;
|
class FileWrapper;
|
||||||
class ProcessThread;
|
class ProcessThread;
|
||||||
@@ -80,8 +81,9 @@ public:
|
|||||||
virtual ~Channel();
|
virtual ~Channel();
|
||||||
static int32_t CreateChannel(Channel*& channel,
|
static int32_t CreateChannel(Channel*& channel,
|
||||||
int32_t channelId,
|
int32_t channelId,
|
||||||
uint32_t instanceId);
|
uint32_t instanceId,
|
||||||
Channel(int32_t channelId, uint32_t instanceId);
|
const Config& config);
|
||||||
|
Channel(int32_t channelId, uint32_t instanceId, const Config& config);
|
||||||
int32_t Init();
|
int32_t Init();
|
||||||
int32_t SetEngineInformation(
|
int32_t SetEngineInformation(
|
||||||
Statistics& engineStatistics,
|
Statistics& engineStatistics,
|
||||||
|
|||||||
@@ -44,14 +44,15 @@ ChannelOwner& ChannelOwner::operator=(const ChannelOwner& other) {
|
|||||||
ChannelOwner::ChannelRef::ChannelRef(class Channel* channel)
|
ChannelOwner::ChannelRef::ChannelRef(class Channel* channel)
|
||||||
: channel(channel), ref_count(1) {}
|
: channel(channel), ref_count(1) {}
|
||||||
|
|
||||||
ChannelManager::ChannelManager(uint32_t instance_id)
|
ChannelManager::ChannelManager(uint32_t instance_id, const Config& config)
|
||||||
: instance_id_(instance_id),
|
: instance_id_(instance_id),
|
||||||
last_channel_id_(-1),
|
last_channel_id_(-1),
|
||||||
lock_(CriticalSectionWrapper::CreateCriticalSection()) {}
|
lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
|
config_(config) {}
|
||||||
|
|
||||||
ChannelOwner ChannelManager::CreateChannel() {
|
ChannelOwner ChannelManager::CreateChannel() {
|
||||||
Channel* channel;
|
Channel* channel;
|
||||||
Channel::CreateChannel(channel, ++last_channel_id_, instance_id_);
|
Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config_);
|
||||||
ChannelOwner channel_owner(channel);
|
ChannelOwner channel_owner(channel);
|
||||||
|
|
||||||
CriticalSectionScoped crit(lock_.get());
|
CriticalSectionScoped crit(lock_.get());
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
class Config;
|
||||||
|
|
||||||
namespace voe {
|
namespace voe {
|
||||||
|
|
||||||
class Channel;
|
class Channel;
|
||||||
@@ -66,7 +69,7 @@ class ChannelOwner {
|
|||||||
|
|
||||||
class ChannelManager {
|
class ChannelManager {
|
||||||
public:
|
public:
|
||||||
ChannelManager(uint32_t instance_id);
|
ChannelManager(uint32_t instance_id, const Config& config);
|
||||||
|
|
||||||
// Upon construction of an Iterator it will grab a copy of the channel list of
|
// Upon construction of an Iterator it will grab a copy of the channel list of
|
||||||
// the ChannelManager. The iteration will then occur over this state, not the
|
// the ChannelManager. The iteration will then occur over this state, not the
|
||||||
@@ -110,6 +113,8 @@ class ChannelManager {
|
|||||||
scoped_ptr<CriticalSectionWrapper> lock_;
|
scoped_ptr<CriticalSectionWrapper> lock_;
|
||||||
std::vector<ChannelOwner> channels_;
|
std::vector<ChannelOwner> channels_;
|
||||||
|
|
||||||
|
const Config& config_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ChannelManager);
|
DISALLOW_COPY_AND_ASSIGN(ChannelManager);
|
||||||
};
|
};
|
||||||
} // namespace voe
|
} // namespace voe
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
class AudioDeviceModule;
|
class AudioDeviceModule;
|
||||||
class AudioProcessing;
|
class AudioProcessing;
|
||||||
|
class Config;
|
||||||
|
|
||||||
const int kVoEDefault = -1;
|
const int kVoEDefault = -1;
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ public:
|
|||||||
// Creates a VoiceEngine object, which can then be used to acquire
|
// Creates a VoiceEngine object, which can then be used to acquire
|
||||||
// sub-APIs. Returns NULL on failure.
|
// sub-APIs. Returns NULL on failure.
|
||||||
static VoiceEngine* Create();
|
static VoiceEngine* Create();
|
||||||
|
static VoiceEngine* Create(const Config& config);
|
||||||
|
|
||||||
// Deletes a created VoiceEngine object and releases the utilized resources.
|
// Deletes a created VoiceEngine object and releases the utilized resources.
|
||||||
// Note that if there are outstanding references held via other interfaces,
|
// Note that if there are outstanding references held via other interfaces,
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ namespace voe {
|
|||||||
|
|
||||||
static int32_t _gInstanceCounter = 0;
|
static int32_t _gInstanceCounter = 0;
|
||||||
|
|
||||||
SharedData::SharedData() :
|
SharedData::SharedData(const Config& config) :
|
||||||
_instanceId(++_gInstanceCounter),
|
_instanceId(++_gInstanceCounter),
|
||||||
_apiCritPtr(CriticalSectionWrapper::CreateCriticalSection()),
|
_apiCritPtr(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_channelManager(_gInstanceCounter),
|
_channelManager(_gInstanceCounter, config),
|
||||||
_engineStatistics(_gInstanceCounter),
|
_engineStatistics(_gInstanceCounter),
|
||||||
_audioDevicePtr(NULL),
|
_audioDevicePtr(NULL),
|
||||||
audioproc_(NULL),
|
audioproc_(NULL),
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
class ProcessThread;
|
class ProcessThread;
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
class Config;
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
|
|
||||||
namespace voe {
|
namespace voe {
|
||||||
@@ -79,7 +80,7 @@ protected:
|
|||||||
|
|
||||||
AudioDeviceModule::AudioLayer _audioDeviceLayer;
|
AudioDeviceModule::AudioLayer _audioDeviceLayer;
|
||||||
|
|
||||||
SharedData();
|
SharedData(const Config& config);
|
||||||
virtual ~SharedData();
|
virtual ~SharedData();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
|
||||||
#include "webrtc/system_wrappers/interface/trace.h"
|
#include "webrtc/system_wrappers/interface/trace.h"
|
||||||
#include "webrtc/voice_engine/voice_engine_impl.h"
|
#include "webrtc/voice_engine/voice_engine_impl.h"
|
||||||
|
|
||||||
@@ -28,13 +29,26 @@ namespace webrtc
|
|||||||
// improvement here.
|
// improvement here.
|
||||||
static int32_t gVoiceEngineInstanceCounter = 0;
|
static int32_t gVoiceEngineInstanceCounter = 0;
|
||||||
|
|
||||||
extern "C"
|
VoiceEngine* GetVoiceEngine(const Config* config, bool owns_config)
|
||||||
{
|
{
|
||||||
WEBRTC_DLLEXPORT VoiceEngine* GetVoiceEngine();
|
#if (defined _WIN32)
|
||||||
|
HMODULE hmod = LoadLibrary(TEXT("VoiceEngineTestingDynamic.dll"));
|
||||||
|
|
||||||
VoiceEngine* GetVoiceEngine()
|
if (hmod) {
|
||||||
{
|
typedef VoiceEngine* (*PfnGetVoiceEngine)(void);
|
||||||
VoiceEngineImpl* self = new VoiceEngineImpl();
|
PfnGetVoiceEngine pfn = (PfnGetVoiceEngine)GetProcAddress(
|
||||||
|
hmod,"GetVoiceEngine");
|
||||||
|
if (pfn) {
|
||||||
|
VoiceEngine* self = pfn();
|
||||||
|
if (owns_config) {
|
||||||
|
delete config;
|
||||||
|
}
|
||||||
|
return (self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VoiceEngineImpl* self = new VoiceEngineImpl(config, owns_config);
|
||||||
if (self != NULL)
|
if (self != NULL)
|
||||||
{
|
{
|
||||||
self->AddRef(); // First reference. Released in VoiceEngine::Delete.
|
self->AddRef(); // First reference. Released in VoiceEngine::Delete.
|
||||||
@@ -42,7 +56,6 @@ VoiceEngine* GetVoiceEngine()
|
|||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
} // extern "C"
|
|
||||||
|
|
||||||
int VoiceEngineImpl::AddRef() {
|
int VoiceEngineImpl::AddRef() {
|
||||||
return ++_ref_count;
|
return ++_ref_count;
|
||||||
@@ -63,25 +76,15 @@ int VoiceEngineImpl::Release() {
|
|||||||
return new_ref;
|
return new_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
VoiceEngine* VoiceEngine::Create()
|
VoiceEngine* VoiceEngine::Create() {
|
||||||
{
|
Config* config = new Config();
|
||||||
#if (defined _WIN32)
|
config->Set<AudioCodingModuleFactory>(new AudioCodingModuleFactory());
|
||||||
HMODULE hmod_ = LoadLibrary(TEXT("VoiceEngineTestingDynamic.dll"));
|
|
||||||
|
|
||||||
if (hmod_)
|
return GetVoiceEngine(config, true);
|
||||||
{
|
}
|
||||||
typedef VoiceEngine* (*PfnGetVoiceEngine)(void);
|
|
||||||
PfnGetVoiceEngine pfn = (PfnGetVoiceEngine)GetProcAddress(
|
|
||||||
hmod_,"GetVoiceEngine");
|
|
||||||
if (pfn)
|
|
||||||
{
|
|
||||||
VoiceEngine* self = pfn();
|
|
||||||
return (self);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return GetVoiceEngine();
|
VoiceEngine* VoiceEngine::Create(const Config& config) {
|
||||||
|
return GetVoiceEngine(&config, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoiceEngine::SetTraceFilter(unsigned int filter)
|
int VoiceEngine::SetTraceFilter(unsigned int filter)
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ class VoiceEngineImpl : public voe::SharedData, // Must be the first base class
|
|||||||
public VoEBaseImpl
|
public VoEBaseImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VoiceEngineImpl() :
|
VoiceEngineImpl(const Config* config, bool owns_config) :
|
||||||
|
SharedData(*config),
|
||||||
#ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
|
#ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
|
||||||
VoEAudioProcessingImpl(this),
|
VoEAudioProcessingImpl(this),
|
||||||
#endif
|
#endif
|
||||||
@@ -137,7 +138,8 @@ public:
|
|||||||
VoEVolumeControlImpl(this),
|
VoEVolumeControlImpl(this),
|
||||||
#endif
|
#endif
|
||||||
VoEBaseImpl(this),
|
VoEBaseImpl(this),
|
||||||
_ref_count(0)
|
_ref_count(0),
|
||||||
|
own_config_(owns_config ? config : NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~VoiceEngineImpl()
|
virtual ~VoiceEngineImpl()
|
||||||
@@ -152,6 +154,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Atomic32 _ref_count;
|
Atomic32 _ref_count;
|
||||||
|
scoped_ptr<const Config> own_config_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
Reference in New Issue
Block a user