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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 2896813002: Activate 'offload debug dump recordings from audio thread to TaskQueue'. (Closed)
Patch Set: Give queue shorter name. Created 3 years, 7 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) 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
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
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_("rtc-low-prio", rtc::TaskQueue::Priority::LOW),
233 adm_(adm),
232 encoder_factory_(encoder_factory), 234 encoder_factory_(encoder_factory),
233 decoder_factory_(decoder_factory), 235 decoder_factory_(decoder_factory),
234 voe_wrapper_(voe_wrapper) { 236 voe_wrapper_(voe_wrapper) {
235 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
236 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; 238 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine";
237 RTC_DCHECK(voe_wrapper); 239 RTC_DCHECK(voe_wrapper);
238 RTC_DCHECK(decoder_factory); 240 RTC_DCHECK(decoder_factory);
239 241
240 signal_thread_checker_.DetachFromThread(); 242 signal_thread_checker_.DetachFromThread();
241 243
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { 682 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) {
681 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 683 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
682 auto it = std::find(channels_.begin(), channels_.end(), channel); 684 auto it = std::find(channels_.begin(), channels_.end(), channel);
683 RTC_DCHECK(it != channels_.end()); 685 RTC_DCHECK(it != channels_.end());
684 channels_.erase(it); 686 channels_.erase(it);
685 } 687 }
686 688
687 bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file, 689 bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file,
688 int64_t max_size_bytes) { 690 int64_t max_size_bytes) {
689 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 691 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
690 FILE* aec_dump_file_stream = rtc::FdopenPlatformFileForWriting(file); 692 auto aec_dump = webrtc::AecDumpFactory::Create(file, max_size_bytes,
691 if (!aec_dump_file_stream) { 693 &low_priority_worker_queue_);
692 LOG(LS_ERROR) << "Could not open AEC dump file stream."; 694 if (!aec_dump) {
693 if (!rtc::ClosePlatformFile(file))
694 LOG(LS_WARNING) << "Could not close file.";
695 return false; 695 return false;
696 } 696 }
697 StopAecDump(); 697 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; 698 return true;
706 } 699 }
707 700
708 void WebRtcVoiceEngine::StartAecDump(const std::string& filename) { 701 void WebRtcVoiceEngine::StartAecDump(const std::string& filename) {
709 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 702 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
710 if (!is_dumping_aec_) { 703
711 // Start dumping AEC when we are not dumping. 704 auto aec_dump =
712 if (apm()->StartDebugRecording(filename.c_str(), -1) != 705 webrtc::AecDumpFactory::Create(filename, -1, &low_priority_worker_queue_);
713 webrtc::AudioProcessing::kNoError) { 706 if (aec_dump) {
714 LOG_RTCERR1(StartDebugRecording, filename.c_str()); 707 apm()->AttachAecDump(std::move(aec_dump));
715 } else {
716 is_dumping_aec_ = true;
717 }
718 } 708 }
719 } 709 }
720 710
721 void WebRtcVoiceEngine::StopAecDump() { 711 void WebRtcVoiceEngine::StopAecDump() {
722 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 712 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
723 if (is_dumping_aec_) { 713 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 } 714 }
731 715
732 int WebRtcVoiceEngine::CreateVoEChannel() { 716 int WebRtcVoiceEngine::CreateVoEChannel() {
733 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 717 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
734 return voe_wrapper_->base()->CreateChannel(channel_config_); 718 return voe_wrapper_->base()->CreateChannel(channel_config_);
735 } 719 }
736 720
737 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { 721 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
738 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 722 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
739 RTC_DCHECK(adm_); 723 RTC_DCHECK(adm_);
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 ssrc); 2341 ssrc);
2358 if (it != unsignaled_recv_ssrcs_.end()) { 2342 if (it != unsignaled_recv_ssrcs_.end()) {
2359 unsignaled_recv_ssrcs_.erase(it); 2343 unsignaled_recv_ssrcs_.erase(it);
2360 return true; 2344 return true;
2361 } 2345 }
2362 return false; 2346 return false;
2363 } 2347 }
2364 } // namespace cricket 2348 } // namespace cricket
2365 2349
2366 #endif // HAVE_WEBRTC_VOICE 2350 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.h ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698