Remove public virtual voe::SharedData inheritance.

This is a fix for coverity issues: 10446, 10445, 10444, 10443.

Although the cl is rather big, there aren't many code changes:

* Instead of an implicit vtable pointer, there is now an explicit |_data| member to access the shared data.
* We don't access the member variables of SharedData directly.  There are accessors instead.
* SharedData setters that set values that must be freed, automatically free the previous value and 'addref' if required the new one.
* Lots and lots of 'rewrapping' due to search/replace after the above changes.

BUG=10446, 10445, 10444, 10443
TEST=Run all tests for VoE.
Review URL: https://webrtc-codereview.appspot.com/472009

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1987 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org 2012-04-04 14:57:19 +00:00
parent ae19720982
commit 851becd00c
32 changed files with 2272 additions and 2405 deletions

View File

@ -70,7 +70,6 @@ public:
const TraceModule module,
const WebRtc_Word32 id,
const char* msg, ...);
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -62,8 +62,23 @@ SharedData::~SharedData()
Trace::ReturnTrace();
}
WebRtc_UWord16
SharedData::NumOfSendingChannels()
void SharedData::set_audio_device(AudioDeviceModule* audio_device)
{
// AddRef first in case the pointers are equal.
if (audio_device)
audio_device->AddRef();
if (_audioDevicePtr)
_audioDevicePtr->Release();
_audioDevicePtr = audio_device;
}
void SharedData::set_audio_processing(AudioProcessing* audio_processing) {
if (_audioProcessingModulePtr)
AudioProcessing::Destroy(_audioProcessingModulePtr);
_audioProcessingModulePtr = audio_processing;
}
WebRtc_UWord16 SharedData::NumOfSendingChannels()
{
WebRtc_Word32 numOfChannels = _channelManager.NumOfChannels();
if (numOfChannels <= 0)
@ -91,6 +106,20 @@ SharedData::NumOfSendingChannels()
return nChannelsSending;
}
void SharedData::SetLastError(const WebRtc_Word32 error) const {
_engineStatistics.SetLastError(error);
}
void SharedData::SetLastError(const WebRtc_Word32 error,
const TraceLevel level) const {
_engineStatistics.SetLastError(error, level);
}
void SharedData::SetLastError(const WebRtc_Word32 error, const TraceLevel level,
const char* msg) const {
_engineStatistics.SetLastError(error, level, msg);
}
} // namespace voe
} // namespace webrtc

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -38,10 +38,32 @@ public:
Statistics& statistics() { return _engineStatistics; }
ChannelManager& channel_manager() { return _channelManager; }
AudioDeviceModule* audio_device() { return _audioDevicePtr; }
void set_audio_device(AudioDeviceModule* audio_device);
AudioProcessing* audio_processing() { return _audioProcessingModulePtr; }
void set_audio_processing(AudioProcessing* audio_processing);
TransmitMixer* transmit_mixer() { return _transmitMixerPtr; }
OutputMixer* output_mixer() { return _outputMixerPtr; }
CriticalSectionWrapper* crit_sec() { return _apiCritPtr; }
bool ext_recording() const { return _externalRecording; }
void set_ext_recording(bool value) { _externalRecording = value; }
bool ext_playout() const { return _externalPlayout; }
void set_ext_playout(bool value) { _externalPlayout = value; }
ProcessThread* process_thread() { return _moduleProcessThreadPtr; }
AudioDeviceModule::AudioLayer audio_device_layer() const {
return _audioDeviceLayer;
}
void set_audio_device_layer(AudioDeviceModule::AudioLayer layer) {
_audioDeviceLayer = layer;
}
protected:
WebRtc_UWord16 NumOfSendingChannels();
// Convenience methods for calling statistics().SetLastError().
void SetLastError(const WebRtc_Word32 error) const;
void SetLastError(const WebRtc_Word32 error, const TraceLevel level) const;
void SetLastError(const WebRtc_Word32 error, const TraceLevel level,
const char* msg) const;
protected:
const WebRtc_UWord32 _instanceId;
CriticalSectionWrapper* _apiCritPtr;
@ -53,13 +75,11 @@ protected:
AudioProcessing* _audioProcessingModulePtr;
ProcessThread* _moduleProcessThreadPtr;
protected:
bool _externalRecording;
bool _externalPlayout;
AudioDeviceModule::AudioLayer _audioDeviceLayer;
protected:
SharedData();
virtual ~SharedData();
};

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,7 @@
namespace webrtc {
class VoEAudioProcessingImpl
: public virtual voe::SharedData,
public VoEAudioProcessing,
: public VoEAudioProcessing,
public voe::RefCount {
public:
virtual int Release();
@ -97,11 +96,12 @@ class VoEAudioProcessingImpl
int penaltyDecay);
protected:
VoEAudioProcessingImpl();
VoEAudioProcessingImpl(voe::SharedData* shared);
virtual ~VoEAudioProcessingImpl();
private:
bool _isAecMode;
voe::SharedData* _shared;
};
} // namespace webrtc

File diff suppressed because it is too large Load Diff

View File

