diff --git a/webrtc/voice_engine/include/voe_base.h b/webrtc/voice_engine/include/voe_base.h index f54027b8a4..4a4788df55 100644 --- a/webrtc/voice_engine/include/voe_base.h +++ b/webrtc/voice_engine/include/voe_base.h @@ -183,6 +183,15 @@ 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) {} protected: VoEBase() {} virtual ~VoEBase() {} diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc index 9434863882..a84d0c1052 100644 --- a/webrtc/voice_engine/voe_base_impl.cc +++ b/webrtc/voice_engine/voe_base_impl.cc @@ -224,26 +224,33 @@ 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) { - voe::ChannelOwner ch = - _shared->channel_manager().GetChannel(voe_channels[i]); - voe::Channel* channel_ptr = ch.channel(); - if (!channel_ptr) - continue; - - if (channel_ptr->InputIsOnHold()) { - channel_ptr->UpdateLocalTimeStamp(); - } else if (channel_ptr->Sending()) { - channel_ptr->Demultiplex(audio_data, sample_rate, number_of_frames, - number_of_channels); - channel_ptr->PrepareEncodeAndSend(sample_rate); - channel_ptr->EncodeAndSend(); - } + CaptureCallback(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) { + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(voe_channel); + voe::Channel* channel_ptr = ch.channel(); + if (!channel_ptr) + return; + + if (channel_ptr->InputIsOnHold()) { + channel_ptr->UpdateLocalTimeStamp(); + } else if (channel_ptr->Sending()) { + channel_ptr->Demultiplex(static_cast(audio_data), + sample_rate, number_of_frames, number_of_channels); + channel_ptr->PrepareEncodeAndSend(sample_rate); + channel_ptr->EncodeAndSend(); + } +} + int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), diff --git a/webrtc/voice_engine/voe_base_impl.h b/webrtc/voice_engine/voe_base_impl.h index bee2ea37cf..aff1a2ed39 100644 --- a/webrtc/voice_engine/voe_base_impl.h +++ b/webrtc/voice_engine/voe_base_impl.h @@ -69,6 +69,10 @@ 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); + // AudioTransport virtual int32_t RecordedDataIsAvailable(const void* audioSamples,