Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 // is asked for permission and device selection. | 251 // is asked for permission and device selection. |
| 252 void CreateUIRequest(const std::string& requested_audio_device_id, | 252 void CreateUIRequest(const std::string& requested_audio_device_id, |
| 253 const std::string& requested_video_device_id) { | 253 const std::string& requested_video_device_id) { |
| 254 DCHECK(!ui_request_); | 254 DCHECK(!ui_request_); |
| 255 target_process_id_ = requesting_process_id; | 255 target_process_id_ = requesting_process_id; |
| 256 target_frame_id_ = requesting_frame_id; | 256 target_frame_id_ = requesting_frame_id; |
| 257 ui_request_.reset(new MediaStreamRequest( | 257 ui_request_.reset(new MediaStreamRequest( |
| 258 requesting_process_id, requesting_frame_id, page_request_id, | 258 requesting_process_id, requesting_frame_id, page_request_id, |
| 259 ConvertToGURL(security_origin), user_gesture, request_type, | 259 ConvertToGURL(security_origin), user_gesture, request_type, |
| 260 requested_audio_device_id, requested_video_device_id, audio_type_, | 260 requested_audio_device_id, requested_video_device_id, audio_type_, |
| 261 video_type_)); | 261 video_type_, mute_source)); |
|
miu
2016/09/07 21:10:03
Seems like the extra bool argument is not needed,
qiangchen
2016/09/09 18:45:24
We need it. Because at this point, the device_id i
| |
| 262 } | 262 } |
| 263 | 263 |
| 264 // Creates a tab capture specific MediaStreamRequest object that is used by | 264 // Creates a tab capture specific MediaStreamRequest object that is used by |
| 265 // this request when UI is asked for permission and device selection. | 265 // this request when UI is asked for permission and device selection. |
| 266 void CreateTabCaptureUIRequest(int target_render_process_id, | 266 void CreateTabCaptureUIRequest(int target_render_process_id, |
| 267 int target_render_frame_id) { | 267 int target_render_frame_id) { |
| 268 DCHECK(!ui_request_); | 268 DCHECK(!ui_request_); |
| 269 target_process_id_ = target_render_process_id; | 269 target_process_id_ = target_render_process_id; |
| 270 target_frame_id_ = target_render_frame_id; | 270 target_frame_id_ = target_render_frame_id; |
| 271 ui_request_.reset(new MediaStreamRequest( | 271 ui_request_.reset(new MediaStreamRequest( |
| 272 target_render_process_id, target_render_frame_id, page_request_id, | 272 target_render_process_id, target_render_frame_id, page_request_id, |
| 273 ConvertToGURL(security_origin), user_gesture, request_type, "", "", | 273 ConvertToGURL(security_origin), user_gesture, request_type, "", "", |
| 274 audio_type_, video_type_)); | 274 audio_type_, video_type_, mute_source)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool HasUIRequest() const { return ui_request_.get() != nullptr; } | 277 bool HasUIRequest() const { return ui_request_.get() != nullptr; } |
| 278 std::unique_ptr<MediaStreamRequest> DetachUIRequest() { | 278 std::unique_ptr<MediaStreamRequest> DetachUIRequest() { |
| 279 return std::move(ui_request_); | 279 return std::move(ui_request_); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Update the request state and notify observers. | 282 // Update the request state and notify observers. |
| 283 void SetState(MediaStreamType stream_type, MediaRequestState new_state) { | 283 void SetState(MediaStreamType stream_type, MediaRequestState new_state) { |
| 284 if (stream_type == NUM_MEDIA_TYPES) { | 284 if (stream_type == NUM_MEDIA_TYPES) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 | 347 |
| 348 // Callback to the requester which audio/video devices have been selected. | 348 // Callback to the requester which audio/video devices have been selected. |
| 349 // It can be null if the requester has no interest to know the result. | 349 // It can be null if the requester has no interest to know the result. |
| 350 // Currently it is only used by |DEVICE_ACCESS| type. | 350 // Currently it is only used by |DEVICE_ACCESS| type. |
| 351 MediaStreamManager::MediaRequestResponseCallback callback; | 351 MediaStreamManager::MediaRequestResponseCallback callback; |
| 352 | 352 |
| 353 std::unique_ptr<MediaStreamUIProxy> ui_proxy; | 353 std::unique_ptr<MediaStreamUIProxy> ui_proxy; |
| 354 | 354 |
| 355 std::string tab_capture_device_id; | 355 std::string tab_capture_device_id; |
| 356 | 356 |
| 357 bool mute_source; | |
| 358 | |
| 357 private: | 359 private: |
| 358 std::vector<MediaRequestState> state_; | 360 std::vector<MediaRequestState> state_; |
| 359 std::unique_ptr<MediaStreamRequest> ui_request_; | 361 std::unique_ptr<MediaStreamRequest> ui_request_; |
| 360 MediaStreamType audio_type_; | 362 MediaStreamType audio_type_; |
| 361 MediaStreamType video_type_; | 363 MediaStreamType video_type_; |
| 362 int target_process_id_; | 364 int target_process_id_; |
| 363 int target_frame_id_; | 365 int target_frame_id_; |
| 364 }; | 366 }; |
| 365 | 367 |
| 366 MediaStreamManager::EnumerationCache::EnumerationCache() | 368 MediaStreamManager::EnumerationCache::EnumerationCache() |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 | 1313 |
| 1312 bool has_valid_device_id = WebContentsMediaCaptureId::ExtractTabCaptureTarget( | 1314 bool has_valid_device_id = WebContentsMediaCaptureId::ExtractTabCaptureTarget( |
| 1313 capture_device_id, &target_render_process_id, &target_render_frame_id); | 1315 capture_device_id, &target_render_process_id, &target_render_frame_id); |
| 1314 if (!has_valid_device_id || | 1316 if (!has_valid_device_id || |
| 1315 (request->audio_type() != MEDIA_TAB_AUDIO_CAPTURE && | 1317 (request->audio_type() != MEDIA_TAB_AUDIO_CAPTURE && |
| 1316 request->audio_type() != MEDIA_NO_SERVICE) || | 1318 request->audio_type() != MEDIA_NO_SERVICE) || |
| 1317 (request->video_type() != MEDIA_TAB_VIDEO_CAPTURE && | 1319 (request->video_type() != MEDIA_TAB_VIDEO_CAPTURE && |
| 1318 request->video_type() != MEDIA_NO_SERVICE)) { | 1320 request->video_type() != MEDIA_NO_SERVICE)) { |
| 1319 return false; | 1321 return false; |
| 1320 } | 1322 } |
| 1321 request->tab_capture_device_id = capture_device_id; | 1323 // TODO(qiangchen): Plug in constraint value here for tabCapture. |
| 1324 request->mute_source = request->controls.mute_source_audio; | |
| 1325 | |
| 1326 content::WebContentsMediaCaptureId web_id = | |
| 1327 content::WebContentsMediaCaptureId::Parse(capture_device_id); | |
| 1328 web_id.mute_source = request->mute_source; | |
| 1329 request->tab_capture_device_id = web_id.ToString(); | |
| 1322 | 1330 |
| 1323 request->CreateTabCaptureUIRequest(target_render_process_id, | 1331 request->CreateTabCaptureUIRequest(target_render_process_id, |
| 1324 target_render_frame_id); | 1332 target_render_frame_id); |
| 1325 | 1333 |
| 1326 DVLOG(3) << "SetupTabCaptureRequest " | 1334 DVLOG(3) << "SetupTabCaptureRequest " |
| 1327 << ", {capture_device_id = " << capture_device_id << "}" | 1335 << ", {capture_device_id = " << capture_device_id << "}" |
| 1328 << ", {target_render_process_id = " << target_render_process_id | 1336 << ", {target_render_process_id = " << target_render_process_id |
| 1329 << "}" | 1337 << "}" |
| 1330 << ", {target_render_frame_id = " << target_render_frame_id << "}"; | 1338 << ", {target_render_frame_id = " << target_render_frame_id << "}"; |
| 1331 return true; | 1339 return true; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1347 | 1355 |
| 1348 std::string video_device_id; | 1356 std::string video_device_id; |
| 1349 if (request->video_type() == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 1357 if (request->video_type() == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
| 1350 const std::string& video_stream_source = | 1358 const std::string& video_stream_source = |
| 1351 request->controls.video.stream_source; | 1359 request->controls.video.stream_source; |
| 1352 | 1360 |
| 1353 if (video_stream_source == kMediaStreamSourceDesktop && | 1361 if (video_stream_source == kMediaStreamSourceDesktop && |
| 1354 !request->controls.video.device_ids.empty()) { | 1362 !request->controls.video.device_ids.empty()) { |
| 1355 video_device_id = request->controls.video.device_ids[0]; | 1363 video_device_id = request->controls.video.device_ids[0]; |
| 1356 } | 1364 } |
| 1365 request->mute_source = request->controls.mute_source_audio; | |
| 1357 } | 1366 } |
| 1358 | 1367 |
| 1359 const std::string audio_device_id = | 1368 const std::string audio_device_id = |
| 1360 request->audio_type() == MEDIA_DESKTOP_AUDIO_CAPTURE ? video_device_id | 1369 request->audio_type() == MEDIA_DESKTOP_AUDIO_CAPTURE ? video_device_id |
| 1361 : ""; | 1370 : ""; |
| 1362 | 1371 |
| 1363 request->CreateUIRequest(audio_device_id, video_device_id); | 1372 request->CreateUIRequest(audio_device_id, video_device_id); |
| 1364 return true; | 1373 return true; |
| 1365 } | 1374 } |
| 1366 | 1375 |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2181 if (device_info.session_id == session_id && | 2190 if (device_info.session_id == session_id && |
| 2182 device_info.device.type == type) { | 2191 device_info.device.type == type) { |
| 2183 request->SetCapturingLinkSecured(is_secure); | 2192 request->SetCapturingLinkSecured(is_secure); |
| 2184 return; | 2193 return; |
| 2185 } | 2194 } |
| 2186 } | 2195 } |
| 2187 } | 2196 } |
| 2188 } | 2197 } |
| 2189 | 2198 |
| 2190 } // namespace content | 2199 } // namespace content |
| OLD | NEW |