@ -22,8 +22,7 @@ namespace webrtc
class ProcessThread;
class VoEBaseImpl: public virtual voe::SharedData,
public VoEBase,
class VoEBaseImpl: public VoEBase,
public voe::RefCount,
public AudioTransport,
public AudioDeviceObserver
@ -119,7 +118,7 @@ public:
virtual void OnWarningIsReported(const WarningCode warning);
protected:
VoEBaseImpl();
VoEBaseImpl(voe::SharedData* shared);
virtual ~VoEBaseImpl();
private:
@ -144,6 +143,7 @@ private:
WebRtc_UWord32 _oldVoEMicLevel;
WebRtc_UWord32 _oldMicLevel;
AudioFrame _audioFrame;
voe::SharedData* _shared;
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -40,81 +40,79 @@ VoECallReport* VoECallReport::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_CALL_REPORT_API
VoECallReportImpl::VoECallReportImpl() :
_file(*FileWrapper::Create())
VoECallReportImpl::VoECallReportImpl(voe::SharedData* shared) :
_file(*FileWrapper::Create()), _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoECallReportImpl() - ctor");
}
VoECallReportImpl::~VoECallReportImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"~VoECallReportImpl() - dtor");
delete &_file;
}
int VoECallReportImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoECallReportImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_engineStatistics.SetLastError(VE_INTERFACE_NOT_FOUND,
kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"VoECallReportImpl reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoECallReportImpl reference counter = %d", refCount);
return (refCount);
}
int VoECallReportImpl::ResetCallReportStatistics(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"ResetCallReportStatistics(channel=%d)", channel);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
assert(_audioProcessingModulePtr != NULL);
assert(_shared->audio_processing() != NULL);
bool echoMode =
_audioProcessingModulePtr->echo_cancellation()->are_metrics_enabled();
_shared->audio_processing()->echo_cancellation()->are_metrics_enabled();
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
" current AudioProcessingModule echo metric state %d)",
echoMode);
// Reset the APM statistics
if (_audioProcessingModulePtr->echo_cancellation()->enable_metrics(true)
if (_shared->audio_processing()->echo_cancellation()->enable_metrics(true)
!= 0)
{
_engineStatistics.SetLastError(VE_APM_ERROR, kTraceError,
"ResetCallReportStatistics() unable to "
"set the AudioProcessingModule echo "
"metrics state");
_shared->SetLastError(VE_APM_ERROR, kTraceError,
"ResetCallReportStatistics() unable to "
"set the AudioProcessingModule echo metrics state");
return -1;
}
// Restore metric states
_audioProcessingModulePtr->echo_cancellation()->enable_metrics(echoMode);
_shared->audio_processing()->echo_cancellation()->enable_metrics(echoMode);
// Reset channel dependent statistics
if (channel != -1)
{
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"ResetCallReportStatistics() failed "
"to locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"ResetCallReportStatistics() failed to locate channel");
return -1;
}
channelPtr->ResetDeadOrAliveCounters();
@ -122,16 +120,17 @@ int VoECallReportImpl::ResetCallReportStatistics(int channel)
}
else
{
WebRtc_Word32 numOfChannels = _channelManager.NumOfChannels();
WebRtc_Word32 numOfChannels =
_shared->channel_manager().NumOfChannels();
if (numOfChannels <= 0)
{
return 0;
}
WebRtc_Word32* channelsArray = new WebRtc_Word32[numOfChannels];
_channelManager.GetChannelIds(channelsArray, numOfChannels);
_shared->channel_manager().GetChannelIds(channelsArray, numOfChannels);
for (int i = 0; i < numOfChannels; i++)
{
voe::ScopedChannel sc(_channelManager, channelsArray[i]);
voe::ScopedChannel sc(_shared->channel_manager(), channelsArray[i]);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr)
{
@ -147,17 +146,17 @@ int VoECallReportImpl::ResetCallReportStatistics(int channel)
int VoECallReportImpl::GetEchoMetricSummary(EchoStatistics& stats)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetEchoMetricSummary()");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
assert(_audioProcessingModulePtr != NULL);
assert(_shared->audio_processing() != NULL);
return (GetEchoMetricSummaryInternal(stats));
}
@ -172,29 +171,31 @@ int VoECallReportImpl::GetEchoMetricSummaryInternal(EchoStatistics& stats)
// Ensure that echo metrics is enabled
mode =
_audioProcessingModulePtr->echo_cancellation()->are_metrics_enabled();
_shared->audio_processing()->echo_cancellation()->are_metrics_enabled();
if (mode != false)
{
ret =
_audioProcessingModulePtr->echo_cancellation()->GetMetrics(&metrics);
ret = _shared->audio_processing()->echo_cancellation()->
GetMetrics(&metrics);
if (ret != 0)
{
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1),
" AudioProcessingModule GetMetrics() => error");
WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" AudioProcessingModule GetMetrics() => error");
}
}
else
{
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1),
" AudioProcessingModule echo metrics is not enabled");
WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" AudioProcessingModule echo metrics is not enabled");
}
if ((ret != 0) || (mode == false))
{
// Mark complete struct as invalid (-100 dB)
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1),
" unable to retrieve echo metrics from the "
"AudioProcessingModule");
WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" unable to retrieve echo metrics from the AudioProcessingModule");
stats.erl.min = -100;
stats.erl.max = -100;
stats.erl.average = -100;
@ -215,53 +216,53 @@ int VoECallReportImpl::GetEchoMetricSummaryInternal(EchoStatistics& stats)
stats.erl.min = metrics.echo_return_loss.minimum;
stats.erl.max = metrics.echo_return_loss.maximum;
stats.erl.average = metrics.echo_return_loss.average;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" erl: min=%d, max=%d, avg=%d", stats.erl.min,
stats.erl.max, stats.erl.average);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1), " erl: min=%d, max=%d, avg=%d",
stats.erl.min, stats.erl.max, stats.erl.average);
stats.erle.min = metrics.echo_return_loss_enhancement.minimum;
stats.erle.max = metrics.echo_return_loss_enhancement.maximum;
stats.erle.average = metrics.echo_return_loss_enhancement.average;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" erle: min=%d, max=%d, avg=%d", stats.erle.min,
stats.erle.max, stats.erle.average);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1), " erle: min=%d, max=%d, avg=%d",
stats.erle.min, stats.erle.max, stats.erle.average);
stats.rerl.min = metrics.residual_echo_return_loss.minimum;
stats.rerl.max = metrics.residual_echo_return_loss.maximum;
stats.rerl.average = metrics.residual_echo_return_loss.average;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" rerl: min=%d, max=%d, avg=%d", stats.rerl.min,
stats.rerl.max, stats.rerl.average);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1), " rerl: min=%d, max=%d, avg=%d",
stats.rerl.min, stats.rerl.max, stats.rerl.average);
stats.a_nlp.min = metrics.a_nlp.minimum;
stats.a_nlp.max = metrics.a_nlp.maximum;
stats.a_nlp.average = metrics.a_nlp.average;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" a_nlp: min=%d, max=%d, avg=%d", stats.a_nlp.min,
stats.a_nlp.max, stats.a_nlp.average);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" a_nlp: min=%d, max=%d, avg=%d",
stats.a_nlp.min, stats.a_nlp.max, stats.a_nlp.average);
}
return 0;
}
int VoECallReportImpl::GetRoundTripTimeSummary(int channel, StatVal& delaysMs)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRoundTripTimeSummary()");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRoundTripTimeSummary() failed to "
"locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRoundTripTimeSummary() failed to locate channel");
return -1;
}
@ -272,14 +273,14 @@ int VoECallReportImpl::GetDeadOrAliveSummary(int channel,
int& numOfDeadDetections,
int& numOfAliveDetections)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetDeadOrAliveSummary(channel=%d)", channel);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
@ -291,21 +292,20 @@ int VoECallReportImpl::GetDeadOrAliveSummaryInternal(int channel,
int& numOfDeadDetections,
int& numOfAliveDetections)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetDeadOrAliveSummary(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRoundTripTimeSummary() failed to "
"locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRoundTripTimeSummary() failed to locate channel");
return -1;
}
@ -315,21 +315,21 @@ int VoECallReportImpl::GetDeadOrAliveSummaryInternal(int channel,
int VoECallReportImpl::WriteReportToFile(const char* fileNameUTF8)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"WriteReportToFile(fileNameUTF8=%s)", fileNameUTF8);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (NULL == fileNameUTF8)
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"WriteReportToFile() invalid filename");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"WriteReportToFile() invalid filename");
return -1;
}
@ -341,9 +341,8 @@ int VoECallReportImpl::WriteReportToFile(const char* fileNameUTF8)
// Open text file in write mode
if (_file.OpenFile(fileNameUTF8, false, false, true) != 0)
{
_engineStatistics.SetLastError(VE_BAD_FILE, kTraceError,
"WriteReportToFile() unable to open the "
"file");
_shared->SetLastError(VE_BAD_FILE, kTraceError,
"WriteReportToFile() unable to open the file");
return -1;
}
@ -354,16 +353,16 @@ int VoECallReportImpl::WriteReportToFile(const char* fileNameUTF8)
_file.WriteText("\nNetwork Packet Round Trip Time (RTT)\n");
_file.WriteText("------------------------------------\n\n");
WebRtc_Word32 numOfChannels = _channelManager.NumOfChannels();
WebRtc_Word32 numOfChannels = _shared->channel_manager().NumOfChannels();
if (numOfChannels <= 0)
{
return 0;
}
WebRtc_Word32* channelsArray = new WebRtc_Word32[numOfChannels];
_channelManager.GetChannelIds(channelsArray, numOfChannels);
_shared->channel_manager().GetChannelIds(channelsArray, numOfChannels);
for (int ch = 0; ch < numOfChannels; ch++)
{
voe::ScopedChannel sc(_channelManager, channelsArray[ch]);
voe::ScopedChannel sc(_shared->channel_manager(), channelsArray[ch]);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr)
{
@ -381,7 +380,7 @@ int VoECallReportImpl::WriteReportToFile(const char* fileNameUTF8)
for (int ch = 0; ch < numOfChannels; ch++)
{
voe::ScopedChannel sc(_channelManager, channelsArray[ch]);
voe::ScopedChannel sc(_shared->channel_manager(), channelsArray[ch]);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -21,8 +21,7 @@ namespace webrtc
{
class FileWrapper;
class VoECallReportImpl: public virtual voe::SharedData,
public VoECallReport,
class VoECallReportImpl: public VoECallReport,
public voe::RefCount
{
public:
@ -41,7 +40,7 @@ public:
virtual int WriteReportToFile(const char* fileNameUTF8);
protected:
VoECallReportImpl();
VoECallReportImpl(voe::SharedData* shared);
virtual ~VoECallReportImpl();
private:
@ -54,6 +53,7 @@ private:
int GetSpeechAndNoiseSummaryInternal(LevelStatistics& stats);
FileWrapper& _file;
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -39,66 +39,68 @@ VoECodec* VoECodec::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_CODEC_API
VoECodecImpl::VoECodecImpl()
VoECodecImpl::VoECodecImpl(voe::SharedData* shared) : _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoECodecImpl() - ctor");
}
VoECodecImpl::~VoECodecImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"~VoECodecImpl() - dtor");
}
int VoECodecImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoECodecImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_engineStatistics.SetLastError(VE_INTERFACE_NOT_FOUND,
kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"VoECodecImpl reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoECodecImpl reference counter = %d", refCount);
return (refCount);
}
int VoECodecImpl::NumOfCodecs()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"NumOfCodecs()");
// Number of supported codecs in the ACM
WebRtc_UWord8 nSupportedCodecs = AudioCodingModule::NumberOfCodecs();
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"NumOfCodecs() => %u", nSupportedCodecs);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"NumOfCodecs() => %u", nSupportedCodecs);
return (nSupportedCodecs);
}
int VoECodecImpl::GetCodec(int index, CodecInst& codec)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetCodec(index=%d, codec=?)", index);
CodecInst acmCodec;
if (AudioCodingModule::Codec(index, (CodecInst&) acmCodec)
== -1)
{
_engineStatistics.SetLastError(VE_INVALID_LISTNR, kTraceError,
"GetCodec() invalid index");
_shared->SetLastError(VE_INVALID_LISTNR, kTraceError,
"GetCodec() invalid index");
return -1;
}
ACMToExternalCodecRepresentation(codec, acmCodec);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"GetCodec() => plname=%s, pacsize=%d, plfreq=%d, pltype=%d, "
"channels=%d, rate=%d", codec.plname, codec.pacsize,
codec.plfreq, codec.pltype, codec.channels, codec.rate);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetCodec() => plname=%s, pacsize=%d, plfreq=%d, pltype=%d, "
"channels=%d, rate=%d", codec.plname, codec.pacsize,
codec.plfreq, codec.pltype, codec.channels, codec.rate);
return 0;
}
@ -107,63 +109,58 @@ int VoECodecImpl::SetSendCodec(int channel, const CodecInst& codec)
CodecInst copyCodec;
ExternalToACMCodecRepresentation(copyCodec, codec);
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetSendCodec(channel=%d, codec)", channel);
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
"codec: plname=%s, pacsize=%d, plfreq=%d, pltype=%d, "
"channels=%d, rate=%d", codec.plname, codec.pacsize,
codec.plfreq, codec.pltype, codec.channels, codec.rate);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
// External sanity checks performed outside the ACM
if ((STR_CASE_CMP(copyCodec.plname, "L16") == 0) &&
(copyCodec.pacsize >= 960))
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid L16 packet "
"size");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid L16 packet size");
return -1;
}
if (!STR_CASE_CMP(copyCodec.plname, "CN")
|| !STR_CASE_CMP(copyCodec.plname, "TELEPHONE-EVENT")
|| !STR_CASE_CMP(copyCodec.plname, "RED"))
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid codec name");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid codec name");
return -1;
}
if ((copyCodec.channels != 1) && (copyCodec.channels != 2))
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid number of "
"channels");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid number of channels");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendCodec() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendCodec() failed to locate channel");
return -1;
}
if (!AudioCodingModule::IsCodecValid(
(CodecInst&) copyCodec))
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid codec");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendCodec() invalid codec");
return -1;
}
if (channelPtr->SetSendCodec(copyCodec) != 0)
{
_engineStatistics.SetLastError(VE_CANNOT_SET_SEND_CODEC,
kTraceError,
"SetSendCodec() failed to set send "
"codec");
_shared->SetLastError(VE_CANNOT_SET_SEND_CODEC, kTraceError,
"SetSendCodec() failed to set send codec");
return -1;
}
@ -171,7 +168,7 @@ int VoECodecImpl::SetSendCodec(int channel, const CodecInst& codec)
// We'll check all channels (sending or not), so we don't have to
// check this again when starting/stopping sending.
voe::ScopedChannel sc2(_channelManager);
voe::ScopedChannel sc2(_shared->channel_manager());
void* iterator(NULL);
channelPtr = sc2.GetFirstChannel(iterator);
int maxNumChannels = 1;
@ -197,13 +194,13 @@ int VoECodecImpl::SetSendCodec(int channel, const CodecInst& codec)
// Check if the number of channels has changed to avoid an unnecessary
// reset.
// TODO(andrew): look at handling this logic in AudioProcessing.
if (_audioProcessingModulePtr->num_output_channels() != maxNumChannels)
if (_shared->audio_processing()->num_output_channels() != maxNumChannels)
{
if (_audioProcessingModulePtr->set_num_channels(
_audioProcessingModulePtr->num_input_channels(),
if (_shared->audio_processing()->set_num_channels(
_shared->audio_processing()->num_input_channels(),
maxNumChannels) != 0)
{
_engineStatistics.SetLastError(VE_APM_ERROR, kTraceError,
_shared->SetLastError(VE_APM_ERROR, kTraceError,
"Init() failed to set APM channels for the send audio stream");
return -1;
}
@ -214,208 +211,197 @@ int VoECodecImpl::SetSendCodec(int channel, const CodecInst& codec)
int VoECodecImpl::GetSendCodec(int channel, CodecInst& codec)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSendCodec(channel=%d, codec=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendCodec() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendCodec() failed to locate channel");
return -1;
}
CodecInst acmCodec;
if (channelPtr->GetSendCodec(acmCodec) != 0)
{
_engineStatistics.SetLastError(VE_CANNOT_GET_SEND_CODEC, kTraceError,
"GetSendCodec() failed to get send "
"codec");
_shared->SetLastError(VE_CANNOT_GET_SEND_CODEC, kTraceError,
"GetSendCodec() failed to get send codec");
return -1;
}
ACMToExternalCodecRepresentation(codec, acmCodec);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"GetSendCodec() => plname=%s, pacsize=%d, plfreq=%d, "
"channels=%d, rate=%d", codec.plname, codec.pacsize,
codec.plfreq, codec.channels, codec.rate);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetSendCodec() => plname=%s, pacsize=%d, plfreq=%d, "
"channels=%d, rate=%d", codec.plname, codec.pacsize,
codec.plfreq, codec.channels, codec.rate);
return 0;
}
int VoECodecImpl::GetRecCodec(int channel, CodecInst& codec)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRecCodec(channel=%d, codec=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRecCodec() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRecCodec() failed to locate channel");
return -1;
}
CodecInst acmCodec;
if (channelPtr->GetRecCodec(acmCodec) != 0)
{
_engineStatistics.SetLastError(VE_CANNOT_GET_REC_CODEC, kTraceError,
"GetRecCodec() failed to get received "
"codec");
_shared->SetLastError(VE_CANNOT_GET_REC_CODEC, kTraceError,
"GetRecCodec() failed to get received codec");
return -1;
}
ACMToExternalCodecRepresentation(codec, acmCodec);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"GetRecCodec() => plname=%s, pacsize=%d, plfreq=%d, "
"channels=%d, rate=%d", codec.plname, codec.pacsize,
codec.plfreq, codec.channels, codec.rate);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetRecCodec() => plname=%s, pacsize=%d, plfreq=%d, "
"channels=%d, rate=%d", codec.plname, codec.pacsize,
codec.plfreq, codec.channels, codec.rate);
return 0;
}
int VoECodecImpl::SetAMREncFormat(int channel, AmrMode mode)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetAMREncFormat(channel=%d, mode=%d)", channel, mode);
#ifdef WEBRTC_CODEC_GSMAMR
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMREncFormat() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMREncFormat() failed to locate channel");
return -1;
}
return channelPtr->SetAMREncFormat(mode);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMREncFormat() AMR codec is not "
"supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMREncFormat() AMR codec is not supported");
return -1;
#endif
}
int VoECodecImpl::SetAMRDecFormat(int channel, AmrMode mode)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetAMRDecFormat(channel=%i, mode=%i)", channel, mode);
#ifdef WEBRTC_CODEC_GSMAMR
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMRDecFormat() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMRDecFormat() failed to locate channel");
return -1;
}
return channelPtr->SetAMRDecFormat(mode);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMRDecFormat() AMR codec is not "
"supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMRDecFormat() AMR codec is not supported");
return -1;
#endif
}
int VoECodecImpl::SetAMRWbEncFormat(int channel, AmrMode mode)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetAMRWbEncFormat(channel=%d, mode=%d)", channel, mode);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_CODEC_GSMAMRWB
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMRWbEncFormat() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMRWbEncFormat() failed to locate channel");
return -1;
}
return channelPtr->SetAMRWbEncFormat(mode);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMRWbEncFormat() AMR-wb codec is not "
"supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMRWbEncFormat() AMR-wb codec is not supported");
return -1;
#endif
}
int VoECodecImpl::SetAMRWbDecFormat(int channel, AmrMode mode)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetAMRWbDecFormat(channel=%i, mode=%i)", channel, mode);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_CODEC_GSMAMRWB
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMRWbDecFormat() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetAMRWbDecFormat() failed to locate channel");
return -1;
}
return channelPtr->SetAMRWbDecFormat(mode);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMRWbDecFormat() AMR-wb codec is not "
"supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetAMRWbDecFormat() AMR-wb codec is not supported");
return -1;
#endif
}
int VoECodecImpl::SetRecPayloadType(int channel, const CodecInst& codec)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetRecPayloadType(channel=%d, codec)", channel);
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
"codec: plname=%s, plfreq=%d, pltype=%d, channels=%u, "
"pacsize=%d, rate=%d", codec.plname, codec.plfreq, codec.pltype,
codec.channels, codec.pacsize, codec.rate);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRecPayloadType() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRecPayloadType() failed to locate channel");
return -1;
}
return channelPtr->SetRecPayloadType(codec);
@ -423,20 +409,19 @@ int VoECodecImpl::SetRecPayloadType(int channel, const CodecInst& codec)
int VoECodecImpl::GetRecPayloadType(int channel, CodecInst& codec)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRecPayloadType(channel=%d, codec)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRecPayloadType() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRecPayloadType() failed to locate channel");
return -1;
}
return channelPtr->GetRecPayloadType(codec);
@ -445,20 +430,19 @@ int VoECodecImpl::GetRecPayloadType(int channel, CodecInst& codec)
int VoECodecImpl::SetSendCNPayloadType(int channel, int type,
PayloadFrequencies frequency)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetSendCNPayloadType(channel=%d, type=%d, frequency=%d)",
channel, type, frequency);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (type < 96 || type > 127)
{
// Only allow dynamic range: 96 to 127
_engineStatistics.SetLastError(VE_INVALID_PLTYPE, kTraceError,
"SetSendCNPayloadType() invalid payload "
"type");
_shared->SetLastError(VE_INVALID_PLTYPE, kTraceError,
"SetSendCNPayloadType() invalid payload type");
return -1;
}
if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz))
@ -466,25 +450,22 @@ int VoECodecImpl::SetSendCNPayloadType(int channel, int type,
// It is not possible to modify the payload type for CN/8000.
// We only allow modification of the CN payload type for CN/16000
// and CN/32000.
_engineStatistics.SetLastError(VE_INVALID_PLFREQ, kTraceError,
"SetSendCNPayloadType() invalid payload"
" frequency");
_shared->SetLastError(VE_INVALID_PLFREQ, kTraceError,
"SetSendCNPayloadType() invalid payload frequency");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSendCNPayloadType() failed to "
"locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSendCNPayloadType() failed to locate channel");
return -1;
}
if (channelPtr->Sending())
{
_engineStatistics.SetLastError(VE_SENDING, kTraceError,
"SetSendCNPayloadType unable so set "
"payload type while sending");
_shared->SetLastError(VE_SENDING, kTraceError,
"SetSendCNPayloadType unable so set payload type while sending");
return -1;
}
return channelPtr->SetSendCNPayloadType(type, frequency);
@ -493,92 +474,86 @@ int VoECodecImpl::SetSendCNPayloadType(int channel, int type,
int VoECodecImpl::SetISACInitTargetRate(int channel, int rateBps,
bool useFixedFrameSize)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetISACInitTargetRate(channel=%d, rateBps=%d, "
"useFixedFrameSize=%d)", channel, rateBps, useFixedFrameSize);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_CODEC_ISAC
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetISACInitTargetRate() failed to "
"locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetISACInitTargetRate() failed to locate channel");
return -1;
}
return channelPtr->SetISACInitTargetRate(rateBps, useFixedFrameSize);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetISACInitTargetRate() iSAC codec is not "
"supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetISACInitTargetRate() iSAC codec is not supported");
return -1;
#endif
}
int VoECodecImpl::SetISACMaxRate(int channel, int rateBps)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetISACMaxRate(channel=%d, rateBps=%d)", channel, rateBps);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_CODEC_ISAC
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetISACMaxRate() failed to locate "
"channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetISACMaxRate() failed to locate channel");
return -1;
}
return channelPtr->SetISACMaxRate(rateBps);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetISACMaxRate() iSAC codec is not "
"supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetISACMaxRate() iSAC codec is not supported");
return -1;
#endif
}
int VoECodecImpl::SetISACMaxPayloadSize(int channel, int sizeBytes)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetISACMaxPayloadSize(channel=%d, sizeBytes=%d)", channel,
sizeBytes);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_CODEC_ISAC
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetISACMaxPayloadSize() failed to "
"locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetISACMaxPayloadSize() failed to locate channel");
return -1;
}
return channelPtr->SetISACMaxPayloadSize(sizeBytes);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetISACMaxPayloadSize() iSAC codec is not "
"supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetISACMaxPayloadSize() iSAC codec is not supported");
return -1;
#endif
return 0;
@ -587,21 +562,21 @@ int VoECodecImpl::SetISACMaxPayloadSize(int channel, int sizeBytes)
int VoECodecImpl::SetVADStatus(int channel, bool enable, VadModes mode,
bool disableDTX)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetVADStatus(channel=%i, enable=%i, mode=%i, disableDTX=%i)",
channel, enable, mode, disableDTX);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetVADStatus failed to locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetVADStatus failed to locate channel");
return -1;
}
@ -627,20 +602,20 @@ int VoECodecImpl::SetVADStatus(int channel, bool enable, VadModes mode,
int VoECodecImpl::GetVADStatus(int channel, bool& enabled, VadModes& mode,
bool& disabledDTX)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetVADStatus(channel=%i)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetVADStatus failed to locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetVADStatus failed to locate channel");
return -1;
}
@ -649,8 +624,8 @@ int VoECodecImpl::GetVADStatus(int channel, bool& enabled, VadModes& mode,
if (ret != 0)
{
_engineStatistics.SetLastError(VE_INVALID_OPERATION, kTraceError,
"GetVADStatus failed to get VAD mode");
_shared->SetLastError(VE_INVALID_OPERATION, kTraceError,
"GetVADStatus failed to get VAD mode");
return -1;
}
switch (vadMode)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -19,8 +19,7 @@
namespace webrtc
{
class VoECodecImpl: public virtual voe::SharedData,
public VoECodec,
class VoECodecImpl: public VoECodec,
public voe::RefCount
{
public:
@ -76,7 +75,7 @@ public:
bool& disabledDTX);
protected:
VoECodecImpl();
VoECodecImpl(voe::SharedData* shared);
virtual ~VoECodecImpl();
private:
@ -85,6 +84,8 @@ private:
void ExternalToACMCodecRepresentation(CodecInst& toInst,
const CodecInst& fromInst);
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -39,35 +39,36 @@ VoEDtmf* VoEDtmf::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_DTMF_API
VoEDtmfImpl::VoEDtmfImpl() :
VoEDtmfImpl::VoEDtmfImpl(voe::SharedData* shared) :
_dtmfFeedback(true),
_dtmfDirectFeedback(false)
_dtmfDirectFeedback(false),
_shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1 ),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEDtmfImpl::VoEDtmfImpl() - ctor");
}
VoEDtmfImpl::~VoEDtmfImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEDtmfImpl::~VoEDtmfImpl() - dtor");
}
int VoEDtmfImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEDtmf::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_engineStatistics.SetLastError(
VE_INTERFACE_NOT_FOUND, kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"VoEDtmf reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEDtmf reference counter = %d", refCount);
return (refCount);
}
@ -77,28 +78,26 @@ int VoEDtmfImpl::SendTelephoneEvent(int channel,
int lengthMs,
int attenuationDb)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SendTelephoneEvent(channel=%d, eventCode=%d, outOfBand=%d,"
"length=%d, attenuationDb=%d)",
channel, eventCode, (int)outOfBand, lengthMs, attenuationDb);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SendTelephoneEvent() failed to locate channel");
return -1;
}
if (!channelPtr->Sending())
{
_engineStatistics.SetLastError(
VE_NOT_SENDING, kTraceError,
_shared->SetLastError(VE_NOT_SENDING, kTraceError,
"SendTelephoneEvent() sending is not active");
return -1;
}
@ -115,8 +114,7 @@ int VoEDtmfImpl::SendTelephoneEvent(int channel,
(attenuationDb > kMaxTelephoneEventAttenuation));
if (testFailed)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SendTelephoneEvent() invalid parameter(s)");
return -1;
}
@ -130,14 +128,15 @@ int VoEDtmfImpl::SendTelephoneEvent(int channel,
{
// Mute the microphone signal while playing back the tone directly.
// This is to reduce the risk of introducing echo from the added output.
_transmitMixerPtr->UpdateMuteMicrophoneTime(lengthMs);
_shared->transmit_mixer()->UpdateMuteMicrophoneTime(lengthMs);
// Play out local feedback tone directly (same approach for both inband
// and outband).
// Reduce the length of the the tone with 80ms to reduce risk of echo.
// For non-direct feedback, outband and inband cases are handled
// differently.
_outputMixerPtr->PlayDtmfTone(eventCode, lengthMs-80, attenuationDb);
_shared->output_mixer()->PlayDtmfTone(eventCode, lengthMs - 80,
attenuationDb);
}
if (outOfBand)
@ -174,20 +173,19 @@ int VoEDtmfImpl::SendTelephoneEvent(int channel,
int VoEDtmfImpl::SetSendTelephoneEventPayloadType(int channel,
unsigned char type)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetSendTelephoneEventPayloadType(channel=%d, type=%u)",
channel, type);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSendTelephoneEventPayloadType() failed to locate channel");
return -1;
}
@ -197,19 +195,18 @@ int VoEDtmfImpl::SetSendTelephoneEventPayloadType(int channel,
int VoEDtmfImpl::GetSendTelephoneEventPayloadType(int channel,
unsigned char& type)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSendTelephoneEventPayloadType(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendTelephoneEventPayloadType() failed to locate channel");
return -1;
}
@ -220,19 +217,18 @@ int VoEDtmfImpl::PlayDtmfTone(int eventCode,
int lengthMs,
int attenuationDb)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"PlayDtmfTone(eventCode=%d, lengthMs=%d, attenuationDb=%d)",
eventCode, lengthMs, attenuationDb);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (!_audioDevicePtr->Playing())
if (!_shared->audio_device()->Playing())
{
_engineStatistics.SetLastError(
VE_NOT_PLAYING, kTraceError,
_shared->SetLastError(VE_NOT_PLAYING, kTraceError,
"PlayDtmfTone() no channel is playing out");
return -1;
}
@ -243,30 +239,29 @@ int VoEDtmfImpl::PlayDtmfTone(int eventCode,
(attenuationDb <kMinTelephoneEventAttenuation) ||
(attenuationDb > kMaxTelephoneEventAttenuation))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"PlayDtmfTone() invalid tone parameter(s)");
return -1;
}
return _outputMixerPtr->PlayDtmfTone(eventCode, lengthMs, attenuationDb);
return _shared->output_mixer()->PlayDtmfTone(eventCode, lengthMs,
attenuationDb);
}
int VoEDtmfImpl::StartPlayingDtmfTone(int eventCode,
int attenuationDb)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"StartPlayingDtmfTone(eventCode=%d, attenuationDb=%d)",
eventCode, attenuationDb);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (!_audioDevicePtr->Playing())
if (!_shared->audio_device()->Playing())
{
_engineStatistics.SetLastError(
VE_NOT_PLAYING, kTraceError,
_shared->SetLastError(VE_NOT_PLAYING, kTraceError,
"StartPlayingDtmfTone() no channel is playing out");
return -1;
}
@ -275,25 +270,25 @@ int VoEDtmfImpl::StartPlayingDtmfTone(int eventCode,
(attenuationDb < kMinTelephoneEventAttenuation) ||
(attenuationDb > kMaxTelephoneEventAttenuation))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"StartPlayingDtmfTone() invalid tone parameter(s)");
return -1;
}
return _outputMixerPtr->StartPlayingDtmfTone(eventCode, attenuationDb);
return _shared->output_mixer()->StartPlayingDtmfTone(eventCode,
attenuationDb);
}
int VoEDtmfImpl::StopPlayingDtmfTone()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"StopPlayingDtmfTone()");
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
return _outputMixerPtr->StopPlayingDtmfTone();
return _shared->output_mixer()->StopPlayingDtmfTone();
}
int VoEDtmfImpl::RegisterTelephoneEventDetection(
@ -301,29 +296,27 @@ int VoEDtmfImpl::RegisterTelephoneEventDetection(
TelephoneEventDetectionMethods detectionMethod,
VoETelephoneEventObserver& observer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
"RegisterTelephoneEventDetection(channel=%d, detectionMethod=%d,"
"observer=0x%x)", channel, detectionMethod, &observer);
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"RegisterTelephoneEventDetection(channel=%d, detectionMethod=%d,"
"observer=0x%x)", channel, detectionMethod, &observer);
#ifdef WEBRTC_DTMF_DETECTION
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterTelephoneEventDetection() failed to locate channel");
return -1;
}
return channelPtr->RegisterTelephoneEventDetection(detectionMethod,
observer);
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceError,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetTelephoneEventDetectionStatus() Dtmf detection is not supported");
return -1;
#endif
@ -331,27 +324,25 @@ int VoEDtmfImpl::RegisterTelephoneEventDetection(
int VoEDtmfImpl::DeRegisterTelephoneEventDetection(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DeRegisterTelephoneEventDetection(channel=%d)", channel);
#ifdef WEBRTC_DTMF_DETECTION
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DeRegisterTelephoneEventDe tection() failed to locate channel");
return -1;
}
return channelPtr->DeRegisterTelephoneEventDetection();
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceError,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"DeRegisterTelephoneEventDetection() Dtmf detection is not supported");
return -1;
#endif
@ -363,27 +354,26 @@ int VoEDtmfImpl::GetTelephoneEventDetectionStatus(
bool& enabled,
TelephoneEventDetectionMethods& detectionMethod)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetTelephoneEventDetectionStatus(channel=%d)", channel);
#ifdef WEBRTC_DTMF_DETECTION
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetTelephoneEventDetectionStatus() failed to locate channel");
return -1;
}
return channelPtr->GetTelephoneEventDetectionStatus(enabled, detectionMethod);
return channelPtr->GetTelephoneEventDetectionStatus(enabled,
detectionMethod);
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceError,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"GetTelephoneEventDetectionStatus() Dtmf detection is not supported");
return -1;
#endif
@ -391,11 +381,11 @@ int VoEDtmfImpl::GetTelephoneEventDetectionStatus(
int VoEDtmfImpl::SetDtmfFeedbackStatus(bool enable, bool directFeedback)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetDtmfFeedbackStatus(enable=%d, directFeeback=%d)",
(int)enable, (int)directFeedback);
CriticalSectionScoped sc(_apiCritPtr);
CriticalSectionScoped sc(_shared->crit_sec());
_dtmfFeedback = enable;
_dtmfDirectFeedback = directFeedback;
@ -405,38 +395,38 @@ int VoEDtmfImpl::SetDtmfFeedbackStatus(bool enable, bool directFeedback)
int VoEDtmfImpl::GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetDtmfFeedbackStatus()");
CriticalSectionScoped sc(_apiCritPtr);
CriticalSectionScoped sc(_shared->crit_sec());
enabled = _dtmfFeedback;
directFeedback = _dtmfDirectFeedback;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetDtmfFeedbackStatus() => enabled=%d, directFeedback=%d",
enabled, directFeedback);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetDtmfFeedbackStatus() => enabled=%d, directFeedback=%d",
enabled, directFeedback);
return 0;
}
int VoEDtmfImpl::SetDtmfPlayoutStatus(int channel, bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetDtmfPlayoutStatus(channel=%d, enable=%d)",
channel, enable);
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetDtmfPlayoutStatus() failed to locate channel");
return -1;
}
@ -445,26 +435,26 @@ int VoEDtmfImpl::SetDtmfPlayoutStatus(int channel, bool enable)
int VoEDtmfImpl::GetDtmfPlayoutStatus(int channel, bool& enabled)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetDtmfPlayoutStatus(channel=%d, enabled=?)", channel);
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetDtmfPlayoutStatus() failed to locate channel");
return -1;
}
enabled = channelPtr->DtmfPlayoutStatus();
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetDtmfPlayoutStatus() => enabled=%d", enabled);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetDtmfPlayoutStatus() => enabled=%d", enabled);
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -19,8 +19,7 @@
namespace webrtc
{
class VoEDtmfImpl : public virtual voe::SharedData,
public VoEDtmf,
class VoEDtmfImpl : public VoEDtmf,
public voe::RefCount
{
public:
@ -70,12 +69,13 @@ public:
virtual int GetDtmfPlayoutStatus(int channel, bool& enabled);
protected:
VoEDtmfImpl();
VoEDtmfImpl(voe::SharedData* shared);
virtual ~VoEDtmfImpl();
private:
bool _dtmfFeedback;
bool _dtmfDirectFeedback;
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -38,21 +38,21 @@ VoEEncryption* VoEEncryption::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_ENCRYPTION_API
VoEEncryptionImpl::VoEEncryptionImpl()
VoEEncryptionImpl::VoEEncryptionImpl(voe::SharedData* shared) : _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEEncryptionImpl::VoEEncryptionImpl() - ctor");
}
VoEEncryptionImpl::~VoEEncryptionImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEEncryptionImpl::~VoEEncryptionImpl() - dtor");
}
int VoEEncryptionImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEEncryption::Release()");
(*this)--;
int refCount = GetCount();
@ -60,12 +60,12 @@ int VoEEncryptionImpl::Release()
{
// reset reference counter to zero => OK to delete VE
Reset();
_engineStatistics.SetLastError(VE_INTERFACE_NOT_FOUND,
kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"VoEEncryption reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEEncryption reference counter = %d", refCount);
return (refCount);
}
@ -80,25 +80,24 @@ int VoEEncryptionImpl::EnableSRTPSend(
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"EnableSRTPSend(channel=%i, cipherType=%i, cipherKeyLength=%i,"
" authType=%i, authKeyLength=%i, authTagLength=%i, level=%i, "
"key=?, useForRTCP=%d)",
channel, cipherType, cipherKeyLength, authType,
authKeyLength, authTagLength, level, useForRTCP);
#ifdef WEBRTC_SRTP
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"EnableSRTPSend() failed to locate channel");
return -1;
}
@ -111,8 +110,7 @@ int VoEEncryptionImpl::EnableSRTPSend(
key,
useForRTCP);
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceError,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"EnableSRTPSend() SRTP is not supported");
return -1;
#endif
@ -120,28 +118,26 @@ int VoEEncryptionImpl::EnableSRTPSend(
int VoEEncryptionImpl::DisableSRTPSend(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DisableSRTPSend(channel=%i)",channel);
#ifdef WEBRTC_SRTP
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DisableSRTPSend() failed to locate channel");
return -1;
}
return channelPtr->DisableSRTPSend();
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceError,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"DisableSRTPSend() SRTP is not supported");
return -1;
#endif
@ -158,25 +154,24 @@ int VoEEncryptionImpl::EnableSRTPReceive(
const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
bool useForRTCP)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"EnableSRTPReceive(channel=%i, cipherType=%i, "
"cipherKeyLength=%i, authType=%i, authKeyLength=%i, "
"authTagLength=%i, level=%i, key=?, useForRTCP=%d)",
channel, cipherType, cipherKeyLength, authType,
authKeyLength, authTagLength, level, useForRTCP);
#ifdef WEBRTC_SRTP
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"EnableSRTPReceive() failed to locate channel");
return -1;
}
@ -189,8 +184,7 @@ int VoEEncryptionImpl::EnableSRTPReceive(
key,
useForRTCP);
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceError,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"EnableSRTPReceive() SRTP is not supported");
return -1;
#endif
@ -198,28 +192,26 @@ int VoEEncryptionImpl::EnableSRTPReceive(
int VoEEncryptionImpl::DisableSRTPReceive(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DisableSRTPReceive(channel=%i)", channel);
#ifdef WEBRTC_SRTP
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DisableSRTPReceive() failed to locate channel");
return -1;
}
return channelPtr->DisableSRTPReceive();
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceError,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"DisableSRTPReceive() SRTP is not supported");
return -1;
#endif
@ -228,20 +220,19 @@ int VoEEncryptionImpl::DisableSRTPReceive(int channel)
int VoEEncryptionImpl::RegisterExternalEncryption(int channel,
Encryption& encryption)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"RegisterExternalEncryption(channel=%d, encryption=0x%x)",
channel, &encryption);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterExternalEncryption() failed to locate channel");
return -1;
}
@ -250,19 +241,18 @@ int VoEEncryptionImpl::RegisterExternalEncryption(int channel,
int VoEEncryptionImpl::DeRegisterExternalEncryption(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DeRegisterExternalEncryption(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DeRegisterExternalEncryption() failed to locate channel");
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -18,8 +18,7 @@
namespace webrtc {
class VoEEncryptionImpl : public virtual voe::SharedData,
public VoEEncryption,
class VoEEncryptionImpl : public VoEEncryption,
public voe::RefCount
{
public:
@ -61,8 +60,11 @@ public:
virtual int DeRegisterExternalEncryption(int channel);
protected:
VoEEncryptionImpl();
VoEEncryptionImpl(voe::SharedData* shared);
virtual ~VoEEncryptionImpl();
private:
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -38,34 +38,34 @@ VoEExternalMedia* VoEExternalMedia::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API
VoEExternalMediaImpl::VoEExternalMediaImpl()
: playout_delay_ms_(0)
VoEExternalMediaImpl::VoEExternalMediaImpl(voe::SharedData* shared)
: playout_delay_ms_(0), shared_(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(shared_->instance_id(), -1),
"VoEExternalMediaImpl() - ctor");
}
VoEExternalMediaImpl::~VoEExternalMediaImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(shared_->instance_id(), -1),
"~VoEExternalMediaImpl() - dtor");
}
int VoEExternalMediaImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(shared_->instance_id(), -1),
"VoEExternalMedia::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_engineStatistics.SetLastError(VE_INTERFACE_NOT_FOUND,
kTraceWarning);
shared_->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"VoEExternalMedia reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(shared_->instance_id(), -1),
"VoEExternalMedia reference counter = %d", refCount);
return (refCount);
}
@ -74,14 +74,14 @@ int VoEExternalMediaImpl::RegisterExternalMediaProcessing(
ProcessingTypes type,
VoEMediaProcess& processObject)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(shared_->instance_id(), -1),
"RegisterExternalMediaProcessing(channel=%d, type=%d, "
"processObject=0x%x)", channel, type, &processObject);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(shared_->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!shared_->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
switch (type)
@ -89,14 +89,13 @@ int VoEExternalMediaImpl::RegisterExternalMediaProcessing(
case kPlaybackPerChannel:
case kRecordingPerChannel:
{
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(shared_->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterExternalMediaProcessing() "
"failed to locate channel");
shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterExternalMediaProcessing() failed to locate "
"channel");
return -1;
}
return channelPtr->RegisterExternalMediaProcessing(type,
@ -104,12 +103,12 @@ int VoEExternalMediaImpl::RegisterExternalMediaProcessing(
}
case kPlaybackAllChannelsMixed:
{
return _outputMixerPtr->RegisterExternalMediaProcessing(
return shared_->output_mixer()->RegisterExternalMediaProcessing(
processObject);
}
case kRecordingAllChannelsMixed:
{
return _transmitMixerPtr->RegisterExternalMediaProcessing(
return shared_->transmit_mixer()->RegisterExternalMediaProcessing(
processObject);
}
}
@ -120,13 +119,13 @@ int VoEExternalMediaImpl::DeRegisterExternalMediaProcessing(
int channel,
ProcessingTypes type)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(shared_->instance_id(), -1),
"DeRegisterExternalMediaProcessing(channel=%d)", channel);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(shared_->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!shared_->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
switch (type)
@ -134,12 +133,11 @@ int VoEExternalMediaImpl::DeRegisterExternalMediaProcessing(
case kPlaybackPerChannel:
case kRecordingPerChannel:
{
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(shared_->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterExternalMediaProcessing() "
"failed to locate channel");
return -1;
@ -148,11 +146,13 @@ int VoEExternalMediaImpl::DeRegisterExternalMediaProcessing(
}
case kPlaybackAllChannelsMixed:
{
return _outputMixerPtr->DeRegisterExternalMediaProcessing();
return shared_->output_mixer()->
DeRegisterExternalMediaProcessing();
}
case kRecordingAllChannelsMixed:
{
return _transmitMixerPtr->DeRegisterExternalMediaProcessing();
return shared_->transmit_mixer()->
DeRegisterExternalMediaProcessing();
}
}
return -1;
@ -160,25 +160,21 @@ int VoEExternalMediaImpl::DeRegisterExternalMediaProcessing(
int VoEExternalMediaImpl::SetExternalRecordingStatus(bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(shared_->instance_id(), -1),
"SetExternalRecordingStatus(enable=%d)", enable);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(shared_->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
if (_audioDevicePtr->Recording())
if (shared_->audio_device()->Recording())
{
_engineStatistics.SetLastError(
VE_ALREADY_SENDING,
kTraceError,
shared_->SetLastError(VE_ALREADY_SENDING, kTraceError,
"SetExternalRecordingStatus() cannot set state while sending");
return -1;
}
_externalRecording = enable;
shared_->set_ext_recording(enable);
return 0;
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED,
kTraceError,
shared_->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetExternalRecordingStatus() external recording is not supported");
return -1;
#endif
@ -190,59 +186,49 @@ int VoEExternalMediaImpl::ExternalRecordingInsertData(
int samplingFreqHz,
int current_delay_ms)
{
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(shared_->instance_id(), -1),
"ExternalRecordingInsertData(speechData10ms=0x%x,"
" lengthSamples=%u, samplingFreqHz=%d, current_delay_ms=%d)",
&speechData10ms[0], lengthSamples, samplingFreqHz,
current_delay_ms);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(shared_->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
if (!_engineStatistics.Initialized())
if (!shared_->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (!_externalRecording)
if (!shared_->ext_recording())
{
_engineStatistics.SetLastError(
VE_INVALID_OPERATION,
kTraceError,
shared_->SetLastError(VE_INVALID_OPERATION, kTraceError,
"ExternalRecordingInsertData() external recording is not enabled");
return -1;
}
if (NumOfSendingChannels() == 0)
if (shared_->NumOfSendingChannels() == 0)
{
_engineStatistics.SetLastError(
VE_ALREADY_SENDING,
kTraceError,
shared_->SetLastError(VE_ALREADY_SENDING, kTraceError,
"SetExternalRecordingStatus() no channel is sending");
return -1;
}
if ((16000 != samplingFreqHz) && (32000 != samplingFreqHz) &&
(48000 != samplingFreqHz) && (44000 != samplingFreqHz))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT,
kTraceError,
shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetExternalRecordingStatus() invalid sample rate");
return -1;
}
if ((0 == lengthSamples) ||
((lengthSamples % (samplingFreqHz / 100)) != 0))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT,
kTraceError,
shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetExternalRecordingStatus() invalid buffer size");
return -1;
}
if (current_delay_ms < 0)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT,
kTraceError,
shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetExternalRecordingStatus() invalid delay)");
return -1;
}
@ -254,12 +240,11 @@ int VoEExternalMediaImpl::ExternalRecordingInsertData(
for (WebRtc_UWord32 i = 0; i < nBlocks; i++)
{
if (!_externalPlayout)
if (!shared_->ext_playout())
{
// Use real playout delay if external playout is not enabled.
if (_audioDevicePtr->PlayoutDelay(&playoutDelayMS) != 0) {
_engineStatistics.SetLastError(
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
if (shared_->audio_device()->PlayoutDelay(&playoutDelayMS) != 0) {
shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
"PlayoutDelay() unable to get the playout delay");
}
totalDelayMS = current_delay_ms + playoutDelayMS;
@ -274,7 +259,7 @@ int VoEExternalMediaImpl::ExternalRecordingInsertData(
if (totalDelayMS < 0)
totalDelayMS = 0;
}
_transmitMixerPtr->PrepareDemux(
shared_->transmit_mixer()->PrepareDemux(
(const WebRtc_Word8*)(&speechData10ms[i*blockSize]),
blockSize,
1,
@ -283,14 +268,12 @@ int VoEExternalMediaImpl::ExternalRecordingInsertData(
0,
0);
_transmitMixerPtr->DemuxAndMix();
_transmitMixerPtr->EncodeAndSend();
shared_->transmit_mixer()->DemuxAndMix();
shared_->transmit_mixer()->EncodeAndSend();
}
return 0;
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED,
kTraceError,
shared_->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"ExternalRecordingInsertData() external recording is not supported");
return -1;
#endif
@ -298,25 +281,21 @@ int VoEExternalMediaImpl::ExternalRecordingInsertData(
int VoEExternalMediaImpl::SetExternalPlayoutStatus(bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(shared_->instance_id(), -1),
"SetExternalPlayoutStatus(enable=%d)", enable);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(shared_->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
if (_audioDevicePtr->Playing())
if (shared_->audio_device()->Playing())
{
_engineStatistics.SetLastError(
VE_ALREADY_SENDING,
kTraceError,
shared_->SetLastError(VE_ALREADY_SENDING, kTraceError,
"SetExternalPlayoutStatus() cannot set state while playing");
return -1;
}
_externalPlayout = enable;
shared_->set_ext_playout(enable);
return 0;
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED,
kTraceError,
shared_->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetExternalPlayoutStatus() external playout is not supported");
return -1;
#endif
@ -328,40 +307,34 @@ int VoEExternalMediaImpl::ExternalPlayoutGetData(
int current_delay_ms,
int& lengthSamples)
{
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(shared_->instance_id(), -1),
"ExternalPlayoutGetData(speechData10ms=0x%x, samplingFreqHz=%d"
", current_delay_ms=%d)", &speechData10ms[0], samplingFreqHz,
current_delay_ms);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(shared_->statistics());
IPHONE_NOT_SUPPORTED();
#ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
if (!_engineStatistics.Initialized())
if (!shared_->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (!_externalPlayout)
if (!shared_->ext_playout())
{
_engineStatistics.SetLastError(
VE_INVALID_OPERATION,
kTraceError,
shared_->SetLastError(VE_INVALID_OPERATION, kTraceError,
"ExternalPlayoutGetData() external playout is not enabled");
return -1;
}
if ((16000 != samplingFreqHz) && (32000 != samplingFreqHz) &&
(48000 != samplingFreqHz) && (44000 != samplingFreqHz))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT,
kTraceError,
shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"ExternalPlayoutGetData() invalid sample rate");
return -1;
}
if (current_delay_ms < 0)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT,
kTraceError,
shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"ExternalPlayoutGetData() invalid delay)");
return -1;
}
@ -369,9 +342,9 @@ int VoEExternalMediaImpl::ExternalPlayoutGetData(
AudioFrame audioFrame;
// Retrieve mixed output at the specified rate
_outputMixerPtr->MixActiveChannels();
_outputMixerPtr->DoOperationsOnCombinedSignal();
_outputMixerPtr->GetMixedAudio(samplingFreqHz, 1, audioFrame);
shared_->output_mixer()->MixActiveChannels();
shared_->output_mixer()->DoOperationsOnCombinedSignal();
shared_->output_mixer()->GetMixedAudio(samplingFreqHz, 1, audioFrame);
// Deliver audio (PCM) samples to the external sink
memcpy(speechData10ms,
@ -384,9 +357,7 @@ int VoEExternalMediaImpl::ExternalPlayoutGetData(
return 0;
#else
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED,
kTraceError,
shared_->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"ExternalPlayoutGetData() external playout is not supported");
return -1;
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -18,8 +18,7 @@
namespace webrtc {
class VoEExternalMediaImpl : public virtual voe::SharedData,
public VoEExternalMedia,
class VoEExternalMediaImpl : public VoEExternalMedia,
public voe::RefCount
{
public:
@ -50,11 +49,12 @@ public:
int& lengthSamples);
protected:
VoEExternalMediaImpl();
VoEExternalMediaImpl(voe::SharedData* shared);
virtual ~VoEExternalMediaImpl();
private:
int playout_delay_ms_;
voe::SharedData* shared_;
};
} // namespace webrtc

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -17,8 +17,8 @@
namespace webrtc {
class VoEFileImpl : public virtual voe::SharedData,
public VoEFile, public voe::RefCount
class VoEFileImpl : public VoEFile,
public voe::RefCount
{
public:
virtual int Release();
@ -132,9 +132,11 @@ public:
virtual int GetPlaybackPosition(int channel, int& positionMs);
protected:
VoEFileImpl();
VoEFileImpl(voe::SharedData* shared);
virtual ~VoEFileImpl();
private:
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -40,10 +40,10 @@ VoEHardware* VoEHardware::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API
VoEHardwareImpl::VoEHardwareImpl() :
_cpu(NULL)
VoEHardwareImpl::VoEHardwareImpl(voe::SharedData* shared) :
_cpu(NULL), _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEHardwareImpl() - ctor");
_cpu = CpuWrapper::CreateCpu();
@ -55,7 +55,7 @@ VoEHardwareImpl::VoEHardwareImpl() :
VoEHardwareImpl::~VoEHardwareImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"~VoEHardwareImpl() - dtor");
if (_cpu)
@ -67,31 +67,31 @@ VoEHardwareImpl::~VoEHardwareImpl()
int VoEHardwareImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEHardwareImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_engineStatistics.SetLastError(VE_INTERFACE_NOT_FOUND,
kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"VoEHardwareImpl reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEHardwareImpl reference counter = %d", refCount);
return (refCount);
}
int VoEHardwareImpl::SetAudioDeviceLayer(AudioLayers audioLayer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetAudioDeviceLayer(audioLayer=%d)", audioLayer);
// Don't allow a change if VoE is initialized
if (_engineStatistics.Initialized())
if (_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_ALREADY_INITED, kTraceError);
_shared->SetLastError(VE_ALREADY_INITED, kTraceError);
return -1;
}
@ -118,14 +118,14 @@ int VoEHardwareImpl::SetAudioDeviceLayer(AudioLayers audioLayer)
}
// Save the audio device layer for Init()
_audioDeviceLayer = wantedLayer;
_shared->set_audio_device_layer(wantedLayer);
return 0;
}
int VoEHardwareImpl::GetAudioDeviceLayer(AudioLayers& audioLayer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetAudioDeviceLayer(devices=?)");
// Can always be called regardless of VoE state
@ -133,20 +133,20 @@ int VoEHardwareImpl::GetAudioDeviceLayer(AudioLayers& audioLayer)
AudioDeviceModule::AudioLayer
activeLayer(AudioDeviceModule::kPlatformDefaultAudio);
if (_audioDevicePtr)
if (_shared->audio_device())
{
// Get active audio layer from ADM
if (_audioDevicePtr->ActiveAudioLayer(&activeLayer) != 0)
if (_shared->audio_device()->ActiveAudioLayer(&activeLayer) != 0)
{
_engineStatistics.SetLastError(VE_UNDEFINED_SC_ERR, kTraceError,
" Audio Device error");
_shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError,
" Audio Device error");
return -1;
}
}
else
{
// Return VoE's internal layer setting
activeLayer = _audioDeviceLayer;
activeLayer = _shared->audio_device_layer();
}
// Map to AudioLayers
@ -168,53 +168,55 @@ int VoEHardwareImpl::GetAudioDeviceLayer(AudioLayers& audioLayer)
audioLayer = kAudioLinuxPulse;
break;
default:
_engineStatistics.SetLastError(VE_UNDEFINED_SC_ERR, kTraceError,
" unknown audio layer");
_shared->SetLastError(VE_UNDEFINED_SC_ERR, kTraceError,
" unknown audio layer");
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: audioLayer=%d", audioLayer);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: audioLayer=%d", audioLayer);
return 0;
}
int VoEHardwareImpl::GetNumOfRecordingDevices(int& devices)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetNumOfRecordingDevices(devices=?)");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
devices = static_cast<int> (_audioDevicePtr->RecordingDevices());
devices = static_cast<int> (_shared->audio_device()->RecordingDevices());
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: devices=%d", devices);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1), " Output: devices=%d", devices);
return 0;
}
int VoEHardwareImpl::GetNumOfPlayoutDevices(int& devices)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetNumOfPlayoutDevices(devices=?)");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
devices = static_cast<int> (_audioDevicePtr->PlayoutDevices());
devices = static_cast<int> (_shared->audio_device()->PlayoutDevices());
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: devices=%d", devices);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: devices=%d", devices);
return 0;
}
@ -223,20 +225,19 @@ int VoEHardwareImpl::GetRecordingDeviceName(int index,
char strNameUTF8[128],
char strGuidUTF8[128])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRecordingDeviceName(index=%d)", index);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (strNameUTF8 == NULL)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"GetRecordingDeviceName() invalid argument");
return -1;
}
@ -254,24 +255,25 @@ int VoEHardwareImpl::GetRecordingDeviceName(int index,
char guid[strLen];
// Get names from module
if (_audioDevicePtr->RecordingDeviceName(index, name, guid) != 0)
if (_shared->audio_device()->RecordingDeviceName(index, name, guid) != 0)
{
_engineStatistics.SetLastError(
VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError,
_shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError,
"GetRecordingDeviceName() failed to get device name");
return -1;
}
// Copy to vectors supplied by user
strncpy(strNameUTF8, name, strLen);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: strNameUTF8=%s", strNameUTF8);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: strNameUTF8=%s", strNameUTF8);
if (strGuidUTF8 != NULL)
{
strncpy(strGuidUTF8, guid, strLen);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: strGuidUTF8=%s", strGuidUTF8);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: strGuidUTF8=%s", strGuidUTF8);
}
return 0;
@ -281,20 +283,19 @@ int VoEHardwareImpl::GetPlayoutDeviceName(int index,
char strNameUTF8[128],
char strGuidUTF8[128])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetPlayoutDeviceName(index=%d)", index);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (strNameUTF8 == NULL)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"GetPlayoutDeviceName() invalid argument");
return -1;
}
@ -312,24 +313,25 @@ int VoEHardwareImpl::GetPlayoutDeviceName(int index,
char guid[strLen];
// Get names from module
if (_audioDevicePtr->PlayoutDeviceName(index, name, guid) != 0)
if (_shared->audio_device()->PlayoutDeviceName(index, name, guid) != 0)
{
_engineStatistics.SetLastError(
VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError,
_shared->SetLastError(VE_CANNOT_RETRIEVE_DEVICE_NAME, kTraceError,
"GetPlayoutDeviceName() failed to get device name");
return -1;
}
// Copy to vectors supplied by user
strncpy(strNameUTF8, name, strLen);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: strNameUTF8=%s", strNameUTF8);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: strNameUTF8=%s", strNameUTF8);
if (strGuidUTF8 != NULL)
{
strncpy(strGuidUTF8, guid, strLen);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: strGuidUTF8=%s", strGuidUTF8);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: strGuidUTF8=%s", strGuidUTF8);
}
return 0;
@ -338,16 +340,16 @@ int VoEHardwareImpl::GetPlayoutDeviceName(int index,
int VoEHardwareImpl::SetRecordingDevice(int index,
StereoChannel recordingChannel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetRecordingDevice(index=%d, recordingChannel=%d)",
index, (int) recordingChannel);
CriticalSectionScoped cs(_apiCritPtr);
ANDROID_NOT_SUPPORTED(_engineStatistics);
CriticalSectionScoped cs(_shared->crit_sec());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
@ -355,16 +357,15 @@ int VoEHardwareImpl::SetRecordingDevice(int index,
// Store state about activated recording to be able to restore it after the
// recording device has been modified.
if (_audioDevicePtr->Recording())
if (_shared->audio_device()->Recording())
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetRecordingDevice() device is modified while recording"
" is active...");
isRecording = true;
if (_audioDevicePtr->StopRecording() == -1)
if (_shared->audio_device()->StopRecording() == -1)
{
_engineStatistics.SetLastError(
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
_shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
"SetRecordingDevice() unable to stop recording");
return -1;
}
@ -388,9 +389,8 @@ int VoEHardwareImpl::SetRecordingDevice(int index,
break;
}
if (_audioDevicePtr->SetRecordingChannel(recCh) != 0) {
_engineStatistics.SetLastError(
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
if (_shared->audio_device()->SetRecordingChannel(recCh) != 0) {
_shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
"SetRecordingChannel() unable to set the recording channel");
}
@ -401,70 +401,65 @@ int VoEHardwareImpl::SetRecordingDevice(int index,
if (index == -1)
{
res = _audioDevicePtr->SetRecordingDevice(
res = _shared->audio_device()->SetRecordingDevice(
AudioDeviceModule::kDefaultCommunicationDevice);
}
else if (index == -2)
{
res = _audioDevicePtr->SetRecordingDevice(
res = _shared->audio_device()->SetRecordingDevice(
AudioDeviceModule::kDefaultDevice);
}
else
{
res = _audioDevicePtr->SetRecordingDevice(indexU);
res = _shared->audio_device()->SetRecordingDevice(indexU);
}
if (res != 0)
{
_engineStatistics.SetLastError(
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
_shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
"SetRecordingDevice() unable to set the recording device");
return -1;
}
// Init microphone, so user can do volume settings etc
if (_audioDevicePtr->InitMicrophone() == -1)
if (_shared->audio_device()->InitMicrophone() == -1)
{
_engineStatistics.SetLastError(
VE_CANNOT_ACCESS_MIC_VOL, kTraceWarning,
_shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceWarning,
"SetRecordingDevice() cannot access microphone");
}
// Set number of channels
bool available(false);
if (_audioDevicePtr->StereoRecordingIsAvailable(&available) != 0) {
_engineStatistics.SetLastError(
VE_SOUNDCARD_ERROR, kTraceWarning,
bool available = false;
if (_shared->audio_device()->StereoRecordingIsAvailable(&available) != 0) {
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
"StereoRecordingIsAvailable() failed to query stereo recording");
}
if (_audioDevicePtr->SetStereoRecording(available ? true : false) != 0)
if (_shared->audio_device()->SetStereoRecording(available) != 0)
{
_engineStatistics.SetLastError(
VE_SOUNDCARD_ERROR, kTraceWarning,
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
"SetRecordingDevice() failed to set mono recording mode");
}
// Restore recording if it was enabled already when calling this function.
if (isRecording)
{
if (!_externalRecording)
if (!_shared->ext_recording())
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"SetRecordingDevice() recording is now being "
"restored...");
if (_audioDevicePtr->InitRecording() != 0)
WEBRTC_TRACE(kTraceInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"SetRecordingDevice() recording is now being restored...");
if (_shared->audio_device()->InitRecording() != 0)
{
WEBRTC_TRACE(kTraceError, kTraceVoice,
VoEId(_instanceId, -1),
"SetRecordingDevice() failed to initialize "
"recording");
VoEId(_shared->instance_id(), -1),
"SetRecordingDevice() failed to initialize recording");
return -1;
}
if (_audioDevicePtr->StartRecording() != 0)
if (_shared->audio_device()->StartRecording() != 0)
{
WEBRTC_TRACE(kTraceError, kTraceVoice,
VoEId(_instanceId, -1),
VoEId(_shared->instance_id(), -1),
"SetRecordingDevice() failed to start recording");
return -1;
}
@ -476,15 +471,15 @@ int VoEHardwareImpl::SetRecordingDevice(int index,
int VoEHardwareImpl::SetPlayoutDevice(int index)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetPlayoutDevice(index=%d)", index);
CriticalSectionScoped cs(_apiCritPtr);
ANDROID_NOT_SUPPORTED(_engineStatistics);
CriticalSectionScoped cs(_shared->crit_sec());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
@ -492,16 +487,15 @@ int VoEHardwareImpl::SetPlayoutDevice(int index)
// Store state about activated playout to be able to restore it after the
// playout device has been modified.
if (_audioDevicePtr->Playing())
if (_shared->audio_device()->Playing())
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetPlayoutDevice() device is modified while playout is "
"active...");
isPlaying = true;
if (_audioDevicePtr->StopPlayout() == -1)
if (_shared->audio_device()->StopPlayout() == -1)
{
_engineStatistics.SetLastError(
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
_shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
"SetPlayoutDevice() unable to stop playout");
return -1;
}
@ -516,63 +510,61 @@ int VoEHardwareImpl::SetPlayoutDevice(int index)
if (index == -1)
{
res = _audioDevicePtr->SetPlayoutDevice(
res = _shared->audio_device()->SetPlayoutDevice(
AudioDeviceModule::kDefaultCommunicationDevice);
}
else if (index == -2)
{
res = _audioDevicePtr->SetPlayoutDevice(
res = _shared->audio_device()->SetPlayoutDevice(
AudioDeviceModule::kDefaultDevice);
}
else
{
res = _audioDevicePtr->SetPlayoutDevice(indexU);
res = _shared->audio_device()->SetPlayoutDevice(indexU);
}
if (res != 0)
{
_engineStatistics.SetLastError(
VE_SOUNDCARD_ERROR, kTraceError,
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceError,
"SetPlayoutDevice() unable to set the playout device");
return -1;
}
// Init speaker, so user can do volume settings etc
if (_audioDevicePtr->InitSpeaker() == -1)
if (_shared->audio_device()->InitSpeaker() == -1)
{
_engineStatistics.SetLastError(
VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceWarning,
_shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceWarning,
"SetPlayoutDevice() cannot access speaker");
}
// Set number of channels
bool available(false);
_audioDevicePtr->StereoPlayoutIsAvailable(&available);
if (_audioDevicePtr->SetStereoPlayout(available ? true : false) != 0)
bool available = false;
_shared->audio_device()->StereoPlayoutIsAvailable(&available);
if (_shared->audio_device()->SetStereoPlayout(available) != 0)
{
_engineStatistics.SetLastError(
VE_SOUNDCARD_ERROR, kTraceWarning,
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
"SetPlayoutDevice() failed to set stereo playout mode");
}
// Restore playout if it was enabled already when calling this function.
if (isPlaying)
{
if (!_externalPlayout)
if (!_shared->ext_playout())
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"SetPlayoutDevice() playout is now being restored...");
if (_audioDevicePtr->InitPlayout() != 0)
WEBRTC_TRACE(kTraceInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"SetPlayoutDevice() playout is now being restored...");
if (_shared->audio_device()->InitPlayout() != 0)
{
WEBRTC_TRACE(kTraceError, kTraceVoice,
VoEId(_instanceId, -1),
"SetPlayoutDevice() failed to initialize playout");
VoEId(_shared->instance_id(), -1),
"SetPlayoutDevice() failed to initialize playout");
return -1;
}
if (_audioDevicePtr->StartPlayout() != 0)
if (_shared->audio_device()->StartPlayout() != 0)
{
WEBRTC_TRACE(kTraceError, kTraceVoice,
VoEId(_instanceId, -1),
VoEId(_shared->instance_id(), -1),
"SetPlayoutDevice() failed to start playout");
return -1;
}
@ -584,14 +576,14 @@ int VoEHardwareImpl::SetPlayoutDevice(int index)
int VoEHardwareImpl::GetRecordingDeviceStatus(bool& isAvailable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRecordingDeviceStatus()");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
@ -600,31 +592,32 @@ int VoEHardwareImpl::GetRecordingDeviceStatus(bool& isAvailable)
bool available(false);
// Check availability
if (_audioDevicePtr->RecordingIsAvailable(&available) != 0)
if (_shared->audio_device()->RecordingIsAvailable(&available) != 0)
{
_engineStatistics.SetLastError(VE_UNDEFINED_SC_REC_ERR, kTraceError,
" Audio Device error");
_shared->SetLastError(VE_UNDEFINED_SC_REC_ERR, kTraceError,
" Audio Device error");
return -1;
}
isAvailable = available;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: isAvailable = %d)", (int) isAvailable);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: isAvailable = %d)", (int) isAvailable);
return 0;
}
int VoEHardwareImpl::GetPlayoutDeviceStatus(bool& isAvailable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetPlayoutDeviceStatus()");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
@ -633,43 +626,44 @@ int VoEHardwareImpl::GetPlayoutDeviceStatus(bool& isAvailable)
bool available(false);
// Check availability
if (_audioDevicePtr->PlayoutIsAvailable(&available) != 0)
if (_shared->audio_device()->PlayoutIsAvailable(&available) != 0)
{
_engineStatistics.SetLastError(VE_PLAY_UNDEFINED_SC_ERR,
kTraceError, " Audio Device error");
_shared->SetLastError(VE_PLAY_UNDEFINED_SC_ERR, kTraceError,
" Audio Device error");
return -1;
}
isAvailable = available;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: isAvailable = %d)", (int) isAvailable);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: isAvailable = %d)", (int) isAvailable);
return 0;
}
int VoEHardwareImpl::ResetAudioDevice()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"ResetAudioDevice()");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
#if defined(MAC_IPHONE)
if (_audioDevicePtr->ResetAudioDevice() < 0)
if (_shared->audio_device()->ResetAudioDevice() < 0)
{
_engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceError,
" Failed to reset sound device");
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceError,
" Failed to reset sound device");
return -1;
}
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for resetting sound device");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for resetting sound device");
return -1;
#endif
@ -679,126 +673,124 @@ int VoEHardwareImpl::ResetAudioDevice()
int VoEHardwareImpl::AudioDeviceControl(unsigned int par1, unsigned int par2,
unsigned int par3)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"AudioDeviceControl(%i, %i, %i)", par1, par2, par3);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for resetting sound device");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for resetting sound device");
return -1;
}
int VoEHardwareImpl::SetLoudspeakerStatus(bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetLoudspeakerStatus(enable=%i)", (int) enable);
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
#if defined(WEBRTC_ANDROID)
if (_audioDevicePtr->SetLoudspeakerStatus(enable) < 0)
if (_shared->audio_device()->SetLoudspeakerStatus(enable) < 0)
{
_engineStatistics.SetLastError(VE_IGNORED_FUNCTION, kTraceError,
" Failed to set loudspeaker status");
_shared->SetLastError(VE_IGNORED_FUNCTION, kTraceError,
" Failed to set loudspeaker status");
return -1;
}
return 0;
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for setting loudspeaker"
" status");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for setting loudspeaker status");
return -1;
#endif
}
int VoEHardwareImpl::GetLoudspeakerStatus(bool& enabled)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetLoudspeakerStatus()");
IPHONE_NOT_SUPPORTED();
#if defined(WEBRTC_ANDROID)
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (_audioDevicePtr->GetLoudspeakerStatus(&enabled) < 0)
if (_shared->audio_device()->GetLoudspeakerStatus(&enabled) < 0)
{
_engineStatistics.SetLastError(VE_IGNORED_FUNCTION, kTraceError,
" Failed to get loudspeaker status");
_shared->SetLastError(VE_IGNORED_FUNCTION, kTraceError,
" Failed to get loudspeaker status");
return -1;
}
return 0;
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for setting loudspeaker "
"status");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for setting loudspeaker status");
return -1;
#endif
}
int VoEHardwareImpl::GetCPULoad(int& loadPercent)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetCPULoad()");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
// Get CPU load from ADM
WebRtc_UWord16 load(0);
if (_audioDevicePtr->CPULoad(&load) != 0)
if (_shared->audio_device()->CPULoad(&load) != 0)
{
_engineStatistics.SetLastError(VE_CPU_INFO_ERROR, kTraceError,
" error getting system CPU load");
_shared->SetLastError(VE_CPU_INFO_ERROR, kTraceError,
" error getting system CPU load");
return -1;
}
loadPercent = static_cast<int> (load);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: loadPercent = %d", loadPercent);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: loadPercent = %d", loadPercent);
return 0;
}
int VoEHardwareImpl::GetSystemCPULoad(int& loadPercent)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSystemCPULoad(loadPercent=?)");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
// Check if implemented for this platform
if (!_cpu)
{
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for getting system CPU "
"load");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
" no support for getting system CPU load");
return -1;
}
@ -806,43 +798,44 @@ int VoEHardwareImpl::GetSystemCPULoad(int& loadPercent)
WebRtc_Word32 load = _cpu->CpuUsage();
if (load < 0)
{
_engineStatistics.SetLastError(VE_CPU_INFO_ERROR, kTraceError,
" error getting system CPU load");
_shared->SetLastError(VE_CPU_INFO_ERROR, kTraceError,
" error getting system CPU load");
return -1;
}
loadPercent = static_cast<int> (load);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
" Output: loadPercent = %d", loadPercent);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
" Output: loadPercent = %d", loadPercent);
return 0;
}
int VoEHardwareImpl::EnableBuiltInAEC(bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"%s", __FUNCTION__);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
return _audioDevicePtr->EnableBuiltInAEC(enable);
return _shared->audio_device()->EnableBuiltInAEC(enable);
}
bool VoEHardwareImpl::BuiltInAECIsEnabled() const
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"%s", __FUNCTION__);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return false;
}
return _audioDevicePtr->BuiltInAECIsEnabled();
return _shared->audio_device()->BuiltInAECIsEnabled();
}
#endif // WEBRTC_VOICE_ENGINE_HARDWARE_API

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -20,8 +20,7 @@ namespace webrtc
{
class CpuWrapper;
class VoEHardwareImpl: public virtual voe::SharedData,
public VoEHardware,
class VoEHardwareImpl: public VoEHardware,
public voe::RefCount
{
public:
@ -71,11 +70,12 @@ public:
virtual bool BuiltInAECIsEnabled() const;
protected:
VoEHardwareImpl();
VoEHardwareImpl(voe::SharedData* shared);
virtual ~VoEHardwareImpl();
private:
CpuWrapper* _cpu;
CpuWrapper* _cpu;
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -39,55 +39,54 @@ VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
VoENetEqStatsImpl::VoENetEqStatsImpl()
VoENetEqStatsImpl::VoENetEqStatsImpl(voe::SharedData* shared) : _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoENetEqStatsImpl::VoENetEqStatsImpl() - ctor");
}
VoENetEqStatsImpl::~VoENetEqStatsImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor");
}
int VoENetEqStatsImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoENetEqStats::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_engineStatistics.SetLastError(
VE_INTERFACE_NOT_FOUND, kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"VoENetEqStats reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoENetEqStats reference counter = %d", refCount);
return (refCount);
}
int VoENetEqStatsImpl::GetNetworkStatistics(int channel,
NetworkStatistics& stats)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetNetworkStatistics(channel=%d, stats=?)", channel);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::Channel* channelPtr = sc.ChannelPtr();
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetNetworkStatistics() failed to locate channel");
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -18,8 +18,7 @@
namespace webrtc {
class VoENetEqStatsImpl : public virtual voe::SharedData,
public VoENetEqStats,
class VoENetEqStatsImpl : public VoENetEqStats,
public voe::RefCount
{
public:
@ -29,8 +28,11 @@ public:
NetworkStatistics& stats);
protected:
VoENetEqStatsImpl();
VoENetEqStatsImpl(voe::SharedData* shared);
virtual ~VoENetEqStatsImpl();
private:
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -38,53 +38,52 @@ VoENetwork* VoENetwork::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_NETWORK_API
VoENetworkImpl::VoENetworkImpl()
VoENetworkImpl::VoENetworkImpl(voe::SharedData* shared) : _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoENetworkImpl() - ctor");
}
VoENetworkImpl::~VoENetworkImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"~VoENetworkImpl() - dtor");
}
int VoENetworkImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoENetworkImpl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset();
_engineStatistics.SetLastError(VE_INTERFACE_NOT_FOUND,
kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"VoENetworkImpl reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoENetworkImpl reference counter = %d", refCount);
return (refCount);
}
int VoENetworkImpl::RegisterExternalTransport(int channel,
Transport& transport)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetExternalTransport(channel=%d, transport=0x%x)",
channel, &transport);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetExternalTransport() failed to locate channel");
return -1;
}
@ -93,19 +92,18 @@ int VoENetworkImpl::RegisterExternalTransport(int channel,
int VoENetworkImpl::DeRegisterExternalTransport(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DeRegisterExternalTransport(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DeRegisterExternalTransport() failed to locate channel");
return -1;
}
@ -116,41 +114,37 @@ int VoENetworkImpl::ReceivedRTPPacket(int channel,
const void* data,
unsigned int length)
{
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_shared->instance_id(), -1),
"ReceivedRTPPacket(channel=%d, length=%u)", channel, length);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if ((length < 12) || (length > 807))
{
_engineStatistics.SetLastError(
VE_INVALID_PACKET, kTraceError,
_shared->SetLastError(VE_INVALID_PACKET, kTraceError,
"ReceivedRTPPacket() invalid packet length");
return -1;
}
if (NULL == data)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"ReceivedRTPPacket() invalid data vector");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"ReceivedRTPPacket() failed to locate channel");
return -1;
}
if (!channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_INVALID_OPERATION, kTraceError,
_shared->SetLastError(VE_INVALID_OPERATION, kTraceError,
"ReceivedRTPPacket() external transport is not enabled");
return -1;
}
@ -160,40 +154,36 @@ int VoENetworkImpl::ReceivedRTPPacket(int channel,
int VoENetworkImpl::ReceivedRTCPPacket(int channel, const void* data,
unsigned int length)
{
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_shared->instance_id(), -1),
"ReceivedRTCPPacket(channel=%d, length=%u)", channel, length);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (length < 4)
{
_engineStatistics.SetLastError(
VE_INVALID_PACKET, kTraceError,
_shared->SetLastError(VE_INVALID_PACKET, kTraceError,
"ReceivedRTCPPacket() invalid packet length");
return -1;
}
if (NULL == data)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"ReceivedRTCPPacket() invalid data vector");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"ReceivedRTCPPacket() failed to locate channel");
return -1;
}
if (!channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_INVALID_OPERATION, kTraceError,
_shared->SetLastError(VE_INVALID_OPERATION, kTraceError,
"ReceivedRTCPPacket() external transport is not enabled");
return -1;
}
@ -205,42 +195,38 @@ int VoENetworkImpl::GetSourceInfo(int channel,
int& rtcpPort,
char ipAddr[64])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSourceInfo(channel=%d, rtpPort=?, rtcpPort=?, ipAddr[]=?)",
channel);
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (NULL == ipAddr)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"GetSourceInfo() invalid IP-address buffer");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSourceInfo() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"GetSourceInfo() external transport is enabled");
return -1;
}
return channelPtr->GetSourceInfo(rtpPort, rtcpPort, ipAddr);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"GetSourceInfo() VoE is built for external transport");
return -1;
#endif
@ -248,19 +234,18 @@ int VoENetworkImpl::GetSourceInfo(int channel,
int VoENetworkImpl::GetLocalIP(char ipAddr[64], bool ipv6)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetLocalIP(ipAddr[]=?, ipv6=%d)", ipv6);
IPHONE_NOT_SUPPORTED();
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (NULL == ipAddr)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"GetLocalIP() invalid IP-address buffer");
return -1;
}
@ -274,8 +259,7 @@ int VoENetworkImpl::GetLocalIP(char ipAddr[64], bool ipv6)
numSockThreads);
if (NULL == socketPtr)
{
_engineStatistics.SetLastError(
VE_SOCKET_TRANSPORT_MODULE_ERROR, kTraceError,
_shared->SetLastError(VE_SOCKET_TRANSPORT_MODULE_ERROR, kTraceError,
"GetLocalIP() failed to create socket module");
return -1;
}
@ -287,8 +271,7 @@ int VoENetworkImpl::GetLocalIP(char ipAddr[64], bool ipv6)
char localIP[16];
if (socketPtr->LocalHostAddressIPV6(localIP) != 0)
{
_engineStatistics.SetLastError(
VE_INVALID_IP_ADDRESS, kTraceError,
_shared->SetLastError(VE_INVALID_IP_ADDRESS, kTraceError,
"GetLocalIP() failed to retrieve local IP - 1");
UdpTransport::Destroy(socketPtr);
return -1;
@ -308,8 +291,7 @@ int VoENetworkImpl::GetLocalIP(char ipAddr[64], bool ipv6)
// Read local IP (as 32-bit address) from the socket module
if (socketPtr->LocalHostAddress(localIP) != 0)
{
_engineStatistics.SetLastError(
VE_INVALID_IP_ADDRESS, kTraceError,
_shared->SetLastError(VE_INVALID_IP_ADDRESS, kTraceError,
"GetLocalIP() failed to retrieve local IP - 2");
UdpTransport::Destroy(socketPtr);
return -1;
@ -325,12 +307,12 @@ int VoENetworkImpl::GetLocalIP(char ipAddr[64], bool ipv6)
UdpTransport::Destroy(socketPtr);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"GetLocalIP() => ipAddr=%s", ipAddr);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetLocalIP() => ipAddr=%s", ipAddr);
return 0;
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"GetLocalIP() VoE is built for external transport");
return -1;
#endif
@ -338,36 +320,33 @@ int VoENetworkImpl::GetLocalIP(char ipAddr[64], bool ipv6)
int VoENetworkImpl::EnableIPv6(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"EnableIPv6(channel=%d)", channel);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"EnableIPv6() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"EnableIPv6() external transport is enabled");
return -1;
}
return channelPtr->EnableIPv6();
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"EnableIPv6() VoE is built for external transport");
return -1;
#endif
@ -375,34 +354,31 @@ int VoENetworkImpl::EnableIPv6(int channel)
bool VoENetworkImpl::IPv6IsEnabled(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"IPv6IsEnabled(channel=%d)", channel);
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return false;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"IPv6IsEnabled() failed to locate channel");
return false;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"IPv6IsEnabled() external transport is enabled");
return false;
}
return channelPtr->IPv6IsEnabled();
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"IPv6IsEnabled() VoE is built for external transport");
return false;
#endif
@ -414,55 +390,50 @@ int VoENetworkImpl::SetSourceFilter(int channel,
const char ipAddr[64])
{
(ipAddr == NULL) ? WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
VoEId(_instanceId, -1),
VoEId(_shared->instance_id(), -1),
"SetSourceFilter(channel=%d, rtpPort=%d,"
" rtcpPort=%d)",
channel, rtpPort, rtcpPort)
: WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
VoEId(_instanceId, -1),
VoEId(_shared->instance_id(), -1),
"SetSourceFilter(channel=%d, rtpPort=%d,"
" rtcpPort=%d, ipAddr=%s)",
channel, rtpPort, rtcpPort, ipAddr);
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if ((rtpPort < 0) || (rtpPort > 65535))
{
_engineStatistics.SetLastError(
VE_INVALID_PORT_NMBR, kTraceError,
_shared->SetLastError(VE_INVALID_PORT_NMBR, kTraceError,
"SetSourceFilter() invalid RTP port");
return -1;
}
if ((rtcpPort < 0) || (rtcpPort > 65535))
{
_engineStatistics.SetLastError(
VE_INVALID_PORT_NMBR, kTraceError,
_shared->SetLastError(VE_INVALID_PORT_NMBR, kTraceError,
"SetSourceFilter() invalid RTCP port");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSourceFilter() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"SetSourceFilter() external transport is enabled");
return -1;
}
return channelPtr->SetSourceFilter(rtpPort, rtcpPort, ipAddr);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"SetSourceFilter() VoE is built for external transport");
return -1;
#endif
@ -473,43 +444,39 @@ int VoENetworkImpl::GetSourceFilter(int channel,
int& rtcpPort,
char ipAddr[64])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSourceFilter(channel=%d, rtpPort=?, rtcpPort=?, "
"ipAddr[]=?)",
channel);
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (NULL == ipAddr)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"GetSourceFilter() invalid IP-address buffer");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSourceFilter() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"GetSourceFilter() external transport is enabled");
return -1;
}
return channelPtr->GetSourceFilter(rtpPort, rtcpPort, ipAddr);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"GetSourceFilter() VoE is built for external transport");
return -1;
#endif
@ -520,41 +487,40 @@ int VoENetworkImpl::SetSendTOS(int channel,
int priority,
bool useSetSockopt)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetSendTOS(channel=%d, DSCP=%d, useSetSockopt=%d)",
channel, DSCP, useSetSockopt);
#if !defined(_WIN32) && !defined(WEBRTC_LINUX) && !defined(WEBRTC_MAC)
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceWarning,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceWarning,
"SetSendTOS() is not supported on this platform");
return -1;
#endif
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if ((DSCP < 0) || (DSCP > 63))
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendTOS() Invalid DSCP value");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendTOS() Invalid DSCP value");
return -1;
}
#if defined(_WIN32) || defined(WEBRTC_LINUX)
if ((priority < -1) || (priority > 7))
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendTOS() Invalid priority value");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendTOS() Invalid priority value");
return -1;
}
#else
if (-1 != priority)
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendTOS() priority not supported");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendTOS() priority not supported");
return -1;
}
#endif
@ -562,38 +528,35 @@ int VoENetworkImpl::SetSendTOS(int channel,
if ((priority >= 0) && useSetSockopt)
{
// On Windows, priority and useSetSockopt cannot be combined
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSendTOS() priority and useSetSockopt conflict");
return -1;
}
#endif
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSendTOS() failed to locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSendTOS() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"SetSendTOS() external transport is enabled");
return -1;
}
#if defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
useSetSockopt = true;
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1),
" force useSetSockopt=true since there is no alternative"
" implementation");
#endif
return channelPtr->SetSendTOS(DSCP, priority, useSetSockopt);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"SetSendTOS() VoE is built for external transport");
return -1;
#endif
@ -604,40 +567,37 @@ int VoENetworkImpl::GetSendTOS(int channel,
int& priority,
bool& useSetSockopt)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSendTOS(channel=%d)", channel);
#if !defined(_WIN32) && !defined(WEBRTC_LINUX) && !defined(WEBRTC_MAC)
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceWarning,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceWarning,
"GetSendTOS() is not supported on this platform");
return -1;
#endif
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendTOS() failed to locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendTOS() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"GetSendTOS() external transport is enabled");
return -1;
}
return channelPtr->GetSendTOS(DSCP, priority, useSetSockopt);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"GetSendTOS() VoE is built for external transport");
return -1;
#endif
@ -648,42 +608,39 @@ int VoENetworkImpl::SetSendGQoS(int channel,
int serviceType,
int overrideDSCP)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetSendGQOS(channel=%d, enable=%d, serviceType=%d,"
" overrideDSCP=%d)",
channel, (int) enable, serviceType, overrideDSCP);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#if !defined(_WIN32)
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceWarning,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceWarning,
"SetSendGQOS() is not supported on this platform");
return -1;
#elif !defined(WEBRTC_EXTERNAL_TRANSPORT)
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSendGQOS() failed to locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetSendGQOS() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"SetSendGQOS() external transport is enabled");
return -1;
}
return channelPtr->SetSendGQoS(enable, serviceType, overrideDSCP);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"SetSendGQOS() VoE is built for external transport");
return -1;
#endif
@ -694,40 +651,37 @@ int VoENetworkImpl::GetSendGQoS(int channel,
int& serviceType,
int& overrideDSCP)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSendGQOS(channel=%d)", channel);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
#if !defined(_WIN32)
_engineStatistics.SetLastError(
VE_FUNC_NOT_SUPPORTED, kTraceWarning,
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceWarning,
"GetSendGQOS() is not supported on this platform");
return -1;
#elif !defined(WEBRTC_EXTERNAL_TRANSPORT)
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendGQOS() failed to locate channel");
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSendGQOS() failed to locate channel");
return -1;
}
if (channelPtr->ExternalTransport())
{
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceError,
"GetSendGQOS() external transport is enabled");
return -1;
}
return channelPtr->GetSendGQoS(enabled, serviceType, overrideDSCP);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"GetSendGQOS() VoE is built for external transport");
return -1;
#endif
@ -737,30 +691,28 @@ int VoENetworkImpl::SetPacketTimeoutNotification(int channel,
bool enable,
int timeoutSeconds)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetPacketTimeoutNotification(channel=%d, enable=%d, "
"timeoutSeconds=%d)",
channel, (int) enable, timeoutSeconds);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (enable &&
((timeoutSeconds < kVoiceEngineMinPacketTimeoutSec) ||
(timeoutSeconds > kVoiceEngineMaxPacketTimeoutSec)))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetPacketTimeoutNotification() invalid timeout size");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetPacketTimeoutNotification() failed to locate channel");
return -1;
}
@ -771,20 +723,19 @@ int VoENetworkImpl::GetPacketTimeoutNotification(int channel,
bool& enabled,
int& timeoutSeconds)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetPacketTimeoutNotification(channel=%d, enabled=?,"
" timeoutSeconds=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetPacketTimeoutNotification() failed to locate channel");
return -1;
}
@ -795,20 +746,19 @@ int VoENetworkImpl::RegisterDeadOrAliveObserver(int channel,
VoEConnectionObserver&
observer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"RegisterDeadOrAliveObserver(channel=%d, observer=0x%x)",
channel, &observer);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterDeadOrAliveObserver() failed to locate channel");
return -1;
}
@ -817,19 +767,18 @@ int VoENetworkImpl::RegisterDeadOrAliveObserver(int channel,
int VoENetworkImpl::DeRegisterDeadOrAliveObserver(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DeRegisterDeadOrAliveObserver(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DeRegisterDeadOrAliveObserver() failed to locate channel");
return -1;
}
@ -839,30 +788,28 @@ int VoENetworkImpl::DeRegisterDeadOrAliveObserver(int channel)
int VoENetworkImpl::SetPeriodicDeadOrAliveStatus(int channel, bool enable,
int sampleTimeSeconds)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetPeriodicDeadOrAliveStatus(channel=%d, enable=%d,"
" sampleTimeSeconds=%d)",
channel, enable, sampleTimeSeconds);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (enable &&
((sampleTimeSeconds < kVoiceEngineMinSampleTimeSec) ||
(sampleTimeSeconds > kVoiceEngineMaxSampleTimeSec)))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetPeriodicDeadOrAliveStatus() invalid sample time");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetPeriodicDeadOrAliveStatus() failed to locate channel");
return -1;
}
@ -873,20 +820,19 @@ int VoENetworkImpl::GetPeriodicDeadOrAliveStatus(int channel,
bool& enabled,
int& sampleTimeSeconds)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetPeriodicDeadOrAliveStatus(channel=%d, enabled=?,"
" sampleTimeSeconds=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetPeriodicDeadOrAliveStatus() failed to locate channel");
return -1;
}
@ -900,33 +846,32 @@ int VoENetworkImpl::SendUDPPacket(int channel,
int& transmittedBytes,
bool useRtcpSocket)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SendUDPPacket(channel=%d, data=0x%x, length=%u, useRTCP=%d)",
channel, data, length, useRtcpSocket);
#ifndef WEBRTC_EXTERNAL_TRANSPORT
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (NULL == data)
{
_engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SendUDPPacket() invalid data buffer");
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SendUDPPacket() invalid data buffer");
return -1;
}
if (0 == length)
{
_engineStatistics.SetLastError(VE_INVALID_PACKET, kTraceError,
"SendUDPPacket() invalid packet size");
_shared->SetLastError(VE_INVALID_PACKET, kTraceError,
"SendUDPPacket() invalid packet size");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SendUDPPacket() failed to locate channel");
return -1;
}
@ -935,8 +880,7 @@ int VoENetworkImpl::SendUDPPacket(int channel,
transmittedBytes,
useRtcpSocket);
#else
_engineStatistics.SetLastError(
VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
_shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning,
"SendUDPPacket() VoE is built for external transport");
return -1;
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -20,8 +20,7 @@
namespace webrtc
{
class VoENetworkImpl: public virtual voe::SharedData,
public VoENetwork,
class VoENetworkImpl: public VoENetwork,
public voe::RefCount
{
public:
@ -108,8 +107,10 @@ public:
bool useRtcpSocket = false);
protected:
VoENetworkImpl();
VoENetworkImpl(voe::SharedData* shared);
virtual ~VoENetworkImpl();
private:
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -38,52 +38,51 @@ VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
VoERTP_RTCPImpl::VoERTP_RTCPImpl()
VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor");
}
VoERTP_RTCPImpl::~VoERTP_RTCPImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor");
}
int VoERTP_RTCPImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoERTP_RTCP::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_engineStatistics.SetLastError(
VE_INTERFACE_NOT_FOUND, kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"VoERTP_RTCP reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoERTP_RTCP reference counter = %d", refCount);
return (refCount);
}
int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"RegisterRTPObserver(channel=%d observer=0x%x)",
channel, &observer);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterRTPObserver() failed to locate channel");
return -1;
}
@ -92,19 +91,18 @@ int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer)
int VoERTP_RTCPImpl::DeRegisterRTPObserver(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DeRegisterRTPObserver(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DeRegisterRTPObserver() failed to locate channel");
return -1;
}
@ -113,20 +111,19 @@ int VoERTP_RTCPImpl::DeRegisterRTPObserver(int channel)
int VoERTP_RTCPImpl::RegisterRTCPObserver(int channel, VoERTCPObserver& observer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"RegisterRTCPObserver(channel=%d observer=0x%x)",
channel, &observer);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"RegisterRTPObserver() failed to locate channel");
return -1;
}
@ -135,19 +132,18 @@ int VoERTP_RTCPImpl::RegisterRTCPObserver(int channel, VoERTCPObserver& observer
int VoERTP_RTCPImpl::DeRegisterRTCPObserver(int channel)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"DeRegisterRTCPObserver(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"DeRegisterRTCPObserver() failed to locate channel");
return -1;
}
@ -156,19 +152,18 @@ int VoERTP_RTCPImpl::DeRegisterRTCPObserver(int channel)
int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetLocalSSRC(channel=%d, %lu)", channel, ssrc);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetLocalSSRC() failed to locate channel");
return -1;
}
@ -177,19 +172,18 @@ int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc)
int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetLocalSSRC(channel=%d, ssrc=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetLocalSSRC() failed to locate channel");
return -1;
}
@ -198,19 +192,18 @@ int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc)
int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRemoteSSRC(channel=%d, ssrc=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRemoteSSRC() failed to locate channel");
return -1;
}
@ -219,19 +212,18 @@ int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc)
int VoERTP_RTCPImpl::GetRemoteCSRCs(int channel, unsigned int arrCSRC[15])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRemoteCSRCs(channel=%d, arrCSRC=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRemoteCSRCs() failed to locate channel");
return -1;
}
@ -243,12 +235,12 @@ int VoERTP_RTCPImpl::SetRTPAudioLevelIndicationStatus(int channel,
bool enable,
unsigned char ID)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetRTPAudioLevelIndicationStatus(channel=%d, enable=%d,"
" ID=%u)", channel, enable, ID);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (ID < kVoiceEngineMinRtpExtensionId ||
@ -256,19 +248,17 @@ int VoERTP_RTCPImpl::SetRTPAudioLevelIndicationStatus(int channel,
{
// [RFC5285] The 4-bit ID is the local identifier of this element in
// the range 1-14 inclusive.
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetRTPAudioLevelIndicationStatus() invalid ID parameter");
return -1;
}
// Set state and ID for the specified channel.
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetRTPAudioLevelIndicationStatus() failed to locate channel");
return -1;
}
@ -279,20 +269,19 @@ int VoERTP_RTCPImpl::GetRTPAudioLevelIndicationStatus(int channel,
bool& enabled,
unsigned char& ID)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRTPAudioLevelIndicationStatus(channel=%d, enable=?, ID=?)",
channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRTPAudioLevelIndicationStatus() failed to locate channel");
return -1;
}
@ -301,19 +290,18 @@ int VoERTP_RTCPImpl::GetRTPAudioLevelIndicationStatus(int channel,
int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetRTCPStatus(channel=%d, enable=%d)", channel, enable);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetRTCPStatus() failed to locate channel");
return -1;
}
@ -322,19 +310,18 @@ int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable)
int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRTCPStatus(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRTCPStatus() failed to locate channel");
return -1;
}
@ -343,19 +330,18 @@ int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled)
int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetRTCP_CNAME() failed to locate channel");
return -1;
}
@ -364,19 +350,18 @@ int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256])
int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRTCP_CNAME(channel=%d, cName=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRTCP_CNAME() failed to locate channel");
return -1;
}
@ -385,19 +370,18 @@ int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256])
int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256])
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRemoteRTCP_CNAME() failed to locate channel");
return -1;
}
@ -413,19 +397,18 @@ int VoERTP_RTCPImpl::GetRemoteRTCPData(
unsigned int* jitter, // from report block 1 in SR/RR
unsigned short* fractionLost) // from report block 1 in SR/RR
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRemoteRTCPData(channel=%d,...)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRemoteRTCP_CNAME() failed to locate channel");
return -1;
}
@ -444,21 +427,20 @@ int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
const char* data,
unsigned short dataLengthInBytes)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SendApplicationDefinedRTCPPacket(channel=%d, subType=%u,"
"name=%u, data=?, dataLengthInBytes=%u)",
channel, subType, name, dataLengthInBytes);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SendApplicationDefinedRTCPPacket() failed to locate channel");
return -1;
}
@ -473,19 +455,18 @@ int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
unsigned int& maxJitterMs,
unsigned int& discardedPackets)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRTPStatistics(channel=%d,....)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRTPStatistics() failed to locate channel");
return -1;
}
@ -496,19 +477,18 @@ int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRTCPStatistics(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRTPStatistics() failed to locate channel");
return -1;
}
@ -517,28 +497,27 @@ int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetFECStatus(channel=%d, enable=%d, redPayloadtype=%d)",
channel, enable, redPayloadtype);
#ifdef WEBRTC_CODEC_RED
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetFECStatus() failed to locate channel");
return -1;
}
return channelPtr->SetFECStatus(enable, redPayloadtype);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetFECStatus() RED is not supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"SetFECStatus() RED is not supported");
return -1;
#endif
}
@ -547,28 +526,27 @@ int VoERTP_RTCPImpl::GetFECStatus(int channel,
bool& enabled,
int& redPayloadtype)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetFECStatus(channel=%d, enabled=?, redPayloadtype=?)",
channel);
#ifdef WEBRTC_CODEC_RED
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetFECStatus() failed to locate channel");
return -1;
}
return channelPtr->GetFECStatus(enabled, redPayloadtype);
#else
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"GetFECStatus() RED is not supported");
_shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
"GetFECStatus() RED is not supported");
return -1;
#endif
}
@ -577,21 +555,20 @@ int VoERTP_RTCPImpl::StartRTPDump(int channel,
const char fileNameUTF8[1024],
RTPDirections direction)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)",
channel, fileNameUTF8, direction);
assert(1024 == FileWrapper::kMaxFileNameSize);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"StartRTPDump() failed to locate channel");
return -1;
}
@ -600,19 +577,18 @@ int VoERTP_RTCPImpl::StartRTPDump(int channel,
int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"StopRTPDump(channel=%d, direction=%d)", channel, direction);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"StopRTPDump() failed to locate channel");
return -1;
}
@ -621,20 +597,19 @@ int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction)
int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"RTPDumpIsActive(channel=%d, direction=%d)",
channel, direction);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"StopRTPDump() failed to locate channel");
return -1;
}
@ -647,21 +622,20 @@ int VoERTP_RTCPImpl::InsertExtraRTPPacket(int channel,
const char* payloadData,
unsigned short payloadSize)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"InsertExtraRTPPacket(channel=%d, payloadType=%u,"
" markerBit=%u, payloadSize=%u)",
channel, payloadType, markerBit, payloadSize);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"StopRTPDump() failed to locate channel");
return -1;
}

