| 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 "content/renderer/pepper/host_globals.h" | 7 #include "content/renderer/pepper/host_globals.h" |
| 8 #include "content/renderer/pepper/pepper_media_device_manager.h" | 8 #include "content/renderer/pepper/pepper_media_device_manager.h" |
| 9 #include "content/renderer/pepper/pepper_platform_video_capture.h" | 9 #include "content/renderer/pepper/pepper_platform_video_capture.h" |
| 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 buffers_[i].in_use = true; | 160 buffers_[i].in_use = true; |
| 161 host()->SendUnsolicitedReply(pp_resource(), | 161 host()->SendUnsolicitedReply(pp_resource(), |
| 162 PpapiPluginMsg_VideoCapture_OnBufferReady(i)); | 162 PpapiPluginMsg_VideoCapture_OnBufferReady(i)); |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 void PepperVideoCaptureHost::OnDeviceInfoReceived( | 168 void PepperVideoCaptureHost::OnDeviceInfoReceived( |
| 169 media::VideoCapture* capture, | 169 media::VideoCapture* capture, |
| 170 const media::VideoCaptureParams& device_info) { | 170 const media::VideoCaptureFormat& device_info) { |
| 171 PP_VideoCaptureDeviceInfo_Dev info = { | 171 PP_VideoCaptureDeviceInfo_Dev info = { |
| 172 static_cast<uint32_t>(device_info.width), | 172 static_cast<uint32_t>(device_info.width), |
| 173 static_cast<uint32_t>(device_info.height), | 173 static_cast<uint32_t>(device_info.height), |
| 174 static_cast<uint32_t>(device_info.frame_rate) | 174 static_cast<uint32_t>(device_info.frame_rate) |
| 175 }; | 175 }; |
| 176 ReleaseBuffers(); | 176 ReleaseBuffers(); |
| 177 | 177 |
| 178 const size_t size = media::VideoFrame::AllocationSize( | 178 const size_t size = media::VideoFrame::AllocationSize( |
| 179 media::VideoFrame::I420, gfx::Size(info.width, info.height)); | 179 media::VideoFrame::I420, gfx::Size(info.width, info.height)); |
| 180 | 180 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 int32_t PepperVideoCaptureHost::OnStartCapture( | 285 int32_t PepperVideoCaptureHost::OnStartCapture( |
| 286 ppapi::host::HostMessageContext* context) { | 286 ppapi::host::HostMessageContext* context) { |
| 287 if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTING, false) || | 287 if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTING, false) || |
| 288 !platform_video_capture_.get()) | 288 !platform_video_capture_.get()) |
| 289 return PP_ERROR_FAILED; | 289 return PP_ERROR_FAILED; |
| 290 | 290 |
| 291 DCHECK(buffers_.empty()); | 291 DCHECK(buffers_.empty()); |
| 292 | 292 |
| 293 // It's safe to call this regardless it's capturing or not, because | 293 // It's safe to call this regardless it's capturing or not, because |
| 294 // PepperPlatformVideoCapture maintains the state. | 294 // PepperPlatformVideoCapture maintains the state. |
| 295 platform_video_capture_->StartCapture(this, capability_); | 295 platform_video_capture_->StartCapture(this, param_request_); |
| 296 return PP_OK; | 296 return PP_OK; |
| 297 } | 297 } |
| 298 | 298 |
| 299 int32_t PepperVideoCaptureHost::OnReuseBuffer( | 299 int32_t PepperVideoCaptureHost::OnReuseBuffer( |
| 300 ppapi::host::HostMessageContext* context, | 300 ppapi::host::HostMessageContext* context, |
| 301 uint32_t buffer) { | 301 uint32_t buffer) { |
| 302 if (buffer >= buffers_.size() || !buffers_[buffer].in_use) | 302 if (buffer >= buffers_.size() || !buffers_[buffer].in_use) |
| 303 return PP_ERROR_BADARGUMENT; | 303 return PP_ERROR_BADARGUMENT; |
| 304 buffers_[buffer].in_use = false; | 304 buffers_[buffer].in_use = false; |
| 305 return PP_OK; | 305 return PP_OK; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 host()->SendUnsolicitedReply(pp_resource(), | 351 host()->SendUnsolicitedReply(pp_resource(), |
| 352 PpapiPluginMsg_VideoCapture_OnStatus(status_)); | 352 PpapiPluginMsg_VideoCapture_OnStatus(status_)); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void PepperVideoCaptureHost::SetRequestedInfo( | 355 void PepperVideoCaptureHost::SetRequestedInfo( |
| 356 const PP_VideoCaptureDeviceInfo_Dev& device_info, | 356 const PP_VideoCaptureDeviceInfo_Dev& device_info, |
| 357 uint32_t buffer_count) { | 357 uint32_t buffer_count) { |
| 358 // Clamp the buffer count to between 1 and |kMaxBuffers|. | 358 // Clamp the buffer count to between 1 and |kMaxBuffers|. |
| 359 buffer_count_hint_ = std::min(std::max(buffer_count, 1U), kMaxBuffers); | 359 buffer_count_hint_ = std::min(std::max(buffer_count, 1U), kMaxBuffers); |
| 360 | 360 |
| 361 capability_.width = device_info.width; | 361 param_request_.width = device_info.width; |
| 362 capability_.height = device_info.height; | 362 param_request_.height = device_info.height; |
| 363 capability_.frame_rate = device_info.frames_per_second; | 363 param_request_.frame_rate = device_info.frames_per_second; |
| 364 capability_.expected_capture_delay = 0; // Ignored. | |
| 365 capability_.color = media::PIXEL_FORMAT_I420; | |
| 366 capability_.interlaced = false; // Ignored. | |
| 367 } | 364 } |
| 368 | 365 |
| 369 void PepperVideoCaptureHost::DetachPlatformVideoCapture() { | 366 void PepperVideoCaptureHost::DetachPlatformVideoCapture() { |
| 370 if (platform_video_capture_.get()) { | 367 if (platform_video_capture_.get()) { |
| 371 platform_video_capture_->DetachEventHandler(); | 368 platform_video_capture_->DetachEventHandler(); |
| 372 platform_video_capture_ = NULL; | 369 platform_video_capture_ = NULL; |
| 373 } | 370 } |
| 374 } | 371 } |
| 375 | 372 |
| 376 bool PepperVideoCaptureHost::SetStatus(PP_VideoCaptureStatus_Dev status, | 373 bool PepperVideoCaptureHost::SetStatus(PP_VideoCaptureStatus_Dev status, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 PepperVideoCaptureHost::BufferInfo::BufferInfo() | 420 PepperVideoCaptureHost::BufferInfo::BufferInfo() |
| 424 : in_use(false), | 421 : in_use(false), |
| 425 data(NULL), | 422 data(NULL), |
| 426 buffer() { | 423 buffer() { |
| 427 } | 424 } |
| 428 | 425 |
| 429 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { | 426 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { |
| 430 } | 427 } |
| 431 | 428 |
| 432 } // namespace content | 429 } // namespace content |
| OLD | NEW |