Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc

Issue 48113011: Remove media::VideoFrame from media::VideoCaptureDevice::Client interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 5b80a5e9 scoped_refptr-ization. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9f1ef3fa9863f939a8e901fb00e819bd8280465d 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_refptr<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 NULL;
+ void* data;
+ size_t size;
+ buffer_pool_->GetBufferInfo(buffer_id, &data, &size);
+ return scoped_refptr<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(const scoped_refptr<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_;

Powered by Google App Engine
This is Rietveld 408576698