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