From c1e28038bac58f096bdb06bc36fddd9130c82f27 Mon Sep 17 00:00:00 2001 From: "xians@webrtc.org" Date: Sun, 2 Feb 2014 15:30:20 +0000 Subject: [PATCH] Moved the new OnData interface to AudioTranport, and expose the AudioTransport pointer via voe_base R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/7779004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5472 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_device/include/audio_device_defines.h | 14 ++++++++++++-- .../audio_device/test/audio_device_test_api.cc | 4 ++++ .../modules/audio_device/test/func_test_manager.cc | 6 ++++++ .../modules/audio_device/test/func_test_manager.h | 5 +++++ webrtc/voice_engine/include/voe_base.h | 10 +++------- webrtc/voice_engine/voe_base_impl.cc | 12 ++++++------ webrtc/voice_engine/voe_base_impl.h | 8 +++++--- 7 files changed, 41 insertions(+), 18 deletions(-) diff --git a/webrtc/modules/audio_device/include/audio_device_defines.h b/webrtc/modules/audio_device/include/audio_device_defines.h index c37c4b1395..9f3e24b10a 100644 --- a/webrtc/modules/audio_device/include/audio_device_defines.h +++ b/webrtc/modules/audio_device/include/audio_device_defines.h @@ -85,8 +85,8 @@ public: // will be ignored. // The return value is the new microphone volume, in the range of |0, 255]. // When the volume does not need to be updated, it returns 0. - // TODO(xians): Make the interface pure virtual after libjingle has its - // implementation. + // TODO(xians): Remove this interface after Chrome and Libjingle switches + // to OnData(). virtual int OnDataAvailable(const int voe_channels[], int number_of_voe_channels, const int16_t* audio_data, @@ -98,6 +98,16 @@ public: bool key_pressed, bool need_audio_processing) { return 0; } + // Method to pass the captured audio data to the specific VoE channel. + // |voe_channel| is the id of the VoE channel which is the sink to the + // capture data. + // TODO(xians): Make the interface pure virtual after libjingle + // has its implementation. + virtual void OnData(int voe_channel, const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, + int number_of_frames) {} + protected: virtual ~AudioTransport() {} }; diff --git a/webrtc/modules/audio_device/test/audio_device_test_api.cc b/webrtc/modules/audio_device/test/audio_device_test_api.cc index fb25cddeed..485c103f4c 100644 --- a/webrtc/modules/audio_device/test/audio_device_test_api.cc +++ b/webrtc/modules/audio_device/test/audio_device_test_api.cc @@ -142,6 +142,10 @@ class AudioTransportAPI: public AudioTransport { return 0; } + virtual void OnData(int voe_channel, const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, + int number_of_frames) {} private: uint32_t rec_count_; uint32_t play_count_; diff --git a/webrtc/modules/audio_device/test/func_test_manager.cc b/webrtc/modules/audio_device/test/func_test_manager.cc index ccbcc2a44f..082b4c2f8d 100644 --- a/webrtc/modules/audio_device/test/func_test_manager.cc +++ b/webrtc/modules/audio_device/test/func_test_manager.cc @@ -542,6 +542,12 @@ int AudioTransportImpl::OnDataAvailable(const int voe_channels[], return 0; } +void AudioTransportImpl::OnData(int voe_channel, + const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, + int number_of_frames) {} + FuncTestManager::FuncTestManager() : _processThread(NULL), _audioDevice(NULL), diff --git a/webrtc/modules/audio_device/test/func_test_manager.h b/webrtc/modules/audio_device/test/func_test_manager.h index f7a150b000..6e21466e67 100644 --- a/webrtc/modules/audio_device/test/func_test_manager.h +++ b/webrtc/modules/audio_device/test/func_test_manager.h @@ -131,6 +131,11 @@ public: bool key_pressed, bool need_audio_processing); + virtual void OnData(int voe_channel, const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, + int number_of_frames); + AudioTransportImpl(AudioDeviceModule* audioDevice); ~AudioTransportImpl(); diff --git a/webrtc/voice_engine/include/voe_base.h b/webrtc/voice_engine/include/voe_base.h index 4a4788df55..c8db8c63d9 100644 --- a/webrtc/voice_engine/include/voe_base.h +++ b/webrtc/voice_engine/include/voe_base.h @@ -40,6 +40,7 @@ namespace webrtc { class AudioDeviceModule; class AudioProcessing; +class AudioTransport; class Config; const int kVoEDefault = -1; @@ -183,15 +184,10 @@ public: // Gets the NetEQ playout mode for a specified |channel| number. virtual int GetNetEQPlayoutMode(int channel, NetEqModes& mode) = 0; - // Method to pass the captured audio data to the specific VoE channel. - // |voe_channel| is the id of the VoE channel which is the sink to the - // capture data. // TODO(xians): Make the interface pure virtual after libjingle // implements the interface in its FakeWebRtcVoiceEngine. - virtual void CaptureCallback(int voe_channel, const void* audio_data, - int bits_per_sample, int sample_rate, - int number_of_channels, - int number_of_frames) {} + virtual AudioTransport* audio_transport() { return NULL; } + protected: VoEBase() {} virtual ~VoEBase() {} diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc index a84d0c1052..4f3e23a41c 100644 --- a/webrtc/voice_engine/voe_base_impl.cc +++ b/webrtc/voice_engine/voe_base_impl.cc @@ -224,18 +224,18 @@ int VoEBaseImpl::OnDataAvailable(const int voe_channels[], // No need to go through the APM, demultiplex the data to each VoE channel, // encode and send to the network. for (int i = 0; i < number_of_voe_channels; ++i) { - CaptureCallback(voe_channels[i], audio_data, 16, sample_rate, - number_of_channels, number_of_frames); + OnData(voe_channels[i], audio_data, 16, sample_rate, + number_of_channels, number_of_frames); } // Return 0 to indicate no need to change the volume. return 0; } -void VoEBaseImpl::CaptureCallback(int voe_channel, const void* audio_data, - int bits_per_sample, int sample_rate, - int number_of_channels, - int number_of_frames) { +void VoEBaseImpl::OnData(int voe_channel, const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, + int number_of_frames) { voe::ChannelOwner ch = _shared->channel_manager().GetChannel(voe_channel); voe::Channel* channel_ptr = ch.channel(); if (!channel_ptr) diff --git a/webrtc/voice_engine/voe_base_impl.h b/webrtc/voice_engine/voe_base_impl.h index aff1a2ed39..00e116ea84 100644 --- a/webrtc/voice_engine/voe_base_impl.h +++ b/webrtc/voice_engine/voe_base_impl.h @@ -69,9 +69,7 @@ public: virtual int LastError(); - virtual void CaptureCallback(int voe_channel, const void* audio_data, - int bits_per_sample, int sample_rate, - int number_of_channels, int number_of_frames); + virtual AudioTransport* audio_transport() { return this; } // AudioTransport virtual int32_t @@ -104,6 +102,10 @@ public: bool key_pressed, bool need_audio_processing); + virtual void OnData(int voe_channel, const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, int number_of_frames); + // AudioDeviceObserver virtual void OnErrorIsReported(ErrorCode error); virtual void OnWarningIsReported(WarningCode warning);