Index: content/renderer/media/video_capture_impl.cc |
diff --git a/content/renderer/media/video_capture_impl.cc b/content/renderer/media/video_capture_impl.cc |
index b7d195d499b3fa3cdbcebc34916febde73603233..23a344d64a1683484482e41598bbb2837932c2b4 100644 |
--- a/content/renderer/media/video_capture_impl.cc |
+++ b/content/renderer/media/video_capture_impl.cc |
@@ -210,14 +210,16 @@ void VideoCaptureImpl::OnBufferDestroyed(int buffer_id) { |
client_buffers_.erase(iter); |
} |
-void VideoCaptureImpl::OnBufferReceived( |
- int buffer_id, |
- base::TimeTicks timestamp, |
- const media::VideoCaptureFormat& format) { |
+void VideoCaptureImpl::OnBufferReceived(int buffer_id, |
+ const media::VideoCaptureFormat& format, |
+ base::TimeTicks timestamp) { |
DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
+ // The capture pipeline supports only I420 for now. |
+ DCHECK_EQ(format.pixel_format, media::PIXEL_FORMAT_I420); |
mcasas
2014/01/21 14:34:02
Yes! (But unfortunately :( )
|
+ |
if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { |
- Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id)); |
+ Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); |
return; |
} |
@@ -238,12 +240,48 @@ void VideoCaptureImpl::OnBufferReceived( |
buffer->buffer_size, |
buffer->buffer->handle(), |
timestamp - first_frame_timestamp_, |
- media::BindToCurrentLoop( |
- base::Bind( |
- &VideoCaptureImpl::OnClientBufferFinished, |
- weak_this_factory_.GetWeakPtr(), |
- buffer_id, |
- buffer))); |
+ media::BindToCurrentLoop(base::Bind( |
+ &VideoCaptureImpl::OnClientBufferFinished, |
+ weak_this_factory_.GetWeakPtr(), |
+ buffer_id, |
+ buffer, |
+ base::Unretained(static_cast<gpu::MailboxHolder*>(NULL))))); |
+ |
+ for (ClientInfo::iterator it = clients_.begin(); it != clients_.end(); ++it) |
+ it->first->OnFrameReady(this, frame); |
+} |
+ |
+static void NullReadPixelsCB(const SkBitmap& bitmap) { NOTIMPLEMENTED(); } |
+ |
+void VideoCaptureImpl::OnMailboxBufferReceived( |
+ int buffer_id, |
+ const gpu::MailboxHolder& mailbox_holder, |
+ const media::VideoCaptureFormat& format, |
+ base::TimeTicks timestamp) { |
+ DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
+ |
+ if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { |
+ Send(new VideoCaptureHostMsg_BufferReady( |
+ device_id_, buffer_id, mailbox_holder.sync_point)); |
+ return; |
+ } |
+ |
+ last_frame_format_ = format; |
+ if (first_frame_timestamp_.is_null()) |
+ first_frame_timestamp_ = timestamp; |
+ |
+ scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( |
+ make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), |
+ media::BindToCurrentLoop( |
+ base::Bind(&VideoCaptureImpl::OnClientBufferFinished, |
+ weak_this_factory_.GetWeakPtr(), |
+ buffer_id, |
+ scoped_refptr<ClientBuffer>())), |
+ last_frame_format_.frame_size, |
+ gfx::Rect(last_frame_format_.frame_size), |
+ last_frame_format_.frame_size, |
+ timestamp - first_frame_timestamp_, |
+ base::Bind(&NullReadPixelsCB)); |
for (ClientInfo::iterator it = clients_.begin(); it != clients_.end(); ++it) |
it->first->OnFrameReady(this, frame); |
@@ -251,9 +289,13 @@ void VideoCaptureImpl::OnBufferReceived( |
void VideoCaptureImpl::OnClientBufferFinished( |
int buffer_id, |
- const scoped_refptr<ClientBuffer>& buffer) { |
+ const scoped_refptr<ClientBuffer>& /* ignored_buffer */, |
+ const gpu::MailboxHolder* mailbox_holder) { |
DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
- Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id)); |
+ uint32 sync_point = 0; |
mcasas
2014/01/21 14:34:02
uint32 sync_point = mailbox_holder ? mailbox_holde
sheu
2014/01/29 01:19:20
Done.
|
+ if (mailbox_holder) |
+ sync_point = mailbox_holder->sync_point; |
+ Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, sync_point)); |
} |
void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) { |