diff --git a/src/system_wrappers/interface/trace.h b/src/system_wrappers/interface/trace.h index 0333e7611..f88d23f8a 100644 --- a/src/system_wrappers/interface/trace.h +++ b/src/system_wrappers/interface/trace.h @@ -70,7 +70,6 @@ public: const TraceModule module, const WebRtc_Word32 id, const char* msg, ...); - }; } // namespace webrtc #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_ diff --git a/src/voice_engine/main/source/shared_data.cc b/src/voice_engine/main/source/shared_data.cc index 2362da5bb..3ceb62e9a 100644 --- a/src/voice_engine/main/source/shared_data.cc +++ b/src/voice_engine/main/source/shared_data.cc @@ -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 diff --git a/src/voice_engine/main/source/shared_data.h b/src/voice_engine/main/source/shared_data.h index afab37b4a..191e369e7 100644 --- a/src/voice_engine/main/source/shared_data.h +++ b/src/voice_engine/main/source/shared_data.h @@ -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(); }; diff --git a/src/voice_engine/main/source/voe_audio_processing_impl.cc b/src/voice_engine/main/source/voe_audio_processing_impl.cc index 1b19932ad..f83a2fab2 100644 --- a/src/voice_engine/main/source/voe_audio_processing_impl.cc +++ b/src/voice_engine/main/source/voe_audio_processing_impl.cc @@ -41,38 +41,38 @@ VoEAudioProcessing* VoEAudioProcessing::GetInterface(VoiceEngine* voiceEngine) { } #ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API -VoEAudioProcessingImpl::VoEAudioProcessingImpl() - : _isAecMode(kDefaultEcMode == kEcAec ? true : false) { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1), +VoEAudioProcessingImpl::VoEAudioProcessingImpl(voe::SharedData* shared) + : _isAecMode(kDefaultEcMode == kEcAec), _shared(shared) { + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEAudioProcessingImpl::VoEAudioProcessingImpl() - ctor"); } VoEAudioProcessingImpl::~VoEAudioProcessingImpl() { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEAudioProcessingImpl::~VoEAudioProcessingImpl() - dtor"); } int VoEAudioProcessingImpl::Release() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEAudioProcessing::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), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEAudioProcessing reference counter = %d", refCount); return (refCount); } int VoEAudioProcessingImpl::SetNsStatus(bool enable, NsModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetNsStatus(enable=%d, mode=%d)", enable, mode); #ifdef WEBRTC_VOICE_ENGINE_NR - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } @@ -83,7 +83,7 @@ int VoEAudioProcessingImpl::SetNsStatus(bool enable, NsModes mode) { nsLevel = (NoiseSuppression::Level)WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE; break; case kNsUnchanged: - nsLevel = _audioProcessingModulePtr->noise_suppression()->level(); + nsLevel = _shared->audio_processing()->noise_suppression()->level(); break; case kNsConference: nsLevel = NoiseSuppression::kHigh; @@ -102,31 +102,32 @@ int VoEAudioProcessingImpl::SetNsStatus(bool enable, NsModes mode) { break; } - if (_audioProcessingModulePtr->noise_suppression()->set_level(nsLevel) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + if (_shared->audio_processing()->noise_suppression()-> + set_level(nsLevel) != 0) { + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetNsStatus() failed to set Ns mode"); return -1; } - if (_audioProcessingModulePtr->noise_suppression()->Enable(enable) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + if (_shared->audio_processing()->noise_suppression()->Enable(enable) != 0) { + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetNsStatus() failed to set Ns state"); return -1; } return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetNsStatus() Ns is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetNsStatus(bool& enabled, NsModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetNsStatus(enabled=?, mode=?)"); #ifdef WEBRTC_VOICE_ENGINE_NR - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } @@ -134,8 +135,8 @@ int VoEAudioProcessingImpl::GetNsStatus(bool& enabled, NsModes& mode) { NoiseSuppression::Level nsLevel( (NoiseSuppression::Level)WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE); - enable = _audioProcessingModulePtr->noise_suppression()->is_enabled(); - nsLevel = _audioProcessingModulePtr->noise_suppression()->level(); + enable = _shared->audio_processing()->noise_suppression()->is_enabled(); + nsLevel = _shared->audio_processing()->noise_suppression()->level(); enabled = enable; @@ -154,28 +155,28 @@ int VoEAudioProcessingImpl::GetNsStatus(bool& enabled, NsModes& mode) { break; } - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetNsStatus() => enabled=% d, mode=%d", enabled, mode); return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetNsStatus() Ns is not supported"); return -1; #endif } int VoEAudioProcessingImpl::SetAgcStatus(bool enable, AgcModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetAgcStatus(enable=%d, mode=%d)", enable, mode); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } #if defined(MAC_IPHONE) || defined(ATA) || defined(WEBRTC_ANDROID) if (mode == kAgcAdaptiveAnalog) { - _engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError, + _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, "SetAgcStatus() invalid Agc mode for mobile device"); return -1; } @@ -188,7 +189,7 @@ int VoEAudioProcessingImpl::SetAgcStatus(bool enable, AgcModes mode) { agcMode = (GainControl::Mode)WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE; break; case kAgcUnchanged: - agcMode = _audioProcessingModulePtr->gain_control()->mode();; + agcMode = _shared->audio_processing()->gain_control()->mode();; break; case kAgcFixedDigital: agcMode = GainControl::kFixedDigital; @@ -201,13 +202,13 @@ int VoEAudioProcessingImpl::SetAgcStatus(bool enable, AgcModes mode) { break; } - if (_audioProcessingModulePtr->gain_control()->set_mode(agcMode) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + if (_shared->audio_processing()->gain_control()->set_mode(agcMode) != 0) { + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetAgcStatus() failed to set Agc mode"); return -1; } - if (_audioProcessingModulePtr->gain_control()->Enable(enable) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + if (_shared->audio_processing()->gain_control()->Enable(enable) != 0) { + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetAgcStatus() failed to set Agc state"); return -1; } @@ -217,26 +218,26 @@ int VoEAudioProcessingImpl::SetAgcStatus(bool enable, AgcModes mode) { // Note that we also enable the ADM Agc when Adaptive Digital mode is // used since we want to be able to provide the APM with updated mic // levels when the user modifies the mic level manually. - if (_audioDevicePtr->SetAGC(enable) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, + if (_shared->audio_device()->SetAGC(enable) != 0) { + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, "SetAgcStatus() failed to set Agc mode"); } } return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetAgcStatus() Agc is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetAgcStatus(bool& enabled, AgcModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetAgcStatus(enabled=?, mode=?)"); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } @@ -244,8 +245,8 @@ int VoEAudioProcessingImpl::GetAgcStatus(bool& enabled, AgcModes& mode) { GainControl::Mode agcMode( (GainControl::Mode)WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE); - enable = _audioProcessingModulePtr->gain_control()->is_enabled(); - agcMode = _audioProcessingModulePtr->gain_control()->mode(); + enable = _shared->audio_processing()->gain_control()->is_enabled(); + agcMode = _shared->audio_processing()->gain_control()->mode(); enabled = enable; @@ -261,71 +262,71 @@ int VoEAudioProcessingImpl::GetAgcStatus(bool& enabled, AgcModes& mode) { break; } - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetAgcStatus() => enabled=%d, mode=%d", enabled, mode); return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetAgcStatus() Agc is not supported"); return -1; #endif } int VoEAudioProcessingImpl::SetAgcConfig(const AgcConfig config) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetAgcConfig()"); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - if (_audioProcessingModulePtr->gain_control()->set_target_level_dbfs( + if (_shared->audio_processing()->gain_control()->set_target_level_dbfs( config.targetLeveldBOv) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetAgcConfig() failed to set target peak |level|" " (or envelope) of the Agc"); return -1; } - if (_audioProcessingModulePtr->gain_control()->set_compression_gain_db( + if (_shared->audio_processing()->gain_control()->set_compression_gain_db( config.digitalCompressionGaindB) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetAgcConfig() failed to set the range in |gain| " "the digital compression stage may apply"); return -1; } - if (_audioProcessingModulePtr->gain_control()->enable_limiter( + if (_shared->audio_processing()->gain_control()->enable_limiter( config.limiterEnable) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetAgcConfig() failed to set hard limiter to the signal"); return -1; } return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetAgcConfig() EC is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetAgcConfig(AgcConfig& config) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetAgcConfig(config=?)"); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } config.targetLeveldBOv = - _audioProcessingModulePtr->gain_control()->target_level_dbfs(); + _shared->audio_processing()->gain_control()->target_level_dbfs(); config.digitalCompressionGaindB = - _audioProcessingModulePtr->gain_control()->compression_gain_db(); + _shared->audio_processing()->gain_control()->compression_gain_db(); config.limiterEnable = - _audioProcessingModulePtr->gain_control()->is_limiter_enabled(); + _shared->audio_processing()->gain_control()->is_limiter_enabled(); - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetAgcConfig() => targetLeveldBOv=%u, " "digitalCompressionGaindB=%u, limiterEnable=%d", config.targetLeveldBOv, @@ -334,7 +335,7 @@ int VoEAudioProcessingImpl::GetAgcConfig(AgcConfig& config) { return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetAgcConfig() EC is not supported"); return -1; #endif @@ -343,25 +344,25 @@ int VoEAudioProcessingImpl::GetAgcConfig(AgcConfig& config) { int VoEAudioProcessingImpl::SetRxNsStatus(int channel, bool enable, NsModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetRxNsStatus(channel=%d, enable=%d, mode=%d)", channel, (int)enable, (int)mode); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "SetRxNsStatus() failed to locate channel"); return -1; } return channelPtr->SetRxNsStatus(enable, mode); #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetRxNsStatus() AGC is not supported"); return -1; #endif @@ -370,24 +371,24 @@ int VoEAudioProcessingImpl::SetRxNsStatus(int channel, int VoEAudioProcessingImpl::GetRxNsStatus(int channel, bool& enabled, NsModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetRxNsStatus(channel=%d, enable=?, mode=?)", channel); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "GetRxNsStatus() failed to locate channel"); return -1; } return channelPtr->GetRxNsStatus(enabled, mode); #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetRxNsStatus() Agc is not supported"); return -1; #endif @@ -396,25 +397,25 @@ int VoEAudioProcessingImpl::GetRxNsStatus(int channel, int VoEAudioProcessingImpl::SetRxAgcStatus(int channel, bool enable, AgcModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetRxAgcStatus(channel=%d, enable=%d, mode=%d)", channel, (int)enable, (int)mode); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "SetRxAgcStatus() failed to locate channel"); return -1; } return channelPtr->SetRxAgcStatus(enable, mode); #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetRxAgcStatus() Agc is not supported"); return -1; #endif @@ -423,24 +424,24 @@ int VoEAudioProcessingImpl::SetRxAgcStatus(int channel, int VoEAudioProcessingImpl::GetRxAgcStatus(int channel, bool& enabled, AgcModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetRxAgcStatus(channel=%d, enable=?, mode=?)", channel); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "GetRxAgcStatus() failed to locate channel"); return -1; } return channelPtr->GetRxAgcStatus(enabled, mode); #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetRxAgcStatus() Agc is not supported"); return -1; #endif @@ -448,60 +449,59 @@ int VoEAudioProcessingImpl::GetRxAgcStatus(int channel, int VoEAudioProcessingImpl::SetRxAgcConfig(int channel, const AgcConfig config) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetRxAgcConfig(channel=%d)", channel); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "SetRxAgcConfig() failed to locate channel"); return -1; } return channelPtr->SetRxAgcConfig(config); #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetRxAgcConfig() Agc is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetRxAgcConfig(int channel, AgcConfig& config) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetRxAgcConfig(channel=%d)", channel); #ifdef WEBRTC_VOICE_ENGINE_AGC - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "GetRxAgcConfig() failed to locate channel"); return -1; } return channelPtr->GetRxAgcConfig(config); #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetRxAgcConfig() Agc is not supported"); return -1; #endif } int VoEAudioProcessingImpl::SetEcStatus(bool enable, EcModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetEcStatus(enable=%d, mode=%d)", enable, mode); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } @@ -513,49 +513,49 @@ int VoEAudioProcessingImpl::SetEcStatus(bool enable, EcModes mode) { (_isAecMode == true))) { if (enable) { // Disable the AECM before enable the AEC - if (_audioProcessingModulePtr->echo_control_mobile()->is_enabled()) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceWarning, + if (_shared->audio_processing()->echo_control_mobile()->is_enabled()) { + _shared->SetLastError(VE_APM_ERROR, kTraceWarning, "SetEcStatus() disable AECM before enabling AEC"); - if (_audioProcessingModulePtr->echo_control_mobile()-> + if (_shared->audio_processing()->echo_control_mobile()-> Enable(false) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to disable AECM"); return -1; } } } - if (_audioProcessingModulePtr->echo_cancellation()->Enable(enable) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + if (_shared->audio_processing()->echo_cancellation()->Enable(enable) != 0) { + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to set AEC state"); return -1; } #ifdef CLOCK_SKEW_COMP - if (_audioProcessingModulePtr->echo_cancellation()-> + if (_shared->audio_processing()->echo_cancellation()-> enable_drift_compensation(true) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to enable drift compensation"); return -1; } #else - if (_audioProcessingModulePtr->echo_cancellation()-> + if (_shared->audio_processing()->echo_cancellation()-> enable_drift_compensation(false) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to disable drift compensation"); return -1; } #endif if (mode == kEcConference) { - if (_audioProcessingModulePtr->echo_cancellation()-> + if (_shared->audio_processing()->echo_cancellation()-> set_suppression_level(EchoCancellation::kHighSuppression) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to set aggressiveness to high"); return -1; } } else { - if (_audioProcessingModulePtr->echo_cancellation()-> + if (_shared->audio_processing()->echo_cancellation()-> set_suppression_level( EchoCancellation::kModerateSuppression) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to set aggressiveness to moderate"); return -1; } @@ -567,85 +567,85 @@ int VoEAudioProcessingImpl::SetEcStatus(bool enable, EcModes mode) { (_isAecMode == false))) { if (enable) { // Disable the AEC before enable the AECM - if (_audioProcessingModulePtr->echo_cancellation()->is_enabled()) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceWarning, + if (_shared->audio_processing()->echo_cancellation()->is_enabled()) { + _shared->SetLastError(VE_APM_ERROR, kTraceWarning, "SetEcStatus() disable AEC before enabling AECM"); - if (_audioProcessingModulePtr->echo_cancellation()-> + if (_shared->audio_processing()->echo_cancellation()-> Enable(false) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to disable AEC"); return -1; } } } - if (_audioProcessingModulePtr->echo_control_mobile()-> + if (_shared->audio_processing()->echo_control_mobile()-> Enable(enable) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcStatus() failed to set AECM state"); return -1; } _isAecMode = false; } else { - _engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError, + _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, "SetEcStatus() invalid EC mode"); return -1; } return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetEcStatus() EC is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetEcStatus(bool& enabled, EcModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEcStatus()"); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } if (_isAecMode == true) { mode = kEcAec; - enabled = _audioProcessingModulePtr->echo_cancellation()->is_enabled(); + enabled = _shared->audio_processing()->echo_cancellation()->is_enabled(); } else { mode = kEcAecm; - enabled = _audioProcessingModulePtr->echo_control_mobile()-> + enabled = _shared->audio_processing()->echo_control_mobile()-> is_enabled(); } - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEcStatus() => enabled=%i, mode=%i", enabled, (int)mode); return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetEcStatus() EC is not supported"); return -1; #endif } void VoEAudioProcessingImpl::SetDelayOffsetMs(int offset) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetDelayOffsetMs(offset = %d)", offset); - _audioProcessingModulePtr->set_delay_offset_ms(offset); + _shared->audio_processing()->set_delay_offset_ms(offset); } int VoEAudioProcessingImpl::DelayOffsetMs() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "DelayOffsetMs()"); - return _audioProcessingModulePtr->delay_offset_ms(); + return _shared->audio_processing()->delay_offset_ms(); } int VoEAudioProcessingImpl::SetAecmMode(AecmModes mode, bool enableCNG) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetAECMMode(mode = %d)", mode); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } @@ -671,41 +671,41 @@ int VoEAudioProcessingImpl::SetAecmMode(AecmModes mode, bool enableCNG) { } - if (_audioProcessingModulePtr->echo_control_mobile()-> + if (_shared->audio_processing()->echo_control_mobile()-> set_routing_mode(aecmMode) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetAECMMode() failed to set AECM routing mode"); return -1; } - if (_audioProcessingModulePtr->echo_control_mobile()-> + if (_shared->audio_processing()->echo_control_mobile()-> enable_comfort_noise(enableCNG) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetAECMMode() failed to set comfort noise state for AECM"); return -1; } return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetAECMMode() EC is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetAecmMode(AecmModes& mode, bool& enabledCNG) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetAECMMode(mode=?)"); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } enabledCNG = false; EchoControlMobile::RoutingMode aecmMode = - _audioProcessingModulePtr->echo_control_mobile()->routing_mode(); - enabledCNG = _audioProcessingModulePtr->echo_control_mobile()-> + _shared->audio_processing()->echo_control_mobile()->routing_mode(); + enabledCNG = _shared->audio_processing()->echo_control_mobile()-> is_comfort_noise_enabled(); switch (aecmMode) { @@ -728,7 +728,7 @@ int VoEAudioProcessingImpl::GetAecmMode(AecmModes& mode, bool& enabledCNG) { return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "GetAECMMode() EC is not supported"); return -1; #endif @@ -737,19 +737,19 @@ int VoEAudioProcessingImpl::GetAecmMode(AecmModes& mode, bool& enabledCNG) { int VoEAudioProcessingImpl::RegisterRxVadObserver( int channel, VoERxVadCallback& observer) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "RegisterRxVadObserver()"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "RegisterRxVadObserver() failed to locate channel"); return -1; } @@ -757,19 +757,19 @@ int VoEAudioProcessingImpl::RegisterRxVadObserver( } int VoEAudioProcessingImpl::DeRegisterRxVadObserver(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "DeRegisterRxVadObserver()"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "DeRegisterRxVadObserver() failed to locate channel"); return -1; } @@ -778,17 +778,17 @@ int VoEAudioProcessingImpl::DeRegisterRxVadObserver(int channel) { } int VoEAudioProcessingImpl::VoiceActivityIndicator(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoiceActivityIndicator(channel=%d)", channel); - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _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, "DeRegisterRxVadObserver() failed to locate channel"); return -1; } @@ -799,63 +799,63 @@ int VoEAudioProcessingImpl::VoiceActivityIndicator(int channel) { } int VoEAudioProcessingImpl::SetEcMetricsStatus(bool enable) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetEcMetricsStatus(enable=%d)", enable); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - if ((_audioProcessingModulePtr->echo_cancellation()->enable_metrics(enable) + if ((_shared->audio_processing()->echo_cancellation()->enable_metrics(enable) != 0) || - (_audioProcessingModulePtr->echo_cancellation()->enable_delay_logging( + (_shared->audio_processing()->echo_cancellation()->enable_delay_logging( enable) != 0)) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "SetEcMetricsStatus() unable to set EC metrics mode"); return -1; } return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetEcStatus() EC is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetEcMetricsStatus(bool& enabled) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEcMetricsStatus(enabled=?)"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } bool echo_mode = - _audioProcessingModulePtr->echo_cancellation()->are_metrics_enabled(); - bool delay_mode = - _audioProcessingModulePtr->echo_cancellation()->is_delay_logging_enabled(); + _shared->audio_processing()->echo_cancellation()->are_metrics_enabled(); + bool delay_mode = _shared->audio_processing()->echo_cancellation()-> + is_delay_logging_enabled(); if (echo_mode != delay_mode) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "GetEcMetricsStatus() delay logging and echo mode are not the same"); return -1; } enabled = echo_mode; - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEcMetricsStatus() => enabled=%d", enabled); return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetEcStatus() EC is not supported"); return -1; #endif @@ -865,27 +865,27 @@ int VoEAudioProcessingImpl::GetEchoMetrics(int& ERL, int& ERLE, int& RERL, int& A_NLP) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEchoMetrics(ERL=?, ERLE=?, RERL=?, A_NLP=?)"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - if (!_audioProcessingModulePtr->echo_cancellation()->is_enabled()) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceWarning, + if (!_shared->audio_processing()->echo_cancellation()->is_enabled()) { + _shared->SetLastError(VE_APM_ERROR, kTraceWarning, "GetEchoMetrics() AudioProcessingModule AEC is not enabled"); return -1; } // Get Echo Metrics from Audio Processing Module. EchoCancellation::Metrics echoMetrics; - if (_audioProcessingModulePtr->echo_cancellation()->GetMetrics( + if (_shared->audio_processing()->echo_cancellation()->GetMetrics( &echoMetrics)) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEchoMetrics(), AudioProcessingModule metrics error"); return -1; } @@ -896,12 +896,12 @@ int VoEAudioProcessingImpl::GetEchoMetrics(int& ERL, RERL = echoMetrics.residual_echo_return_loss.instant; A_NLP = echoMetrics.a_nlp.instant; - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEchoMetrics() => ERL=%d, ERLE=%d, RERL=%d, A_NLP=%d", ERL, ERLE, RERL, A_NLP); return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetEcStatus() EC is not supported"); return -1; #endif @@ -909,18 +909,18 @@ int VoEAudioProcessingImpl::GetEchoMetrics(int& ERL, int VoEAudioProcessingImpl::GetEcDelayMetrics(int& delay_median, int& delay_std) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEcDelayMetrics(median=?, std=?)"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_ECHO - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - if (!_audioProcessingModulePtr->echo_cancellation()->is_enabled()) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceWarning, + if (!_shared->audio_processing()->echo_cancellation()->is_enabled()) { + _shared->SetLastError(VE_APM_ERROR, kTraceWarning, "GetEcDelayMetrics() AudioProcessingModule AEC is not enabled"); return -1; } @@ -928,9 +928,9 @@ int VoEAudioProcessingImpl::GetEcDelayMetrics(int& delay_median, int median = 0; int std = 0; // Get delay-logging values from Audio Processing Module. - if (_audioProcessingModulePtr->echo_cancellation()->GetDelayMetrics( + if (_shared->audio_processing()->echo_cancellation()->GetDelayMetrics( &median, &std)) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEcDelayMetrics(), AudioProcessingModule delay-logging " "error"); return -1; @@ -940,93 +940,93 @@ int VoEAudioProcessingImpl::GetEcDelayMetrics(int& delay_median, delay_median = median; delay_std = std; - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetEcDelayMetrics() => delay_median=%d, delay_std=%d", delay_median, delay_std); return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetEcStatus() EC is not supported"); return -1; #endif } int VoEAudioProcessingImpl::StartDebugRecording(const char* fileNameUTF8) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartDebugRecording()"); - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - return _audioProcessingModulePtr->StartDebugRecording(fileNameUTF8); + return _shared->audio_processing()->StartDebugRecording(fileNameUTF8); } int VoEAudioProcessingImpl::StopDebugRecording() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopDebugRecording()"); - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - return _audioProcessingModulePtr->StopDebugRecording(); + return _shared->audio_processing()->StopDebugRecording(); } int VoEAudioProcessingImpl::SetTypingDetectionStatus(bool enable) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetTypingDetectionStatus()"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } // Just use the VAD state to determine if we should enable typing detection // or not - if (_audioProcessingModulePtr->voice_detection()->Enable(enable)) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceWarning, + if (_shared->audio_processing()->voice_detection()->Enable(enable)) { + _shared->SetLastError(VE_APM_ERROR, kTraceWarning, "SetTypingDetectionStatus() failed to set VAD state"); return -1; } - if (_audioProcessingModulePtr->voice_detection()->set_likelihood( + if (_shared->audio_processing()->voice_detection()->set_likelihood( VoiceDetection::kVeryLowLikelihood)) { - _engineStatistics.SetLastError( VE_APM_ERROR, kTraceWarning, + _shared->SetLastError(VE_APM_ERROR, kTraceWarning, "SetTypingDetectionStatus() failed to set VAD likelihood to low"); return -1; } return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetTypingDetectionStatus is not supported"); return -1; #endif } int VoEAudioProcessingImpl::GetTypingDetectionStatus(bool& enabled) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetTypingDetectionStatus()"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } // Just use the VAD state to determine if we should enable typing // detection or not - enabled = _audioProcessingModulePtr->voice_detection()->is_enabled(); + enabled = _shared->audio_processing()->voice_detection()->is_enabled(); return 0; #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetTypingDetectionStatus is not supported"); return -1; #endif @@ -1034,59 +1034,55 @@ int VoEAudioProcessingImpl::GetTypingDetectionStatus(bool& enabled) { int VoEAudioProcessingImpl::TimeSinceLastTyping(int &seconds) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "TimeSinceLastTyping()"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } // Check if typing detection is enabled - bool enabled = _audioProcessingModulePtr->voice_detection()->is_enabled(); + bool enabled = _shared->audio_processing()->voice_detection()->is_enabled(); if (enabled) { - _transmitMixerPtr->TimeSinceLastTyping(seconds); + _shared->transmit_mixer()->TimeSinceLastTyping(seconds); return 0; } else { - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetTypingDetectionStatus is not enabled"); return -1; } #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetTypingDetectionStatus is not supported"); return -1; #endif - } int VoEAudioProcessingImpl::SetTypingDetectionParameters(int timeWindow, int costPerTyping, int reportingThreshold, int penaltyDecay) { - - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetTypingDetectionParameters()"); - ANDROID_NOT_SUPPORTED(_engineStatistics); + ANDROID_NOT_SUPPORTED(_shared->statistics()); IPHONE_NOT_SUPPORTED(); #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION - if (!_engineStatistics.Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + if (!_shared->statistics().Initialized()) { + _shared->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } - return (_transmitMixerPtr->SetTypingDetectionParameters(timeWindow, - costPerTyping, - reportingThreshold, - penaltyDecay)); + return (_shared->transmit_mixer()->SetTypingDetectionParameters(timeWindow, + costPerTyping, reportingThreshold, penaltyDecay)); #else - _engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, + _shared->statistics().SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, "SetTypingDetectionParameters is not supported"); return -1; #endif diff --git a/src/voice_engine/main/source/voe_audio_processing_impl.h b/src/voice_engine/main/source/voe_audio_processing_impl.h index 6140eec72..170f19b89 100644 --- a/src/voice_engine/main/source/voe_audio_processing_impl.h +++ b/src/voice_engine/main/source/voe_audio_processing_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_base_impl.cc b/src/voice_engine/main/source/voe_base_impl.cc index 7b1ddd815..8bb5627c8 100644 --- a/src/voice_engine/main/source/voe_base_impl.cc +++ b/src/voice_engine/main/source/voe_base_impl.cc @@ -46,18 +46,19 @@ VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine) return (d); } -VoEBaseImpl::VoEBaseImpl() : +VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared) : _voiceEngineObserverPtr(NULL), _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), - _voiceEngineObserver(false), _oldVoEMicLevel(0), _oldMicLevel(0) + _voiceEngineObserver(false), _oldVoEMicLevel(0), _oldMicLevel(0), + _shared(shared) { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl() - ctor"); } VoEBaseImpl::~VoEBaseImpl() { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), "~VoEBaseImpl() - dtor"); TerminateInternal(); @@ -67,18 +68,19 @@ VoEBaseImpl::~VoEBaseImpl() int VoEBaseImpl::Release() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::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), - "VoEBaseImpl reference counter = %d", refCount); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "VoEBaseImpl reference counter = %d", refCount); return (refCount); } @@ -93,16 +95,17 @@ void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) if (error == AudioDeviceObserver::kRecordingError) { errCode = VE_RUNTIME_REC_ERROR; - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), - "VoEBaseImpl::OnErrorIsReported() => " - "VE_RUNTIME_REC_ERROR"); + WEBRTC_TRACE(kTraceInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "VoEBaseImpl::OnErrorIsReported() => VE_RUNTIME_REC_ERROR"); } else if (error == AudioDeviceObserver::kPlayoutError) { errCode = VE_RUNTIME_PLAY_ERROR; - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), - "VoEBaseImpl::OnErrorIsReported() => " - "VE_RUNTIME_PLAY_ERROR"); + WEBRTC_TRACE(kTraceInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "VoEBaseImpl::OnErrorIsReported() => " + "VE_RUNTIME_PLAY_ERROR"); } // Deliver callback (-1 <=> no channel dependency) _voiceEngineObserverPtr->CallbackOnError(-1, errCode); @@ -121,16 +124,18 @@ void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) if (warning == AudioDeviceObserver::kRecordingWarning) { warningCode = VE_RUNTIME_REC_WARNING; - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), - "VoEBaseImpl::OnErrorIsReported() => " - "VE_RUNTIME_REC_WARNING"); + WEBRTC_TRACE(kTraceInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "VoEBaseImpl::OnErrorIsReported() => " + "VE_RUNTIME_REC_WARNING"); } else if (warning == AudioDeviceObserver::kPlayoutWarning) { warningCode = VE_RUNTIME_PLAY_WARNING; - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), - "VoEBaseImpl::OnErrorIsReported() => " - "VE_RUNTIME_PLAY_WARNING"); + WEBRTC_TRACE(kTraceInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "VoEBaseImpl::OnErrorIsReported() => " + "VE_RUNTIME_PLAY_WARNING"); } // Deliver callback (-1 <=> no channel dependency) _voiceEngineObserverPtr->CallbackOnError(-1, warningCode); @@ -149,23 +154,23 @@ WebRtc_Word32 VoEBaseImpl::RecordedDataIsAvailable( const WebRtc_UWord32 currentMicLevel, WebRtc_UWord32& newMicLevel) { - WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::RecordedDataIsAvailable(nSamples=%u, " "nBytesPerSample=%u, nChannels=%u, samplesPerSec=%u, " "totalDelayMS=%u, clockDrift=%d, currentMicLevel=%u)", nSamples, nBytesPerSample, nChannels, samplesPerSec, totalDelayMS, clockDrift, currentMicLevel); - assert(_transmitMixerPtr != NULL); - assert(_audioDevicePtr != NULL); + assert(_shared->transmit_mixer() != NULL); + assert(_shared->audio_device() != NULL); bool isAnalogAGC(false); WebRtc_UWord32 maxVolume(0); WebRtc_UWord16 currentVoEMicLevel(0); WebRtc_UWord32 newVoEMicLevel(0); - if (_audioProcessingModulePtr - && (_audioProcessingModulePtr->gain_control()->mode() + if (_shared->audio_processing() && + (_shared->audio_processing()->gain_control()->mode() == GainControl::kAdaptiveAnalog)) { isAnalogAGC = true; @@ -175,7 +180,7 @@ WebRtc_Word32 VoEBaseImpl::RecordedDataIsAvailable( if (isAnalogAGC) { // Scale from ADM to VoE level range - if (_audioDevicePtr->MaxMicrophoneVolume(&maxVolume) == 0) + if (_shared->audio_device()->MaxMicrophoneVolume(&maxVolume) == 0) { if (0 != maxVolume) { @@ -207,7 +212,7 @@ WebRtc_Word32 VoEBaseImpl::RecordedDataIsAvailable( // Perform channel-independent operations // (APM, mix with file, record to file, mute, etc.) - _transmitMixerPtr->PrepareDemux(audioSamples, nSamples, nChannels, + _shared->transmit_mixer()->PrepareDemux(audioSamples, nSamples, nChannels, samplesPerSec, (WebRtc_UWord16) totalDelayMS, clockDrift, currentVoEMicLevel); @@ -215,16 +220,16 @@ WebRtc_Word32 VoEBaseImpl::RecordedDataIsAvailable( // Copy the audio frame to each sending channel and perform // channel-dependent operations (file mixing, mute, etc.) to prepare // for encoding. - _transmitMixerPtr->DemuxAndMix(); + _shared->transmit_mixer()->DemuxAndMix(); // Do the encoding and packetize+transmit the RTP packet when encoding // is done. - _transmitMixerPtr->EncodeAndSend(); + _shared->transmit_mixer()->EncodeAndSend(); // Will only deal with the volume in adaptive analog mode if (isAnalogAGC) { // Scale from VoE to ADM level range - newVoEMicLevel = _transmitMixerPtr->CaptureLevel(); + newVoEMicLevel = _shared->transmit_mixer()->CaptureLevel(); if (newVoEMicLevel != currentVoEMicLevel) { // Add (kMaxVolumeLevel/2) to round the value @@ -253,21 +258,22 @@ WebRtc_Word32 VoEBaseImpl::NeedMorePlayData( void* audioSamples, WebRtc_UWord32& nSamplesOut) { - WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::NeedMorePlayData(nSamples=%u, " "nBytesPerSample=%d, nChannels=%d, samplesPerSec=%u)", nSamples, nBytesPerSample, nChannels, samplesPerSec); - assert(_outputMixerPtr != NULL); + assert(_shared->output_mixer() != NULL); // Perform mixing of all active participants (channel-based mixing) - _outputMixerPtr->MixActiveChannels(); + _shared->output_mixer()->MixActiveChannels(); // Additional operations on the combined signal - _outputMixerPtr->DoOperationsOnCombinedSignal(); + _shared->output_mixer()->DoOperationsOnCombinedSignal(); // Retrieve the final output mix (resampled to match the ADM) - _outputMixerPtr->GetMixedAudio(samplesPerSec, nChannels, _audioFrame); + _shared->output_mixer()->GetMixedAudio(samplesPerSec, nChannels, + _audioFrame); assert(nSamples == _audioFrame._payloadDataLengthInSamples); assert(samplesPerSec == @@ -287,19 +293,18 @@ WebRtc_Word32 VoEBaseImpl::NeedMorePlayData( int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "RegisterVoiceEngineObserver(observer=0x%d)", &observer); CriticalSectionScoped cs(&_callbackCritSect); if (_voiceEngineObserverPtr) { - _engineStatistics.SetLastError(VE_INVALID_OPERATION, kTraceError, - "RegisterVoiceEngineObserver() observer" - " already enabled"); + _shared->SetLastError(VE_INVALID_OPERATION, kTraceError, + "RegisterVoiceEngineObserver() observer already enabled"); return -1; } // Register the observer in all active channels - voe::ScopedChannel sc(_channelManager); + voe::ScopedChannel sc(_shared->channel_manager()); void* iterator(NULL); voe::Channel* channelPtr = sc.GetFirstChannel(iterator); while (channelPtr != NULL) @@ -307,7 +312,7 @@ int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) channelPtr->RegisterVoiceEngineObserver(observer); channelPtr = sc.GetNextChannel(iterator); } - _transmitMixerPtr->RegisterVoiceEngineObserver(observer); + _shared->transmit_mixer()->RegisterVoiceEngineObserver(observer); _voiceEngineObserverPtr = &observer; _voiceEngineObserver = true; @@ -317,12 +322,12 @@ int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) int VoEBaseImpl::DeRegisterVoiceEngineObserver() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "DeRegisterVoiceEngineObserver()"); CriticalSectionScoped cs(&_callbackCritSect); if (!_voiceEngineObserverPtr) { - _engineStatistics.SetLastError(VE_INVALID_OPERATION, kTraceError, + _shared->SetLastError(VE_INVALID_OPERATION, kTraceError, "DeRegisterVoiceEngineObserver() observer already disabled"); return 0; } @@ -331,7 +336,7 @@ int VoEBaseImpl::DeRegisterVoiceEngineObserver() _voiceEngineObserverPtr = NULL; // Deregister the observer in all active channels - voe::ScopedChannel sc(_channelManager); + voe::ScopedChannel sc(_shared->channel_manager()); void* iterator(NULL); voe::Channel* channelPtr = sc.GetFirstChannel(iterator); while (channelPtr != NULL) @@ -345,20 +350,20 @@ int VoEBaseImpl::DeRegisterVoiceEngineObserver() int VoEBaseImpl::Init(AudioDeviceModule* external_adm) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "Init(external_adm=0x%p)", external_adm); - CriticalSectionScoped cs(_apiCritPtr); + CriticalSectionScoped cs(_shared->crit_sec()); - if (_engineStatistics.Initialized()) + if (_shared->statistics().Initialized()) { return 0; } - if (_moduleProcessThreadPtr) + if (_shared->process_thread()) { - if (_moduleProcessThreadPtr->Start() != 0) + if (_shared->process_thread()->Start() != 0) { - _engineStatistics.SetLastError(VE_THREAD_ERROR, kTraceError, + _shared->SetLastError(VE_THREAD_ERROR, kTraceError, "Init() failed to start module process thread"); return -1; } @@ -369,35 +374,31 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm) if (external_adm == NULL) { // Create the internal ADM implementation. - _audioDevicePtr = AudioDeviceModuleImpl::Create( - VoEId(_instanceId, -1), _audioDeviceLayer); + _shared->set_audio_device(AudioDeviceModuleImpl::Create( + VoEId(_shared->instance_id(), -1), _shared->audio_device_layer())); - if (_audioDevicePtr == NULL) + if (_shared->audio_device() == NULL) { - _engineStatistics.SetLastError(VE_NO_MEMORY, kTraceCritical, - "Init() failed to create the ADM"); + _shared->SetLastError(VE_NO_MEMORY, kTraceCritical, + "Init() failed to create the ADM"); return -1; } } else { // Use the already existing external ADM implementation. - _audioDevicePtr = external_adm; - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), + _shared->set_audio_device(external_adm); + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "An external ADM implementation will be used in VoiceEngine"); } - // Increase the reference counter for both external and internal usage. - _audioDevicePtr->AddRef(); - // Register the ADM to the process thread, which will drive the error // callback mechanism - if (_moduleProcessThreadPtr && - _moduleProcessThreadPtr->RegisterModule(_audioDevicePtr) != 0) + if (_shared->process_thread() && + _shared->process_thread()->RegisterModule(_shared->audio_device()) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceError, - "Init() failed to register the ADM"); + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, + "Init() failed to register the ADM"); return -1; } @@ -407,89 +408,83 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm) // Reinitialize the ADM // Register the AudioObserver implementation - if (_audioDevicePtr->RegisterEventObserver(this) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceWarning, - "Init() failed to register event observer " - "for the ADM"); + if (_shared->audio_device()->RegisterEventObserver(this) != 0) { + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, + "Init() failed to register event observer for the ADM"); } // Register the AudioTransport implementation - if (_audioDevicePtr->RegisterAudioCallback(this) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceWarning, - "Init() failed to register audio callback " - "for the ADM"); + if (_shared->audio_device()->RegisterAudioCallback(this) != 0) { + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, + "Init() failed to register audio callback for the ADM"); } // ADM initialization - if (_audioDevicePtr->Init() != 0) + if (_shared->audio_device()->Init() != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceError, - "Init() failed to initialize the ADM"); + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, + "Init() failed to initialize the ADM"); return -1; } // Initialize the default speaker - if (_audioDevicePtr->SetPlayoutDevice(WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) - != 0) + if (_shared->audio_device()->SetPlayoutDevice( + WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceInfo, + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceInfo, "Init() failed to set the default output device"); } - if (_audioDevicePtr->SpeakerIsAvailable(&available) != 0) + if (_shared->audio_device()->SpeakerIsAvailable(&available) != 0) { - _engineStatistics.SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, + _shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, "Init() failed to check speaker availability, trying to " "initialize speaker anyway"); } else if (!available) { - _engineStatistics.SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, + _shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, "Init() speaker not available, trying to initialize speaker " "anyway"); } - if (_audioDevicePtr->InitSpeaker() != 0) + if (_shared->audio_device()->InitSpeaker() != 0) { - _engineStatistics.SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, + _shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, "Init() failed to initialize the speaker"); } // Initialize the default microphone - if (_audioDevicePtr->SetRecordingDevice(WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) - != 0) + if (_shared->audio_device()->SetRecordingDevice( + WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceInfo, + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceInfo, "Init() failed to set the default input device"); } - if (_audioDevicePtr->MicrophoneIsAvailable(&available) != 0) + if (_shared->audio_device()->MicrophoneIsAvailable(&available) != 0) { - _engineStatistics.SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, + _shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, "Init() failed to check microphone availability, trying to " "initialize microphone anyway"); } else if (!available) { - _engineStatistics.SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, + _shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, "Init() microphone not available, trying to initialize " "microphone anyway"); } - if (_audioDevicePtr->InitMicrophone() != 0) + if (_shared->audio_device()->InitMicrophone() != 0) { - _engineStatistics.SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, + _shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, "Init() failed to initialize the microphone"); } // Set number of channels - if (_audioDevicePtr->StereoPlayoutIsAvailable(&available) != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, - "Init() failed to query stereo playout " - "mode"); + if (_shared->audio_device()->StereoPlayoutIsAvailable(&available) != 0) { + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, + "Init() failed to query stereo playout mode"); } - if (_audioDevicePtr->SetStereoPlayout(available) != 0) + if (_shared->audio_device()->SetStereoPlayout(available) != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, "Init() failed to set mono/stereo playout mode"); } @@ -500,10 +495,10 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm) // // These functions may be changed; tracked here: // http://code.google.com/p/webrtc/issues/detail?id=204 - _audioDevicePtr->StereoRecordingIsAvailable(&available); - if (_audioDevicePtr->SetStereoRecording(available) != 0) + _shared->audio_device()->StereoRecordingIsAvailable(&available); + if (_shared->audio_device()->SetStereoRecording(available) != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, "Init() failed to set mono/stereo recording mode"); } @@ -512,33 +507,35 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm) // Create the AudioProcessing Module if it does not exist. - if (_audioProcessingModulePtr == NULL) + if (_shared->audio_processing() == NULL) { - _audioProcessingModulePtr = AudioProcessing::Create( - VoEId(_instanceId, -1)); - if (_audioProcessingModulePtr == NULL) + _shared->set_audio_processing(AudioProcessing::Create( + VoEId(_shared->instance_id(), -1))); + if (_shared->audio_processing() == NULL) { - _engineStatistics.SetLastError(VE_NO_MEMORY, kTraceCritical, + _shared->SetLastError(VE_NO_MEMORY, kTraceCritical, "Init() failed to create the AP module"); return -1; } // Ensure that mixers in both directions has access to the created APM - _transmitMixerPtr->SetAudioProcessingModule(_audioProcessingModulePtr); - _outputMixerPtr->SetAudioProcessingModule(_audioProcessingModulePtr); + _shared->transmit_mixer()->SetAudioProcessingModule( + _shared->audio_processing()); + _shared->output_mixer()->SetAudioProcessingModule( + _shared->audio_processing()); - if (_audioProcessingModulePtr->echo_cancellation()-> + if (_shared->audio_processing()->echo_cancellation()-> set_device_sample_rate_hz( kVoiceEngineAudioProcessingDeviceSampleRateHz)) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set the device sample rate to 48K for AP " " module"); return -1; } // Using 8 kHz as inital Fs. Might be changed already at first call. - if (_audioProcessingModulePtr->set_sample_rate_hz(8000)) + if (_shared->audio_processing()->set_sample_rate_hz(8000)) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set the sample rate to 8K for AP module"); return -1; } @@ -547,88 +544,88 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm) // we receive the first captured frame. We set stereo input here to // avoid triggering a possible error in SetSendCodec when a stereo // codec is selected. - if (_audioProcessingModulePtr->set_num_channels(2, 1) != 0) + if (_shared->audio_processing()->set_num_channels(2, 1) != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceError, + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceError, "Init() failed to set channels for the primary audio stream"); return -1; } - if (_audioProcessingModulePtr->set_num_reverse_channels(1) != 0) + if (_shared->audio_processing()->set_num_reverse_channels(1) != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceError, + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceError, "Init() failed to set channels for the primary audio stream"); return -1; } // high-pass filter - if (_audioProcessingModulePtr->high_pass_filter()->Enable( + if (_shared->audio_processing()->high_pass_filter()->Enable( WEBRTC_VOICE_ENGINE_HP_DEFAULT_STATE) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set the high-pass filter for AP module"); return -1; } // Echo Cancellation - if (_audioProcessingModulePtr->echo_cancellation()-> + if (_shared->audio_processing()->echo_cancellation()-> enable_drift_compensation(false) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set drift compensation for AP module"); return -1; } - if (_audioProcessingModulePtr->echo_cancellation()->Enable( + if (_shared->audio_processing()->echo_cancellation()->Enable( WEBRTC_VOICE_ENGINE_EC_DEFAULT_STATE)) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set echo cancellation state for AP module"); return -1; } // Noise Reduction - if (_audioProcessingModulePtr->noise_suppression()->set_level( + if (_shared->audio_processing()->noise_suppression()->set_level( (NoiseSuppression::Level) WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set noise reduction level for AP module"); return -1; } - if (_audioProcessingModulePtr->noise_suppression()->Enable( + if (_shared->audio_processing()->noise_suppression()->Enable( WEBRTC_VOICE_ENGINE_NS_DEFAULT_STATE) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set noise reduction state for AP module"); return -1; } // Automatic Gain control - if (_audioProcessingModulePtr->gain_control()->set_analog_level_limits( - kMinVolumeLevel,kMaxVolumeLevel) != 0) + if (_shared->audio_processing()->gain_control()-> + set_analog_level_limits(kMinVolumeLevel,kMaxVolumeLevel) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set AGC analog level for AP module"); return -1; } - if (_audioProcessingModulePtr->gain_control()->set_mode( + if (_shared->audio_processing()->gain_control()->set_mode( (GainControl::Mode) WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set AGC mode for AP module"); return -1; } - if (_audioProcessingModulePtr->gain_control()->Enable( + if (_shared->audio_processing()->gain_control()->Enable( WEBRTC_VOICE_ENGINE_AGC_DEFAULT_STATE) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set AGC state for AP module"); return -1; } // VAD - if (_audioProcessingModulePtr->voice_detection()->Enable( + if (_shared->audio_processing()->voice_detection()->Enable( WEBRTC_VOICE_ENGINE_VAD_DEFAULT_STATE) != 0) { - _engineStatistics.SetLastError(VE_APM_ERROR, kTraceError, + _shared->SetLastError(VE_APM_ERROR, kTraceError, "Init() failed to set VAD state for AP module"); return -1; } @@ -637,135 +634,132 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm) // Set default AGC mode for the ADM #ifdef WEBRTC_VOICE_ENGINE_AGC bool enable(false); - if (_audioProcessingModulePtr->gain_control()->mode() + if (_shared->audio_processing()->gain_control()->mode() != GainControl::kFixedDigital) { - enable = _audioProcessingModulePtr->gain_control()->is_enabled(); + enable = _shared->audio_processing()->gain_control()->is_enabled(); // Only set the AGC mode for the ADM when Adaptive AGC mode is selected - if (_audioDevicePtr->SetAGC(enable) != 0) + if (_shared->audio_device()->SetAGC(enable) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, "Init() failed to set default AGC mode in ADM 0"); } } #endif - return _engineStatistics.SetInitialized(); + return _shared->statistics().SetInitialized(); } int VoEBaseImpl::Terminate() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "Terminate()"); - CriticalSectionScoped cs(_apiCritPtr); + CriticalSectionScoped cs(_shared->crit_sec()); return TerminateInternal(); } int VoEBaseImpl::MaxNumOfChannels() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "MaxNumOfChannels()"); - WebRtc_Word32 maxNumOfChannels = _channelManager.MaxNumOfChannels(); - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), - "MaxNumOfChannels() => %d", maxNumOfChannels); + WebRtc_Word32 maxNumOfChannels = + _shared->channel_manager().MaxNumOfChannels(); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "MaxNumOfChannels() => %d", maxNumOfChannels); return (maxNumOfChannels); } int VoEBaseImpl::CreateChannel() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "CreateChannel()"); - CriticalSectionScoped cs(_apiCritPtr); + CriticalSectionScoped cs(_shared->crit_sec()); - if (!_engineStatistics.Initialized()) + if (!_shared->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } WebRtc_Word32 channelId = -1; - if (!_channelManager.CreateChannel(channelId)) + if (!_shared->channel_manager().CreateChannel(channelId)) { - _engineStatistics.SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, - "CreateChannel() failed to allocate " - "memory for channel"); + _shared->SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, + "CreateChannel() failed to allocate memory for channel"); return -1; } bool destroyChannel(false); { - voe::ScopedChannel sc(_channelManager, channelId); + voe::ScopedChannel sc(_shared->channel_manager(), channelId); voe::Channel* channelPtr = sc.ChannelPtr(); if (channelPtr == NULL) { - _engineStatistics.SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, - "CreateChannel() failed to allocate" - " memory for channel"); + _shared->SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, + "CreateChannel() failed to allocate memory for channel"); return -1; } - else if (channelPtr->SetEngineInformation(_engineStatistics, - *_outputMixerPtr, - *_transmitMixerPtr, - *_moduleProcessThreadPtr, - *_audioDevicePtr, + else if (channelPtr->SetEngineInformation(_shared->statistics(), + *_shared->output_mixer(), + *_shared->transmit_mixer(), + *_shared->process_thread(), + *_shared->audio_device(), _voiceEngineObserverPtr, &_callbackCritSect) != 0) { destroyChannel = true; - _engineStatistics.SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, - "CreateChannel() failed to " - "associate engine and channel." - " Destroying channel."); + _shared->SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, + "CreateChannel() failed to associate engine and channel." + " Destroying channel."); } else if (channelPtr->Init() != 0) { destroyChannel = true; - _engineStatistics.SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, - "CreateChannel() failed to " - "initialize channel. Destroying" - " channel."); + _shared->SetLastError(VE_CHANNEL_NOT_CREATED, kTraceError, + "CreateChannel() failed to initialize channel. Destroying" + " channel."); } } if (destroyChannel) { - _channelManager.DestroyChannel(channelId); + _shared->channel_manager().DestroyChannel(channelId); return -1; } - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), - "CreateChannel() => %d", channelId); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "CreateChannel() => %d", channelId); return channelId; } int VoEBaseImpl::DeleteChannel(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "DeleteChannel(channel=%d)", channel); - CriticalSectionScoped cs(_apiCritPtr); + CriticalSectionScoped cs(_shared->crit_sec()); - 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, - "DeleteChannel() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "DeleteChannel() failed to locate channel"); return -1; } } - if (_channelManager.DestroyChannel(channel) != 0) + if (_shared->channel_manager().DestroyChannel(channel) != 0) { - _engineStatistics.SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "DeleteChannel() failed to destroy " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "DeleteChannel() failed to destroy channel"); return -1; } @@ -796,59 +790,61 @@ int VoEBaseImpl::SetLocalReceiver(int channel, int port, int RTCPport, // SetSendDestination and StartSend without having called SetLocalReceiver // first. The sockets are then created at the first packet transmission. - CriticalSectionScoped cs(_apiCritPtr); + CriticalSectionScoped cs(_shared->crit_sec()); if (ipAddr == NULL && multiCastAddr == NULL) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), - "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d)", - channel, port, RTCPport); + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d)", + channel, port, RTCPport); } else if (ipAddr != NULL && multiCastAddr == NULL) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), - "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d, " - "ipAddr=%s)", channel, port, RTCPport, ipAddr); + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d, ipAddr=%s)", + channel, port, RTCPport, ipAddr); } else if (ipAddr == NULL && multiCastAddr != NULL) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), - "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d, " - "multiCastAddr=%s)", channel, port, RTCPport, - multiCastAddr); + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d, " + "multiCastAddr=%s)", channel, port, RTCPport, multiCastAddr); } else { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), - "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d, " - "ipAddr=%s, multiCastAddr=%s)", channel, port, - RTCPport, ipAddr, multiCastAddr); + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "SetLocalReceiver(channel=%d, port=%d, RTCPport=%d, " + "ipAddr=%s, multiCastAddr=%s)", channel, port, RTCPport, ipAddr, + multiCastAddr); } #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 ((port < 0) || (port > 65535)) { - _engineStatistics.SetLastError(VE_INVALID_PORT_NMBR, kTraceError, - "SetLocalReceiver() invalid RTP port"); + _shared->SetLastError(VE_INVALID_PORT_NMBR, kTraceError, + "SetLocalReceiver() invalid RTP port"); return -1; } if (((RTCPport != kVoEDefault) && (RTCPport < 0)) || ((RTCPport != kVoEDefault) && (RTCPport > 65535))) { - _engineStatistics.SetLastError(VE_INVALID_PORT_NMBR, kTraceError, - "SetLocalReceiver() invalid RTCP port"); + _shared->SetLastError(VE_INVALID_PORT_NMBR, kTraceError, + "SetLocalReceiver() 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, - "SetLocalReceiver() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetLocalReceiver() failed to locate channel"); return -1; } @@ -863,10 +859,9 @@ int VoEBaseImpl::SetLocalReceiver(int channel, int port, int RTCPport, return channelPtr->SetLocalReceiver(port, rtcpPortUW16, ipAddr, multiCastAddr); #else - _engineStatistics.SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, - kTraceWarning, - "SetLocalReceiver() VoE is built for " - "external transport"); + _shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, + kTraceWarning, "SetLocalReceiver() VoE is built for external " + "transport"); return -1; #endif } @@ -874,42 +869,40 @@ int VoEBaseImpl::SetLocalReceiver(int channel, int port, int RTCPport, int VoEBaseImpl::GetLocalReceiver(int channel, int& port, int& RTCPport, char ipAddr[64]) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetLocalReceiver(channel=%d, 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; } - 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, - "SetLocalReceiver() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetLocalReceiver() failed to locate channel"); return -1; } WebRtc_Word32 ret = channelPtr->GetLocalReceiver(port, RTCPport, ipAddr); if (ipAddr != NULL) { - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), - "GetLocalReceiver() => port=%d, RTCPport=%d, ipAddr=%s", - port, RTCPport, ipAddr); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "GetLocalReceiver() => port=%d, RTCPport=%d, ipAddr=%s", + port, RTCPport, ipAddr); } else { - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), - "GetLocalReceiver() => port=%d, RTCPport=%d", port, - RTCPport); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "GetLocalReceiver() => port=%d, RTCPport=%d", port, RTCPport); } return ret; #else - _engineStatistics.SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, - kTraceWarning, - "SetLocalReceiver() VoE is built for " - "external transport"); + _shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning, + "SetLocalReceiver() VoE is built for external transport"); return -1; #endif } @@ -920,46 +913,43 @@ int VoEBaseImpl::SetSendDestination(int channel, int port, const char* ipaddr, WEBRTC_TRACE( kTraceApiCall, kTraceVoice, - VoEId(_instanceId, -1), + VoEId(_shared->instance_id(), -1), "SetSendDestination(channel=%d, port=%d, ipaddr=%s," "sourcePort=%d, RTCPport=%d)", channel, port, ipaddr, sourcePort, RTCPport); - CriticalSectionScoped cs(_apiCritPtr); + CriticalSectionScoped cs(_shared->crit_sec()); #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, - "SetSendDestination() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetSendDestination() failed to locate channel"); return -1; } if ((port < 0) || (port > 65535)) { - _engineStatistics.SetLastError(VE_INVALID_PORT_NMBR, kTraceError, - "SetSendDestination() invalid RTP port"); + _shared->SetLastError(VE_INVALID_PORT_NMBR, kTraceError, + "SetSendDestination() invalid RTP port"); return -1; } if (((RTCPport != kVoEDefault) && (RTCPport < 0)) || ((RTCPport != kVoEDefault) && (RTCPport > 65535))) { - _engineStatistics.SetLastError(VE_INVALID_PORT_NMBR, kTraceError, - "SetSendDestination() invalid RTCP " - "port"); + _shared->SetLastError(VE_INVALID_PORT_NMBR, kTraceError, + "SetSendDestination() invalid RTCP port"); return -1; } if (((sourcePort != kVoEDefault) && (sourcePort < 0)) || ((sourcePort != kVoEDefault) && (sourcePort > 65535))) { - _engineStatistics.SetLastError(VE_INVALID_PORT_NMBR, kTraceError, - "SetSendDestination() invalid source " - "port"); + _shared->SetLastError(VE_INVALID_PORT_NMBR, kTraceError, + "SetSendDestination() invalid source port"); return -1; } @@ -972,7 +962,7 @@ int VoEBaseImpl::SetSendDestination(int channel, int port, const char* ipaddr, WEBRTC_TRACE( kTraceInfo, kTraceVoice, - VoEId(_instanceId, channel), + VoEId(_shared->instance_id(), channel), "SetSendDestination() non default RTCP port %u will be " "utilized", rtcpPortUW16); @@ -981,10 +971,8 @@ int VoEBaseImpl::SetSendDestination(int channel, int port, const char* ipaddr, return channelPtr->SetSendDestination(port, ipaddr, sourcePort, rtcpPortUW16); #else - _engineStatistics.SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, - kTraceWarning, - "SetSendDestination() VoE is built for " - "external transport"); + _shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning, + "SetSendDestination() VoE is built for external transport"); return -1; #endif } @@ -995,23 +983,22 @@ int VoEBaseImpl::GetSendDestination(int channel, int& port, char ipAddr[64], WEBRTC_TRACE( kTraceApiCall, kTraceVoice, - VoEId(_instanceId, -1), + VoEId(_shared->instance_id(), -1), "GetSendDestination(channel=%d, ipAddr[]=?, sourcePort=?," "RTCPport=?)", 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; } - 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, - "GetSendDestination() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "GetSendDestination() failed to locate channel"); return -1; } WebRtc_Word32 ret = channelPtr->GetSendDestination(port, ipAddr, @@ -1021,7 +1008,7 @@ int VoEBaseImpl::GetSendDestination(int channel, int& port, char ipAddr[64], WEBRTC_TRACE( kTraceStateInfo, kTraceVoice, - VoEId(_instanceId, -1), + VoEId(_shared->instance_id(), -1), "GetSendDestination() => port=%d, RTCPport=%d, ipAddr=%s, " "sourcePort=%d, RTCPport=%d", port, RTCPport, ipAddr, sourcePort, RTCPport); @@ -1031,38 +1018,35 @@ int VoEBaseImpl::GetSendDestination(int channel, int& port, char ipAddr[64], WEBRTC_TRACE( kTraceStateInfo, kTraceVoice, - VoEId(_instanceId, -1), + VoEId(_shared->instance_id(), -1), "GetSendDestination() => port=%d, RTCPport=%d, " "sourcePort=%d, RTCPport=%d", port, RTCPport, sourcePort, RTCPport); } return ret; #else - _engineStatistics.SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, - kTraceWarning, - "GetSendDestination() VoE is built for " - "external transport"); + _shared->SetLastError(VE_EXTERNAL_TRANSPORT_ENABLED, kTraceWarning, + "GetSendDestination() VoE is built for external transport"); return -1; #endif } int VoEBaseImpl::StartReceive(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartReceive(channel=%d)", channel); - CriticalSectionScoped cs(_apiCritPtr); - if (!_engineStatistics.Initialized()) + CriticalSectionScoped cs(_shared->crit_sec()); + 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, - "StartReceive() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "StartReceive() failed to locate channel"); return -1; } return channelPtr->StartReceiving(); @@ -1070,21 +1054,20 @@ int VoEBaseImpl::StartReceive(int channel) int VoEBaseImpl::StopReceive(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopListen(channel=%d)", channel); - CriticalSectionScoped cs(_apiCritPtr); - if (!_engineStatistics.Initialized()) + CriticalSectionScoped cs(_shared->crit_sec()); + 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, - "SetLocalReceiver() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetLocalReceiver() failed to locate channel"); return -1; } return channelPtr->StopReceiving(); @@ -1092,21 +1075,20 @@ int VoEBaseImpl::StopReceive(int channel) int VoEBaseImpl::StartPlayout(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartPlayout(channel=%d)", channel); - CriticalSectionScoped cs(_apiCritPtr); - if (!_engineStatistics.Initialized()) + CriticalSectionScoped cs(_shared->crit_sec()); + 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, - "StartPlayout() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "StartPlayout() failed to locate channel"); return -1; } if (channelPtr->Playing()) @@ -1115,10 +1097,8 @@ int VoEBaseImpl::StartPlayout(int channel) } if (StartPlayout() != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceError, - "StartPlayout() failed to start " - "playout"); + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, + "StartPlayout() failed to start playout"); return -1; } return channelPtr->StartPlayout(); @@ -1126,48 +1106,47 @@ int VoEBaseImpl::StartPlayout(int channel) int VoEBaseImpl::StopPlayout(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopPlayout(channel=%d)", channel); - CriticalSectionScoped cs(_apiCritPtr); - if (!_engineStatistics.Initialized()) + CriticalSectionScoped cs(_shared->crit_sec()); + 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, - "StopPlayout() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "StopPlayout() failed to locate channel"); return -1; } if (channelPtr->StopPlayout() != 0) { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), - "StopPlayout() failed to stop playout for channel %d", - channel); + WEBRTC_TRACE(kTraceWarning, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StopPlayout() failed to stop playout for channel %d", channel); } return StopPlayout(); } int VoEBaseImpl::StartSend(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartSend(channel=%d)", channel); - CriticalSectionScoped cs(_apiCritPtr); - if (!_engineStatistics.Initialized()) + CriticalSectionScoped cs(_shared->crit_sec()); + 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, - "StartSend() failed to locate channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "StartSend() failed to locate channel"); return -1; } if (channelPtr->Sending()) @@ -1178,17 +1157,15 @@ int VoEBaseImpl::StartSend(int channel) if (!channelPtr->ExternalTransport() && !channelPtr->SendSocketsInitialized()) { - _engineStatistics.SetLastError(VE_DESTINATION_NOT_INITED, kTraceError, - "StartSend() must set send destination " - "first"); + _shared->SetLastError(VE_DESTINATION_NOT_INITED, kTraceError, + "StartSend() must set send destination first"); return -1; } #endif if (StartSend() != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceError, - "StartSend() failed to start recording"); + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, + "StartSend() failed to start recording"); return -1; } return channelPtr->StartSend(); @@ -1196,40 +1173,40 @@ int VoEBaseImpl::StartSend(int channel) int VoEBaseImpl::StopSend(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopSend(channel=%d)", channel); - CriticalSectionScoped cs(_apiCritPtr); - if (!_engineStatistics.Initialized()) + CriticalSectionScoped cs(_shared->crit_sec()); + 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, - "StopSend() failed to locate channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "StopSend() failed to locate channel"); return -1; } if (channelPtr->StopSend() != 0) { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), - "StopSend() failed to stop sending for channel %d", - channel); + WEBRTC_TRACE(kTraceWarning, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StopSend() failed to stop sending for channel %d", channel); } return StopSend(); } int VoEBaseImpl::GetVersion(char version[1024]) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetVersion(version=?)"); assert(kVoiceEngineVersionMaxMessageSize == 1024); if (version == NULL) { - _engineStatistics.SetLastError(VE_INVALID_ARGUMENT, kTraceError); + _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError); return (-1); } @@ -1283,8 +1260,8 @@ int VoEBaseImpl::GetVersion(char version[1024]) // to avoid the truncation in the trace, split the string into parts char partOfVersion[256]; - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), - "GetVersion() =>"); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), "GetVersion() =>"); for (int partStart = 0; partStart < accLen;) { memset(partOfVersion, 0, sizeof(partOfVersion)); @@ -1302,8 +1279,8 @@ int VoEBaseImpl::GetVersion(char version[1024]) memcpy(partOfVersion, &version[partStart], accLen - partStart); } partStart = partEnd; - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), - "%s", partOfVersion); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), "%s", partOfVersion); } return 0; @@ -1335,28 +1312,27 @@ WebRtc_Word32 VoEBaseImpl::AddExternalRecAndPlayoutBuild(char* str) const int VoEBaseImpl::LastError() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "LastError()"); - return (_engineStatistics.LastError()); + return (_shared->statistics().LastError()); } int VoEBaseImpl::SetNetEQPlayoutMode(int channel, NetEqModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetNetEQPlayoutMode(channel=%i, mode=%i)", channel, mode); - 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, - "SetNetEQPlayoutMode() failed to locate" - " channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetNetEQPlayoutMode() failed to locate channel"); return -1; } return channelPtr->SetNetEQPlayoutMode(mode); @@ -1364,20 +1340,19 @@ int VoEBaseImpl::SetNetEQPlayoutMode(int channel, NetEqModes mode) int VoEBaseImpl::GetNetEQPlayoutMode(int channel, NetEqModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetNetEQPlayoutMode(channel=%i, mode=?)", 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, - "GetNetEQPlayoutMode() failed to locate" - " channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "GetNetEQPlayoutMode() failed to locate channel"); return -1; } return channelPtr->GetNetEQPlayoutMode(mode); @@ -1385,20 +1360,19 @@ int VoEBaseImpl::GetNetEQPlayoutMode(int channel, NetEqModes& mode) int VoEBaseImpl::SetNetEQBGNMode(int channel, NetEqBgnModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetNetEQBGNMode(channel=%i, mode=%i)", channel, mode); - 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, - "SetNetEQBGNMode() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetNetEQBGNMode() failed to locate channel"); return -1; } return channelPtr->SetNetEQBGNMode(mode); @@ -1406,20 +1380,19 @@ int VoEBaseImpl::SetNetEQBGNMode(int channel, NetEqBgnModes mode) int VoEBaseImpl::GetNetEQBGNMode(int channel, NetEqBgnModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetNetEQBGNMode(channel=%i, mode=?)", 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, - "GetNetEQBGNMode() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "GetNetEQBGNMode() failed to locate channel"); return -1; } return channelPtr->GetNetEQBGNMode(mode); @@ -1427,21 +1400,20 @@ int VoEBaseImpl::GetNetEQBGNMode(int channel, NetEqBgnModes& mode) int VoEBaseImpl::SetOnHoldStatus(int channel, bool enable, OnHoldModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetOnHoldStatus(channel=%d, enable=%d, mode=%d)", channel, enable, mode); - 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, - "SetOnHoldStatus() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetOnHoldStatus() failed to locate channel"); return -1; } return channelPtr->SetOnHoldStatus(enable, mode); @@ -1449,20 +1421,19 @@ int VoEBaseImpl::SetOnHoldStatus(int channel, bool enable, OnHoldModes mode) int VoEBaseImpl::GetOnHoldStatus(int channel, bool& enabled, OnHoldModes& mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetOnHoldStatus(channel=%d, enabled=?, mode=?)", 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, - "GetOnHoldStatus() failed to locate " - "channel"); + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "GetOnHoldStatus() failed to locate channel"); return -1; } return channelPtr->GetOnHoldStatus(enabled, mode); @@ -1470,24 +1441,26 @@ int VoEBaseImpl::GetOnHoldStatus(int channel, bool& enabled, OnHoldModes& mode) WebRtc_Word32 VoEBaseImpl::StartPlayout() { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::StartPlayout()"); - if (_audioDevicePtr->Playing()) + if (_shared->audio_device()->Playing()) { return 0; } - if (!_externalPlayout) + if (!_shared->ext_playout()) { - if (_audioDevicePtr->InitPlayout() != 0) + if (_shared->audio_device()->InitPlayout() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), - "StartPlayout() failed to initialize playout"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartPlayout() failed to initialize playout"); return -1; } - if (_audioDevicePtr->StartPlayout() != 0) + if (_shared->audio_device()->StartPlayout() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), - "StartPlayout() failed to start playout"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartPlayout() failed to start playout"); return -1; } } @@ -1496,10 +1469,10 @@ WebRtc_Word32 VoEBaseImpl::StartPlayout() WebRtc_Word32 VoEBaseImpl::StopPlayout() { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::StopPlayout()"); - WebRtc_Word32 numOfChannels = _channelManager.NumOfChannels(); + WebRtc_Word32 numOfChannels = _shared->channel_manager().NumOfChannels(); if (numOfChannels <= 0) { return 0; @@ -1509,10 +1482,10 @@ WebRtc_Word32 VoEBaseImpl::StopPlayout() WebRtc_Word32* channelsArray = new WebRtc_Word32[numOfChannels]; // Get number of playing channels - _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* chPtr = sc.ChannelPtr(); if (chPtr) { @@ -1527,11 +1500,10 @@ WebRtc_Word32 VoEBaseImpl::StopPlayout() // Stop audio-device playing if no channel is playing out if (nChannelsPlaying == 0) { - if (_audioDevicePtr->StopPlayout() != 0) + if (_shared->audio_device()->StopPlayout() != 0) { - _engineStatistics.SetLastError(VE_CANNOT_STOP_PLAYOUT, kTraceError, - "StopPlayout() failed to stop " - "playout"); + _shared->SetLastError(VE_CANNOT_STOP_PLAYOUT, kTraceError, + "StopPlayout() failed to stop playout"); return -1; } } @@ -1540,24 +1512,26 @@ WebRtc_Word32 VoEBaseImpl::StopPlayout() WebRtc_Word32 VoEBaseImpl::StartSend() { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::StartSend()"); - if (_audioDevicePtr->Recording()) + if (_shared->audio_device()->Recording()) { return 0; } - if (!_externalRecording) + if (!_shared->ext_recording()) { - if (_audioDevicePtr->InitRecording() != 0) + if (_shared->audio_device()->InitRecording() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), - "StartSend() failed to initialize recording"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartSend() failed to initialize recording"); return -1; } - if (_audioDevicePtr->StartRecording() != 0) + if (_shared->audio_device()->StartRecording() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), - "StartSend() failed to start recording"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartSend() failed to start recording"); return -1; } } @@ -1567,21 +1541,20 @@ WebRtc_Word32 VoEBaseImpl::StartSend() WebRtc_Word32 VoEBaseImpl::StopSend() { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::StopSend()"); - if ((NumOfSendingChannels() == 0) && !_transmitMixerPtr->IsRecordingMic()) + if (_shared->NumOfSendingChannels() == 0 && + !_shared->transmit_mixer()->IsRecordingMic()) { // Stop audio-device recording if no channel is recording - if (_audioDevicePtr->StopRecording() != 0) + if (_shared->audio_device()->StopRecording() != 0) { - _engineStatistics.SetLastError(VE_CANNOT_STOP_RECORDING, - kTraceError, - "StopSend() failed to stop " - "recording"); + _shared->SetLastError(VE_CANNOT_STOP_RECORDING, kTraceError, + "StopSend() failed to stop recording"); return -1; } - _transmitMixerPtr->StopSend(); + _shared->transmit_mixer()->StopSend(); } return 0; @@ -1589,15 +1562,15 @@ WebRtc_Word32 VoEBaseImpl::StopSend() WebRtc_Word32 VoEBaseImpl::TerminateInternal() { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEBaseImpl::TerminateInternal()"); // Delete any remaining channel objects - WebRtc_Word32 numOfChannels = _channelManager.NumOfChannels(); + WebRtc_Word32 numOfChannels = _shared->channel_manager().NumOfChannels(); if (numOfChannels > 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++) { DeleteChannel(channelsArray[i]); @@ -1605,75 +1578,66 @@ WebRtc_Word32 VoEBaseImpl::TerminateInternal() delete[] channelsArray; } - if (_moduleProcessThreadPtr) + if (_shared->process_thread()) { - if (_audioDevicePtr) + if (_shared->audio_device()) { - if (_moduleProcessThreadPtr->DeRegisterModule(_audioDevicePtr) != 0) + if (_shared->process_thread()-> + DeRegisterModule(_shared->audio_device()) != 0) { - _engineStatistics.SetLastError(VE_THREAD_ERROR, kTraceError, - "TerminateInternal() failed to " - "deregister ADM"); + _shared->SetLastError(VE_THREAD_ERROR, kTraceError, + "TerminateInternal() failed to deregister ADM"); } } - if (_moduleProcessThreadPtr->Stop() != 0) + if (_shared->process_thread()->Stop() != 0) { - _engineStatistics.SetLastError(VE_THREAD_ERROR, kTraceError, - "TerminateInternal() failed to stop " - "module process thread"); + _shared->SetLastError(VE_THREAD_ERROR, kTraceError, + "TerminateInternal() failed to stop module process thread"); } } // Audio Device Module - if (_audioDevicePtr != NULL) + if (_shared->audio_device() != NULL) { - if (_audioDevicePtr->StopPlayout() != 0) + if (_shared->audio_device()->StopPlayout() != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, - "TerminateInternal() failed to stop " - "playout"); + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, + "TerminateInternal() failed to stop playout"); } - if (_audioDevicePtr->StopRecording() != 0) + if (_shared->audio_device()->StopRecording() != 0) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, - "TerminateInternal() failed to stop " - "recording"); + _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, + "TerminateInternal() failed to stop recording"); } - if (_audioDevicePtr->RegisterEventObserver(NULL) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceWarning, - "TerminateInternal() failed to de-" - "register event observer for the ADM"); + if (_shared->audio_device()->RegisterEventObserver(NULL) != 0) { + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, + "TerminateInternal() failed to de-register event observer " + "for the ADM"); } - if (_audioDevicePtr->RegisterAudioCallback(NULL) != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceWarning, - "TerminateInternal() failed to de-" - "register audio callback for the ADM"); + if (_shared->audio_device()->RegisterAudioCallback(NULL) != 0) { + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, + "TerminateInternal() failed to de-register audio callback " + "for the ADM"); } - if (_audioDevicePtr->Terminate() != 0) + if (_shared->audio_device()->Terminate() != 0) { - _engineStatistics.SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, - kTraceError, - "TerminateInternal() failed to " - "terminate the ADM"); + _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, + "TerminateInternal() failed to terminate the ADM"); } - _audioDevicePtr->Release(); - _audioDevicePtr = NULL; + _shared->set_audio_device(NULL); } // AP module - if (_audioProcessingModulePtr != NULL) + if (_shared->audio_processing() != NULL) { - _transmitMixerPtr->SetAudioProcessingModule(NULL); - AudioProcessing::Destroy(_audioProcessingModulePtr); - _audioProcessingModulePtr = NULL; + _shared->transmit_mixer()->SetAudioProcessingModule(NULL); + _shared->set_audio_processing(NULL); } - return _engineStatistics.SetUnInitialized(); + return _shared->statistics().SetUnInitialized(); } } // namespace webrtc diff --git a/src/voice_engine/main/source/voe_base_impl.h b/src/voice_engine/main/source/voe_base_impl.h index 9a31bdfd4..264c4adb5 100644 --- a/src/voice_engine/main/source/voe_base_impl.h +++ b/src/voice_engine/main/source/voe_base_impl.h @@ -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; }; diff --git a/src/voice_engine/main/source/voe_call_report_impl.cc b/src/voice_engine/main/source/voe_call_report_impl.cc index 8be8e0152..7875ec6b8 100644 --- a/src/voice_engine/main/source/voe_call_report_impl.cc +++ b/src/voice_engine/main/source/voe_call_report_impl.cc @@ -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) { diff --git a/src/voice_engine/main/source/voe_call_report_impl.h b/src/voice_engine/main/source/voe_call_report_impl.h index f5852b4dc..2a39bd6d9 100644 --- a/src/voice_engine/main/source/voe_call_report_impl.h +++ b/src/voice_engine/main/source/voe_call_report_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_codec_impl.cc b/src/voice_engine/main/source/voe_codec_impl.cc index 8bb084017..b7623336e 100644 --- a/src/voice_engine/main/source/voe_codec_impl.cc +++ b/src/voice_engine/main/source/voe_codec_impl.cc @@ -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) diff --git a/src/voice_engine/main/source/voe_codec_impl.h b/src/voice_engine/main/source/voe_codec_impl.h index fde1d4155..8fef9fed2 100644 --- a/src/voice_engine/main/source/voe_codec_impl.h +++ b/src/voice_engine/main/source/voe_codec_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_dtmf_impl.cc b/src/voice_engine/main/source/voe_dtmf_impl.cc index a554da898..b9ce67e93 100644 --- a/src/voice_engine/main/source/voe_dtmf_impl.cc +++ b/src/voice_engine/main/source/voe_dtmf_impl.cc @@ -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 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; } diff --git a/src/voice_engine/main/source/voe_dtmf_impl.h b/src/voice_engine/main/source/voe_dtmf_impl.h index 5b5396905..27fa68bbc 100644 --- a/src/voice_engine/main/source/voe_dtmf_impl.h +++ b/src/voice_engine/main/source/voe_dtmf_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_encryption_impl.cc b/src/voice_engine/main/source/voe_encryption_impl.cc index 5ba944be1..b84fa1b37 100644 --- a/src/voice_engine/main/source/voe_encryption_impl.cc +++ b/src/voice_engine/main/source/voe_encryption_impl.cc @@ -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; } diff --git a/src/voice_engine/main/source/voe_encryption_impl.h b/src/voice_engine/main/source/voe_encryption_impl.h index 050dd8811..e2aa296c0 100644 --- a/src/voice_engine/main/source/voe_encryption_impl.h +++ b/src/voice_engine/main/source/voe_encryption_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_external_media_impl.cc b/src/voice_engine/main/source/voe_external_media_impl.cc index 3fc323982..998198eb4 100644 --- a/src/voice_engine/main/source/voe_external_media_impl.cc +++ b/src/voice_engine/main/source/voe_external_media_impl.cc @@ -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 diff --git a/src/voice_engine/main/source/voe_external_media_impl.h b/src/voice_engine/main/source/voe_external_media_impl.h index fa1ff8aad..36696e0f8 100644 --- a/src/voice_engine/main/source/voe_external_media_impl.h +++ b/src/voice_engine/main/source/voe_external_media_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_file_impl.cc b/src/voice_engine/main/source/voe_file_impl.cc index 637dce733..06b45d13d 100644 --- a/src/voice_engine/main/source/voe_file_impl.cc +++ b/src/voice_engine/main/source/voe_file_impl.cc @@ -41,33 +41,33 @@ VoEFile* VoEFile::GetInterface(VoiceEngine* voiceEngine) #ifdef WEBRTC_VOICE_ENGINE_FILE_API -VoEFileImpl::VoEFileImpl() +VoEFileImpl::VoEFileImpl(voe::SharedData* shared) : _shared(shared) { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEFileImpl::VoEFileImpl() - ctor"); } VoEFileImpl::~VoEFileImpl() { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEFileImpl::~VoEFileImpl() - dtor"); } int VoEFileImpl::Release() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "VoEFile::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), - "VoEFile reference counter = %d", refCount); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "VoEFile reference counter = %d", refCount); return (refCount); } @@ -79,24 +79,23 @@ int VoEFileImpl::StartPlayingFileLocally( int startPointMs, int stopPointMs) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartPlayingFileLocally(channel=%d, fileNameUTF8[]=%s, " "loop=%d, format=%d, volumeScaling=%5.3f, startPointMs=%d," " stopPointMs=%d)", channel, fileNameUTF8, loop, format, volumeScaling, startPointMs, stopPointMs); 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, "StartPlayingFileLocally() failed to locate channel"); return -1; } @@ -117,23 +116,22 @@ int VoEFileImpl::StartPlayingFileLocally(int channel, int startPointMs, int stopPointMs) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartPlayingFileLocally(channel=%d, stream, format=%d, " "volumeScaling=%5.3f, startPointMs=%d, stopPointMs=%d)", channel, format, volumeScaling, startPointMs, stopPointMs); - 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, "StartPlayingFileLocally() failed to locate channel"); return -1; } @@ -148,19 +146,18 @@ int VoEFileImpl::StartPlayingFileLocally(int channel, int VoEFileImpl::StopPlayingFileLocally(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopPlayingFileLocally()"); - 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, "StopPlayingFileLocally() failed to locate channel"); return -1; } @@ -169,19 +166,18 @@ int VoEFileImpl::StopPlayingFileLocally(int channel) int VoEFileImpl::IsPlayingFileLocally(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "IsPlayingFileLocally(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, "StopPlayingFileLocally() failed to locate channel"); return -1; } @@ -190,20 +186,19 @@ int VoEFileImpl::IsPlayingFileLocally(int channel) int VoEFileImpl::ScaleLocalFilePlayout(int channel, float scale) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ScaleLocalFilePlayout(channel=%d, scale=%5.3f)", channel, scale); - 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, "StopPlayingFileLocally() failed to locate channel"); return -1; } @@ -217,16 +212,16 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, FileFormats format, float volumeScaling) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartPlayingFileAsMicrophone(channel=%d, fileNameUTF8=%s, " "loop=%d, mixWithMicrophone=%d, format=%d, " "volumeScaling=%5.3f)", channel, fileNameUTF8, loop, mixWithMicrophone, format, volumeScaling); 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; } @@ -235,7 +230,7 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, if (channel == -1) { - int res = _transmitMixerPtr->StartPlayingFileAsMicrophone( + int res = _shared->transmit_mixer()->StartPlayingFileAsMicrophone( fileNameUTF8, loop, format, @@ -245,25 +240,25 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, NULL); if (res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartPlayingFileAsMicrophone() failed to start" - " playing file"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartPlayingFileAsMicrophone() failed to start playing file"); return(-1); } else { - _transmitMixerPtr->SetMixWithMicStatus(mixWithMicrophone); + _shared->transmit_mixer()->SetMixWithMicStatus(mixWithMicrophone); return(0); } } else { // Add file 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, "StartPlayingFileAsMicrophone() failed to locate channel"); return -1; } @@ -277,9 +272,9 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, NULL); if (res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartPlayingFileAsMicrophone() failed to start " - "playing file"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartPlayingFileAsMicrophone() failed to start playing file"); return -1; } else @@ -296,14 +291,14 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, FileFormats format, float volumeScaling) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartPlayingFileAsMicrophone(channel=%d, stream," " mixWithMicrophone=%d, format=%d, volumeScaling=%5.3f)", channel, mixWithMicrophone, format, volumeScaling); - if (!_engineStatistics.Initialized()) + if (!_shared->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } @@ -312,7 +307,7 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, if (channel == -1) { - int res = _transmitMixerPtr->StartPlayingFileAsMicrophone( + int res = _shared->transmit_mixer()->StartPlayingFileAsMicrophone( stream, format, startPointMs, @@ -321,26 +316,26 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, NULL); if (res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartPlayingFileAsMicrophone() failed to start" - " playing stream"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartPlayingFileAsMicrophone() failed to start " + "playing stream"); return(-1); } else { - _transmitMixerPtr->SetMixWithMicStatus(mixWithMicrophone); + _shared->transmit_mixer()->SetMixWithMicStatus(mixWithMicrophone); return(0); } } else { // Add file 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, "StartPlayingFileAsMicrophone() failed to locate channel"); return -1; } @@ -349,9 +344,10 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, stream, format, startPointMs, volumeScaling, stopPointMs, NULL); if (res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartPlayingFileAsMicrophone() failed to start" - " playing stream"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartPlayingFileAsMicrophone() failed to start " + "playing stream"); return -1; } else @@ -364,27 +360,26 @@ int VoEFileImpl::StartPlayingFileAsMicrophone(int channel, int VoEFileImpl::StopPlayingFileAsMicrophone(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopPlayingFileAsMicrophone(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) { // Stop adding file before demultiplexing <=> affects all channels - return _transmitMixerPtr->StopPlayingFileAsMicrophone(); + return _shared->transmit_mixer()->StopPlayingFileAsMicrophone(); } else { // Stop adding file 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, "StopPlayingFileAsMicrophone() failed to locate channel"); return -1; } @@ -394,26 +389,25 @@ int VoEFileImpl::StopPlayingFileAsMicrophone(int channel) int VoEFileImpl::IsPlayingFileAsMicrophone(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "IsPlayingFileAsMicrophone(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) { - return _transmitMixerPtr->IsPlayingFileAsMicrophone(); + return _shared->transmit_mixer()->IsPlayingFileAsMicrophone(); } else { // Stop adding file 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, "IsPlayingFileAsMicrophone() failed to locate channel"); return -1; } @@ -423,28 +417,27 @@ int VoEFileImpl::IsPlayingFileAsMicrophone(int channel) int VoEFileImpl::ScaleFileAsMicrophonePlayout(int channel, float scale) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ScaleFileAsMicrophonePlayout(channel=%d, scale=%5.3f)", channel, scale); - 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 _transmitMixerPtr->ScaleFileAsMicrophonePlayout(scale); + return _shared->transmit_mixer()->ScaleFileAsMicrophonePlayout(scale); } else { // Stop adding file 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, "IsPlayingFileAsMicrophone() failed to locate channel"); return -1; } @@ -456,31 +449,30 @@ int VoEFileImpl::StartRecordingPlayout( int channel, const char* fileNameUTF8, CodecInst* compression, int maxSizeBytes) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartRecordingPlayout(channel=%d, fileNameUTF8=%s, " "compression, maxSizeBytes=%d)", channel, fileNameUTF8, maxSizeBytes); 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; } if (channel == -1) { - return _outputMixerPtr->StartRecordingPlayout + return _shared->output_mixer()->StartRecordingPlayout (fileNameUTF8, compression); } else { // Add file 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, "StartRecordingPlayout() failed to locate channel"); return -1; } @@ -491,26 +483,26 @@ int VoEFileImpl::StartRecordingPlayout( int VoEFileImpl::StartRecordingPlayout( int channel, OutStream* stream, CodecInst* compression) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartRecordingPlayout(channel=%d, stream, compression)", 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->StartRecordingPlayout(stream, compression); + return _shared->output_mixer()-> + StartRecordingPlayout(stream, compression); } 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, "StartRecordingPlayout() failed to locate channel"); return -1; } @@ -520,25 +512,24 @@ int VoEFileImpl::StartRecordingPlayout( int VoEFileImpl::StopRecordingPlayout(int channel) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopRecordingPlayout(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) { - return _outputMixerPtr->StopRecordingPlayout(); + return _shared->output_mixer()->StopRecordingPlayout(); } 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, "StopRecordingPlayout() failed to locate channel"); return -1; } @@ -549,38 +540,41 @@ int VoEFileImpl::StopRecordingPlayout(int channel) int VoEFileImpl::StartRecordingMicrophone( const char* fileNameUTF8, CodecInst* compression, int maxSizeBytes) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartRecordingMicrophone(fileNameUTF8=%s, compression, " "maxSizeBytes=%d)", fileNameUTF8, maxSizeBytes); 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; } - if (_transmitMixerPtr->StartRecordingMicrophone(fileNameUTF8, compression)) + if (_shared->transmit_mixer()->StartRecordingMicrophone(fileNameUTF8, + compression)) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartRecordingMicrophone() failed to start recording"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartRecordingMicrophone() failed to start recording"); return -1; } - if (_audioDevicePtr->Recording()) + if (_shared->audio_device()->Recording()) { return 0; } - if (!_externalRecording) + if (!_shared->ext_recording()) { - if (_audioDevicePtr->InitRecording() != 0) + if (_shared->audio_device()->InitRecording() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartRecordingMicrophone() failed to initialize" - " recording"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartRecordingMicrophone() failed to initialize recording"); return -1; } - if (_audioDevicePtr->StartRecording() != 0) + if (_shared->audio_device()->StartRecording() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), "StartRecordingMicrophone() failed to start recording"); return -1; } @@ -591,38 +585,40 @@ int VoEFileImpl::StartRecordingMicrophone( int VoEFileImpl::StartRecordingMicrophone( OutStream* stream, CodecInst* compression) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StartRecordingMicrophone(stream, compression)"); - if (!_engineStatistics.Initialized()) + if (!_shared->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - if (_transmitMixerPtr->StartRecordingMicrophone(stream, compression) == -1) + if (_shared->transmit_mixer()->StartRecordingMicrophone(stream, + compression) == -1) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartRecordingMicrophone() failed to start recording"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartRecordingMicrophone() failed to start recording"); return -1; } - if (_audioDevicePtr->Recording()) + if (_shared->audio_device()->Recording()) { return 0; } - if (!_externalRecording) + if (!_shared->ext_recording()) { - if (_audioDevicePtr->InitRecording() != 0) + if (_shared->audio_device()->InitRecording() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartRecordingMicrophone() failed to initialize " - "recording"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartRecordingMicrophone() failed to initialize recording"); return -1; } - if (_audioDevicePtr->StartRecording() != 0) + if (_shared->audio_device()->StartRecording() != 0) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "StartRecordingMicrophone() failed to start" - " recording"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StartRecordingMicrophone() failed to start recording"); return -1; } } @@ -631,31 +627,31 @@ int VoEFileImpl::StartRecordingMicrophone( int VoEFileImpl::StopRecordingMicrophone() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "StopRecordingMicrophone()"); - if (!_engineStatistics.Initialized()) + if (!_shared->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - if ((NumOfSendingChannels() == 0)&&_audioDevicePtr->Recording()) + if (_shared->NumOfSendingChannels() == 0 && + _shared->audio_device()->Recording()) { // Stop audio-device recording if no channel is recording - if (_audioDevicePtr->StopRecording() != 0) + if (_shared->audio_device()->StopRecording() != 0) { - _engineStatistics.SetLastError( - VE_CANNOT_STOP_RECORDING, kTraceError, + _shared->SetLastError(VE_CANNOT_STOP_RECORDING, kTraceError, "StopRecordingMicrophone() failed to stop recording"); return -1; } } - return _transmitMixerPtr->StopRecordingMicrophone(); + return _shared->transmit_mixer()->StopRecordingMicrophone(); } int VoEFileImpl::ConvertPCMToWAV(const char* fileNameInUTF8, const char* fileNameOutUTF8) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertPCMToWAV(fileNameInUTF8=%s, fileNameOutUTF8=%s)", fileNameInUTF8, fileNameOutUTF8); @@ -667,8 +663,7 @@ int VoEFileImpl::ConvertPCMToWAV(const char* fileNameInUTF8, int res=playerObj.StartPlayingFile(fileNameInUTF8,false,0,1.0,0,0, NULL); if (res) { - _engineStatistics.SetLastError( - VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToWAV failed to create player object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -690,8 +685,7 @@ int VoEFileImpl::ConvertPCMToWAV(const char* fileNameInUTF8, res = recObj.StartRecordingAudioFile(fileNameOutUTF8,codecInst,0); if (res) { - _engineStatistics.SetLastError( - VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToWAV failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -720,18 +714,18 @@ int VoEFileImpl::ConvertPCMToWAV(const char* fileNameInUTF8, AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToWAV failed during conversion " - "(audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToWAV failed during conversion (audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToWAV failed during converstion " - "(write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToWAV failed during conversion (write frame)"); } } @@ -745,13 +739,13 @@ int VoEFileImpl::ConvertPCMToWAV(const char* fileNameInUTF8, int VoEFileImpl::ConvertPCMToWAV(InStream* streamIn, OutStream* streamOut) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertPCMToWAV(streamIn, streamOut)"); if ((streamIn == NULL) || (streamOut == NULL)) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "invalid stream handles"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), "invalid stream handles"); return (-1); } @@ -761,7 +755,7 @@ int VoEFileImpl::ConvertPCMToWAV(InStream* streamIn, OutStream* streamOut) int res = playerObj.StartPlayingFile(*streamIn,0,1.0,0,0,NULL); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToWAV failed to create player object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -781,7 +775,7 @@ int VoEFileImpl::ConvertPCMToWAV(InStream* streamIn, OutStream* streamOut) res = recObj.StartRecordingAudioFile(*streamOut,codecInst,0); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToWAV failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -810,18 +804,19 @@ int VoEFileImpl::ConvertPCMToWAV(InStream* streamIn, OutStream* streamOut) AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToWAV failed during conversion " - "(create audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToWAV failed during conversion " + "(create audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToWAV failed during converstion " - "(write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToWAV failed during conversion (write frame)"); } } @@ -836,7 +831,7 @@ int VoEFileImpl::ConvertPCMToWAV(InStream* streamIn, OutStream* streamOut) int VoEFileImpl::ConvertWAVToPCM(const char* fileNameInUTF8, const char* fileNameOutUTF8) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertWAVToPCM(fileNameInUTF8=%s, fileNameOutUTF8=%s)", fileNameInUTF8, fileNameOutUTF8); @@ -846,8 +841,7 @@ int VoEFileImpl::ConvertWAVToPCM(const char* fileNameInUTF8, int res = playerObj.StartPlayingFile(fileNameInUTF8,false,0,1.0,0,0,NULL); if (res) { - _engineStatistics.SetLastError( - VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertWAVToPCM failed to create player object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -869,8 +863,7 @@ int VoEFileImpl::ConvertWAVToPCM(const char* fileNameInUTF8, res = recObj.StartRecordingAudioFile(fileNameOutUTF8,codecInst,0); if (res) { - _engineStatistics.SetLastError( - VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertWAVToPCM failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -899,18 +892,18 @@ int VoEFileImpl::ConvertWAVToPCM(const char* fileNameInUTF8, AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertWAVToPCM failed during conversion " - "(audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertWAVToPCM failed during conversion (audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertWAVToPCM failed during converstion " - "(write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertWAVToPCM failed during conversion (write frame)"); } } @@ -924,13 +917,13 @@ int VoEFileImpl::ConvertWAVToPCM(const char* fileNameInUTF8, int VoEFileImpl::ConvertWAVToPCM(InStream* streamIn, OutStream* streamOut) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertWAVToPCM(streamIn, streamOut)"); if ((streamIn == NULL) || (streamOut == NULL)) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "invalid stream handles"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), "invalid stream handles"); return (-1); } @@ -940,7 +933,7 @@ int VoEFileImpl::ConvertWAVToPCM(InStream* streamIn, OutStream* streamOut) int res = playerObj.StartPlayingFile(*streamIn,0,1.0,0,0,NULL); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertWAVToPCM failed to create player object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -962,7 +955,7 @@ int VoEFileImpl::ConvertWAVToPCM(InStream* streamIn, OutStream* streamOut) res = recObj.StartRecordingAudioFile(*streamOut,codecInst,0); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertWAVToPCM failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -991,18 +984,18 @@ int VoEFileImpl::ConvertWAVToPCM(InStream* streamIn, OutStream* streamOut) AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertWAVToPCM failed during conversion " - "(audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertWAVToPCM failed during conversion (audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertWAVToPCM failed during converstion" - " (write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertWAVToPCM failed during conversion (write frame)"); } } @@ -1018,10 +1011,10 @@ int VoEFileImpl::ConvertPCMToCompressed(const char* fileNameInUTF8, const char* fileNameOutUTF8, CodecInst* compression) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertPCMToCompressed(fileNameInUTF8=%s, fileNameOutUTF8=%s" ", compression)", fileNameInUTF8, fileNameOutUTF8); - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), " compression: plname=%s, plfreq=%d, pacsize=%d", compression->plname, compression->plfreq, compression->pacsize); @@ -1033,7 +1026,7 @@ int VoEFileImpl::ConvertPCMToCompressed(const char* fileNameInUTF8, int res = playerObj.StartPlayingFile(fileNameInUTF8,false,0,1.0,0,0, NULL); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToCompressed failed to create player object"); // Clean up and shutdown the file player playerObj.StopPlayingFile(); @@ -1048,7 +1041,7 @@ int VoEFileImpl::ConvertPCMToCompressed(const char* fileNameInUTF8, res = recObj.StartRecordingAudioFile(fileNameOutUTF8, *compression,0); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToCompressed failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -1076,18 +1069,20 @@ int VoEFileImpl::ConvertPCMToCompressed(const char* fileNameInUTF8, AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToCompressed failed during conversion " - "(audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToCompressed failed during conversion " + "(audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToCompressed failed during converstion " - "(write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToCompressed failed during conversion " + "(write frame)"); } } @@ -1103,17 +1098,17 @@ int VoEFileImpl::ConvertPCMToCompressed(InStream* streamIn, OutStream* streamOut, CodecInst* compression) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertPCMToCompressed(streamIn, streamOut, compression)"); if ((streamIn == NULL) || (streamOut == NULL)) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "invalid stream handles"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), "invalid stream handles"); return (-1); } - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), " compression: plname=%s, plfreq=%d, pacsize=%d", compression->plname, compression->plfreq, compression->pacsize); @@ -1125,7 +1120,7 @@ int VoEFileImpl::ConvertPCMToCompressed(InStream* streamIn, int res = playerObj.StartPlayingFile(*streamIn,0,1.0,0,0,NULL); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToCompressed failed to create player object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -1138,7 +1133,7 @@ int VoEFileImpl::ConvertPCMToCompressed(InStream* streamIn, res = recObj.StartRecordingAudioFile(*streamOut,*compression,0); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertPCMToCompressed failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -1166,18 +1161,20 @@ int VoEFileImpl::ConvertPCMToCompressed(InStream* streamIn, AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToCompressed failed during conversion" - " (audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToCompressed failed during conversion " + "(audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertPCMToCompressed failed during converstion " - "(write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertPCMToCompressed failed during conversion " + "(write frame)"); } } @@ -1192,7 +1189,7 @@ int VoEFileImpl::ConvertPCMToCompressed(InStream* streamIn, int VoEFileImpl::ConvertCompressedToPCM(const char* fileNameInUTF8, const char* fileNameOutUTF8) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertCompressedToPCM(fileNameInUTF8=%s," " fileNameOutUTF8=%s)", fileNameInUTF8, fileNameOutUTF8); @@ -1204,7 +1201,7 @@ int VoEFileImpl::ConvertCompressedToPCM(const char* fileNameInUTF8, int res = playerObj.StartPlayingFile(fileNameInUTF8,false,0,1.0,0,0,NULL); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertCompressedToPCM failed to create player object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -1226,7 +1223,7 @@ int VoEFileImpl::ConvertCompressedToPCM(const char* fileNameInUTF8, res = recObj.StartRecordingAudioFile(fileNameOutUTF8,codecInst,0); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertCompressedToPCM failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -1255,18 +1252,20 @@ int VoEFileImpl::ConvertCompressedToPCM(const char* fileNameInUTF8, AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertCompressedToPCM failed during conversion " - "(create audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertCompressedToPCM failed during conversion " + "(create audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertCompressedToPCM failed during converstion " - "(write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertCompressedToPCM failed during conversion " + "(write frame)"); } } @@ -1281,13 +1280,13 @@ int VoEFileImpl::ConvertCompressedToPCM(const char* fileNameInUTF8, int VoEFileImpl::ConvertCompressedToPCM(InStream* streamIn, OutStream* streamOut) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "ConvertCompressedToPCM(file, file);"); if ((streamIn == NULL) || (streamOut == NULL)) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "invalid stream handles"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), "invalid stream handles"); return (-1); } @@ -1299,7 +1298,7 @@ int VoEFileImpl::ConvertCompressedToPCM(InStream* streamIn, res = playerObj.StartPlayingFile(*streamIn,0,1.0,0,0,NULL); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertCompressedToPCM failed to create player object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -1321,7 +1320,7 @@ int VoEFileImpl::ConvertCompressedToPCM(InStream* streamIn, res = recObj.StartRecordingAudioFile(*streamOut,codecInst,0); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "ConvertCompressedToPCM failed to create recorder object"); playerObj.StopPlayingFile(); FilePlayer::DestroyFilePlayer(&playerObj); @@ -1350,18 +1349,20 @@ int VoEFileImpl::ConvertCompressedToPCM(InStream* streamIn, AudioFrame::kVadActive); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertCompressedToPCM failed during conversion" - " (audio frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertCompressedToPCM failed during conversion " + "(audio frame)"); break; } res=recObj.RecordAudioToFile(audioFrame); if(res) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), - "ConvertCompressedToPCM failed during converstion" - " (write frame)"); + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "ConvertCompressedToPCM failed during conversion " + "(write frame)"); } } @@ -1378,7 +1379,7 @@ int VoEFileImpl::GetFileDuration(const char* fileNameUTF8, int& durationMs, FileFormats format) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetFileDuration(fileNameUTF8=%s, format=%d)", fileNameUTF8, format); @@ -1390,7 +1391,7 @@ int VoEFileImpl::GetFileDuration(const char* fileNameUTF8, int res=fileModule->FileDurationMs(fileNameUTF8,duration,format); if (res) { - _engineStatistics.SetLastError(VE_BAD_FILE, kTraceError, + _shared->SetLastError(VE_BAD_FILE, kTraceError, "GetFileDuration() failed measure file duration"); return -1; } @@ -1403,15 +1404,14 @@ int VoEFileImpl::GetFileDuration(const char* fileNameUTF8, int VoEFileImpl::GetPlaybackPosition(int channel, int& positionMs) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "GetPlaybackPosition(channel=%d)", 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, "GetPlaybackPosition() failed to locate channel"); return -1; } diff --git a/src/voice_engine/main/source/voe_file_impl.h b/src/voice_engine/main/source/voe_file_impl.h index 2d938766e..20ac8e5a1 100644 --- a/src/voice_engine/main/source/voe_file_impl.h +++ b/src/voice_engine/main/source/voe_file_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_hardware_impl.cc b/src/voice_engine/main/source/voe_hardware_impl.cc index 3a86c6c26..c6ed4aef8 100644 --- a/src/voice_engine/main/source/voe_hardware_impl.cc +++ b/src/voice_engine/main/source/voe_hardware_impl.cc @@ -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 (_audioDevicePtr->RecordingDevices()); + devices = static_cast (_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 (_audioDevicePtr->PlayoutDevices()); + devices = static_cast (_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 (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 (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 diff --git a/src/voice_engine/main/source/voe_hardware_impl.h b/src/voice_engine/main/source/voe_hardware_impl.h index af934ba2a..4a5a3c35f 100644 --- a/src/voice_engine/main/source/voe_hardware_impl.h +++ b/src/voice_engine/main/source/voe_hardware_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_neteq_stats_impl.cc b/src/voice_engine/main/source/voe_neteq_stats_impl.cc index fd87a971e..b4a8ecafd 100644 --- a/src/voice_engine/main/source/voe_neteq_stats_impl.cc +++ b/src/voice_engine/main/source/voe_neteq_stats_impl.cc @@ -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; } diff --git a/src/voice_engine/main/source/voe_neteq_stats_impl.h b/src/voice_engine/main/source/voe_neteq_stats_impl.h index 47dd2f693..e261ef410 100644 --- a/src/voice_engine/main/source/voe_neteq_stats_impl.h +++ b/src/voice_engine/main/source/voe_neteq_stats_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_network_impl.cc b/src/voice_engine/main/source/voe_network_impl.cc index 0bebbf5fa..317a09a1a 100644 --- a/src/voice_engine/main/source/voe_network_impl.cc +++ b/src/voice_engine/main/source/voe_network_impl.cc @@ -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 diff --git a/src/voice_engine/main/source/voe_network_impl.h b/src/voice_engine/main/source/voe_network_impl.h index cc300acb5..fa5d8c535 100644 --- a/src/voice_engine/main/source/voe_network_impl.h +++ b/src/voice_engine/main/source/voe_network_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_rtp_rtcp_impl.cc b/src/voice_engine/main/source/voe_rtp_rtcp_impl.cc index ba6d36576..62609b878 100644 --- a/src/voice_engine/main/source/voe_rtp_rtcp_impl.cc +++ b/src/voice_engine/main/source/voe_rtp_rtcp_impl.cc @@ -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; } diff --git a/src/voice_engine/main/source/voe_rtp_rtcp_impl.h b/src/voice_engine/main/source/voe_rtp_rtcp_impl.h index 1912c3a81..845b93fc2 100644 --- a/src/voice_engine/main/source/voe_rtp_rtcp_impl.h +++ b/src/voice_engine/main/source/voe_rtp_rtcp_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_video_sync_impl.cc b/src/voice_engine/main/source/voe_video_sync_impl.cc index 8ee62965d..5b6773b87 100644 --- a/src/voice_engine/main/source/voe_video_sync_impl.cc +++ b/src/voice_engine/main/source/voe_video_sync_impl.cc @@ -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; } diff --git a/src/voice_engine/main/source/voe_video_sync_impl.h b/src/voice_engine/main/source/voe_video_sync_impl.h index 02c85d19c..c4c946f77 100644 --- a/src/voice_engine/main/source/voe_video_sync_impl.h +++ b/src/voice_engine/main/source/voe_video_sync_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voe_volume_control_impl.cc b/src/voice_engine/main/source/voe_volume_control_impl.cc index dd3d54d36..92d787059 100644 --- a/src/voice_engine/main/source/voe_volume_control_impl.cc +++ b/src/voice_engine/main/source/voe_volume_control_impl.cc @@ -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 (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 (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; } diff --git a/src/voice_engine/main/source/voe_volume_control_impl.h b/src/voice_engine/main/source/voe_volume_control_impl.h index 18f4a1b5c..4faebba8b 100644 --- a/src/voice_engine/main/source/voe_volume_control_impl.h +++ b/src/voice_engine/main/source/voe_volume_control_impl.h @@ -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 diff --git a/src/voice_engine/main/source/voice_engine_impl.h b/src/voice_engine/main/source/voice_engine_impl.h index 708ac5d8c..68df2b657 100644 --- a/src/voice_engine/main/source/voice_engine_impl.h +++ b/src/voice_engine/main/source/voice_engine_impl.h @@ -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()