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

Side by Side Diff: content/renderer/media/webrtc/peer_connection_dependency_factory.cc

Issue 334743006: Support multiple files for AEC dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review (sky). Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 5 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 blink::WebFrame* web_frame_; 161 blink::WebFrame* web_frame_;
162 }; 162 };
163 163
164 PeerConnectionDependencyFactory::PeerConnectionDependencyFactory( 164 PeerConnectionDependencyFactory::PeerConnectionDependencyFactory(
165 P2PSocketDispatcher* p2p_socket_dispatcher) 165 P2PSocketDispatcher* p2p_socket_dispatcher)
166 : network_manager_(NULL), 166 : network_manager_(NULL),
167 p2p_socket_dispatcher_(p2p_socket_dispatcher), 167 p2p_socket_dispatcher_(p2p_socket_dispatcher),
168 signaling_thread_(NULL), 168 signaling_thread_(NULL),
169 worker_thread_(NULL), 169 worker_thread_(NULL),
170 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { 170 chrome_worker_thread_("Chrome_libJingle_WorkerThread") {
171 if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) {
172 aec_dump_message_filter_ = AecDumpMessageFilter::Get();
173 DCHECK(aec_dump_message_filter_);
174 aec_dump_message_filter_->SetObserver(this);
175 }
171 } 176 }
172 177
173 PeerConnectionDependencyFactory::~PeerConnectionDependencyFactory() { 178 PeerConnectionDependencyFactory::~PeerConnectionDependencyFactory() {
174 CleanupPeerConnectionFactory(); 179 CleanupPeerConnectionFactory();
180 if (aec_dump_message_filter_)
181 aec_dump_message_filter_->SetObserver(NULL);
175 } 182 }
176 183
177 blink::WebRTCPeerConnectionHandler* 184 blink::WebRTCPeerConnectionHandler*
178 PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler( 185 PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler(
179 blink::WebRTCPeerConnectionHandlerClient* client) { 186 blink::WebRTCPeerConnectionHandlerClient* client) {
180 // Save histogram data so we can see how much PeerConnetion is used. 187 // Save histogram data so we can see how much PeerConnetion is used.
181 // The histogram counts the number of calls to the JS API 188 // The histogram counts the number of calls to the JS API
182 // webKitRTCPeerConnection. 189 // webKitRTCPeerConnection.
183 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); 190 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION);
184 191
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 decoder_factory.release())); 347 decoder_factory.release()));
341 CHECK(factory); 348 CHECK(factory);
342 349
343 pc_factory_ = factory; 350 pc_factory_ = factory;
344 webrtc::PeerConnectionFactoryInterface::Options factory_options; 351 webrtc::PeerConnectionFactoryInterface::Options factory_options;
345 factory_options.disable_sctp_data_channels = false; 352 factory_options.disable_sctp_data_channels = false;
346 factory_options.disable_encryption = 353 factory_options.disable_encryption =
347 cmd_line->HasSwitch(switches::kDisableWebRtcEncryption); 354 cmd_line->HasSwitch(switches::kDisableWebRtcEncryption);
348 pc_factory_->SetOptions(factory_options); 355 pc_factory_->SetOptions(factory_options);
349 356
350 // |aec_dump_file| will be invalid when dump is not enabled. 357 // TODO(xians): Remove the following code after kDisableAudioTrackProcessing
351 if (aec_dump_file_.IsValid()) 358 // is removed.
352 StartAecDump(aec_dump_file_.Pass()); 359 if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() &&
360 aec_dump_message_filter_) {
361 // There's only one AEC dump if not using track processing, we use ID 0.
362 // PCDF lives as long as the renderer lives, so we don't need to unregister.
363 aec_dump_message_filter_->io_message_loop()->PostTask(
364 FROM_HERE,
365 base::Bind(
366 &AecDumpMessageFilter::RegisterAecDumpConsumer,
367 aec_dump_message_filter_,
368 0));
369 }
353 } 370 }
354 371
355 bool PeerConnectionDependencyFactory::PeerConnectionFactoryCreated() { 372 bool PeerConnectionDependencyFactory::PeerConnectionFactoryCreated() {
356 return pc_factory_.get() != NULL; 373 return pc_factory_.get() != NULL;
357 } 374 }
358 375
359 scoped_refptr<webrtc::PeerConnectionInterface> 376 scoped_refptr<webrtc::PeerConnectionInterface>
360 PeerConnectionDependencyFactory::CreatePeerConnection( 377 PeerConnectionDependencyFactory::CreatePeerConnection(
361 const webrtc::PeerConnectionInterface::IceServers& ice_servers, 378 const webrtc::PeerConnectionInterface::IceServers& ice_servers,
362 const webrtc::MediaConstraintsInterface* constraints, 379 const webrtc::MediaConstraintsInterface* constraints,
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 static_cast<webrtc::AudioTrackInterface*>(native_track), 622 static_cast<webrtc::AudioTrackInterface*>(native_track),
606 is_local_track)); 623 is_local_track));
607 } 624 }
608 625
609 scoped_refptr<base::MessageLoopProxy> 626 scoped_refptr<base::MessageLoopProxy>
610 PeerConnectionDependencyFactory::GetWebRtcWorkerThread() const { 627 PeerConnectionDependencyFactory::GetWebRtcWorkerThread() const {
611 DCHECK(CalledOnValidThread()); 628 DCHECK(CalledOnValidThread());
612 return chrome_worker_thread_.message_loop_proxy(); 629 return chrome_worker_thread_.message_loop_proxy();
613 } 630 }
614 631
615 bool PeerConnectionDependencyFactory::OnControlMessageReceived( 632 void PeerConnectionDependencyFactory::OnAecDumpFile(
616 const IPC::Message& message) { 633 int id,
617 bool handled = true; 634 const IPC::PlatformFileForTransit& file_handle) {
618 IPC_BEGIN_MESSAGE_MAP(PeerConnectionDependencyFactory, message) 635 DCHECK(CalledOnValidThread());
619 IPC_MESSAGE_HANDLER(MediaStreamMsg_EnableAecDump, OnAecDumpFile) 636 DCHECK(!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled());
620 IPC_MESSAGE_HANDLER(MediaStreamMsg_DisableAecDump, OnDisableAecDump) 637 DCHECK(PeerConnectionFactoryCreated());
621 IPC_MESSAGE_UNHANDLED(handled = false) 638 DCHECK(id == 0) << id;
622 IPC_END_MESSAGE_MAP()
623 return handled;
624 }
625 639
626 void PeerConnectionDependencyFactory::OnAecDumpFile(
627 IPC::PlatformFileForTransit file_handle) {
628 DCHECK(!aec_dump_file_.IsValid());
629 base::File file = IPC::PlatformFileForTransitToFile(file_handle); 640 base::File file = IPC::PlatformFileForTransitToFile(file_handle);
630 DCHECK(file.IsValid()); 641 DCHECK(file.IsValid());
631 642
632 if (MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) { 643 // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump()
633 EnsureWebRtcAudioDeviceImpl(); 644 // fails, |aec_dump_file| will be closed.
634 GetWebRtcAudioDevice()->EnableAecDump(file.Pass()); 645 if (!GetPcFactory()->StartAecDump(file.TakePlatformFile()))
635 return; 646 VLOG(1) << "Could not start AEC dump.";
636 }
637
638 // TODO(xians): Remove the following code after kDisableAudioTrackProcessing
639 // is removed.
640 if (PeerConnectionFactoryCreated())
641 StartAecDump(file.Pass());
642 else
643 aec_dump_file_ = file.Pass();
644 } 647 }
645 648
646 void PeerConnectionDependencyFactory::OnDisableAecDump() { 649 void PeerConnectionDependencyFactory::OnDisableAecDump() {
647 if (MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) { 650 DCHECK(CalledOnValidThread());
648 // Do nothing if OnAecDumpFile() has never been called. 651 DCHECK(!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled());
649 if (GetWebRtcAudioDevice()) 652 // Do nothing. We never disable AEC dump for non-track-processing case.
650 GetWebRtcAudioDevice()->DisableAecDump();
651 return;
652 }
653
654 // TODO(xians): Remove the following code after kDisableAudioTrackProcessing
655 // is removed.
656 if (aec_dump_file_.IsValid())
657 aec_dump_file_.Close();
658 } 653 }
659 654
660 void PeerConnectionDependencyFactory::StartAecDump(base::File aec_dump_file) { 655 void PeerConnectionDependencyFactory::OnIpcClosed() {
661 // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump() 656 DCHECK(CalledOnValidThread());
662 // fails, |aec_dump_file| will be closed. 657 aec_dump_message_filter_ = NULL;
663 if (!GetPcFactory()->StartAecDump(aec_dump_file.TakePlatformFile()))
664 VLOG(1) << "Could not start AEC dump.";
665 } 658 }
666 659
667 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { 660 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() {
668 if (audio_device_) 661 if (audio_device_)
669 return; 662 return;
670 663
671 audio_device_ = new WebRtcAudioDeviceImpl(); 664 audio_device_ = new WebRtcAudioDeviceImpl();
672 } 665 }
673 666
674 } // namespace content 667 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698