OLD | NEW |
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" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "content/common/media/media_stream_messages.h" | 12 #include "content/common/media/media_stream_messages.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
14 #include "content/renderer/media/media_stream.h" | 14 #include "content/renderer/media/media_stream.h" |
| 15 #include "content/renderer/media/media_stream_audio_processor.h" |
15 #include "content/renderer/media/media_stream_audio_processor_options.h" | 16 #include "content/renderer/media/media_stream_audio_processor_options.h" |
16 #include "content/renderer/media/media_stream_audio_source.h" | 17 #include "content/renderer/media/media_stream_audio_source.h" |
17 #include "content/renderer/media/media_stream_video_source.h" | 18 #include "content/renderer/media/media_stream_video_source.h" |
18 #include "content/renderer/media/media_stream_video_track.h" | 19 #include "content/renderer/media/media_stream_video_track.h" |
19 #include "content/renderer/media/peer_connection_identity_service.h" | 20 #include "content/renderer/media/peer_connection_identity_service.h" |
20 #include "content/renderer/media/rtc_media_constraints.h" | 21 #include "content/renderer/media/rtc_media_constraints.h" |
21 #include "content/renderer/media/rtc_peer_connection_handler.h" | 22 #include "content/renderer/media/rtc_peer_connection_handler.h" |
22 #include "content/renderer/media/rtc_video_decoder_factory.h" | 23 #include "content/renderer/media/rtc_video_decoder_factory.h" |
23 #include "content/renderer/media/rtc_video_encoder_factory.h" | 24 #include "content/renderer/media/rtc_video_encoder_factory.h" |
24 #include "content/renderer/media/webaudio_capturer_source.h" | 25 #include "content/renderer/media/webaudio_capturer_source.h" |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 IPC_END_MESSAGE_MAP() | 620 IPC_END_MESSAGE_MAP() |
620 return handled; | 621 return handled; |
621 } | 622 } |
622 | 623 |
623 void PeerConnectionDependencyFactory::OnAecDumpFile( | 624 void PeerConnectionDependencyFactory::OnAecDumpFile( |
624 IPC::PlatformFileForTransit file_handle) { | 625 IPC::PlatformFileForTransit file_handle) { |
625 DCHECK(!aec_dump_file_.IsValid()); | 626 DCHECK(!aec_dump_file_.IsValid()); |
626 base::File file = IPC::PlatformFileForTransitToFile(file_handle); | 627 base::File file = IPC::PlatformFileForTransitToFile(file_handle); |
627 DCHECK(file.IsValid()); | 628 DCHECK(file.IsValid()); |
628 | 629 |
629 if (CommandLine::ForCurrentProcess()->HasSwitch( | 630 if (MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) { |
630 switches::kEnableAudioTrackProcessing)) { | |
631 EnsureWebRtcAudioDeviceImpl(); | 631 EnsureWebRtcAudioDeviceImpl(); |
632 GetWebRtcAudioDevice()->EnableAecDump(file.Pass()); | 632 GetWebRtcAudioDevice()->EnableAecDump(file.Pass()); |
633 return; | 633 return; |
634 } | 634 } |
635 | 635 |
636 // TODO(xians): Remove the following code after kEnableAudioTrackProcessing | 636 // TODO(xians): Remove the following code after kDisableAudioTrackProcessing |
637 // is removed. | 637 // is removed. |
638 if (PeerConnectionFactoryCreated()) | 638 if (PeerConnectionFactoryCreated()) |
639 StartAecDump(file.Pass()); | 639 StartAecDump(file.Pass()); |
640 else | 640 else |
641 aec_dump_file_ = file.Pass(); | 641 aec_dump_file_ = file.Pass(); |
642 } | 642 } |
643 | 643 |
644 void PeerConnectionDependencyFactory::OnDisableAecDump() { | 644 void PeerConnectionDependencyFactory::OnDisableAecDump() { |
645 if (CommandLine::ForCurrentProcess()->HasSwitch( | 645 if (MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) { |
646 switches::kEnableAudioTrackProcessing)) { | |
647 GetWebRtcAudioDevice()->DisableAecDump(); | 646 GetWebRtcAudioDevice()->DisableAecDump(); |
648 return; | 647 return; |
649 } | 648 } |
650 | 649 |
651 // TODO(xians): Remove the following code after kEnableAudioTrackProcessing | 650 // TODO(xians): Remove the following code after kDisableAudioTrackProcessing |
652 // is removed. | 651 // is removed. |
653 if (aec_dump_file_.IsValid()) | 652 if (aec_dump_file_.IsValid()) |
654 aec_dump_file_.Close(); | 653 aec_dump_file_.Close(); |
655 } | 654 } |
656 | 655 |
657 void PeerConnectionDependencyFactory::StartAecDump(base::File aec_dump_file) { | 656 void PeerConnectionDependencyFactory::StartAecDump(base::File aec_dump_file) { |
658 // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump() | 657 // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump() |
659 // fails, |aec_dump_file| will be closed. | 658 // fails, |aec_dump_file| will be closed. |
660 if (!GetPcFactory()->StartAecDump(aec_dump_file.TakePlatformFile())) | 659 if (!GetPcFactory()->StartAecDump(aec_dump_file.TakePlatformFile())) |
661 VLOG(1) << "Could not start AEC dump."; | 660 VLOG(1) << "Could not start AEC dump."; |
662 } | 661 } |
663 | 662 |
664 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 663 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
665 if (audio_device_) | 664 if (audio_device_) |
666 return; | 665 return; |
667 | 666 |
668 audio_device_ = new WebRtcAudioDeviceImpl(); | 667 audio_device_ = new WebRtcAudioDeviceImpl(); |
669 } | 668 } |
670 | 669 |
671 } // namespace content | 670 } // namespace content |
OLD | NEW |