| 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_video_capture_host.h" | 5 #include "content/renderer/pepper/pepper_video_capture_host.h" |
| 6 | 6 |
| 7 #include "ppapi/host/dispatch_host_message.h" | 7 #include "ppapi/host/dispatch_host_message.h" |
| 8 #include "ppapi/host/ppapi_host.h" | 8 #include "ppapi/host/ppapi_host.h" |
| 9 #include "ppapi/proxy/host_dispatcher.h" | 9 #include "ppapi/proxy/host_dispatcher.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (instance) | 244 if (instance) |
| 245 return instance->delegate(); | 245 return instance->delegate(); |
| 246 return NULL; | 246 return NULL; |
| 247 } | 247 } |
| 248 | 248 |
| 249 int32_t PepperVideoCaptureHost::OnOpen( | 249 int32_t PepperVideoCaptureHost::OnOpen( |
| 250 ppapi::host::HostMessageContext* context, | 250 ppapi::host::HostMessageContext* context, |
| 251 const std::string& device_id, | 251 const std::string& device_id, |
| 252 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 252 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 253 uint32_t buffer_count) { | 253 uint32_t buffer_count) { |
| 254 if (platform_video_capture_.get()) | 254 if (platform_video_capture_) |
| 255 return PP_ERROR_FAILED; | 255 return PP_ERROR_FAILED; |
| 256 | 256 |
| 257 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); | 257 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); |
| 258 if (!plugin_delegate) | 258 if (!plugin_delegate) |
| 259 return PP_ERROR_FAILED; | 259 return PP_ERROR_FAILED; |
| 260 | 260 |
| 261 SetRequestedInfo(requested_info, buffer_count); | 261 SetRequestedInfo(requested_info, buffer_count); |
| 262 | 262 |
| 263 platform_video_capture_ = | 263 platform_video_capture_ = |
| 264 plugin_delegate->CreateVideoCapture(device_id, this); | 264 plugin_delegate->CreateVideoCapture(device_id, this); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 DCHECK(platform_video_capture_.get()); | 316 DCHECK(platform_video_capture_.get()); |
| 317 | 317 |
| 318 ReleaseBuffers(); | 318 ReleaseBuffers(); |
| 319 // It's safe to call this regardless it's capturing or not, because | 319 // It's safe to call this regardless it's capturing or not, because |
| 320 // PepperPlatformVideoCaptureImpl maintains the state. | 320 // PepperPlatformVideoCaptureImpl maintains the state. |
| 321 platform_video_capture_->StopCapture(this); | 321 platform_video_capture_->StopCapture(this); |
| 322 return PP_OK; | 322 return PP_OK; |
| 323 } | 323 } |
| 324 | 324 |
| 325 int32_t PepperVideoCaptureHost::Close() { | 325 int32_t PepperVideoCaptureHost::Close() { |
| 326 if (!platform_video_capture_.get()) | 326 if (!platform_video_capture_) |
| 327 return PP_OK; | 327 return PP_OK; |
| 328 | 328 |
| 329 StopCapture(); | 329 StopCapture(); |
| 330 DCHECK(buffers_.empty()); | 330 DCHECK(buffers_.empty()); |
| 331 DetachPlatformVideoCapture(); | 331 DetachPlatformVideoCapture(); |
| 332 return PP_OK; | 332 return PP_OK; |
| 333 } | 333 } |
| 334 | 334 |
| 335 void PepperVideoCaptureHost::ReleaseBuffers() { | 335 void PepperVideoCaptureHost::ReleaseBuffers() { |
| 336 ::ppapi::ResourceTracker* tracker = HostGlobals::Get()->GetResourceTracker(); | 336 ::ppapi::ResourceTracker* tracker = HostGlobals::Get()->GetResourceTracker(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 354 | 354 |
| 355 capability_.width = device_info.width; | 355 capability_.width = device_info.width; |
| 356 capability_.height = device_info.height; | 356 capability_.height = device_info.height; |
| 357 capability_.frame_rate = device_info.frames_per_second; | 357 capability_.frame_rate = device_info.frames_per_second; |
| 358 capability_.expected_capture_delay = 0; // Ignored. | 358 capability_.expected_capture_delay = 0; // Ignored. |
| 359 capability_.color = media::VideoCaptureCapability::kI420; | 359 capability_.color = media::VideoCaptureCapability::kI420; |
| 360 capability_.interlaced = false; // Ignored. | 360 capability_.interlaced = false; // Ignored. |
| 361 } | 361 } |
| 362 | 362 |
| 363 void PepperVideoCaptureHost::DetachPlatformVideoCapture() { | 363 void PepperVideoCaptureHost::DetachPlatformVideoCapture() { |
| 364 if (platform_video_capture_.get()) { | 364 if (platform_video_capture_) { |
| 365 platform_video_capture_->DetachEventHandler(); | 365 platform_video_capture_->DetachEventHandler(); |
| 366 platform_video_capture_ = NULL; | 366 platform_video_capture_ = NULL; |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 | 369 |
| 370 bool PepperVideoCaptureHost::SetStatus(PP_VideoCaptureStatus_Dev status, | 370 bool PepperVideoCaptureHost::SetStatus(PP_VideoCaptureStatus_Dev status, |
| 371 bool forced) { | 371 bool forced) { |
| 372 if (!forced) { | 372 if (!forced) { |
| 373 switch (status) { | 373 switch (status) { |
| 374 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | 374 case PP_VIDEO_CAPTURE_STATUS_STOPPED: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 PepperVideoCaptureHost::BufferInfo::BufferInfo() | 417 PepperVideoCaptureHost::BufferInfo::BufferInfo() |
| 418 : in_use(false), | 418 : in_use(false), |
| 419 data(NULL), | 419 data(NULL), |
| 420 buffer() { | 420 buffer() { |
| 421 } | 421 } |
| 422 | 422 |
| 423 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { | 423 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace content | 426 } // namespace content |
| OLD | NEW |