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

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

Issue 671793004: Clean up the media stream audio track code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 // 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 P2PSocketDispatcher* p2p_socket_dispatcher) 167 P2PSocketDispatcher* p2p_socket_dispatcher)
168 : network_manager_(NULL), 168 : network_manager_(NULL),
169 p2p_socket_dispatcher_(p2p_socket_dispatcher), 169 p2p_socket_dispatcher_(p2p_socket_dispatcher),
170 signaling_thread_(NULL), 170 signaling_thread_(NULL),
171 worker_thread_(NULL), 171 worker_thread_(NULL),
172 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { 172 chrome_worker_thread_("Chrome_libJingle_WorkerThread") {
173 } 173 }
174 174
175 PeerConnectionDependencyFactory::~PeerConnectionDependencyFactory() { 175 PeerConnectionDependencyFactory::~PeerConnectionDependencyFactory() {
176 CleanupPeerConnectionFactory(); 176 CleanupPeerConnectionFactory();
177 if (aec_dump_message_filter_.get())
178 aec_dump_message_filter_->RemoveDelegate(this);
179 } 177 }
180 178
181 blink::WebRTCPeerConnectionHandler* 179 blink::WebRTCPeerConnectionHandler*
182 PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler( 180 PeerConnectionDependencyFactory::CreateRTCPeerConnectionHandler(
183 blink::WebRTCPeerConnectionHandlerClient* client) { 181 blink::WebRTCPeerConnectionHandlerClient* client) {
184 // Save histogram data so we can see how much PeerConnetion is used. 182 // Save histogram data so we can see how much PeerConnetion is used.
185 // The histogram counts the number of calls to the JS API 183 // The histogram counts the number of calls to the JS API
186 // webKitRTCPeerConnection. 184 // webKitRTCPeerConnection.
187 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); 185 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION);
188 186
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 encoder_factory.release(), 343 encoder_factory.release(),
346 decoder_factory.release())); 344 decoder_factory.release()));
347 CHECK(factory.get()); 345 CHECK(factory.get());
348 346
349 pc_factory_ = factory; 347 pc_factory_ = factory;
350 webrtc::PeerConnectionFactoryInterface::Options factory_options; 348 webrtc::PeerConnectionFactoryInterface::Options factory_options;
351 factory_options.disable_sctp_data_channels = false; 349 factory_options.disable_sctp_data_channels = false;
352 factory_options.disable_encryption = 350 factory_options.disable_encryption =
353 cmd_line->HasSwitch(switches::kDisableWebRtcEncryption); 351 cmd_line->HasSwitch(switches::kDisableWebRtcEncryption);
354 pc_factory_->SetOptions(factory_options); 352 pc_factory_->SetOptions(factory_options);
355
356 // TODO(xians): Remove the following code after kDisableAudioTrackProcessing
357 // is removed.
358 if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) {
359 aec_dump_message_filter_ = AecDumpMessageFilter::Get();
360 // In unit tests not creating a message filter, |aec_dump_message_filter_|
361 // will be NULL. We can just ignore that. Other unit tests and browser tests
362 // ensure that we do get the filter when we should.
363 if (aec_dump_message_filter_.get())
364 aec_dump_message_filter_->AddDelegate(this);
365 }
366 } 353 }
367 354
368 bool PeerConnectionDependencyFactory::PeerConnectionFactoryCreated() { 355 bool PeerConnectionDependencyFactory::PeerConnectionFactoryCreated() {
369 return pc_factory_.get() != NULL; 356 return pc_factory_.get() != NULL;
370 } 357 }
371 358
372 scoped_refptr<webrtc::PeerConnectionInterface> 359 scoped_refptr<webrtc::PeerConnectionInterface>
373 PeerConnectionDependencyFactory::CreatePeerConnection( 360 PeerConnectionDependencyFactory::CreatePeerConnection(
374 const webrtc::PeerConnectionInterface::RTCConfiguration& config, 361 const webrtc::PeerConnectionInterface::RTCConfiguration& config,
375 const webrtc::MediaConstraintsInterface* constraints, 362 const webrtc::MediaConstraintsInterface* constraints,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 436
450 StartLocalAudioTrack(audio_track.get()); 437 StartLocalAudioTrack(audio_track.get());
451 438
452 // Pass the ownership of the native local audio track to the blink track. 439 // Pass the ownership of the native local audio track to the blink track.
453 blink::WebMediaStreamTrack writable_track = track; 440 blink::WebMediaStreamTrack writable_track = track;
454 writable_track.setExtraData(audio_track.release()); 441 writable_track.setExtraData(audio_track.release());
455 } 442 }
456 443
457 void PeerConnectionDependencyFactory::StartLocalAudioTrack( 444 void PeerConnectionDependencyFactory::StartLocalAudioTrack(
458 WebRtcLocalAudioTrack* audio_track) { 445 WebRtcLocalAudioTrack* audio_track) {
459 // Add the WebRtcAudioDevice as the sink to the local audio track.
460 // TODO(xians): Remove the following line of code after the APM in WebRTC is
461 // completely deprecated. See http://crbug/365672.
462 if (!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled())
463 audio_track->AddSink(GetWebRtcAudioDevice());
464
465 // Start the audio track. This will hook the |audio_track| to the capturer 446 // Start the audio track. This will hook the |audio_track| to the capturer
466 // as the sink of the audio, and only start the source of the capturer if 447 // as the sink of the audio, and only start the source of the capturer if
467 // it is the first audio track connecting to the capturer. 448 // it is the first audio track connecting to the capturer.
468 audio_track->Start(); 449 audio_track->Start();
469 } 450 }
470 451
471 scoped_refptr<WebAudioCapturerSource> 452 scoped_refptr<WebAudioCapturerSource>
472 PeerConnectionDependencyFactory::CreateWebAudioSource( 453 PeerConnectionDependencyFactory::CreateWebAudioSource(
473 blink::WebMediaStreamSource* source) { 454 blink::WebMediaStreamSource* source) {
474 DVLOG(1) << "PeerConnectionDependencyFactory::CreateWebAudioSource()"; 455 DVLOG(1) << "PeerConnectionDependencyFactory::CreateWebAudioSource()";
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 static_cast<webrtc::AudioTrackInterface*>(native_track), 596 static_cast<webrtc::AudioTrackInterface*>(native_track),
616 is_local_track)); 597 is_local_track));
617 } 598 }
618 599
619 scoped_refptr<base::MessageLoopProxy> 600 scoped_refptr<base::MessageLoopProxy>
620 PeerConnectionDependencyFactory::GetWebRtcWorkerThread() const { 601 PeerConnectionDependencyFactory::GetWebRtcWorkerThread() const {
621 DCHECK(CalledOnValidThread()); 602 DCHECK(CalledOnValidThread());
622 return chrome_worker_thread_.message_loop_proxy(); 603 return chrome_worker_thread_.message_loop_proxy();
623 } 604 }
624 605
625 void PeerConnectionDependencyFactory::OnAecDumpFile(
626 const IPC::PlatformFileForTransit& file_handle) {
627 DCHECK(CalledOnValidThread());
628 DCHECK(!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled());
629 DCHECK(PeerConnectionFactoryCreated());
630
631 base::File file = IPC::PlatformFileForTransitToFile(file_handle);
632 DCHECK(file.IsValid());
633
634 // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump()
635 // fails, |aec_dump_file| will be closed.
636 if (!GetPcFactory()->StartAecDump(file.TakePlatformFile()))
637 VLOG(1) << "Could not start AEC dump.";
638 }
639
640 void PeerConnectionDependencyFactory::OnDisableAecDump() {
641 DCHECK(CalledOnValidThread());
642 DCHECK(!MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled());
643 // Do nothing. We never disable AEC dump for non-track-processing case.
644 }
645
646 void PeerConnectionDependencyFactory::OnIpcClosing() {
647 DCHECK(CalledOnValidThread());
648 aec_dump_message_filter_ = NULL;
649 }
650
651 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { 606 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() {
652 if (audio_device_.get()) 607 if (audio_device_.get())
653 return; 608 return;
654 609
655 audio_device_ = new WebRtcAudioDeviceImpl(); 610 audio_device_ = new WebRtcAudioDeviceImpl();
656 } 611 }
657 612
658 } // namespace content 613 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698