| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 20 matching lines...) Expand all Loading... |
| 31 #include "webrtc/base/trace_event.h" | 31 #include "webrtc/base/trace_event.h" |
| 32 #include "webrtc/media/base/audiosource.h" | 32 #include "webrtc/media/base/audiosource.h" |
| 33 #include "webrtc/media/base/mediaconstants.h" | 33 #include "webrtc/media/base/mediaconstants.h" |
| 34 #include "webrtc/media/base/streamparams.h" | 34 #include "webrtc/media/base/streamparams.h" |
| 35 #include "webrtc/media/engine/adm_helpers.h" | 35 #include "webrtc/media/engine/adm_helpers.h" |
| 36 #include "webrtc/media/engine/apm_helpers.h" | 36 #include "webrtc/media/engine/apm_helpers.h" |
| 37 #include "webrtc/media/engine/payload_type_mapper.h" | 37 #include "webrtc/media/engine/payload_type_mapper.h" |
| 38 #include "webrtc/media/engine/webrtcmediaengine.h" | 38 #include "webrtc/media/engine/webrtcmediaengine.h" |
| 39 #include "webrtc/media/engine/webrtcvoe.h" | 39 #include "webrtc/media/engine/webrtcvoe.h" |
| 40 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 40 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
| 41 #include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h" | |
| 42 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 41 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 43 #include "webrtc/system_wrappers/include/field_trial.h" | 42 #include "webrtc/system_wrappers/include/field_trial.h" |
| 44 #include "webrtc/system_wrappers/include/metrics.h" | 43 #include "webrtc/system_wrappers/include/metrics.h" |
| 45 #include "webrtc/system_wrappers/include/trace.h" | 44 #include "webrtc/system_wrappers/include/trace.h" |
| 46 #include "webrtc/voice_engine/transmit_mixer.h" | 45 #include "webrtc/voice_engine/transmit_mixer.h" |
| 47 | 46 |
| 48 namespace cricket { | 47 namespace cricket { |
| 49 namespace { | 48 namespace { |
| 50 | 49 |
| 51 constexpr size_t kMaxUnsignaledRecvStreams = 1; | 50 constexpr size_t kMaxUnsignaledRecvStreams = 1; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 audio_state_ = | 221 audio_state_ = |
| 223 webrtc::AudioState::Create(MakeAudioStateConfig(voe(), audio_mixer)); | 222 webrtc::AudioState::Create(MakeAudioStateConfig(voe(), audio_mixer)); |
| 224 } | 223 } |
| 225 | 224 |
| 226 WebRtcVoiceEngine::WebRtcVoiceEngine( | 225 WebRtcVoiceEngine::WebRtcVoiceEngine( |
| 227 webrtc::AudioDeviceModule* adm, | 226 webrtc::AudioDeviceModule* adm, |
| 228 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory, | 227 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory, |
| 229 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, | 228 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, |
| 230 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, | 229 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, |
| 231 VoEWrapper* voe_wrapper) | 230 VoEWrapper* voe_wrapper) |
| 232 : low_priority_worker_queue_("rtc-low-prio", rtc::TaskQueue::Priority::LOW), | 231 : adm_(adm), |
| 233 adm_(adm), | |
| 234 encoder_factory_(encoder_factory), | 232 encoder_factory_(encoder_factory), |
| 235 decoder_factory_(decoder_factory), | 233 decoder_factory_(decoder_factory), |
| 236 voe_wrapper_(voe_wrapper) { | 234 voe_wrapper_(voe_wrapper) { |
| 237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 235 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 238 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; | 236 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; |
| 239 RTC_DCHECK(voe_wrapper); | 237 RTC_DCHECK(voe_wrapper); |
| 240 RTC_DCHECK(decoder_factory); | 238 RTC_DCHECK(decoder_factory); |
| 241 | 239 |
| 242 signal_thread_checker_.DetachFromThread(); | 240 signal_thread_checker_.DetachFromThread(); |
| 243 | 241 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { | 680 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { |
| 683 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 681 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 684 auto it = std::find(channels_.begin(), channels_.end(), channel); | 682 auto it = std::find(channels_.begin(), channels_.end(), channel); |
| 685 RTC_DCHECK(it != channels_.end()); | 683 RTC_DCHECK(it != channels_.end()); |
| 686 channels_.erase(it); | 684 channels_.erase(it); |
| 687 } | 685 } |
| 688 | 686 |
| 689 bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file, | 687 bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file, |
| 690 int64_t max_size_bytes) { | 688 int64_t max_size_bytes) { |
| 691 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 689 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 692 auto aec_dump = webrtc::AecDumpFactory::Create(file, max_size_bytes, | 690 FILE* aec_dump_file_stream = rtc::FdopenPlatformFileForWriting(file); |
| 693 &low_priority_worker_queue_); | 691 if (!aec_dump_file_stream) { |
| 694 if (!aec_dump) { | 692 LOG(LS_ERROR) << "Could not open AEC dump file stream."; |
| 693 if (!rtc::ClosePlatformFile(file)) |
| 694 LOG(LS_WARNING) << "Could not close file."; |
| 695 return false; | 695 return false; |
| 696 } | 696 } |
| 697 apm()->AttachAecDump(std::move(aec_dump)); | 697 StopAecDump(); |
| 698 if (apm()->StartDebugRecording(aec_dump_file_stream, max_size_bytes) != |
| 699 webrtc::AudioProcessing::kNoError) { |
| 700 LOG_RTCERR0(StartDebugRecording); |
| 701 fclose(aec_dump_file_stream); |
| 702 return false; |
| 703 } |
| 704 is_dumping_aec_ = true; |
| 698 return true; | 705 return true; |
| 699 } | 706 } |
| 700 | 707 |
| 701 void WebRtcVoiceEngine::StartAecDump(const std::string& filename) { | 708 void WebRtcVoiceEngine::StartAecDump(const std::string& filename) { |
| 702 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 709 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 703 | 710 if (!is_dumping_aec_) { |
| 704 auto aec_dump = | 711 // Start dumping AEC when we are not dumping. |
| 705 webrtc::AecDumpFactory::Create(filename, -1, &low_priority_worker_queue_); | 712 if (apm()->StartDebugRecording(filename.c_str(), -1) != |
| 706 if (aec_dump) { | 713 webrtc::AudioProcessing::kNoError) { |
| 707 apm()->AttachAecDump(std::move(aec_dump)); | 714 LOG_RTCERR1(StartDebugRecording, filename.c_str()); |
| 715 } else { |
| 716 is_dumping_aec_ = true; |
| 717 } |
| 708 } | 718 } |
| 709 } | 719 } |
| 710 | 720 |
| 711 void WebRtcVoiceEngine::StopAecDump() { | 721 void WebRtcVoiceEngine::StopAecDump() { |
| 712 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 722 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 713 apm()->DetachAecDump(); | 723 if (is_dumping_aec_) { |
| 724 // Stop dumping AEC when we are dumping. |
| 725 if (apm()->StopDebugRecording() != webrtc::AudioProcessing::kNoError) { |
| 726 LOG_RTCERR0(StopDebugRecording); |
| 727 } |
| 728 is_dumping_aec_ = false; |
| 729 } |
| 714 } | 730 } |
| 715 | 731 |
| 716 int WebRtcVoiceEngine::CreateVoEChannel() { | 732 int WebRtcVoiceEngine::CreateVoEChannel() { |
| 717 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 733 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 718 return voe_wrapper_->base()->CreateChannel(channel_config_); | 734 return voe_wrapper_->base()->CreateChannel(channel_config_); |
| 719 } | 735 } |
| 720 | 736 |
| 721 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { | 737 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { |
| 722 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 738 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 723 RTC_DCHECK(adm_); | 739 RTC_DCHECK(adm_); |
| (...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2341 ssrc); | 2357 ssrc); |
| 2342 if (it != unsignaled_recv_ssrcs_.end()) { | 2358 if (it != unsignaled_recv_ssrcs_.end()) { |
| 2343 unsignaled_recv_ssrcs_.erase(it); | 2359 unsignaled_recv_ssrcs_.erase(it); |
| 2344 return true; | 2360 return true; |
| 2345 } | 2361 } |
| 2346 return false; | 2362 return false; |
| 2347 } | 2363 } |
| 2348 } // namespace cricket | 2364 } // namespace cricket |
| 2349 | 2365 |
| 2350 #endif // HAVE_WEBRTC_VOICE | 2366 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |