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

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

Issue 10177008: Shift media_stream::StreamOptions to align with the new getUserMedia spec (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 7 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/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/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 27 matching lines...) Expand all
38 int random_char = base::RandGenerator(sizeof(alphabet) - 1); 38 int random_char = base::RandGenerator(sizeof(alphabet) - 1);
39 label[i] = alphabet[random_char]; 39 label[i] = alphabet[random_char];
40 } 40 }
41 return label; 41 return label;
42 } 42 }
43 43
44 // Helper to verify if a media stream type is part of options or not. 44 // Helper to verify if a media stream type is part of options or not.
45 static bool Requested(const StreamOptions& options, 45 static bool Requested(const StreamOptions& options,
46 MediaStreamType stream_type) { 46 MediaStreamType stream_type) {
47 if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE && 47 if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE &&
48 (options.video_option != StreamOptions::kNoCamera)) { 48 options.video) {
49 return true; 49 return true;
50 } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE && 50 } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE &&
51 options.audio == true) { 51 options.audio) {
52 return true; 52 return true;
53 } 53 }
54 return false; 54 return false;
55 } 55 }
56 56
57 struct MediaStreamManager::DeviceRequest { 57 struct MediaStreamManager::DeviceRequest {
58 enum RequestState { 58 enum RequestState {
59 kNotRequested = 0, 59 kNotRequested = 0,
60 kRequested, 60 kRequested,
61 kPendingApproval, 61 kPendingApproval,
62 kOpening, 62 kOpening,
63 kDone, 63 kDone,
64 kError 64 kError
65 }; 65 };
66 66
67 enum RequestType { 67 enum RequestType {
68 kGenerateStream = 0, 68 kGenerateStream = 0,
69 kEnumerateDevices, 69 kEnumerateDevices,
70 kOpenDevice 70 kOpenDevice
71 }; 71 };
72 72
73 DeviceRequest() 73 DeviceRequest()
74 : requester(NULL), 74 : requester(NULL),
75 state(content::NUM_MEDIA_STREAM_DEVICE_TYPES, kNotRequested), 75 state(content::NUM_MEDIA_STREAM_DEVICE_TYPES, kNotRequested),
76 type(kGenerateStream) { 76 type(kGenerateStream) {
77 options.audio = false; 77 options.audio = false;
78 options.video_option = StreamOptions::kNoCamera; 78 options.video = false;
79 } 79 }
80 80
81 DeviceRequest(MediaStreamRequester* requester, 81 DeviceRequest(MediaStreamRequester* requester,
82 const StreamOptions& request_options) 82 const StreamOptions& request_options)
83 : requester(requester), 83 : requester(requester),
84 options(request_options), 84 options(request_options),
85 state(content::NUM_MEDIA_STREAM_DEVICE_TYPES, kNotRequested), 85 state(content::NUM_MEDIA_STREAM_DEVICE_TYPES, kNotRequested),
86 type(kGenerateStream) { 86 type(kGenerateStream) {
87 DCHECK(requester); 87 DCHECK(requester);
88 } 88 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 MediaStreamType type, 221 MediaStreamType type,
222 const std::string& security_origin, 222 const std::string& security_origin,
223 std::string* label) { 223 std::string* label) {
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
225 225
226 // Create a new request. 226 // Create a new request.
227 StreamOptions options; 227 StreamOptions options;
228 if (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) 228 if (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
229 options.audio = true; 229 options.audio = true;
230 else 230 else
231 options.video_option = StreamOptions::kFacingUser; 231 options.video = true;
232 232
233 DeviceRequest new_request = DeviceRequest(requester, options); 233 DeviceRequest new_request = DeviceRequest(requester, options);
234 new_request.type = DeviceRequest::kEnumerateDevices; 234 new_request.type = DeviceRequest::kEnumerateDevices;
235 235
236 StartEnumeration(&new_request, render_process_id, render_view_id, 236 StartEnumeration(&new_request, render_process_id, render_view_id,
237 security_origin, label); 237 security_origin, label);
238 } 238 }
239 239
240 void MediaStreamManager::OpenDevice( 240 void MediaStreamManager::OpenDevice(
241 MediaStreamRequester* requester, 241 MediaStreamRequester* requester,
242 int render_process_id, 242 int render_process_id,
243 int render_view_id, 243 int render_view_id,
244 const std::string& device_id, 244 const std::string& device_id,
245 MediaStreamType type, 245 MediaStreamType type,
246 const std::string& security_origin, 246 const std::string& security_origin,
247 std::string* label) { 247 std::string* label) {
248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
249 249
250 // Create a new request. 250 // Create a new request.
251 StreamOptions options; 251 StreamOptions options;
252 if (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) 252 if (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
253 options.audio = true; 253 options.audio = true;
254 else 254 else
255 options.video_option = StreamOptions::kFacingUser; 255 options.video = true;
256 256
257 DeviceRequest new_request = DeviceRequest(requester, options); 257 DeviceRequest new_request = DeviceRequest(requester, options);
258 new_request.type = DeviceRequest::kOpenDevice; 258 new_request.type = DeviceRequest::kOpenDevice;
259 new_request.requested_device_id = device_id; 259 new_request.requested_device_id = device_id;
260 260
261 StartEnumeration(&new_request, render_process_id, render_view_id, 261 StartEnumeration(&new_request, render_process_id, render_view_id,
262 security_origin, label); 262 security_origin, label);
263 } 263 }
264 264
265 void MediaStreamManager::StartEnumeration( 265 void MediaStreamManager::StartEnumeration(
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) { 588 if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) {
589 return video_capture_manager(); 589 return video_capture_manager();
590 } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) { 590 } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) {
591 return audio_input_device_manager(); 591 return audio_input_device_manager();
592 } 592 }
593 NOTREACHED(); 593 NOTREACHED();
594 return NULL; 594 return NULL;
595 } 595 }
596 596
597 } // namespace media_stream 597 } // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698