| 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/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 shared_memory_segment_count(0), | 87 shared_memory_segment_count(0), |
| 88 pending_close(false), | 88 pending_close(false), |
| 89 has_keyboard_mic(false) { | 89 has_keyboard_mic(false) { |
| 90 } | 90 } |
| 91 | 91 |
| 92 AudioInputRendererHost::AudioEntry::~AudioEntry() { | 92 AudioInputRendererHost::AudioEntry::~AudioEntry() { |
| 93 } | 93 } |
| 94 | 94 |
| 95 AudioInputRendererHost::AudioInputRendererHost( | 95 AudioInputRendererHost::AudioInputRendererHost( |
| 96 int render_process_id, | 96 int render_process_id, |
| 97 int32_t renderer_pid, | |
| 98 media::AudioManager* audio_manager, | 97 media::AudioManager* audio_manager, |
| 99 MediaStreamManager* media_stream_manager, | 98 MediaStreamManager* media_stream_manager, |
| 100 AudioMirroringManager* audio_mirroring_manager, | 99 AudioMirroringManager* audio_mirroring_manager, |
| 101 media::UserInputMonitor* user_input_monitor) | 100 media::UserInputMonitor* user_input_monitor) |
| 102 : BrowserMessageFilter(AudioMsgStart), | 101 : BrowserMessageFilter(AudioMsgStart), |
| 103 render_process_id_(render_process_id), | 102 render_process_id_(render_process_id), |
| 104 renderer_pid_(renderer_pid), | 103 renderer_pid_(0), |
| 105 audio_manager_(audio_manager), | 104 audio_manager_(audio_manager), |
| 106 media_stream_manager_(media_stream_manager), | 105 media_stream_manager_(media_stream_manager), |
| 107 audio_mirroring_manager_(audio_mirroring_manager), | 106 audio_mirroring_manager_(audio_mirroring_manager), |
| 108 user_input_monitor_(user_input_monitor), | 107 user_input_monitor_(user_input_monitor), |
| 109 audio_log_(MediaInternals::GetInstance()->CreateAudioLog( | 108 audio_log_(MediaInternals::GetInstance()->CreateAudioLog( |
| 110 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER)) {} | 109 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER)) {} |
| 111 | 110 |
| 112 AudioInputRendererHost::~AudioInputRendererHost() { | 111 AudioInputRendererHost::~AudioInputRendererHost() { |
| 113 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 112 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 114 DCHECK(audio_entries_.empty()); | 113 DCHECK(audio_entries_.empty()); |
| 115 } | 114 } |
| 116 | 115 |
| 117 #if BUILDFLAG(ENABLE_WEBRTC) | 116 #if BUILDFLAG(ENABLE_WEBRTC) |
| 118 void AudioInputRendererHost::EnableDebugRecording(const base::FilePath& file) { | 117 void AudioInputRendererHost::EnableDebugRecording(const base::FilePath& file) { |
| 119 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 118 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 119 if (audio_entries_.empty()) |
| 120 return; |
| 120 base::FilePath file_with_extensions = | 121 base::FilePath file_with_extensions = |
| 121 GetDebugRecordingFilePathWithExtensions(file); | 122 GetDebugRecordingFilePathWithExtensions(file); |
| 122 for (const auto& entry : audio_entries_) | 123 for (const auto& entry : audio_entries_) |
| 123 EnableDebugRecordingForId(file_with_extensions, entry.first); | 124 EnableDebugRecordingForId(file_with_extensions, entry.first); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void AudioInputRendererHost::DisableDebugRecording() { | 127 void AudioInputRendererHost::DisableDebugRecording() { |
| 127 for (const auto& entry : audio_entries_) { | 128 for (const auto& entry : audio_entries_) { |
| 128 entry.second->controller->DisableDebugRecording(); | 129 entry.second->controller->DisableDebugRecording(); |
| 129 } | 130 } |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 ->UnregisterKeyboardMicStream(); | 549 ->UnregisterKeyboardMicStream(); |
| 549 } | 550 } |
| 550 #endif | 551 #endif |
| 551 } | 552 } |
| 552 | 553 |
| 553 #if BUILDFLAG(ENABLE_WEBRTC) | 554 #if BUILDFLAG(ENABLE_WEBRTC) |
| 554 void AudioInputRendererHost::MaybeEnableDebugRecordingForId(int stream_id) { | 555 void AudioInputRendererHost::MaybeEnableDebugRecordingForId(int stream_id) { |
| 555 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 556 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 556 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { | 557 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| 557 BrowserThread::PostTask( | 558 BrowserThread::PostTask( |
| 558 BrowserThread::IO, | 559 BrowserThread::IO, FROM_HERE, |
| 559 FROM_HERE, | |
| 560 base::Bind( | 560 base::Bind( |
| 561 &AudioInputRendererHost::EnableDebugRecordingForId, | 561 &AudioInputRendererHost:: |
| 562 AddExtensionsToPathAndEnableDebugRecordingForId, |
| 562 this, | 563 this, |
| 563 GetDebugRecordingFilePathWithExtensions( | 564 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath(), |
| 564 WebRTCInternals::GetInstance()-> | |
| 565 GetAudioDebugRecordingsFilePath()), | |
| 566 stream_id)); | 565 stream_id)); |
| 567 } | 566 } |
| 568 } | 567 } |
| 569 | 568 |
| 570 #if defined(OS_WIN) | 569 #if defined(OS_WIN) |
| 571 #define IntToStringType base::IntToString16 | 570 #define IntToStringType base::IntToString16 |
| 572 #else | 571 #else |
| 573 #define IntToStringType base::IntToString | 572 #define IntToStringType base::IntToString |
| 574 #endif | 573 #endif |
| 575 | 574 |
| 576 base::FilePath AudioInputRendererHost::GetDebugRecordingFilePathWithExtensions( | 575 base::FilePath AudioInputRendererHost::GetDebugRecordingFilePathWithExtensions( |
| 577 const base::FilePath& file) { | 576 const base::FilePath& file) { |
| 577 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 578 // We expect |renderer_pid_| to be set. |
| 579 DCHECK_GT(renderer_pid_, 0); |
| 578 return file.AddExtension(IntToStringType(renderer_pid_)) | 580 return file.AddExtension(IntToStringType(renderer_pid_)) |
| 579 .AddExtension(kDebugRecordingFileNameAddition); | 581 .AddExtension(kDebugRecordingFileNameAddition); |
| 580 } | 582 } |
| 581 | 583 |
| 582 void AudioInputRendererHost::EnableDebugRecordingForId( | 584 void AudioInputRendererHost::EnableDebugRecordingForId( |
| 583 const base::FilePath& file_name, | 585 const base::FilePath& file_name, |
| 584 int stream_id) { | 586 int stream_id) { |
| 585 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 587 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 586 AudioEntry* entry = LookupById(stream_id); | 588 AudioEntry* entry = LookupById(stream_id); |
| 587 if (!entry) | 589 if (!entry) |
| 588 return; | 590 return; |
| 589 entry->controller->EnableDebugRecording( | 591 entry->controller->EnableDebugRecording( |
| 590 file_name.AddExtension(IntToStringType(stream_id)) | 592 file_name.AddExtension(IntToStringType(stream_id)) |
| 591 .AddExtension(kDebugRecordingFileNameExtension)); | 593 .AddExtension(kDebugRecordingFileNameExtension)); |
| 592 } | 594 } |
| 593 | 595 |
| 594 #undef IntToStringType | 596 #undef IntToStringType |
| 595 | 597 |
| 598 void AudioInputRendererHost::AddExtensionsToPathAndEnableDebugRecordingForId( |
| 599 const base::FilePath& file, |
| 600 int stream_id) { |
| 601 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 602 EnableDebugRecordingForId(GetDebugRecordingFilePathWithExtensions(file), |
| 603 stream_id); |
| 604 } |
| 605 |
| 596 #endif // BUILDFLAG(ENABLE_WEBRTC) | 606 #endif // BUILDFLAG(ENABLE_WEBRTC) |
| 597 | 607 |
| 598 } // namespace content | 608 } // namespace content |
| OLD | NEW |