OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_stream_dependency_factory.h" | 5 #include "content/renderer/media/media_stream_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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 IPC_MESSAGE_HANDLER(MediaStreamMsg_EnableAecDump, OnAecDumpFile) | 746 IPC_MESSAGE_HANDLER(MediaStreamMsg_EnableAecDump, OnAecDumpFile) |
747 IPC_MESSAGE_HANDLER(MediaStreamMsg_DisableAecDump, OnDisableAecDump) | 747 IPC_MESSAGE_HANDLER(MediaStreamMsg_DisableAecDump, OnDisableAecDump) |
748 IPC_MESSAGE_UNHANDLED(handled = false) | 748 IPC_MESSAGE_UNHANDLED(handled = false) |
749 IPC_END_MESSAGE_MAP() | 749 IPC_END_MESSAGE_MAP() |
750 return handled; | 750 return handled; |
751 } | 751 } |
752 | 752 |
753 void MediaStreamDependencyFactory::OnAecDumpFile( | 753 void MediaStreamDependencyFactory::OnAecDumpFile( |
754 IPC::PlatformFileForTransit file_handle) { | 754 IPC::PlatformFileForTransit file_handle) { |
755 DCHECK_EQ(aec_dump_file_, base::kInvalidPlatformFileValue); | 755 DCHECK_EQ(aec_dump_file_, base::kInvalidPlatformFileValue); |
756 if (PeerConnectionFactoryCreated()) { | 756 base::PlatformFile file = |
757 base::PlatformFile file = | 757 IPC::PlatformFileForTransitToPlatformFile(file_handle); |
758 IPC::PlatformFileForTransitToPlatformFile(file_handle); | 758 DCHECK_NE(file, base::kInvalidPlatformFileValue); |
759 DCHECK_NE(file, base::kInvalidPlatformFileValue); | 759 |
| 760 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 761 switches::kEnableAudioTrackProcessing)) { |
| 762 EnsureWebRtcAudioDeviceImpl(); |
| 763 GetWebRtcAudioDevice()->EnableAecDump(file); |
| 764 return; |
| 765 } |
| 766 |
| 767 // TODO(xians): Remove the following code after kEnableAudioTrackProcessing |
| 768 // is removed. |
| 769 if (PeerConnectionFactoryCreated()) |
760 StartAecDump(file); | 770 StartAecDump(file); |
761 } else { | 771 else |
762 aec_dump_file_ = IPC::PlatformFileForTransitToPlatformFile(file_handle); | 772 aec_dump_file_ = file; |
763 DCHECK_NE(aec_dump_file_, base::kInvalidPlatformFileValue); | |
764 } | |
765 } | 773 } |
766 | 774 |
767 void MediaStreamDependencyFactory::OnDisableAecDump() { | 775 void MediaStreamDependencyFactory::OnDisableAecDump() { |
| 776 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 777 switches::kEnableAudioTrackProcessing)) { |
| 778 GetWebRtcAudioDevice()->DisableAecDump(); |
| 779 return; |
| 780 } |
| 781 |
| 782 // TODO(xians): Remove the following code after kEnableAudioTrackProcessing |
| 783 // is removed. |
768 if (aec_dump_file_ != base::kInvalidPlatformFileValue) | 784 if (aec_dump_file_ != base::kInvalidPlatformFileValue) |
769 base::ClosePlatformFile(aec_dump_file_); | 785 base::ClosePlatformFile(aec_dump_file_); |
770 aec_dump_file_ = base::kInvalidPlatformFileValue; | 786 aec_dump_file_ = base::kInvalidPlatformFileValue; |
771 } | 787 } |
772 | 788 |
773 void MediaStreamDependencyFactory::StartAecDump( | 789 void MediaStreamDependencyFactory::StartAecDump( |
774 const base::PlatformFile& aec_dump_file) { | 790 const base::PlatformFile& aec_dump_file) { |
775 // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump() | 791 // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump() |
776 // fails, |aec_dump_file| will be closed. | 792 // fails, |aec_dump_file| will be closed. |
777 if (!GetPcFactory()->StartAecDump(aec_dump_file)) | 793 if (!GetPcFactory()->StartAecDump(aec_dump_file)) |
778 VLOG(1) << "Could not start AEC dump."; | 794 VLOG(1) << "Could not start AEC dump."; |
779 } | 795 } |
780 | 796 |
781 void MediaStreamDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 797 void MediaStreamDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
782 if (audio_device_) | 798 if (audio_device_) |
783 return; | 799 return; |
784 | 800 |
785 audio_device_ = new WebRtcAudioDeviceImpl(); | 801 audio_device_ = new WebRtcAudioDeviceImpl(); |
786 } | 802 } |
787 | 803 |
788 } // namespace content | 804 } // namespace content |
OLD | NEW |