OLD | NEW |
---|---|
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 | 102 |
103 if (options.video_type != MEDIA_TAB_VIDEO_CAPTURE && | 103 if (options.video_type != MEDIA_TAB_VIDEO_CAPTURE && |
104 options.audio_type != MEDIA_TAB_AUDIO_CAPTURE) | 104 options.audio_type != MEDIA_TAB_AUDIO_CAPTURE) |
105 return; | 105 return; |
106 | 106 |
107 MediaObserver* media_observer = | 107 MediaObserver* media_observer = |
108 GetContentClient()->browser()->GetMediaObserver(); | 108 GetContentClient()->browser()->GetMediaObserver(); |
109 if (media_observer == NULL) | 109 if (media_observer == NULL) |
110 return; | 110 return; |
111 | 111 |
112 // We expect the device_id without the device_id scheme in chrome/. | |
Alpha Left Google
2012/11/28 01:04:47
What does this mean?
justinlin
2012/11/28 14:30:31
Clarified the comment.
| |
113 std::string device_id = | |
114 WebContentsCaptureUtil::StripWebContentsDeviceScheme( | |
115 requested_device_id); | |
116 | |
112 media_observer->OnMediaRequestStateChanged( | 117 media_observer->OnMediaRequestStateChanged( |
113 render_process_id, render_view_id, | 118 render_process_id, render_view_id, |
114 MediaStreamDevice( | 119 MediaStreamDevice( |
115 stream_type, requested_device_id, requested_device_id), new_state); | 120 stream_type, device_id, device_id), new_state); |
116 } | 121 } |
117 | 122 |
118 MediaRequestState getState(MediaStreamType stream_type) const { | 123 MediaRequestState getState(MediaStreamType stream_type) const { |
119 return state_[stream_type]; | 124 return state_[stream_type]; |
120 } | 125 } |
121 | 126 |
122 MediaStreamRequester* requester; // Can be NULL. | 127 MediaStreamRequester* requester; // Can be NULL. |
123 StreamOptions options; | 128 StreamOptions options; |
124 RequestType type; | 129 RequestType type; |
125 int render_process_id; | 130 int render_process_id; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 // this currently exists. Also, we don't have a user-friendly device name for | 273 // this currently exists. Also, we don't have a user-friendly device name for |
269 // the infobar UI. | 274 // the infobar UI. |
270 if (IsAudioMediaType(options.audio_type)) { | 275 if (IsAudioMediaType(options.audio_type)) { |
271 // TODO(justinlin): Updating the state to requested and pending are no-ops | 276 // 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 | 277 // 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). | 278 // support in terms of extensions (which is registered as an observer). |
274 request.setState(options.audio_type, MEDIA_REQUEST_STATE_REQUESTED); | 279 request.setState(options.audio_type, MEDIA_REQUEST_STATE_REQUESTED); |
275 request.setState(options.audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 280 request.setState(options.audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
276 ui_controller_->AddAvailableDevicesToRequest( | 281 ui_controller_->AddAvailableDevicesToRequest( |
277 *label, options.audio_type, StreamDeviceInfoArray( | 282 *label, options.audio_type, StreamDeviceInfoArray( |
278 1, StreamDeviceInfo(options.audio_type, device_id, device_id, | 283 1, StreamDeviceInfo(options.audio_type, |
Alpha Left Google
2012/11/28 01:04:47
No need to change this line isn't it?
justinlin
2012/11/28 14:30:31
Done.
| |
284 device_id, | |
285 device_id, | |
279 false))); | 286 false))); |
280 } | 287 } |
281 if (IsVideoMediaType(options.video_type)) { | 288 if (IsVideoMediaType(options.video_type)) { |
282 request.setState(options.video_type, MEDIA_REQUEST_STATE_REQUESTED); | 289 request.setState(options.video_type, MEDIA_REQUEST_STATE_REQUESTED); |
283 request.setState(options.video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 290 request.setState(options.video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
284 ui_controller_->AddAvailableDevicesToRequest( | 291 ui_controller_->AddAvailableDevicesToRequest( |
285 *label, options.video_type, StreamDeviceInfoArray( | 292 *label, options.video_type, StreamDeviceInfoArray( |
286 1, StreamDeviceInfo(options.video_type, device_id, device_id, | 293 1, StreamDeviceInfo(options.video_type, |
Alpha Left Google
2012/11/28 01:04:47
Same for this line.
justinlin
2012/11/28 14:30:31
Done.
| |
294 device_id, | |
295 device_id, | |
287 false))); | 296 false))); |
288 } | 297 } |
289 } | 298 } |
290 | 299 |
291 void MediaStreamManager::CancelRequest(const std::string& label) { | 300 void MediaStreamManager::CancelRequest(const std::string& label) { |
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
293 | 302 |
294 DeviceRequests::iterator it = requests_.find(label); | 303 DeviceRequests::iterator it = requests_.find(label); |
295 if (it != requests_.end()) { | 304 if (it != requests_.end()) { |
296 // The request isn't complete, notify the UI immediately. | 305 // The request isn't complete, notify the UI immediately. |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 } | 1059 } |
1051 | 1060 |
1052 // Always do enumeration even though some enumeration is in progress, | 1061 // Always do enumeration even though some enumeration is in progress, |
1053 // because those enumeration commands could be sent before these devices | 1062 // because those enumeration commands could be sent before these devices |
1054 // change. | 1063 // change. |
1055 ++active_enumeration_ref_count_[stream_type]; | 1064 ++active_enumeration_ref_count_[stream_type]; |
1056 GetDeviceManager(stream_type)->EnumerateDevices(); | 1065 GetDeviceManager(stream_type)->EnumerateDevices(); |
1057 } | 1066 } |
1058 | 1067 |
1059 } // namespace content | 1068 } // namespace content |
OLD | NEW |