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

Side by Side Diff: chrome/browser/media/webrtc/desktop_capture_access_handler.cc

Issue 2291893002: Let Contraints Controll Mute/Unmute Audio Local Playback For Desktop Sharing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/media/webrtc/desktop_capture_access_handler.h" 5 #include "chrome/browser/media/webrtc/desktop_capture_access_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const base::string16& application_title, 145 const base::string16& application_title,
146 const base::string16& registered_extension_name) { 146 const base::string16& registered_extension_name) {
147 DCHECK_CURRENTLY_ON(BrowserThread::UI); 147 DCHECK_CURRENTLY_ON(BrowserThread::UI);
148 std::unique_ptr<content::MediaStreamUI> ui; 148 std::unique_ptr<content::MediaStreamUI> ui;
149 149
150 // Add selected desktop source to the list. 150 // Add selected desktop source to the list.
151 devices->push_back(content::MediaStreamDevice( 151 devices->push_back(content::MediaStreamDevice(
152 content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen")); 152 content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen"));
153 if (capture_audio) { 153 if (capture_audio) {
154 if (media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) { 154 if (media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) {
155 content::WebContentsMediaCaptureId web_id = media_id.web_contents_id;
156 web_id.mute_source = mute_system_audio;
155 devices->push_back( 157 devices->push_back(
156 content::MediaStreamDevice(content::MEDIA_DESKTOP_AUDIO_CAPTURE, 158 content::MediaStreamDevice(content::MEDIA_DESKTOP_AUDIO_CAPTURE,
157 media_id.ToString(), "Tab audio")); 159 web_id.ToString(), "Tab audio"));
158 } else if (mute_system_audio) { 160 } else if (mute_system_audio) {
159 // Use the special loopback device ID for system audio capture. 161 // Use the special loopback device ID for system audio capture.
160 devices->push_back(content::MediaStreamDevice( 162 devices->push_back(content::MediaStreamDevice(
161 content::MEDIA_DESKTOP_AUDIO_CAPTURE, 163 content::MEDIA_DESKTOP_AUDIO_CAPTURE,
162 media::AudioDeviceDescription::kLoopbackWithMuteDeviceId, 164 media::AudioDeviceDescription::kLoopbackWithMuteDeviceId,
163 "System Audio")); 165 "System Audio"));
164 } else { 166 } else {
165 // Use the special loopback device ID for system audio capture. 167 // Use the special loopback device ID for system audio capture.
166 devices->push_back(content::MediaStreamDevice( 168 devices->push_back(content::MediaStreamDevice(
167 content::MEDIA_DESKTOP_AUDIO_CAPTURE, 169 content::MEDIA_DESKTOP_AUDIO_CAPTURE,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 #endif // !defined(OS_CHROMEOS) 311 #endif // !defined(OS_CHROMEOS)
310 312
311 bool capture_audio = 313 bool capture_audio =
312 (request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE && 314 (request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE &&
313 loopback_audio_supported); 315 loopback_audio_supported);
314 316
315 // Unless we're being invoked from a component extension, register to 317 // Unless we're being invoked from a component extension, register to
316 // display the notification for stream capture. 318 // display the notification for stream capture.
317 bool display_notification = !component_extension; 319 bool display_notification = !component_extension;
318 320
319 ui = GetDevicesForDesktopCapture(&devices, screen_id, capture_audio, true, 321 ui = GetDevicesForDesktopCapture(&devices, screen_id, capture_audio,
322 request.mute_source,
320 display_notification, application_title, 323 display_notification, application_title,
321 application_title); 324 application_title);
322 DCHECK(!devices.empty()); 325 DCHECK(!devices.empty());
323 } 326 }
324 327
325 // The only case when devices can be empty is if the user has denied 328 // The only case when devices can be empty is if the user has denied
326 // permission. 329 // permission.
327 result = devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED 330 result = devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED
328 : content::MEDIA_DEVICE_OK; 331 : content::MEDIA_DEVICE_OK;
329 } 332 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 loopback_audio_supported) || 421 loopback_audio_supported) ||
419 media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS; 422 media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS;
420 423
421 const bool check_audio_permission = 424 const bool check_audio_permission =
422 !base::CommandLine::ForCurrentProcess()->HasSwitch( 425 !base::CommandLine::ForCurrentProcess()->HasSwitch(
423 extensions::switches::kDisableDesktopCaptureAudio); 426 extensions::switches::kDisableDesktopCaptureAudio);
424 const bool capture_audio = 427 const bool capture_audio =
425 (check_audio_permission ? audio_permitted : true) && audio_requested && 428 (check_audio_permission ? audio_permitted : true) && audio_requested &&
426 audio_supported; 429 audio_supported;
427 430
428 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, false, 431 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio,
432 request.mute_source,
429 true, 433 true,
430 GetApplicationTitle(web_contents, extension), 434 GetApplicationTitle(web_contents, extension),
431 base::UTF8ToUTF16(original_extension_name)); 435 base::UTF8ToUTF16(original_extension_name));
432 UpdateExtensionTrusted(request, extension); 436 UpdateExtensionTrusted(request, extension);
433 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui)); 437 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui));
434 } 438 }
435 439
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698