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