Index: content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
diff --git a/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc b/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
index accac84b575e3bf3aadf619cdb946214a19c990e..9ac453f815493061d7f4fdd3f1e96b8339d9d3d9 100644 |
--- a/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
+++ b/content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc |
@@ -315,33 +315,45 @@ class StubClient : public media::VideoCaptureDevice::Client { |
} |
virtual ~StubClient() {} |
- virtual scoped_refptr<media::VideoFrame> ReserveOutputBuffer( |
- const gfx::Size& size) OVERRIDE { |
+ virtual scoped_ptr<media::VideoCaptureDevice::Client::Buffer> |
+ ReserveOutputBuffer(media::VideoFrame::Format format, |
+ const gfx::Size& dimensions) OVERRIDE { |
+ const size_t frame_bytes = |
+ media::VideoFrame::AllocationSize(format, dimensions); |
int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; // Ignored. |
- return buffer_pool_->ReserveI420VideoFrame(size, 0, &buffer_id_to_drop); |
- } |
- |
- virtual void OnIncomingCapturedFrame( |
- const uint8* data, |
- int length, |
- base::Time timestamp, |
- int rotation, |
- bool flip_vert, |
- bool flip_horiz) OVERRIDE { |
+ int buffer_id = |
+ buffer_pool_->ReserveForProducer(frame_bytes, &buffer_id_to_drop); |
+ if (buffer_id == VideoCaptureBufferPool::kInvalidId) |
+ return scoped_ptr<media::VideoCaptureDevice::Client::Buffer>(); |
+ void* data; |
+ size_t size; |
+ buffer_pool_->GetBufferInfo(buffer_id, &data, &size); |
+ return scoped_ptr<media::VideoCaptureDevice::Client::Buffer>( |
+ new PoolBuffer(buffer_pool_, buffer_id, data, size)); |
+ } |
+ |
+ virtual void OnIncomingCapturedFrame(const uint8* data, |
+ int length, |
+ base::Time timestamp, |
+ int rotation, |
+ bool flip_vert, |
+ bool flip_horiz) OVERRIDE { |
FAIL(); |
} |
- virtual void OnIncomingCapturedVideoFrame( |
- const scoped_refptr<media::VideoFrame>& frame, |
- base::Time timestamp) OVERRIDE { |
- EXPECT_EQ(gfx::Size(kTestWidth, kTestHeight), frame->coded_size()); |
- EXPECT_EQ(media::VideoFrame::I420, frame->format()); |
- EXPECT_LE( |
- 0, |
- buffer_pool_->RecognizeReservedBuffer(frame->shared_memory_handle())); |
+ virtual void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer, |
+ media::VideoFrame::Format format, |
+ const gfx::Size& dimensions, |
+ base::Time timestamp) OVERRIDE { |
+ EXPECT_EQ(gfx::Size(kTestWidth, kTestHeight), dimensions); |
+ EXPECT_EQ(media::VideoFrame::I420, format); |
+ EXPECT_LE(0, buffer_pool_->RecognizeReservedBuffer(buffer->data())); |
uint8 yuv[3]; |
+ size_t offset = 0; |
for (int plane = 0; plane < 3; ++plane) { |
- yuv[plane] = frame->data(plane)[0]; |
+ yuv[plane] = reinterpret_cast<uint8*>(buffer->data())[offset]; |
+ offset += media::VideoFrame::PlaneAllocationSize( |
+ media::VideoFrame::I420, plane, dimensions); |
} |
// TODO(nick): We just look at the first pixel presently, because if |
// the analysis is too slow, the backlog of frames will grow without bound |
@@ -358,6 +370,20 @@ class StubClient : public media::VideoCaptureDevice::Client { |
} |
private: |
+ class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { |
+ public: |
+ PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
+ int buffer_id, |
+ void* data, |
+ size_t size) |
+ : Buffer(data, size), pool_(pool), buffer_id_(buffer_id) {} |
+ virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(buffer_id_); } |
+ |
+ private: |
+ const scoped_refptr<VideoCaptureBufferPool> pool_; |
+ const int buffer_id_; |
+ }; |
+ |
scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
base::Callback<void(SkColor)> color_callback_; |
base::Closure error_callback_; |