diff --git a/src/voice_engine/main/source/shared_data.h b/src/voice_engine/main/source/shared_data.h index 40b95e4560..afab37b4a0 100644 --- a/src/voice_engine/main/source/shared_data.h +++ b/src/voice_engine/main/source/shared_data.h @@ -29,11 +29,19 @@ namespace voe { class TransmitMixer; class OutputMixer; -class SharedData +class SharedData { +public: + // Public accessors. + WebRtc_UWord32 instance_id() const { return _instanceId; } + Statistics& statistics() { return _engineStatistics; } + ChannelManager& channel_manager() { return _channelManager; } + AudioDeviceModule* audio_device() { return _audioDevicePtr; } + protected: WebRtc_UWord16 NumOfSendingChannels(); + protected: const WebRtc_UWord32 _instanceId; CriticalSectionWrapper* _apiCritPtr; diff --git a/src/voice_engine/main/source/statistics.h b/src/voice_engine/main/source/statistics.h index 0c18bf8cd1..fc0bf8c6cd 100644 --- a/src/voice_engine/main/source/statistics.h +++ b/src/voice_engine/main/source/statistics.h @@ -33,7 +33,7 @@ class Statistics WebRtc_Word32 SetUnInitialized(); bool Initialized() const; WebRtc_Word32 SetLastError(const WebRtc_Word32 error) const; - WebRtc_Word32 SetLastError(const WebRtc_Word32 error, + WebRtc_Word32 SetLastError(const WebRtc_Word32 error, const TraceLevel level) const; WebRtc_Word32 SetLastError(const WebRtc_Word32 error, const TraceLevel level, 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 2d210be3c9..40cb3d0a3c 100644 --- a/src/voice_engine/main/source/voe_video_sync_impl.cc +++ b/src/voice_engine/main/source/voe_video_sync_impl.cc @@ -37,53 +37,53 @@ VoEVideoSync* VoEVideoSync::GetInterface(VoiceEngine* voiceEngine) #ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API -VoEVideoSyncImpl::VoEVideoSyncImpl() +VoEVideoSyncImpl::VoEVideoSyncImpl(voe::SharedData* data) : _data(data) { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_data->instance_id(),-1), "VoEVideoSyncImpl::VoEVideoSyncImpl() - ctor"); } VoEVideoSyncImpl::~VoEVideoSyncImpl() { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_data->instance_id(),-1), "VoEVideoSyncImpl::~VoEVideoSyncImpl() - dtor"); } int VoEVideoSyncImpl::Release() { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "VoEVideoSync::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); + _data->statistics().SetLastError(VE_INTERFACE_NOT_FOUND, + kTraceWarning); return (-1); } - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_data->instance_id(),-1), "VoEVideoSync reference counter = %d", refCount); return (refCount); } int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, unsigned int& timestamp) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "GetPlayoutTimestamp(channel=%d, timestamp=?)", channel); ANDROID_NOT_SUPPORTED(); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) + if (!_data->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _data->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_channelManager, channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ScopedChannel sc(_data->channel_manager(), channel); + voe::Channel* channelPtr = sc.ChannelPtr(); if (channelPtr == NULL) { - _engineStatistics.SetLastError( + _data->statistics().SetLastError( VE_CHANNEL_NOT_VALID, kTraceError, "GetPlayoutTimestamp() failed to locate channel"); return -1; @@ -94,22 +94,22 @@ int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, unsigned int& timestamp) int VoEVideoSyncImpl::SetInitTimestamp(int channel, unsigned int timestamp) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "SetInitTimestamp(channel=%d, timestamp=%lu)", channel, timestamp); ANDROID_NOT_SUPPORTED(); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) + if (!_data->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _data->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_channelManager, channel); + voe::ScopedChannel sc(_data->channel_manager(), channel); voe::Channel* channelPtr = sc.ChannelPtr(); if (channelPtr == NULL) { - _engineStatistics.SetLastError( + _data->statistics().SetLastError( VE_CHANNEL_NOT_VALID, kTraceError, "SetInitTimestamp() failed to locate channel"); return -1; @@ -120,22 +120,22 @@ int VoEVideoSyncImpl::SetInitTimestamp(int channel, int VoEVideoSyncImpl::SetInitSequenceNumber(int channel, short sequenceNumber) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "SetInitSequenceNumber(channel=%d, sequenceNumber=%hd)", channel, sequenceNumber); ANDROID_NOT_SUPPORTED(); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) + if (!_data->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _data->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_channelManager, channel); + voe::ScopedChannel sc(_data->channel_manager(), channel); voe::Channel* channelPtr = sc.ChannelPtr(); if (channelPtr == NULL) { - _engineStatistics.SetLastError( + _data->statistics().SetLastError( VE_CHANNEL_NOT_VALID, kTraceError, "SetInitSequenceNumber() failed to locate channel"); return -1; @@ -145,22 +145,22 @@ int VoEVideoSyncImpl::SetInitSequenceNumber(int channel, int VoEVideoSyncImpl::SetMinimumPlayoutDelay(int channel,int delayMs) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "SetMinimumPlayoutDelay(channel=%d, delayMs=%d)", channel, delayMs); ANDROID_NOT_SUPPORTED(); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) + if (!_data->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _data->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_channelManager, channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ScopedChannel sc(_data->channel_manager(), channel); + voe::Channel* channelPtr = sc.ChannelPtr(); if (channelPtr == NULL) { - _engineStatistics.SetLastError( + _data->statistics().SetLastError( VE_CHANNEL_NOT_VALID, kTraceError, "SetMinimumPlayoutDelay() failed to locate channel"); return -1; @@ -170,21 +170,21 @@ int VoEVideoSyncImpl::SetMinimumPlayoutDelay(int channel,int delayMs) int VoEVideoSyncImpl::GetDelayEstimate(int channel, int& delayMs) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "GetDelayEstimate(channel=%d, delayMs=?)", channel); ANDROID_NOT_SUPPORTED(); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) + if (!_data->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _data->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_channelManager, channel); + voe::ScopedChannel sc(_data->channel_manager(), channel); voe::Channel* channelPtr = sc.ChannelPtr(); if (channelPtr == NULL) { - _engineStatistics.SetLastError( + _data->statistics().SetLastError( VE_CHANNEL_NOT_VALID, kTraceError, "GetDelayEstimate() failed to locate channel"); return -1; @@ -194,48 +194,47 @@ int VoEVideoSyncImpl::GetDelayEstimate(int channel, int& delayMs) int VoEVideoSyncImpl::GetPlayoutBufferSize(int& bufferMs) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "GetPlayoutBufferSize(bufferMs=?)"); ANDROID_NOT_SUPPORTED(); IPHONE_NOT_SUPPORTED(); - if (!_engineStatistics.Initialized()) + if (!_data->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _data->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } AudioDeviceModule::BufferType type (AudioDeviceModule::kFixedBufferSize); WebRtc_UWord16 sizeMS(0); - if (_audioDevicePtr->PlayoutBuffer(&type, &sizeMS) != 0) + if (_data->audio_device()->PlayoutBuffer(&type, &sizeMS) != 0) { - _engineStatistics.SetLastError( - VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, - "GetPlayoutBufferSize() failed to read buffer size"); + _data->statistics().SetLastError( + VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, + "GetPlayoutBufferSize() failed to read buffer size"); return -1; } bufferMs = sizeMS; - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_data->instance_id(),-1), "GetPlayoutBufferSize() => bufferMs=%d", bufferMs); return 0; } -int VoEVideoSyncImpl::GetRtpRtcp(int channel, - RtpRtcp* &rtpRtcpModule) +int VoEVideoSyncImpl::GetRtpRtcp(int channel, RtpRtcp* &rtpRtcpModule) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_data->instance_id(),-1), "GetRtpRtcp(channel=%i)", channel); - if (!_engineStatistics.Initialized()) + if (!_data->statistics().Initialized()) { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); + _data->statistics().SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_channelManager, channel); + voe::ScopedChannel sc(_data->channel_manager(), channel); voe::Channel* channelPtr = sc.ChannelPtr(); if (channelPtr == NULL) { - _engineStatistics.SetLastError( + _data->statistics().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 13c901a541..02c85d19c8 100644 --- a/src/voice_engine/main/source/voe_video_sync_impl.h +++ b/src/voice_engine/main/source/voe_video_sync_impl.h @@ -18,8 +18,7 @@ namespace webrtc { -class VoEVideoSyncImpl : public virtual voe::SharedData, - public VoEVideoSync, +class VoEVideoSyncImpl : public VoEVideoSync, public voe::RefCount { public: @@ -37,12 +36,14 @@ public: virtual int GetPlayoutTimestamp(int channel, unsigned int& timestamp); - virtual int GetRtpRtcp (int channel, - RtpRtcp* &rtpRtcpModule); + virtual int GetRtpRtcp(int channel, RtpRtcp* &rtpRtcpModule); protected: - VoEVideoSyncImpl(); + VoEVideoSyncImpl(voe::SharedData* data); virtual ~VoEVideoSyncImpl(); + +private: + voe::SharedData* _data; }; } // 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 99564dce23..708ac5d8c6 100644 --- a/src/voice_engine/main/source/voice_engine_impl.h +++ b/src/voice_engine/main/source/voice_engine_impl.h @@ -100,12 +100,17 @@ class VoiceEngineImpl : public VoEBaseImpl { public: - VoiceEngineImpl() + VoiceEngineImpl() : +#ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API + VoEVideoSyncImpl(this), +#endif + VoEBaseImpl() // Included in initializer list to satisfy condition when + // none of the WEBRTC_VOICE_XXX defines are set. { - }; + } virtual ~VoiceEngineImpl() { - }; + } }; } // namespace webrtc