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

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

Issue 2350693002: Remove device enumeration, caching and monitoring from MediaStreamManager. (Closed)
Patch Set: latest hta@ comments Created 4 years, 3 months 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/files/file.h" 11 #include "base/files/file.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/shared_memory.h" 13 #include "base/memory/shared_memory.h"
13 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
14 #include "base/numerics/safe_math.h" 15 #include "base/numerics/safe_math.h"
15 #include "base/process/process.h" 16 #include "base/process/process.h"
16 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" 20 #include "content/browser/media/capture/desktop_capture_device_uma_types.h"
20 #include "content/browser/media/capture/web_contents_audio_input_stream.h" 21 #include "content/browser/media/capture/web_contents_audio_input_stream.h"
21 #include "content/browser/media/media_internals.h" 22 #include "content/browser/media/media_internals.h"
22 #include "content/browser/renderer_host/media/audio_input_debug_writer.h" 23 #include "content/browser/renderer_host/media/audio_input_debug_writer.h"
23 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 24 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
24 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" 25 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
25 #include "content/browser/renderer_host/media/media_stream_manager.h" 26 #include "content/browser/renderer_host/media/media_stream_manager.h"
26 #include "content/browser/webrtc/webrtc_internals.h" 27 #include "content/browser/webrtc/webrtc_internals.h"
27 #include "content/public/browser/web_contents_media_capture_id.h" 28 #include "content/public/browser/web_contents_media_capture_id.h"
28 #include "media/audio/audio_device_description.h" 29 #include "media/audio/audio_device_description.h"
29 #include "media/base/audio_bus.h" 30 #include "media/base/audio_bus.h"
31 #include "media/base/media_switches.h"
30 32
31 namespace content { 33 namespace content {
32 34
33 namespace { 35 namespace {
34 36
35 #ifdef ENABLE_WEBRTC 37 #ifdef ENABLE_WEBRTC
36 const base::FilePath::CharType kDebugRecordingFileNameAddition[] = 38 const base::FilePath::CharType kDebugRecordingFileNameAddition[] =
37 FILE_PATH_LITERAL("source_input"); 39 FILE_PATH_LITERAL("source_input");
38 const base::FilePath::CharType kDebugRecordingFileNameExtension[] = 40 const base::FilePath::CharType kDebugRecordingFileNameExtension[] =
39 FILE_PATH_LITERAL("wav"); 41 FILE_PATH_LITERAL("wav");
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 DCHECK_GT(render_frame_id, 0); 362 DCHECK_GT(render_frame_id, 0);
361 363
362 // media::AudioParameters is validated in the deserializer. 364 // media::AudioParameters is validated in the deserializer.
363 if (LookupById(stream_id) != NULL) { 365 if (LookupById(stream_id) != NULL) {
364 SendErrorMessage(stream_id, STREAM_ALREADY_EXISTS); 366 SendErrorMessage(stream_id, STREAM_ALREADY_EXISTS);
365 MaybeUnregisterKeyboardMicStream(config); 367 MaybeUnregisterKeyboardMicStream(config);
366 return; 368 return;
367 } 369 }
368 370
369 media::AudioParameters audio_params(config.params); 371 media::AudioParameters audio_params(config.params);
370 if (media_stream_manager_->audio_input_device_manager() 372 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
371 ->ShouldUseFakeDevice()) 373 switches::kUseFakeDeviceForMediaStream)) {
372 audio_params.set_format(media::AudioParameters::AUDIO_FAKE); 374 audio_params.set_format(media::AudioParameters::AUDIO_FAKE);
375 }
373 376
374 // Check if we have the permission to open the device and which device to use. 377 // Check if we have the permission to open the device and which device to use.
375 MediaStreamType type = MEDIA_NO_SERVICE; 378 MediaStreamType type = MEDIA_NO_SERVICE;
376 std::string device_name; 379 std::string device_name;
377 std::string device_id = media::AudioDeviceDescription::kDefaultDeviceId; 380 std::string device_id = media::AudioDeviceDescription::kDefaultDeviceId;
378 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { 381 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) {
379 const StreamDeviceInfo* info = media_stream_manager_-> 382 const StreamDeviceInfo* info = media_stream_manager_->
380 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); 383 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id);
381 if (!info) { 384 if (!info) {
382 SendErrorMessage(stream_id, PERMISSION_DENIED); 385 SendErrorMessage(stream_id, PERMISSION_DENIED);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 if (entry->input_debug_writer.get()) { 725 if (entry->input_debug_writer.get()) {
723 BrowserThread::PostTask( 726 BrowserThread::PostTask(
724 BrowserThread::FILE, FROM_HERE, 727 BrowserThread::FILE, FROM_HERE,
725 base::Bind(&DeleteInputDebugWriterOnFileThread, 728 base::Bind(&DeleteInputDebugWriterOnFileThread,
726 base::Passed(std::move(entry->input_debug_writer)))); 729 base::Passed(std::move(entry->input_debug_writer))));
727 } 730 }
728 } 731 }
729 #endif // defined(ENABLE_WEBRTC) 732 #endif // defined(ENABLE_WEBRTC)
730 733
731 } // namespace content 734 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698