Index: content/renderer/pepper/pepper_video_capture_host.cc |
diff --git a/content/renderer/pepper/pepper_video_capture_host.cc b/content/renderer/pepper/pepper_video_capture_host.cc |
index 5813a722902d84fdc12041f2d26baa8c34d515ac..ec0c926d4a3a6483ffd9efc9201da2f4ff5a943c 100644 |
--- a/content/renderer/pepper/pepper_video_capture_host.cc |
+++ b/content/renderer/pepper/pepper_video_capture_host.cc |
@@ -129,29 +129,37 @@ void PepperVideoCaptureHost::OnError(media::VideoCapture* capture, |
void PepperVideoCaptureHost::OnRemoved(media::VideoCapture* capture) { |
} |
-void PepperVideoCaptureHost::OnBufferReady( |
+void PepperVideoCaptureHost::OnFrameReady( |
media::VideoCapture* capture, |
- scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) { |
- DCHECK(buffer.get()); |
+ const scoped_refptr<media::VideoFrame>& frame) { |
+ DCHECK(frame.get()); |
for (uint32_t i = 0; i < buffers_.size(); ++i) { |
if (!buffers_[i].in_use) { |
- // TODO(ihf): Switch to a size calculation based on stride. |
- // Stride is filled out now but not more meaningful than size |
- // until wjia unifies VideoFrameBuffer and media::VideoFrame. |
- size_t size = std::min(static_cast<size_t>(buffers_[i].buffer->size()), |
- buffer->buffer_size); |
- memcpy(buffers_[i].data, buffer->memory_pointer, size); |
+ DCHECK_EQ(frame->format(), media::VideoFrame::I420); |
+ if (static_cast<size_t>(buffers_[i].buffer->size() < |
miu
2013/09/12 03:01:58
Need to place the closing parenthesis of the stati
sheu
2013/09/12 18:47:43
Done.
|
+ media::VideoFrame::AllocationSize( |
+ frame->format(), frame->coded_size()))) { |
+ // TODO(ihf): handle size mismatches gracefully here. |
+ return; |
+ } |
+ uint8* dst = reinterpret_cast<uint8*>(buffers_[i].data); |
+ for (size_t j = 0; j < media::VideoFrame::NumPlanes(frame->format()); |
+ ++j) { |
ncarter (slow)
2013/09/11 18:04:56
This loop is correct, but it kind of opaquely reli
sheu
2013/09/11 19:28:10
I DCHECKED for I420 above, so this is safe for now
ncarter (slow)
2013/09/11 19:56:08
The I420 DCHECK is on the source. The thing that's
ilja
2013/09/12 01:31:43
It is not specified anywhere, but right now Flash
sheu
2013/09/12 18:47:43
Done.
|
+ const uint8* src = frame->data(j); |
+ const size_t row_bytes = frame->row_bytes(j); |
+ const size_t src_stride = frame->stride(j); |
+ for (int k = 0; k < frame->rows(j); ++k) { |
+ memcpy(dst, src, row_bytes); |
+ dst += row_bytes; |
+ src += src_stride; |
+ } |
+ } |
buffers_[i].in_use = true; |
- platform_video_capture_->FeedBuffer(buffer); |
host()->SendUnsolicitedReply(pp_resource(), |
PpapiPluginMsg_VideoCapture_OnBufferReady(i)); |
return; |
} |
} |
- |
- // No free slot, just discard the frame and tell the media layer it can |
- // re-use the buffer. |
- platform_video_capture_->FeedBuffer(buffer); |
} |
void PepperVideoCaptureHost::OnDeviceInfoReceived( |
@@ -164,10 +172,8 @@ void PepperVideoCaptureHost::OnDeviceInfoReceived( |
}; |
ReleaseBuffers(); |
- // YUV 4:2:0 |
- int uv_width = info.width / 2; |
- int uv_height = info.height / 2; |
- size_t size = info.width * info.height + 2 * uv_width * uv_height; |
+ const size_t size = media::VideoFrame::AllocationSize( |
+ media::VideoFrame::I420, gfx::Size(info.width, info.height)); |
ppapi::proxy::ResourceMessageReplyParams params(pp_resource(), 0); |