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

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

Issue 11298006: Browser-wide audio mirroring for TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Relevant files only. Created 8 years, 1 month 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 | Annotate | Revision Log
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/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 const GURL& security_origin, std::string* label) { 239 const GURL& security_origin, std::string* label) {
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
241 241
242 // Create a new request based on options. 242 // Create a new request based on options.
243 AddRequest(DeviceRequest(requester, options, 243 AddRequest(DeviceRequest(requester, options,
244 DeviceRequest::GENERATE_STREAM, 244 DeviceRequest::GENERATE_STREAM,
245 render_process_id, render_view_id, 245 render_process_id, render_view_id,
246 security_origin), 246 security_origin),
247 label); 247 label);
248 DeviceRequest& request = requests_[*label]; 248 DeviceRequest& request = requests_[*label];
249 request.requested_device_id = device_id; 249
250 // Append our tab capture device id scheme.
251 // TODO(justinlin): This is kind of a hack, but the plumbing for audio streams
252 // is too complicated to plumb in by type. Will revisit once it's refactored.
253 const std::string &virtual_device_id =
254 WebContentsCaptureUtil::AppendWebContentsDeviceScheme(device_id);
255
256 request.requested_device_id = virtual_device_id;
250 257
251 // Get user confirmation to use the capture device. 258 // Get user confirmation to use the capture device.
252 PostRequestToUI(*label); 259 PostRequestToUI(*label);
253 260
254 if (!security_origin.SchemeIs(kExtensionScheme) || 261 if (!security_origin.SchemeIs(kExtensionScheme) ||
255 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE && 262 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE &&
256 options.audio_type != MEDIA_NO_SERVICE) || 263 options.audio_type != MEDIA_NO_SERVICE) ||
257 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE && 264 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE &&
258 options.video_type != MEDIA_NO_SERVICE)) { 265 options.video_type != MEDIA_NO_SERVICE)) {
259 LOG(ERROR) << "Invalid request or used tab capture outside extension API."; 266 LOG(ERROR) << "Invalid request or used tab capture outside extension API.";
260 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 267 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
261 base::Bind(&MediaStreamManager::CancelRequest, 268 base::Bind(&MediaStreamManager::CancelRequest,
262 base::Unretained(this), *label)); 269 base::Unretained(this), *label));
263 return; 270 return;
264 } 271 }
265 272
266 // TODO(miu): We should ask the device manager whether a device with id 273 // TODO(miu): We should ask the device manager whether a device with id
267 // |device_id| actually exists. Note that no such MediaStreamProvider API for 274 // |device_id| actually exists. Note that no such MediaStreamProvider API for
268 // this currently exists. Also, we don't have a user-friendly device name for 275 // this currently exists. Also, we don't have a user-friendly device name for
269 // the infobar UI. 276 // the infobar UI.
270 if (IsAudioMediaType(options.audio_type)) { 277 if (IsAudioMediaType(options.audio_type)) {
271 // TODO(justinlin): Updating the state to requested and pending are no-ops 278 // TODO(justinlin): Updating the state to requested and pending are no-ops
272 // in terms of the media manager, but these are the state changes we want to 279 // in terms of the media manager, but these are the state changes we want to
273 // support in terms of extensions (which is registered as an observer). 280 // support in terms of extensions (which is registered as an observer).
274 request.setState(options.audio_type, MEDIA_REQUEST_STATE_REQUESTED); 281 request.setState(options.audio_type, MEDIA_REQUEST_STATE_REQUESTED);
275 request.setState(options.audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 282 request.setState(options.audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
276 ui_controller_->AddAvailableDevicesToRequest( 283 ui_controller_->AddAvailableDevicesToRequest(
277 *label, options.audio_type, StreamDeviceInfoArray( 284 *label, options.audio_type, StreamDeviceInfoArray(
278 1, StreamDeviceInfo(options.audio_type, device_id, device_id, 285 1, StreamDeviceInfo(options.audio_type,
286 virtual_device_id,
287 virtual_device_id,
279 false))); 288 false)));
280 } 289 }
281 if (IsVideoMediaType(options.video_type)) { 290 if (IsVideoMediaType(options.video_type)) {
282 request.setState(options.video_type, MEDIA_REQUEST_STATE_REQUESTED); 291 request.setState(options.video_type, MEDIA_REQUEST_STATE_REQUESTED);
283 request.setState(options.video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 292 request.setState(options.video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
284 ui_controller_->AddAvailableDevicesToRequest( 293 ui_controller_->AddAvailableDevicesToRequest(
285 *label, options.video_type, StreamDeviceInfoArray( 294 *label, options.video_type, StreamDeviceInfoArray(
286 1, StreamDeviceInfo(options.video_type, device_id, device_id, 295 1, StreamDeviceInfo(options.video_type,
296 virtual_device_id,
297 virtual_device_id,
287 false))); 298 false)));
288 } 299 }
289 } 300 }
290 301
291 void MediaStreamManager::CancelRequest(const std::string& label) { 302 void MediaStreamManager::CancelRequest(const std::string& label) {
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
293 304
294 DeviceRequests::iterator it = requests_.find(label); 305 DeviceRequests::iterator it = requests_.find(label);
295 if (it != requests_.end()) { 306 if (it != requests_.end()) {
296 // The request isn't complete, notify the UI immediately. 307 // The request isn't complete, notify the UI immediately.
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } 1061 }
1051 1062
1052 // Always do enumeration even though some enumeration is in progress, 1063 // Always do enumeration even though some enumeration is in progress,
1053 // because those enumeration commands could be sent before these devices 1064 // because those enumeration commands could be sent before these devices
1054 // change. 1065 // change.
1055 ++active_enumeration_ref_count_[stream_type]; 1066 ++active_enumeration_ref_count_[stream_type];
1056 GetDeviceManager(stream_type)->EnumerateDevices(); 1067 GetDeviceManager(stream_type)->EnumerateDevices();
1057 } 1068 }
1058 1069
1059 } // namespace content 1070 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698