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/renderer/pepper/pepper_platform_video_capture.h" | 5 #include "content/renderer/pepper/pepper_platform_video_capture.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "content/renderer/media/video_capture_impl_manager.h" | 10 #include "content/renderer/media/video_capture_impl_manager.h" |
11 #include "content/renderer/pepper/pepper_media_device_manager.h" | 11 #include "content/renderer/pepper/pepper_media_device_manager.h" |
12 #include "content/renderer/pepper/pepper_video_capture_host.h" | 12 #include "content/renderer/pepper/pepper_video_capture_host.h" |
13 #include "content/renderer/render_frame_impl.h" | 13 #include "content/renderer/render_frame_impl.h" |
14 #include "content/renderer/render_thread_impl.h" | 14 #include "content/renderer/render_thread_impl.h" |
15 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
16 #include "media/base/video_frame.h" | 16 #include "media/base/video_frame.h" |
17 #include "url/gurl.h" | |
18 | 17 |
19 namespace content { | 18 namespace content { |
20 | 19 |
21 PepperPlatformVideoCapture::PepperPlatformVideoCapture( | 20 PepperPlatformVideoCapture::PepperPlatformVideoCapture( |
22 int render_frame_id, | 21 int render_frame_id, |
23 const std::string& device_id, | 22 const std::string& device_id, |
24 const GURL& document_url, | |
25 PepperVideoCaptureHost* handler) | 23 PepperVideoCaptureHost* handler) |
26 : render_frame_id_(render_frame_id), | 24 : render_frame_id_(render_frame_id), |
27 device_id_(device_id), | 25 device_id_(device_id), |
28 session_id_(0), | 26 session_id_(0), |
29 handler_(handler), | 27 handler_(handler), |
30 pending_open_device_(false), | 28 pending_open_device_(false), |
31 pending_open_device_id_(-1), | 29 pending_open_device_id_(-1), |
32 weak_factory_(this) { | 30 weak_factory_(this) { |
33 // We need to open the device and obtain the label and session ID before | 31 // We need to open the device and obtain the label and session ID before |
34 // initializing. | 32 // initializing. |
35 PepperMediaDeviceManager* const device_manager = GetMediaDeviceManager(); | 33 PepperMediaDeviceManager* const device_manager = GetMediaDeviceManager(); |
36 if (device_manager) { | 34 if (device_manager) { |
37 pending_open_device_id_ = device_manager->OpenDevice( | 35 pending_open_device_id_ = device_manager->OpenDevice( |
38 PP_DEVICETYPE_DEV_VIDEOCAPTURE, | 36 PP_DEVICETYPE_DEV_VIDEOCAPTURE, device_id, handler->pp_instance(), |
39 device_id, | |
40 document_url, | |
41 base::Bind(&PepperPlatformVideoCapture::OnDeviceOpened, | 37 base::Bind(&PepperPlatformVideoCapture::OnDeviceOpened, |
42 weak_factory_.GetWeakPtr())); | 38 weak_factory_.GetWeakPtr())); |
43 pending_open_device_ = true; | 39 pending_open_device_ = true; |
44 } | 40 } |
45 } | 41 } |
46 | 42 |
47 void PepperPlatformVideoCapture::StartCapture( | 43 void PepperPlatformVideoCapture::StartCapture( |
48 const media::VideoCaptureParams& params) { | 44 const media::VideoCaptureParams& params) { |
49 DCHECK(thread_checker_.CalledOnValidThread()); | 45 DCHECK(thread_checker_.CalledOnValidThread()); |
50 if (!stop_capture_cb_.is_null()) | 46 if (!stop_capture_cb_.is_null()) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 145 } |
150 | 146 |
151 PepperMediaDeviceManager* PepperPlatformVideoCapture::GetMediaDeviceManager() { | 147 PepperMediaDeviceManager* PepperPlatformVideoCapture::GetMediaDeviceManager() { |
152 RenderFrameImpl* const render_frame = | 148 RenderFrameImpl* const render_frame = |
153 RenderFrameImpl::FromRoutingID(render_frame_id_); | 149 RenderFrameImpl::FromRoutingID(render_frame_id_); |
154 return render_frame ? | 150 return render_frame ? |
155 PepperMediaDeviceManager::GetForRenderFrame(render_frame).get() : NULL; | 151 PepperMediaDeviceManager::GetForRenderFrame(render_frame).get() : NULL; |
156 } | 152 } |
157 | 153 |
158 } // namespace content | 154 } // namespace content |
OLD | NEW |