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

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 2517953003: Move enable_webrtc to a buildflag header. (Closed)
Patch Set: Fix Created 4 years 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 (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 11 matching lines...) Expand all
22 #include "content/browser/media/media_internals.h" 22 #include "content/browser/media/media_internals.h"
23 #include "content/browser/renderer_host/media/audio_input_debug_writer.h" 23 #include "content/browser/renderer_host/media/audio_input_debug_writer.h"
24 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 24 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
25 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" 25 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
26 #include "content/browser/renderer_host/media/media_stream_manager.h" 26 #include "content/browser/renderer_host/media/media_stream_manager.h"
27 #include "content/browser/webrtc/webrtc_internals.h" 27 #include "content/browser/webrtc/webrtc_internals.h"
28 #include "content/public/browser/web_contents_media_capture_id.h" 28 #include "content/public/browser/web_contents_media_capture_id.h"
29 #include "media/audio/audio_device_description.h" 29 #include "media/audio/audio_device_description.h"
30 #include "media/base/audio_bus.h" 30 #include "media/base/audio_bus.h"
31 #include "media/base/media_switches.h" 31 #include "media/base/media_switches.h"
32 #include "media/media_features.h"
32 33
33 namespace content { 34 namespace content {
34 35
35 namespace { 36 namespace {
36 37
37 #ifdef ENABLE_WEBRTC 38 #if BUILDFLAG(ENABLE_WEBRTC)
38 const base::FilePath::CharType kDebugRecordingFileNameAddition[] = 39 const base::FilePath::CharType kDebugRecordingFileNameAddition[] =
39 FILE_PATH_LITERAL("source_input"); 40 FILE_PATH_LITERAL("source_input");
40 const base::FilePath::CharType kDebugRecordingFileNameExtension[] = 41 const base::FilePath::CharType kDebugRecordingFileNameExtension[] =
41 FILE_PATH_LITERAL("wav"); 42 FILE_PATH_LITERAL("wav");
42 #endif 43 #endif
43 44
44 void LogMessage(int stream_id, const std::string& msg, bool add_prefix) { 45 void LogMessage(int stream_id, const std::string& msg, bool add_prefix) {
45 std::ostringstream oss; 46 std::ostringstream oss;
46 oss << "[stream_id=" << stream_id << "] "; 47 oss << "[stream_id=" << stream_id << "] ";
47 if (add_prefix) 48 if (add_prefix)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 user_input_monitor_(user_input_monitor), 106 user_input_monitor_(user_input_monitor),
106 audio_log_(MediaInternals::GetInstance()->CreateAudioLog( 107 audio_log_(MediaInternals::GetInstance()->CreateAudioLog(
107 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER)), 108 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER)),
108 weak_factory_(this) {} 109 weak_factory_(this) {}
109 110
110 AudioInputRendererHost::~AudioInputRendererHost() { 111 AudioInputRendererHost::~AudioInputRendererHost() {
111 DCHECK_CURRENTLY_ON(BrowserThread::IO); 112 DCHECK_CURRENTLY_ON(BrowserThread::IO);
112 DCHECK(audio_entries_.empty()); 113 DCHECK(audio_entries_.empty());
113 } 114 }
114 115
115 #ifdef ENABLE_WEBRTC 116 #if BUILDFLAG(ENABLE_WEBRTC)
116 void AudioInputRendererHost::EnableDebugRecording(const base::FilePath& file) { 117 void AudioInputRendererHost::EnableDebugRecording(const base::FilePath& file) {
117 DCHECK_CURRENTLY_ON(BrowserThread::IO); 118 DCHECK_CURRENTLY_ON(BrowserThread::IO);
118 base::FilePath file_with_extensions = 119 base::FilePath file_with_extensions =
119 GetDebugRecordingFilePathWithExtensions(file); 120 GetDebugRecordingFilePathWithExtensions(file);
120 for (const auto& entry : audio_entries_) 121 for (const auto& entry : audio_entries_)
121 EnableDebugRecordingForId(file_with_extensions, entry.first); 122 EnableDebugRecordingForId(file_with_extensions, entry.first);
122 } 123 }
123 124
124 void AudioInputRendererHost::DisableDebugRecording() { 125 void AudioInputRendererHost::DisableDebugRecording() {
125 for (const auto& entry : audio_entries_) { 126 for (const auto& entry : audio_entries_) {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 std::unique_ptr<AudioInputSyncWriter> writer(new AudioInputSyncWriter( 382 std::unique_ptr<AudioInputSyncWriter> writer(new AudioInputSyncWriter(
382 entry->shared_memory.memory(), entry->shared_memory.requested_size(), 383 entry->shared_memory.memory(), entry->shared_memory.requested_size(),
383 entry->shared_memory_segment_count, audio_params)); 384 entry->shared_memory_segment_count, audio_params));
384 385
385 if (!writer->Init()) { 386 if (!writer->Init()) {
386 SendErrorMessage(stream_id, SYNC_WRITER_INIT_FAILED); 387 SendErrorMessage(stream_id, SYNC_WRITER_INIT_FAILED);
387 MaybeUnregisterKeyboardMicStream(config); 388 MaybeUnregisterKeyboardMicStream(config);
388 return; 389 return;
389 } 390 }
390 391
391 #if defined(ENABLE_WEBRTC) 392 #if BUILDFLAG(ENABLE_WEBRTC)
392 std::unique_ptr<media::AudioInputWriter> debug_writer( 393 std::unique_ptr<media::AudioInputWriter> debug_writer(
393 new AudioInputDebugWriter(audio_params)); 394 new AudioInputDebugWriter(audio_params));
394 #else 395 #else
395 std::unique_ptr<media::AudioInputWriter> debug_writer(nullptr); 396 std::unique_ptr<media::AudioInputWriter> debug_writer(nullptr);
396 #endif 397 #endif
397 398
398 // If we have successfully created the SyncWriter then assign it to the 399 // If we have successfully created the SyncWriter then assign it to the
399 // entry and construct an AudioInputController. 400 // entry and construct an AudioInputController.
400 entry->writer.reset(writer.release()); 401 entry->writer.reset(writer.release());
401 if (WebContentsMediaCaptureId::Parse(device_id, nullptr)) { 402 if (WebContentsMediaCaptureId::Parse(device_id, nullptr)) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 DVLOG(1) << oss.str(); 454 DVLOG(1) << oss.str();
454 455
455 // Since the controller was created successfully, create an entry and add it 456 // Since the controller was created successfully, create an entry and add it
456 // to the map. 457 // to the map.
457 entry->stream_id = stream_id; 458 entry->stream_id = stream_id;
458 audio_entries_.insert(std::make_pair(stream_id, entry.release())); 459 audio_entries_.insert(std::make_pair(stream_id, entry.release()));
459 audio_log_->OnCreated(stream_id, audio_params, device_id); 460 audio_log_->OnCreated(stream_id, audio_params, device_id);
460 MediaInternals::GetInstance()->SetWebContentsTitleForAudioLogEntry( 461 MediaInternals::GetInstance()->SetWebContentsTitleForAudioLogEntry(
461 stream_id, render_process_id_, render_frame_id, audio_log_.get()); 462 stream_id, render_process_id_, render_frame_id, audio_log_.get());
462 463
463 #if defined(ENABLE_WEBRTC) 464 #if BUILDFLAG(ENABLE_WEBRTC)
464 BrowserThread::PostTask( 465 BrowserThread::PostTask(
465 BrowserThread::UI, 466 BrowserThread::UI,
466 FROM_HERE, 467 FROM_HERE,
467 base::Bind( 468 base::Bind(
468 &AudioInputRendererHost::MaybeEnableDebugRecordingForId, 469 &AudioInputRendererHost::MaybeEnableDebugRecordingForId,
469 this, 470 this,
470 stream_id)); 471 stream_id));
471 #endif 472 #endif
472 } 473 }
473 474
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 const AudioInputHostMsg_CreateStream_Config& config) { 596 const AudioInputHostMsg_CreateStream_Config& config) {
596 #if defined(OS_CHROMEOS) 597 #if defined(OS_CHROMEOS)
597 if (config.params.channel_layout() == 598 if (config.params.channel_layout() ==
598 media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { 599 media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) {
599 media_stream_manager_->audio_input_device_manager() 600 media_stream_manager_->audio_input_device_manager()
600 ->UnregisterKeyboardMicStream(); 601 ->UnregisterKeyboardMicStream();
601 } 602 }
602 #endif 603 #endif
603 } 604 }
604 605
605 #if defined(ENABLE_WEBRTC) 606 #if BUILDFLAG(ENABLE_WEBRTC)
606 void AudioInputRendererHost::MaybeEnableDebugRecordingForId(int stream_id) { 607 void AudioInputRendererHost::MaybeEnableDebugRecordingForId(int stream_id) {
607 DCHECK_CURRENTLY_ON(BrowserThread::UI); 608 DCHECK_CURRENTLY_ON(BrowserThread::UI);
608 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { 609 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
609 BrowserThread::PostTask( 610 BrowserThread::PostTask(
610 BrowserThread::IO, 611 BrowserThread::IO,
611 FROM_HERE, 612 FROM_HERE,
612 base::Bind( 613 base::Bind(
613 &AudioInputRendererHost::EnableDebugRecordingForId, 614 &AudioInputRendererHost::EnableDebugRecordingForId,
614 this, 615 this,
615 GetDebugRecordingFilePathWithExtensions( 616 GetDebugRecordingFilePathWithExtensions(
(...skipping 22 matching lines...) Expand all
638 AudioEntry* entry = LookupById(stream_id); 639 AudioEntry* entry = LookupById(stream_id);
639 if (!entry) 640 if (!entry)
640 return; 641 return;
641 entry->controller->EnableDebugRecording( 642 entry->controller->EnableDebugRecording(
642 file_name.AddExtension(IntToStringType(stream_id)) 643 file_name.AddExtension(IntToStringType(stream_id))
643 .AddExtension(kDebugRecordingFileNameExtension)); 644 .AddExtension(kDebugRecordingFileNameExtension));
644 } 645 }
645 646
646 #undef IntToStringType 647 #undef IntToStringType
647 648
648 #endif // defined(ENABLE_WEBRTC) 649 #endif // BUILDFLAG(ENABLE_WEBRTC)
649 650
650 } // namespace content 651 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698