Inject config when creating channels to override the existing one.
BUG= R=xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/3239004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5116 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
e8433eb115
commit
03f33709f8
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/voice_engine/channel_manager.h"
|
||||
|
||||
#include "webrtc/voice_engine/channel.h"
|
||||
@ -51,8 +52,16 @@ ChannelManager::ChannelManager(uint32_t instance_id, const Config& config)
|
||||
config_(config) {}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannel() {
|
||||
return CreateChannelInternal(config_);
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannel(const Config& external_config) {
|
||||
return CreateChannelInternal(external_config);
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannelInternal(const Config& config) {
|
||||
Channel* channel;
|
||||
Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config_);
|
||||
Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config);
|
||||
ChannelOwner channel_owner(channel);
|
||||
|
||||
CriticalSectionScoped crit(lock_.get());
|
||||
|
@ -92,8 +92,13 @@ class ChannelManager {
|
||||
DISALLOW_COPY_AND_ASSIGN(Iterator);
|
||||
};
|
||||
|
||||
// CreateChannel will always return a valid ChannelOwner instance.
|
||||
// CreateChannel will always return a valid ChannelOwner instance. The channel
|
||||
// is created either based on internal configuration, i.e. |config_|, by
|
||||
// calling CreateChannel(), or using and external configuration
|
||||
// |external_config| if the overloaded method
|
||||
// CreateChannel(const Config& external_config) is called.
|
||||
ChannelOwner CreateChannel();
|
||||
ChannelOwner CreateChannel(const Config& external_config);
|
||||
|
||||
// ChannelOwner.channel() will be NULL if channel_id is invalid or no longer
|
||||
// exists. This should be checked with ChannelOwner::IsValid().
|
||||
@ -106,6 +111,9 @@ class ChannelManager {
|
||||
size_t NumOfChannels() const;
|
||||
|
||||
private:
|
||||
// Create a channel given a configuration, |config|.
|
||||
ChannelOwner CreateChannelInternal(const Config& config);
|
||||
|
||||
uint32_t instance_id_;
|
||||
|
||||
Atomic32 last_channel_id_;
|
||||
|
@ -133,7 +133,10 @@ public:
|
||||
virtual int Terminate() = 0;
|
||||
|
||||
// Creates a new channel and allocates the required resources for it.
|
||||
// One can use |config| to configure the channel. Currently that is used for
|
||||
// choosing between ACM1 and ACM2, when creating Audio Coding Module.
|
||||
virtual int CreateChannel() = 0;
|
||||
virtual int CreateChannel(const Config& config) = 0;
|
||||
|
||||
// Deletes an existing channel and releases the utilized resources.
|
||||
virtual int DeleteChannel(int channel) = 0;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/voice_engine/voe_base_impl.h"
|
||||
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_impl.h"
|
||||
@ -520,22 +521,34 @@ int VoEBaseImpl::Terminate()
|
||||
return TerminateInternal();
|
||||
}
|
||||
|
||||
int VoEBaseImpl::CreateChannel()
|
||||
{
|
||||
int VoEBaseImpl::CreateChannel() {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
|
||||
"CreateChannel()");
|
||||
CriticalSectionScoped cs(_shared->crit_sec());
|
||||
|
||||
if (!_shared->statistics().Initialized())
|
||||
{
|
||||
if (!_shared->statistics().Initialized()) {
|
||||
_shared->SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
|
||||
voe::ChannelOwner channel_owner =
|
||||
_shared->channel_manager().CreateChannel();
|
||||
voe::ChannelOwner channel_owner = _shared->channel_manager().CreateChannel();
|
||||
|
||||
if (channel_owner.channel()->SetEngineInformation(
|
||||
return InitializeChannel(&channel_owner);
|
||||
}
|
||||
|
||||
int VoEBaseImpl::CreateChannel(const Config& config) {
|
||||
CriticalSectionScoped cs(_shared->crit_sec());
|
||||
if (!_shared->statistics().Initialized()) {
|
||||
_shared->SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
voe::ChannelOwner channel_owner = _shared->channel_manager().CreateChannel(
|
||||
config);
|
||||
return InitializeChannel(&channel_owner);
|
||||
}
|
||||
|
||||
int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner)
|
||||
{
|
||||
if (channel_owner->channel()->SetEngineInformation(
|
||||
_shared->statistics(),
|
||||
*_shared->output_mixer(),
|
||||
*_shared->transmit_mixer(),
|
||||
@ -549,23 +562,23 @@ int VoEBaseImpl::CreateChannel()
|
||||
"CreateChannel() failed to associate engine and channel."
|
||||
" Destroying channel.");
|
||||
_shared->channel_manager()
|
||||
.DestroyChannel(channel_owner.channel()->ChannelId());
|
||||
.DestroyChannel(channel_owner->channel()->ChannelId());
|
||||
return -1;
|
||||
} else if (channel_owner.channel()->Init() != 0) {
|
||||
} else if (channel_owner->channel()->Init() != 0) {
|
||||
_shared->SetLastError(
|
||||
VE_CHANNEL_NOT_CREATED,
|
||||
kTraceError,
|
||||
"CreateChannel() failed to initialize channel. Destroying"
|
||||
" channel.");
|
||||
_shared->channel_manager()
|
||||
.DestroyChannel(channel_owner.channel()->ChannelId());
|
||||
.DestroyChannel(channel_owner->channel()->ChannelId());
|
||||
return -1;
|
||||
}
|
||||
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
|
||||
VoEId(_shared->instance_id(), -1),
|
||||
"CreateChannel() => %d", channel_owner.channel()->ChannelId());
|
||||
return channel_owner.channel()->ChannelId();
|
||||
"CreateChannel() => %d", channel_owner->channel()->ChannelId());
|
||||
return channel_owner->channel()->ChannelId();
|
||||
}
|
||||
|
||||
int VoEBaseImpl::DeleteChannel(int channel)
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
virtual int Terminate();
|
||||
|
||||
virtual int CreateChannel();
|
||||
virtual int CreateChannel(const Config& config);
|
||||
|
||||
virtual int DeleteChannel(int channel);
|
||||
|
||||
@ -133,6 +134,10 @@ private:
|
||||
|
||||
int32_t AddBuildInfo(char* str) const;
|
||||
int32_t AddVoEVersion(char* str) const;
|
||||
|
||||
// Initialize channel by setting Engine Information then initializing
|
||||
// channel.
|
||||
int InitializeChannel(voe::ChannelOwner* channel_owner);
|
||||
#ifdef WEBRTC_EXTERNAL_TRANSPORT
|
||||
int32_t AddExternalTransportBuild(char* str) const;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user