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_impl.h" | 5 #include "content/renderer/pepper/pepper_platform_video_capture_impl.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/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/renderer/media/video_capture_impl_manager.h" | 10 #include "content/renderer/media/video_capture_impl_manager.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // We need to open the device and obtain the label and session ID before | 35 // We need to open the device and obtain the label and session ID before |
36 // initializing. | 36 // initializing. |
37 if (plugin_delegate_) { | 37 if (plugin_delegate_) { |
38 plugin_delegate_->OpenDevice( | 38 plugin_delegate_->OpenDevice( |
39 PP_DEVICETYPE_DEV_VIDEOCAPTURE, device_id, | 39 PP_DEVICETYPE_DEV_VIDEOCAPTURE, device_id, |
40 base::Bind(&PepperPlatformVideoCaptureImpl::OnDeviceOpened, this)); | 40 base::Bind(&PepperPlatformVideoCaptureImpl::OnDeviceOpened, this)); |
41 } | 41 } |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 PepperPlatformVideoCaptureImpl::~PepperPlatformVideoCaptureImpl() { | |
46 if (video_capture_) { | |
47 VideoCaptureImplManager* manager = | |
48 RenderThreadImpl::current()->video_capture_impl_manager(); | |
49 manager->RemoveDevice(session_id_, handler_proxy_.get()); | |
50 } | |
51 | |
52 if (plugin_delegate_ && !label_.empty()) | |
53 plugin_delegate_->CloseDevice(label_); | |
54 } | |
55 | |
56 void PepperPlatformVideoCaptureImpl::StartCapture( | 45 void PepperPlatformVideoCaptureImpl::StartCapture( |
57 media::VideoCapture::EventHandler* handler, | 46 media::VideoCapture::EventHandler* handler, |
58 const media::VideoCaptureCapability& capability) { | 47 const media::VideoCaptureCapability& capability) { |
59 DCHECK(handler == handler_); | 48 DCHECK(handler == handler_); |
60 | 49 |
61 if (unbalanced_start_) | 50 if (unbalanced_start_) |
62 return; | 51 return; |
63 | 52 |
64 if (video_capture_) { | 53 if (video_capture_) { |
65 unbalanced_start_ = true; | 54 unbalanced_start_ = true; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 137 } |
149 } | 138 } |
150 | 139 |
151 void PepperPlatformVideoCaptureImpl::OnDeviceInfoReceived( | 140 void PepperPlatformVideoCaptureImpl::OnDeviceInfoReceived( |
152 VideoCapture* capture, | 141 VideoCapture* capture, |
153 const media::VideoCaptureParams& device_info) { | 142 const media::VideoCaptureParams& device_info) { |
154 if (handler_) | 143 if (handler_) |
155 handler_->OnDeviceInfoReceived(capture, device_info); | 144 handler_->OnDeviceInfoReceived(capture, device_info); |
156 } | 145 } |
157 | 146 |
| 147 PepperPlatformVideoCaptureImpl::~PepperPlatformVideoCaptureImpl() { |
| 148 if (video_capture_) { |
| 149 VideoCaptureImplManager* manager = |
| 150 RenderThreadImpl::current()->video_capture_impl_manager(); |
| 151 manager->RemoveDevice(session_id_, handler_proxy_.get()); |
| 152 } |
| 153 |
| 154 if (plugin_delegate_ && !label_.empty()) |
| 155 plugin_delegate_->CloseDevice(label_); |
| 156 } |
| 157 |
158 void PepperPlatformVideoCaptureImpl::Initialize() { | 158 void PepperPlatformVideoCaptureImpl::Initialize() { |
159 VideoCaptureImplManager* manager = | 159 VideoCaptureImplManager* manager = |
160 RenderThreadImpl::current()->video_capture_impl_manager(); | 160 RenderThreadImpl::current()->video_capture_impl_manager(); |
161 video_capture_ = manager->AddDevice(session_id_, handler_proxy_.get()); | 161 video_capture_ = manager->AddDevice(session_id_, handler_proxy_.get()); |
162 } | 162 } |
163 | 163 |
164 void PepperPlatformVideoCaptureImpl::OnDeviceOpened(int request_id, | 164 void PepperPlatformVideoCaptureImpl::OnDeviceOpened(int request_id, |
165 bool succeeded, | 165 bool succeeded, |
166 const std::string& label) { | 166 const std::string& label) { |
167 succeeded = succeeded && plugin_delegate_; | 167 succeeded = succeeded && plugin_delegate_; |
168 if (succeeded) { | 168 if (succeeded) { |
169 label_ = label; | 169 label_ = label; |
170 session_id_ = plugin_delegate_->GetSessionID(PP_DEVICETYPE_DEV_VIDEOCAPTURE, | 170 session_id_ = plugin_delegate_->GetSessionID(PP_DEVICETYPE_DEV_VIDEOCAPTURE, |
171 label); | 171 label); |
172 Initialize(); | 172 Initialize(); |
173 } | 173 } |
174 | 174 |
175 if (handler_) | 175 if (handler_) |
176 handler_->OnInitialized(this, succeeded); | 176 handler_->OnInitialized(this, succeeded); |
177 } | 177 } |
178 | 178 |
179 } // namespace content | 179 } // namespace content |
OLD | NEW |