| OLD | NEW |
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 audioSamples, elapsed_time_ms, ntp_time_ms); | 105 audioSamples, elapsed_time_ms, ntp_time_ms); |
| 106 nSamplesOut = audioFrame_.samples_per_channel_; | 106 nSamplesOut = audioFrame_.samples_per_channel_; |
| 107 return 0; | 107 return 0; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void VoEBaseImpl::PushCaptureData(int voe_channel, const void* audio_data, | 110 void VoEBaseImpl::PushCaptureData(int voe_channel, const void* audio_data, |
| 111 int bits_per_sample, int sample_rate, | 111 int bits_per_sample, int sample_rate, |
| 112 size_t number_of_channels, | 112 size_t number_of_channels, |
| 113 size_t number_of_frames) { | 113 size_t number_of_frames) { |
| 114 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(voe_channel); | 114 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(voe_channel); |
| 115 voe::Channel* channel_ptr = ch.channel(); | 115 voe::Channel* channel = ch.channel(); |
| 116 if (!channel_ptr) return; | 116 if (!channel) |
| 117 | 117 return; |
| 118 if (channel_ptr->Sending()) { | 118 if (channel->Sending()) { |
| 119 channel_ptr->Demultiplex(static_cast<const int16_t*>(audio_data), | 119 // Send the audio to each channel directly without using the APM in the |
| 120 sample_rate, number_of_frames, number_of_channels); | 120 // transmit mixer. |
| 121 channel_ptr->PrepareEncodeAndSend(sample_rate); | 121 channel->ProcessAndEncodeAudio(static_cast<const int16_t*>(audio_data), |
| 122 channel_ptr->EncodeAndSend(); | 122 sample_rate, number_of_frames, |
| 123 number_of_channels); |
| 123 } | 124 } |
| 124 } | 125 } |
| 125 | 126 |
| 126 void VoEBaseImpl::PullRenderData(int bits_per_sample, | 127 void VoEBaseImpl::PullRenderData(int bits_per_sample, |
| 127 int sample_rate, | 128 int sample_rate, |
| 128 size_t number_of_channels, | 129 size_t number_of_channels, |
| 129 size_t number_of_frames, | 130 size_t number_of_frames, |
| 130 void* audio_data, int64_t* elapsed_time_ms, | 131 void* audio_data, int64_t* elapsed_time_ms, |
| 131 int64_t* ntp_time_ms) { | 132 int64_t* ntp_time_ms) { |
| 132 assert(bits_per_sample == 16); | 133 assert(bits_per_sample == 16); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 config_copy.acm_config.decoder_factory = decoder_factory_; | 371 config_copy.acm_config.decoder_factory = decoder_factory_; |
| 371 voe::ChannelOwner channel_owner = | 372 voe::ChannelOwner channel_owner = |
| 372 shared_->channel_manager().CreateChannel(config_copy); | 373 shared_->channel_manager().CreateChannel(config_copy); |
| 373 return InitializeChannel(&channel_owner); | 374 return InitializeChannel(&channel_owner); |
| 374 } | 375 } |
| 375 | 376 |
| 376 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { | 377 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { |
| 377 if (channel_owner->channel()->SetEngineInformation( | 378 if (channel_owner->channel()->SetEngineInformation( |
| 378 shared_->statistics(), *shared_->output_mixer(), | 379 shared_->statistics(), *shared_->output_mixer(), |
| 379 *shared_->process_thread(), *shared_->audio_device(), | 380 *shared_->process_thread(), *shared_->audio_device(), |
| 380 voiceEngineObserverPtr_, &callbackCritSect_) != 0) { | 381 voiceEngineObserverPtr_, &callbackCritSect_, |
| 382 shared_->encoder_queue()) != 0) { |
| 381 shared_->SetLastError( | 383 shared_->SetLastError( |
| 382 VE_CHANNEL_NOT_CREATED, kTraceError, | 384 VE_CHANNEL_NOT_CREATED, kTraceError, |
| 383 "CreateChannel() failed to associate engine and channel." | 385 "CreateChannel() failed to associate engine and channel." |
| 384 " Destroying channel."); | 386 " Destroying channel."); |
| 385 shared_->channel_manager().DestroyChannel( | 387 shared_->channel_manager().DestroyChannel( |
| 386 channel_owner->channel()->ChannelId()); | 388 channel_owner->channel()->ChannelId()); |
| 387 return -1; | 389 return -1; |
| 388 } else if (channel_owner->channel()->Init() != 0) { | 390 } else if (channel_owner->channel()->Init() != 0) { |
| 389 shared_->SetLastError( | 391 shared_->SetLastError( |
| 390 VE_CHANNEL_NOT_CREATED, kTraceError, | 392 VE_CHANNEL_NOT_CREATED, kTraceError, |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 audio_data, number_of_frames, number_of_channels, sample_rate, | 688 audio_data, number_of_frames, number_of_channels, sample_rate, |
| 687 static_cast<uint16_t>(audio_delay_milliseconds), clock_drift, | 689 static_cast<uint16_t>(audio_delay_milliseconds), clock_drift, |
| 688 voe_mic_level, key_pressed); | 690 voe_mic_level, key_pressed); |
| 689 | 691 |
| 690 // Copy the audio frame to each sending channel and perform | 692 // Copy the audio frame to each sending channel and perform |
| 691 // channel-dependent operations (file mixing, mute, etc.), encode and | 693 // channel-dependent operations (file mixing, mute, etc.), encode and |
| 692 // packetize+transmit the RTP packet. When |number_of_voe_channels| == 0, | 694 // packetize+transmit the RTP packet. When |number_of_voe_channels| == 0, |
| 693 // do the operations on all the existing VoE channels; otherwise the | 695 // do the operations on all the existing VoE channels; otherwise the |
| 694 // operations will be done on specific channels. | 696 // operations will be done on specific channels. |
| 695 if (number_of_voe_channels == 0) { | 697 if (number_of_voe_channels == 0) { |
| 696 shared_->transmit_mixer()->DemuxAndMix(); | 698 shared_->transmit_mixer()->ProcessAudio(); |
| 697 shared_->transmit_mixer()->EncodeAndSend(); | |
| 698 } else { | 699 } else { |
| 699 shared_->transmit_mixer()->DemuxAndMix(voe_channels, | 700 // TODO(henrika): I am unable to find any client who triggers this else |
| 700 number_of_voe_channels); | 701 // clause. To me it looks like it can be removed. |
| 701 shared_->transmit_mixer()->EncodeAndSend(voe_channels, | 702 shared_->transmit_mixer()->ProcessAudio(voe_channels, |
| 702 number_of_voe_channels); | 703 number_of_voe_channels); |
| 703 } | 704 } |
| 704 | 705 |
| 705 // Scale from VoE to ADM level range. | 706 // Scale from VoE to ADM level range. |
| 706 uint32_t new_voe_mic_level = shared_->transmit_mixer()->CaptureLevel(); | 707 uint32_t new_voe_mic_level = shared_->transmit_mixer()->CaptureLevel(); |
| 707 if (new_voe_mic_level != voe_mic_level) { | 708 if (new_voe_mic_level != voe_mic_level) { |
| 708 // Return the new volume if AGC has changed the volume. | 709 // Return the new volume if AGC has changed the volume. |
| 709 return static_cast<int>((new_voe_mic_level * max_volume + | 710 return static_cast<int>((new_voe_mic_level * max_volume + |
| 710 static_cast<int>(kMaxVolumeLevel / 2)) / | 711 static_cast<int>(kMaxVolumeLevel / 2)) / |
| 711 kMaxVolumeLevel); | 712 kMaxVolumeLevel); |
| 712 } | 713 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 768 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 768 "AssociateSendChannel() failed to locate accociate_send_channel"); | 769 "AssociateSendChannel() failed to locate accociate_send_channel"); |
| 769 return -1; | 770 return -1; |
| 770 } | 771 } |
| 771 | 772 |
| 772 channel_ptr->set_associate_send_channel(ch); | 773 channel_ptr->set_associate_send_channel(ch); |
| 773 return 0; | 774 return 0; |
| 774 } | 775 } |
| 775 | 776 |
| 776 } // namespace webrtc | 777 } // namespace webrtc |
| OLD | NEW |