summaryrefslogtreecommitdiff
path: root/voice_engine/voe_base_impl.cc
diff options
context:
space:
mode:
authorxians@webrtc.org <xians@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-07-31 16:23:37 +0000
committerxians@webrtc.org <xians@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-07-31 16:23:37 +0000
commit44f1239d9595c91f69f656e5beb1382463c4da8f (patch)
treebb23527af93df9bc466ce5b2451a8b0077e79d30 /voice_engine/voe_base_impl.cc
parent60bf21e85cdf9a8dd18376d934bde5e785ebba87 (diff)
downloadwebrtc-44f1239d9595c91f69f656e5beb1382463c4da8f.tar.gz
Merge r4326 from stable to trunk.
r4326 was mistakenly committed to stable, so this is to re-merge back to trunk. Add new interface to support multiple sources in webrtc. CaptureData() will be called by chrome with a flag |need_audio_processing| to indicate if the data needs to be processed by APM or not. Different from the old interface that will send the data to all voe channels, the new interface will specify a list of voe channels that the data is demultiplexing to. R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1919004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@4449 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'voice_engine/voe_base_impl.cc')
-rw-r--r--voice_engine/voe_base_impl.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/voice_engine/voe_base_impl.cc b/voice_engine/voe_base_impl.cc
index f9934573..c703efda 100644
--- a/voice_engine/voe_base_impl.cc
+++ b/voice_engine/voe_base_impl.cc
@@ -274,6 +274,69 @@ int32_t VoEBaseImpl::NeedMorePlayData(
return 0;
}
+int VoEBaseImpl::OnDataAvailable(int voe_channels[],
+ int number_of_voe_channels,
+ const int16_t* audio_data,
+ int sample_rate,
+ int number_of_channels,
+ int number_of_frames,
+ int audio_delay_milliseconds,
+ int current_volume,
+ bool key_pressed,
+ bool need_audio_processing) {
+ WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_shared->instance_id(), -1),
+ "VoEBaseImpl::OnDataAvailable(number_of_voe_channels=%d, "
+ "sample_rate=%d, number_of_channels=%d, number_of_frames=%d, "
+ "audio_delay_milliseconds=%d, current_volume=%d, "
+ "key_pressed=%d, need_audio_processing=%d)",
+ number_of_voe_channels, sample_rate, number_of_channels,
+ number_of_frames, audio_delay_milliseconds, current_volume,
+ key_pressed, need_audio_processing);
+
+ if (need_audio_processing) {
+ // Perform channel-independent operations
+ // (APM, mix with file, record to file, mute, etc.)
+ _shared->transmit_mixer()->PrepareDemux(
+ audio_data, number_of_frames, number_of_channels,
+ sample_rate, static_cast<uint16_t>(audio_delay_milliseconds), 0,
+ current_volume, key_pressed);
+ _shared->transmit_mixer()->DemuxAndMix(voe_channels,
+ number_of_voe_channels);
+ _shared->transmit_mixer()->EncodeAndSend(voe_channels,
+ number_of_voe_channels);
+ // Update the volume if the analog AGC is working.
+ if (_shared->audio_processing() &&
+ _shared->audio_processing()->gain_control()->mode() ==
+ GainControl::kAdaptiveAnalog) {
+ return _shared->transmit_mixer()->CaptureLevel();
+ }
+
+ // Return 0 to indicate no need to change the volume.
+ return 0;
+ }
+
+ // 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::ScopedChannel sc(_shared->channel_manager(), voe_channels[i]);
+ voe::Channel* channel_ptr = sc.ChannelPtr();
+ 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();
+ }
+ }
+
+ // Return 0 to indicate no need to change the volume.
+ return 0;
+}
+
int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),