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

Side by Side Diff: content/browser/media/media_devices_util.cc

Issue 2707033003: Fall back to default media device from preferences if no default is supplied from the command line. (Closed)
Patch Set: comment Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/media/media_devices_util.h" 5 #include "content/browser/media/media_devices_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 case MEDIA_DEVICE_TYPE_VIDEO_INPUT: 42 case MEDIA_DEVICE_TYPE_VIDEO_INPUT:
43 media_stream_type = MEDIA_DEVICE_VIDEO_CAPTURE; 43 media_stream_type = MEDIA_DEVICE_VIDEO_CAPTURE;
44 break; 44 break;
45 default: 45 default:
46 return std::string(); 46 return std::string();
47 } 47 }
48 48
49 return delegate->GetDefaultMediaDeviceID(media_stream_type); 49 return delegate->GetDefaultMediaDeviceID(media_stream_type);
50 } 50 }
51 51
52 // This function is intended for testing purposes. 52 // This function is intended for testing purposes. It returns an empty string
53 // if no default device is supplied via the command line.
53 std::string GetDefaultMediaDeviceIDFromCommandLine( 54 std::string GetDefaultMediaDeviceIDFromCommandLine(
54 MediaDeviceType device_type) { 55 MediaDeviceType device_type) {
55 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 56 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
56 switches::kUseFakeDeviceForMediaStream)); 57 switches::kUseFakeDeviceForMediaStream));
57 const std::string option = 58 const std::string option =
58 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 59 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
59 switches::kUseFakeDeviceForMediaStream); 60 switches::kUseFakeDeviceForMediaStream);
60 // Optional comma delimited parameters to the command line can specify values 61 // Optional comma delimited parameters to the command line can specify values
61 // for the default device IDs. 62 // for the default device IDs.
62 // Examples: "video-input-default-id=mycam, audio-input-default-id=mymic" 63 // Examples: "video-input-default-id=mycam, audio-input-default-id=mymic"
(...skipping 24 matching lines...) Expand all
87 88
88 } // namespace 89 } // namespace
89 90
90 void GetDefaultMediaDeviceID( 91 void GetDefaultMediaDeviceID(
91 MediaDeviceType device_type, 92 MediaDeviceType device_type,
92 int render_process_id, 93 int render_process_id,
93 int render_frame_id, 94 int render_frame_id,
94 const base::Callback<void(const std::string&)>& callback) { 95 const base::Callback<void(const std::string&)>& callback) {
95 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 96 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
96 switches::kUseFakeDeviceForMediaStream)) { 97 switches::kUseFakeDeviceForMediaStream)) {
97 callback.Run(GetDefaultMediaDeviceIDFromCommandLine(device_type)); 98 std::string command_line_default_device_id =
98 return; 99 GetDefaultMediaDeviceIDFromCommandLine(device_type);
100 if (!command_line_default_device_id.empty()) {
101 callback.Run(command_line_default_device_id);
102 return;
103 }
99 } 104 }
100 105
101 BrowserThread::PostTaskAndReplyWithResult( 106 BrowserThread::PostTaskAndReplyWithResult(
102 BrowserThread::UI, FROM_HERE, 107 BrowserThread::UI, FROM_HERE,
103 base::Bind(&GetDefaultMediaDeviceIDOnUIThread, device_type, 108 base::Bind(&GetDefaultMediaDeviceIDOnUIThread, device_type,
104 render_process_id, render_frame_id), 109 render_process_id, render_frame_id),
105 callback); 110 callback);
106 } 111 }
107 112
108 } // namespace content 113 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698