View File

@ -18,8 +18,7 @@
namespace webrtc {
class VoERTP_RTCPImpl : public virtual voe::SharedData,
public VoERTP_RTCP,
class VoERTP_RTCPImpl : public VoERTP_RTCP,
public voe::RefCount
{
public:
@ -113,8 +112,11 @@ public:
unsigned short payloadSize);
protected:
VoERTP_RTCPImpl();
VoERTP_RTCPImpl(voe::SharedData* shared);
virtual ~VoERTP_RTCPImpl();
private:
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -37,54 +37,53 @@ VoEVideoSync* VoEVideoSync::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
VoEVideoSyncImpl::VoEVideoSyncImpl(voe::SharedData* data) : _data(data)
VoEVideoSyncImpl::VoEVideoSyncImpl(voe::SharedData* shared) : _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVideoSyncImpl::VoEVideoSyncImpl() - ctor");
}
VoEVideoSyncImpl::~VoEVideoSyncImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVideoSyncImpl::~VoEVideoSyncImpl() - dtor");
}
int VoEVideoSyncImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVideoSync::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_data->statistics().SetLastError(VE_INTERFACE_NOT_FOUND,
kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_data->instance_id(),-1),
"VoEVideoSync reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEVideoSync reference counter = %d", refCount);
return (refCount);
}
int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, unsigned int& timestamp)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetPlayoutTimestamp(channel=%d, timestamp=?)", channel);
ANDROID_NOT_SUPPORTED(_data->statistics());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_data->statistics().Initialized())
if (!_shared->statistics().Initialized())
{
_data->statistics().SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_data->channel_manager(), channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_data->statistics().SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetPlayoutTimestamp() failed to locate channel");
return -1;
}
@ -94,23 +93,22 @@ int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, unsigned int& timestamp)
int VoEVideoSyncImpl::SetInitTimestamp(int channel,
unsigned int timestamp)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetInitTimestamp(channel=%d, timestamp=%lu)",
channel, timestamp);
ANDROID_NOT_SUPPORTED(_data->statistics());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_data->statistics().Initialized())
if (!_shared->statistics().Initialized())
{
_data->statistics().SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_data->channel_manager(), channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_data->statistics().SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetInitTimestamp() failed to locate channel");
return -1;
}
@ -120,23 +118,22 @@ int VoEVideoSyncImpl::SetInitTimestamp(int channel,
int VoEVideoSyncImpl::SetInitSequenceNumber(int channel,
short sequenceNumber)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetInitSequenceNumber(channel=%d, sequenceNumber=%hd)",
channel, sequenceNumber);
ANDROID_NOT_SUPPORTED(_data->statistics());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_data->statistics().Initialized())
if (!_shared->statistics().Initialized())
{
_data->statistics().SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_data->channel_manager(), channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_data->statistics().SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetInitSequenceNumber() failed to locate channel");
return -1;
}
@ -145,23 +142,22 @@ int VoEVideoSyncImpl::SetInitSequenceNumber(int channel,
int VoEVideoSyncImpl::SetMinimumPlayoutDelay(int channel,int delayMs)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetMinimumPlayoutDelay(channel=%d, delayMs=%d)",
channel, delayMs);
ANDROID_NOT_SUPPORTED(_data->statistics());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_data->statistics().Initialized())
if (!_shared->statistics().Initialized())
{
_data->statistics().SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_data->channel_manager(), channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_data->statistics().SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetMinimumPlayoutDelay() failed to locate channel");
return -1;
}
@ -170,22 +166,21 @@ int VoEVideoSyncImpl::SetMinimumPlayoutDelay(int channel,int delayMs)
int VoEVideoSyncImpl::GetDelayEstimate(int channel, int& delayMs)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetDelayEstimate(channel=%d, delayMs=?)", channel);
ANDROID_NOT_SUPPORTED(_data->statistics());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_data->statistics().Initialized())
if (!_shared->statistics().Initialized())
{
_data->statistics().SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_data->channel_manager(), channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_data->statistics().SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetDelayEstimate() failed to locate channel");
return -1;
}
@ -194,48 +189,47 @@ int VoEVideoSyncImpl::GetDelayEstimate(int channel, int& delayMs)
int VoEVideoSyncImpl::GetPlayoutBufferSize(int& bufferMs)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetPlayoutBufferSize(bufferMs=?)");
ANDROID_NOT_SUPPORTED(_data->statistics());
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_data->statistics().Initialized())
if (!_shared->statistics().Initialized())
{
_data->statistics().SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
AudioDeviceModule::BufferType type
(AudioDeviceModule::kFixedBufferSize);
WebRtc_UWord16 sizeMS(0);
if (_data->audio_device()->PlayoutBuffer(&type, &sizeMS) != 0)
if (_shared->audio_device()->PlayoutBuffer(&type, &sizeMS) != 0)
{
_data->statistics().SetLastError(
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
_shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
"GetPlayoutBufferSize() failed to read buffer size");
return -1;
}
bufferMs = sizeMS;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_data->instance_id(),-1),
"GetPlayoutBufferSize() => bufferMs=%d", bufferMs);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetPlayoutBufferSize() => bufferMs=%d", bufferMs);
return 0;
}
int VoEVideoSyncImpl::GetRtpRtcp(int channel, RtpRtcp* &rtpRtcpModule)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRtpRtcp(channel=%i)", channel);
if (!_data->statistics().Initialized())
if (!_shared->statistics().Initialized())
{
_data->statistics().SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_data->channel_manager(), channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_data->statistics().SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetPlayoutTimestamp() failed to locate channel");
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -39,11 +39,11 @@ public:
virtual int GetRtpRtcp(int channel, RtpRtcp* &rtpRtcpModule);
protected:
VoEVideoSyncImpl(voe::SharedData* data);
VoEVideoSyncImpl(voe::SharedData* shared);
virtual ~VoEVideoSyncImpl();
private:
voe::SharedData* _data;
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -39,51 +39,51 @@ VoEVolumeControl* VoEVolumeControl::GetInterface(VoiceEngine* voiceEngine)
#ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
VoEVolumeControlImpl::VoEVolumeControlImpl()
VoEVolumeControlImpl::VoEVolumeControlImpl(voe::SharedData* shared)
: _shared(shared)
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVolumeControlImpl::VoEVolumeControlImpl() - ctor");
}
VoEVolumeControlImpl::~VoEVolumeControlImpl()
{
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVolumeControlImpl::~VoEVolumeControlImpl() - dtor");
}
int VoEVolumeControlImpl::Release()
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"VoEVolumeControl::Release()");
(*this)--;
int refCount = GetCount();
if (refCount < 0)
{
Reset(); // reset reference counter to zero => OK to delete VE
_engineStatistics.SetLastError(
VE_INTERFACE_NOT_FOUND, kTraceWarning);
_shared->SetLastError(VE_INTERFACE_NOT_FOUND, kTraceWarning);
return (-1);
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"VoEVolumeControl reference counter = %d", refCount);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"VoEVolumeControl reference counter = %d", refCount);
return (refCount);
}
int VoEVolumeControlImpl::SetSpeakerVolume(unsigned int volume)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetSpeakerVolume(volume=%u)", volume);
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (volume > kMaxVolumeLevel)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetSpeakerVolume() invalid argument");
return -1;
}
@ -92,10 +92,9 @@ int VoEVolumeControlImpl::SetSpeakerVolume(unsigned int volume)
WebRtc_UWord32 spkrVol(0);
// scale: [0,kMaxVolumeLevel] -> [0,MaxSpeakerVolume]
if (_audioDevicePtr->MaxSpeakerVolume(&maxVol) != 0)
if (_shared->audio_device()->MaxSpeakerVolume(&maxVol) != 0)
{
_engineStatistics.SetLastError(
VE_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError,
"SetSpeakerVolume() failed to get max volume");
return -1;
}
@ -104,10 +103,9 @@ int VoEVolumeControlImpl::SetSpeakerVolume(unsigned int volume)
(int)(kMaxVolumeLevel / 2)) / (kMaxVolumeLevel));
// set the actual volume using the audio mixer
if (_audioDevicePtr->SetSpeakerVolume(spkrVol) != 0)
if (_shared->audio_device()->SetSpeakerVolume(spkrVol) != 0)
{
_engineStatistics.SetLastError(
VE_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError,
"SetSpeakerVolume() failed to set speaker volume");
return -1;
}
@ -116,32 +114,30 @@ int VoEVolumeControlImpl::SetSpeakerVolume(unsigned int volume)
int VoEVolumeControlImpl::GetSpeakerVolume(unsigned int& volume)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSpeakerVolume()");
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
WebRtc_UWord32 spkrVol(0);
WebRtc_UWord32 maxVol(0);
if (_audioDevicePtr->SpeakerVolume(&spkrVol) != 0)
if (_shared->audio_device()->SpeakerVolume(&spkrVol) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"GetSpeakerVolume() unable to get speaker volume");
return -1;
}
// scale: [0, MaxSpeakerVolume] -> [0, kMaxVolumeLevel]
if (_audioDevicePtr->MaxSpeakerVolume(&maxVol) != 0)
if (_shared->audio_device()->MaxSpeakerVolume(&maxVol) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"GetSpeakerVolume() unable to get max speaker volume");
return -1;
}
@ -149,26 +145,26 @@ int VoEVolumeControlImpl::GetSpeakerVolume(unsigned int& volume)
volume = (WebRtc_UWord32) ((spkrVol * kMaxVolumeLevel +
(int)(maxVol / 2)) / (maxVol));
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetSpeakerVolume() => volume=%d", volume);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetSpeakerVolume() => volume=%d", volume);
return 0;
}
int VoEVolumeControlImpl::SetSystemOutputMute(bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSystemOutputMute(enabled=%d)", enable);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (_audioDevicePtr->SetSpeakerMute(enable) != 0)
if (_shared->audio_device()->SetSpeakerMute(enable) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"SpeakerMute() unable to Set speaker mute");
return -1;
}
@ -178,43 +174,42 @@ int VoEVolumeControlImpl::SetSystemOutputMute(bool enable)
int VoEVolumeControlImpl::GetSystemOutputMute(bool& enabled)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSystemOutputMute(enabled=?)");
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (_audioDevicePtr->SpeakerMute(&enabled) != 0)
if (_shared->audio_device()->SpeakerMute(&enabled) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"SpeakerMute() unable to get speaker mute state");
return -1;
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetSystemOutputMute() => %d", enabled);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetSystemOutputMute() => %d", enabled);
return 0;
}
int VoEVolumeControlImpl::SetMicVolume(unsigned int volume)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetMicVolume(volume=%u)", volume);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (volume > kMaxVolumeLevel)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetMicVolume() invalid argument");
return -1;
}
@ -223,10 +218,9 @@ int VoEVolumeControlImpl::SetMicVolume(unsigned int volume)
WebRtc_UWord32 micVol(0);
// scale: [0, kMaxVolumeLevel] -> [0,MaxMicrophoneVolume]
if (_audioDevicePtr->MaxMicrophoneVolume(&maxVol) != 0)
if (_shared->audio_device()->MaxMicrophoneVolume(&maxVol) != 0)
{
_engineStatistics.SetLastError(
VE_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError,
"SetMicVolume() failed to get max volume");
return -1;
}
@ -237,9 +231,8 @@ int VoEVolumeControlImpl::SetMicVolume(unsigned int volume)
// scaling. WebRTC does not support setting the volume above 100%, and
// simply ignores changing the volume if the user tries to set it to
// |kMaxVolumeLevel| while the current volume is higher than |maxVol|.
if (_audioDevicePtr->MicrophoneVolume(&micVol) != 0) {
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
if (_shared->audio_device()->MicrophoneVolume(&micVol) != 0) {
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"SetMicVolume() unable to get microphone volume");
return -1;
}
@ -252,10 +245,9 @@ int VoEVolumeControlImpl::SetMicVolume(unsigned int volume)
(int)(kMaxVolumeLevel / 2)) / (kMaxVolumeLevel));
// set the actual volume using the audio mixer
if (_audioDevicePtr->SetMicrophoneVolume(micVol) != 0)
if (_shared->audio_device()->SetMicrophoneVolume(micVol) != 0)
{
_engineStatistics.SetLastError(
VE_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_MIC_VOL_ERROR, kTraceError,
"SetMicVolume() failed to set mic volume");
return -1;
}
@ -264,33 +256,31 @@ int VoEVolumeControlImpl::SetMicVolume(unsigned int volume)
int VoEVolumeControlImpl::GetMicVolume(unsigned int& volume)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetMicVolume()");
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
WebRtc_UWord32 micVol(0);
WebRtc_UWord32 maxVol(0);
if (_audioDevicePtr->MicrophoneVolume(&micVol) != 0)
if (_shared->audio_device()->MicrophoneVolume(&micVol) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"GetMicVolume() unable to get microphone volume");
return -1;
}
// scale: [0, MaxMicrophoneVolume] -> [0, kMaxVolumeLevel]
if (_audioDevicePtr->MaxMicrophoneVolume(&maxVol) != 0)
if (_shared->audio_device()->MaxMicrophoneVolume(&maxVol) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"GetMicVolume() unable to get max microphone volume");
return -1;
}
@ -303,35 +293,35 @@ int VoEVolumeControlImpl::GetMicVolume(unsigned int& volume)
volume = kMaxVolumeLevel;
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetMicVolume() => volume=%d", volume);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetMicVolume() => volume=%d", volume);
return 0;
}
int VoEVolumeControlImpl::SetInputMute(int channel, bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetInputMute(channel=%d, enable=%d)", channel, enable);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (channel == -1)
{
// Mute before demultiplexing <=> affects all channels
return _transmitMixerPtr->SetMute(enable);
return _shared->transmit_mixer()->SetMute(enable);
}
else
{
// Mute after demultiplexing <=> affects one channel only
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetInputMute() failed to locate channel");
return -1;
}
@ -342,51 +332,50 @@ int VoEVolumeControlImpl::SetInputMute(int channel, bool enable)
int VoEVolumeControlImpl::GetInputMute(int channel, bool& enabled)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetInputMute(channel=%d)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (channel == -1)
{
enabled = _transmitMixerPtr->Mute();
enabled = _shared->transmit_mixer()->Mute();
}
else
{
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetInputMute() failed to locate channel");
return -1;
}
enabled = channelPtr->Mute();
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetInputMute() => enabled = %d", (int)enabled);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetInputMute() => enabled = %d", (int)enabled);
return 0;
}
int VoEVolumeControlImpl::SetSystemInputMute(bool enable)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetSystemInputMute(enabled=%d)", enable);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (_audioDevicePtr->SetMicrophoneMute(enable) != 0)
if (_shared->audio_device()->SetMicrophoneMute(enable) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"MicrophoneMute() unable to set microphone mute state");
return -1;
}
@ -396,67 +385,68 @@ int VoEVolumeControlImpl::SetSystemInputMute(bool enable)
int VoEVolumeControlImpl::GetSystemInputMute(bool& enabled)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSystemInputMute(enabled=?)");
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (_audioDevicePtr->MicrophoneMute(&enabled) != 0)
if (_shared->audio_device()->MicrophoneMute(&enabled) != 0)
{
_engineStatistics.SetLastError(
VE_GET_MIC_VOL_ERROR, kTraceError,
_shared->SetLastError(VE_GET_MIC_VOL_ERROR, kTraceError,
"MicrophoneMute() unable to get microphone mute state");
return -1;
}
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetSystemInputMute() => %d", enabled);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetSystemInputMute() => %d", enabled);
return 0;
}
int VoEVolumeControlImpl::GetSpeechInputLevel(unsigned int& level)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSpeechInputLevel()");
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
WebRtc_Word8 currentLevel = _transmitMixerPtr->AudioLevel();
WebRtc_Word8 currentLevel = _shared->transmit_mixer()->AudioLevel();
level = static_cast<unsigned int> (currentLevel);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetSpeechInputLevel() => %d", level);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetSpeechInputLevel() => %d", level);
return 0;
}
int VoEVolumeControlImpl::GetSpeechOutputLevel(int channel,
unsigned int& level)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSpeechOutputLevel(channel=%d, level=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (channel == -1)
{
return _outputMixerPtr->GetSpeechOutputLevel((WebRtc_UWord32&)level);
return _shared->output_mixer()->GetSpeechOutputLevel(
(WebRtc_UWord32&)level);
}
else
{
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSpeechOutputLevel() failed to locate channel");
return -1;
}
@ -467,45 +457,46 @@ int VoEVolumeControlImpl::GetSpeechOutputLevel(int channel,
int VoEVolumeControlImpl::GetSpeechInputLevelFullRange(unsigned int& level)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSpeechInputLevelFullRange(level=?)");
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
WebRtc_Word16 currentLevel = _transmitMixerPtr->AudioLevelFullRange();
WebRtc_Word16 currentLevel = _shared->transmit_mixer()->
AudioLevelFullRange();
level = static_cast<unsigned int> (currentLevel);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1),
"GetSpeechInputLevelFullRange() => %d", level);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_shared->instance_id(), -1),
"GetSpeechInputLevelFullRange() => %d", level);
return 0;
}
int VoEVolumeControlImpl::GetSpeechOutputLevelFullRange(int channel,
unsigned int& level)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetSpeechOutputLevelFullRange(channel=%d, level=?)", channel);
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (channel == -1)
{
return _outputMixerPtr->GetSpeechOutputLevelFullRange(
return _shared->output_mixer()->GetSpeechOutputLevelFullRange(
(WebRtc_UWord32&)level);
}
else
{
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetSpeechOutputLevelFullRange() failed to locate channel");
return -1;
}
@ -517,29 +508,27 @@ int VoEVolumeControlImpl::GetSpeechOutputLevelFullRange(int channel,
int VoEVolumeControlImpl::SetChannelOutputVolumeScaling(int channel,
float scaling)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetChannelOutputVolumeScaling(channel=%d, scaling=%3.2f)",
channel, scaling);
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
if (scaling < kMinOutputVolumeScaling ||
scaling > kMaxOutputVolumeScaling)
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetChannelOutputVolumeScaling() invalid parameter");
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetChannelOutputVolumeScaling() failed to locate channel");
return -1;
}
@ -549,20 +538,19 @@ int VoEVolumeControlImpl::SetChannelOutputVolumeScaling(int channel,
int VoEVolumeControlImpl::GetChannelOutputVolumeScaling(int channel,
float& scaling)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetChannelOutputVolumeScaling(channel=%d, scaling=?)", channel);
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetChannelOutputVolumeScaling() failed to locate channel");
return -1;
}
@ -573,24 +561,23 @@ int VoEVolumeControlImpl::SetOutputVolumePan(int channel,
float left,
float right)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetOutputVolumePan(channel=%d, left=%2.1f, right=%2.1f)",
channel, left, right);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
bool available(false);
_audioDevicePtr->StereoPlayoutIsAvailable(&available);
_shared->audio_device()->StereoPlayoutIsAvailable(&available);
if (!available)
{
_engineStatistics.SetLastError(
VE_FUNC_NO_STEREO, kTraceError,
_shared->SetLastError(VE_FUNC_NO_STEREO, kTraceError,
"SetOutputVolumePan() stereo playout not supported");
return -1;
}
@ -599,8 +586,7 @@ int VoEVolumeControlImpl::SetOutputVolumePan(int channel,
(right < kMinOutputVolumePanning) ||
(right > kMaxOutputVolumePanning))
{
_engineStatistics.SetLastError(
VE_INVALID_ARGUMENT, kTraceError,
_shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"SetOutputVolumePan() invalid parameter");
return -1;
}
@ -608,17 +594,16 @@ int VoEVolumeControlImpl::SetOutputVolumePan(int channel,
if (channel == -1)
{
// Master balance (affectes the signal after output mixing)
return _outputMixerPtr->SetOutputVolumePan(left, right);
return _shared->output_mixer()->SetOutputVolumePan(left, right);
}
else
{
// Per-channel balance (affects the signal before output mixing)
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"SetOutputVolumePan() failed to locate channel");
return -1;
}
@ -631,39 +616,37 @@ int VoEVolumeControlImpl::GetOutputVolumePan(int channel,
float& left,
float& right)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1),
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetOutputVolumePan(channel=%d, left=?, right=?)", channel);
ANDROID_NOT_SUPPORTED(_engineStatistics);
ANDROID_NOT_SUPPORTED(_shared->statistics());
IPHONE_NOT_SUPPORTED();
if (!_engineStatistics.Initialized())
if (!_shared->statistics().Initialized())
{
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
bool available(false);
_audioDevicePtr->StereoPlayoutIsAvailable(&available);
_shared->audio_device()->StereoPlayoutIsAvailable(&available);
if (!available)
{
_engineStatistics.SetLastError(
VE_FUNC_NO_STEREO, kTraceError,
_shared->SetLastError(VE_FUNC_NO_STEREO, kTraceError,
"GetOutputVolumePan() stereo playout not supported");
return -1;
}
if (channel == -1)
{
return _outputMixerPtr->GetOutputVolumePan(left, right);
return _shared->output_mixer()->GetOutputVolumePan(left, right);
}
else
{
voe::ScopedChannel sc(_channelManager, channel);
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channelPtr = sc.ChannelPtr();
if (channelPtr == NULL)
{
_engineStatistics.SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetOutputVolumePan() failed to locate channel");
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -18,8 +18,7 @@
namespace webrtc {
class VoEVolumeControlImpl : public virtual voe::SharedData,
public VoEVolumeControl,
class VoEVolumeControlImpl : public VoEVolumeControl,
public voe::RefCount
{
public:
@ -64,8 +63,11 @@ public:
protected:
VoEVolumeControlImpl();
VoEVolumeControlImpl(voe::SharedData* shared);
virtual ~VoEVolumeControlImpl();
private:
voe::SharedData* _shared;
};
} // namespace webrtc

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -57,55 +57,90 @@
namespace webrtc
{
class VoiceEngineImpl :
class VoiceEngineImpl : public voe::SharedData, // Must be the first base class
#ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
public VoEAudioProcessingImpl,
public VoEAudioProcessingImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_CALL_REPORT_API
public VoECallReportImpl,
public VoECallReportImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_CODEC_API
public VoECodecImpl,
public VoECodecImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_DTMF_API
public VoEDtmfImpl,
public VoEDtmfImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_ENCRYPTION_API
public VoEEncryptionImpl,
public VoEEncryptionImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API
public VoEExternalMediaImpl,
public VoEExternalMediaImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_FILE_API
public VoEFileImpl,
public VoEFileImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API
public VoEHardwareImpl,
public VoEHardwareImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
public VoENetEqStatsImpl,
public VoENetEqStatsImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_NETWORK_API
public VoENetworkImpl,
public VoENetworkImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
public VoERTP_RTCPImpl,
public VoERTP_RTCPImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
public VoEVideoSyncImpl,
public VoEVideoSyncImpl,
#endif
#ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
public VoEVolumeControlImpl,
public VoEVolumeControlImpl,
#endif
public VoEBaseImpl
public VoEBaseImpl
{
public:
VoiceEngineImpl() :
#ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
VoEVideoSyncImpl(this),
#ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
VoEAudioProcessingImpl(this),
#endif
VoEBaseImpl() // Included in initializer list to satisfy condition when
// none of the WEBRTC_VOICE_XXX defines are set.
#ifdef WEBRTC_VOICE_ENGINE_CALL_REPORT_API
VoECallReportImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_CODEC_API
VoECodecImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_DTMF_API
VoEDtmfImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_ENCRYPTION_API
VoEEncryptionImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API
VoEExternalMediaImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_FILE_API
VoEFileImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API
VoEHardwareImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
VoENetEqStatsImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_NETWORK_API
VoENetworkImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
VoERTP_RTCPImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
VoEVideoSyncImpl(this),
#endif
#ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
VoEVolumeControlImpl(this),
#endif
VoEBaseImpl(this)
{
}
virtual ~VoiceEngineImpl()