Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: webrtc/voice_engine/voe_base_impl.cc

Issue 2665693002: Moves channel-dependent audio input processing to separate encoder task queue (Closed)
Patch Set: BUILD changes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 audioSamples, elapsed_time_ms, ntp_time_ms); 104 audioSamples, elapsed_time_ms, ntp_time_ms);
105 nSamplesOut = audioFrame_.samples_per_channel_; 105 nSamplesOut = audioFrame_.samples_per_channel_;
106 return 0; 106 return 0;
107 } 107 }
108 108
109 void VoEBaseImpl::PushCaptureData(int voe_channel, const void* audio_data, 109 void VoEBaseImpl::PushCaptureData(int voe_channel, const void* audio_data,
110 int bits_per_sample, int sample_rate, 110 int bits_per_sample, int sample_rate,
111 size_t number_of_channels, 111 size_t number_of_channels,
112 size_t number_of_frames) { 112 size_t number_of_frames) {
113 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(voe_channel); 113 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(voe_channel);
114 voe::Channel* channel_ptr = ch.channel(); 114 voe::Channel* channel = ch.channel();
115 if (!channel_ptr) return; 115 if (!channel)
116 116 return;
117 if (channel_ptr->Sending()) { 117 if (channel->Sending()) {
118 channel_ptr->Demultiplex(static_cast<const int16_t*>(audio_data), 118 // Send the audio to each channel directly without using the APM in the
119 sample_rate, number_of_frames, number_of_channels); 119 // transmit mixer.
120 channel_ptr->PrepareEncodeAndSend(sample_rate); 120 channel->ProcessAndEncodeAudio(static_cast<const int16_t*>(audio_data),
121 channel_ptr->EncodeAndSend(); 121 sample_rate, number_of_frames,
122 number_of_channels);
122 } 123 }
123 } 124 }
124 125
125 void VoEBaseImpl::PullRenderData(int bits_per_sample, 126 void VoEBaseImpl::PullRenderData(int bits_per_sample,
126 int sample_rate, 127 int sample_rate,
127 size_t number_of_channels, 128 size_t number_of_channels,
128 size_t number_of_frames, 129 size_t number_of_frames,
129 void* audio_data, int64_t* elapsed_time_ms, 130 void* audio_data, int64_t* elapsed_time_ms,
130 int64_t* ntp_time_ms) { 131 int64_t* ntp_time_ms) {
131 assert(bits_per_sample == 16); 132 assert(bits_per_sample == 16);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 config_copy.acm_config.decoder_factory = decoder_factory_; 369 config_copy.acm_config.decoder_factory = decoder_factory_;
369 voe::ChannelOwner channel_owner = 370 voe::ChannelOwner channel_owner =
370 shared_->channel_manager().CreateChannel(config_copy); 371 shared_->channel_manager().CreateChannel(config_copy);
371 return InitializeChannel(&channel_owner); 372 return InitializeChannel(&channel_owner);
372 } 373 }
373 374
374 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { 375 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) {
375 if (channel_owner->channel()->SetEngineInformation( 376 if (channel_owner->channel()->SetEngineInformation(
376 shared_->statistics(), *shared_->output_mixer(), 377 shared_->statistics(), *shared_->output_mixer(),
377 *shared_->transmit_mixer(), *shared_->process_thread(), 378 *shared_->transmit_mixer(), *shared_->process_thread(),
378 *shared_->audio_device(), voiceEngineObserverPtr_, 379 *shared_->audio_device(), voiceEngineObserverPtr_, &callbackCritSect_,
379 &callbackCritSect_) != 0) { 380 shared_->encoder_queue()) != 0) {
380 shared_->SetLastError( 381 shared_->SetLastError(
381 VE_CHANNEL_NOT_CREATED, kTraceError, 382 VE_CHANNEL_NOT_CREATED, kTraceError,
382 "CreateChannel() failed to associate engine and channel." 383 "CreateChannel() failed to associate engine and channel."
383 " Destroying channel."); 384 " Destroying channel.");
384 shared_->channel_manager().DestroyChannel( 385 shared_->channel_manager().DestroyChannel(
385 channel_owner->channel()->ChannelId()); 386 channel_owner->channel()->ChannelId());
386 return -1; 387 return -1;
387 } else if (channel_owner->channel()->Init() != 0) { 388 } else if (channel_owner->channel()->Init() != 0) {
388 shared_->SetLastError( 389 shared_->SetLastError(
389 VE_CHANNEL_NOT_CREATED, kTraceError, 390 VE_CHANNEL_NOT_CREATED, kTraceError,
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 audio_data, number_of_frames, number_of_channels, sample_rate, 687 audio_data, number_of_frames, number_of_channels, sample_rate,
687 static_cast<uint16_t>(audio_delay_milliseconds), clock_drift, 688 static_cast<uint16_t>(audio_delay_milliseconds), clock_drift,
688 voe_mic_level, key_pressed); 689 voe_mic_level, key_pressed);
689 690
690 // Copy the audio frame to each sending channel and perform 691 // Copy the audio frame to each sending channel and perform
691 // channel-dependent operations (file mixing, mute, etc.), encode and 692 // channel-dependent operations (file mixing, mute, etc.), encode and
692 // packetize+transmit the RTP packet. When |number_of_voe_channels| == 0, 693 // packetize+transmit the RTP packet. When |number_of_voe_channels| == 0,
693 // do the operations on all the existing VoE channels; otherwise the 694 // do the operations on all the existing VoE channels; otherwise the
694 // operations will be done on specific channels. 695 // operations will be done on specific channels.
695 if (number_of_voe_channels == 0) { 696 if (number_of_voe_channels == 0) {
696 shared_->transmit_mixer()->DemuxAndMix(); 697 shared_->transmit_mixer()->ProcessAudio();
697 shared_->transmit_mixer()->EncodeAndSend();
698 } else { 698 } else {
699 shared_->transmit_mixer()->DemuxAndMix(voe_channels, 699 // TODO(henrika): I am unable to find any client who triggers this else
700 number_of_voe_channels); 700 // clause. To me it looks like it can be removed.
701 shared_->transmit_mixer()->EncodeAndSend(voe_channels, 701 shared_->transmit_mixer()->ProcessAudio(voe_channels,
702 number_of_voe_channels); 702 number_of_voe_channels);
703 } 703 }
704 704
705 // Scale from VoE to ADM level range. 705 // Scale from VoE to ADM level range.
706 uint32_t new_voe_mic_level = shared_->transmit_mixer()->CaptureLevel(); 706 uint32_t new_voe_mic_level = shared_->transmit_mixer()->CaptureLevel();
707 if (new_voe_mic_level != voe_mic_level) { 707 if (new_voe_mic_level != voe_mic_level) {
708 // Return the new volume if AGC has changed the volume. 708 // Return the new volume if AGC has changed the volume.
709 return static_cast<int>((new_voe_mic_level * max_volume + 709 return static_cast<int>((new_voe_mic_level * max_volume +
710 static_cast<int>(kMaxVolumeLevel / 2)) / 710 static_cast<int>(kMaxVolumeLevel / 2)) /
711 kMaxVolumeLevel); 711 kMaxVolumeLevel);
712 } 712 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 767 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
768 "AssociateSendChannel() failed to locate accociate_send_channel"); 768 "AssociateSendChannel() failed to locate accociate_send_channel");
769 return -1; 769 return -1;
770 } 770 }
771 771
772 channel_ptr->set_associate_send_channel(ch); 772 channel_ptr->set_associate_send_channel(ch);
773 return 0; 773 return 0;
774 } 774 }
775 775
776 } // namespace webrtc 776 } // namespace webrtc
OLDNEW
« webrtc/voice_engine/channel.cc ('K') | « webrtc/voice_engine/transmit_mixer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698