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/video_capture_manager.h" | 5 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "content/browser/media/media_internals.h" | 27 #include "content/browser/media/media_internals.h" |
| 28 #include "content/browser/renderer_host/media/video_capture_controller.h" | 28 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 29 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" | 29 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" |
| 30 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" | 30 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" |
| 31 #include "content/browser/renderer_host/media/video_frame_receiver_on_io_thread. h" | 31 #include "content/browser/renderer_host/media/video_frame_receiver_on_io_thread. h" |
| 32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/desktop_media_id.h" | 33 #include "content/public/browser/desktop_media_id.h" |
| 34 #include "content/public/common/media_stream_request.h" | 34 #include "content/public/common/media_stream_request.h" |
| 35 #include "media/base/bind_to_current_loop.h" | 35 #include "media/base/bind_to_current_loop.h" |
| 36 #include "media/base/media_switches.h" | 36 #include "media/base/media_switches.h" |
| 37 #include "media/base/video_facing.h" | |
| 37 #include "media/capture/video/video_capture_buffer_pool_impl.h" | 38 #include "media/capture/video/video_capture_buffer_pool_impl.h" |
| 38 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" | 39 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" |
| 39 #include "media/capture/video/video_capture_device.h" | 40 #include "media/capture/video/video_capture_device.h" |
| 40 #include "media/capture/video/video_capture_device_client.h" | 41 #include "media/capture/video/video_capture_device_client.h" |
| 41 #include "media/capture/video/video_capture_device_factory.h" | 42 #include "media/capture/video/video_capture_device_factory.h" |
| 42 | 43 |
| 43 #if defined(ENABLE_SCREEN_CAPTURE) | 44 #if defined(ENABLE_SCREEN_CAPTURE) |
| 44 | 45 |
| 45 #if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_ANDROID) | 46 #if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_ANDROID) |
| 46 #include "content/browser/media/capture/desktop_capture_device.h" | 47 #include "content/browser/media/capture/desktop_capture_device.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 int serial_id, | 329 int serial_id, |
| 329 media::VideoCaptureSessionId session_id, | 330 media::VideoCaptureSessionId session_id, |
| 330 const media::VideoCaptureParams& params) | 331 const media::VideoCaptureParams& params) |
| 331 : serial_id_(serial_id), | 332 : serial_id_(serial_id), |
| 332 session_id_(session_id), | 333 session_id_(session_id), |
| 333 params_(params), | 334 params_(params), |
| 334 abort_start_(false) { | 335 abort_start_(false) { |
| 335 } | 336 } |
| 336 | 337 |
| 337 VideoCaptureManager::VideoCaptureManager( | 338 VideoCaptureManager::VideoCaptureManager( |
| 338 std::unique_ptr<media::VideoCaptureDeviceFactory> factory) | 339 std::unique_ptr<media::VideoCaptureDeviceFactory> factory, |
| 340 component::VideoCaptureOberser observer) | |
| 339 : listener_(nullptr), | 341 : listener_(nullptr), |
| 340 new_capture_session_id_(1), | 342 new_capture_session_id_(1), |
| 341 video_capture_device_factory_(std::move(factory)) {} | 343 video_capture_device_factory_(std::move(factory)), |
| 344 capture_observer_(observer) {} | |
| 342 | 345 |
| 343 VideoCaptureManager::~VideoCaptureManager() { | 346 VideoCaptureManager::~VideoCaptureManager() { |
| 344 DCHECK(devices_.empty()); | 347 DCHECK(devices_.empty()); |
| 345 DCHECK(device_start_queue_.empty()); | 348 DCHECK(device_start_queue_.empty()); |
| 346 } | 349 } |
| 347 | 350 |
| 348 void VideoCaptureManager::Register( | 351 void VideoCaptureManager::Register( |
| 349 MediaStreamProviderListener* listener, | 352 MediaStreamProviderListener* listener, |
| 350 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { | 353 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { |
| 351 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 354 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 | 649 |
| 647 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 650 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
| 648 video_capture_device = | 651 video_capture_device = |
| 649 video_capture_device_factory_->CreateDevice(descriptor); | 652 video_capture_device_factory_->CreateDevice(descriptor); |
| 650 | 653 |
| 651 if (!video_capture_device) { | 654 if (!video_capture_device) { |
| 652 device_client->OnError(FROM_HERE, "Could not create capture device"); | 655 device_client->OnError(FROM_HERE, "Could not create capture device"); |
| 653 return nullptr; | 656 return nullptr; |
| 654 } | 657 } |
| 655 | 658 |
| 659 if (capture_observer_ != NULL) { | |
| 660 component::VideoFacingMode facing = | |
| 661 component::VideoFacingMode::NONE; | |
| 662 switch (descriptor.facing) { | |
| 663 case media::MEDIA_VIDEO_FACING_NONE: | |
| 664 case media::NUM_MEDIA_VIDEO_FACING_MODE: | |
| 665 facing = component::VideoFacingMode::NONE; | |
| 666 break; | |
| 667 case media::MEDIA_VIDEO_FACING_USER: | |
| 668 facing = component::VideoFacingMode::USER; | |
| 669 break; | |
| 670 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: | |
| 671 facing = component::VideoFacingMode::ENVIRONMENT; | |
| 672 break; | |
| 673 } | |
| 674 capture_observer_->OnVideoCaptureStarted(facing); | |
|
chfremer
2017/01/20 18:23:53
Where will we call OnVideoCaptureStopped()?
shenghao
2017/01/24 12:52:01
Oh I forgot to add it.
| |
| 675 } | |
| 676 | |
| 656 video_capture_device->AllocateAndStart(params, std::move(device_client)); | 677 video_capture_device->AllocateAndStart(params, std::move(device_client)); |
| 657 return video_capture_device; | 678 return video_capture_device; |
| 658 } | 679 } |
| 659 | 680 |
| 660 std::unique_ptr<media::VideoCaptureDevice> | 681 std::unique_ptr<media::VideoCaptureDevice> |
| 661 VideoCaptureManager::DoStartTabCaptureOnDeviceThread( | 682 VideoCaptureManager::DoStartTabCaptureOnDeviceThread( |
| 662 const std::string& id, | 683 const std::string& id, |
| 663 const media::VideoCaptureParams& params, | 684 const media::VideoCaptureParams& params, |
| 664 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 685 std::unique_ptr<VideoCaptureDevice::Client> device_client) { |
| 665 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 686 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1328 if (!device_in_queue) { | 1349 if (!device_in_queue) { |
| 1329 // Session ID is only valid for Screen capture. So we can fake it to | 1350 // Session ID is only valid for Screen capture. So we can fake it to |
| 1330 // resume video capture devices here. | 1351 // resume video capture devices here. |
| 1331 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1352 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); |
| 1332 } | 1353 } |
| 1333 } | 1354 } |
| 1334 } | 1355 } |
| 1335 #endif // defined(OS_ANDROID) | 1356 #endif // defined(OS_ANDROID) |
| 1336 | 1357 |
| 1337 } // namespace content | 1358 } // namespace content |
| OLD | NEW |