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

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

Issue 1064703002: VideoCaptureBufferPool: Refactor to allow support of non-ShMem backed buffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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/video_capture_controller_unittest.cc
diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
index 7e8f055aa130e36147e4dcf337ed678cc0698622..3c6a3c473b7b2d1b786067993c91863128be321f 100644
--- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
@@ -293,7 +293,8 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
media::VideoCaptureParams session_1 = session_100;
const gfx::Size capture_resolution(444, 200);
-
+ const media::VideoCaptureFormat capture_format(capture_resolution, 0.0,
+ media::PIXEL_FORMAT_I420);
// The device format needn't match the VideoCaptureParams (the camera can do
// what it wants). Pick something random.
media::VideoCaptureFormat device_format(
@@ -325,9 +326,8 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
// Now, simulate an incoming captured buffer from the capture device. As a
// side effect this will cause the first buffer to be shared with clients.
uint8 buffer_no = 1;
- scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer;
- buffer =
- device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution);
+ scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer =
+ device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
memset(buffer->data(), buffer_no++, buffer->size());
{
@@ -358,8 +358,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
// Second buffer which ought to use the same shared memory buffer. In this
// case pretend that the Buffer pointer is held by the device for a long
// delay. This shouldn't affect anything.
- buffer =
- device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution);
+ buffer = device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
memset(buffer->data(), buffer_no++, buffer->size());
device_->OnIncomingCapturedVideoFrame(
@@ -386,8 +385,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
// Third, fourth, and fifth buffers. Pretend they all arrive at the same time.
for (int i = 0; i < kPoolSize; i++) {
- buffer = device_->ReserveOutputBuffer(media::VideoFrame::I420,
- capture_resolution);
+ buffer = device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
memset(buffer->data(), buffer_no++, buffer->size());
device_->OnIncomingCapturedVideoFrame(
@@ -397,8 +395,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
buffer = NULL;
}
// ReserveOutputBuffer ought to fail now, because the pool is depleted.
- ASSERT_FALSE(device_->ReserveOutputBuffer(media::VideoFrame::I420,
- capture_resolution).get());
+ ASSERT_FALSE(device_->ReserveOutputBuffer(capture_format).get());
// The new client needs to be told of 3 buffers; the old clients only 2.
EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_2)).Times(kPoolSize);
@@ -423,8 +420,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1);
controller_->StopSession(300);
// Queue up another buffer.
- buffer =
- device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution);
+ buffer = device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
memset(buffer->data(), buffer_no++, buffer->size());
device_->OnIncomingCapturedVideoFrame(
@@ -432,8 +428,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
WrapI420Buffer(buffer, capture_resolution),
base::TimeTicks());
buffer = NULL;
- buffer =
- device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution);
+ buffer = device_->ReserveOutputBuffer(capture_format);
{
// Kill A2 via session close (posts a task to disconnect, but A2 must not
// be sent either of these two buffers).
@@ -469,8 +464,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
}
for (int i = 0; i < shm_buffers; ++i) {
- buffer = device_->ReserveOutputBuffer(media::VideoFrame::I420,
- capture_resolution);
+ buffer = device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
device_->OnIncomingCapturedVideoFrame(
buffer,
@@ -480,9 +474,10 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
}
std::vector<uint32> mailbox_syncpoints(mailbox_buffers);
std::vector<uint32> release_syncpoints(mailbox_buffers);
+ const media::VideoCaptureFormat capture_as_texture_format(
+ gfx::Size(0, 0), 0.0, media::PIXEL_FORMAT_TEXTURE);
for (int i = 0; i < mailbox_buffers; ++i) {
- buffer = device_->ReserveOutputBuffer(media::VideoFrame::NATIVE_TEXTURE,
- gfx::Size(0, 0));
+ buffer = device_->ReserveOutputBuffer(capture_as_texture_format);
ASSERT_TRUE(buffer.get());
#if !defined(OS_ANDROID)
mailbox_syncpoints[i] = gl_helper->InsertSyncPoint();
@@ -498,10 +493,8 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
}
// ReserveOutputBuffers ought to fail now regardless of buffer format, because
// the pool is depleted.
- ASSERT_FALSE(device_->ReserveOutputBuffer(media::VideoFrame::I420,
- capture_resolution).get());
- ASSERT_FALSE(device_->ReserveOutputBuffer(media::VideoFrame::NATIVE_TEXTURE,
- gfx::Size(0, 0)).get());
+ ASSERT_FALSE(device_->ReserveOutputBuffer(capture_format).get());
+ ASSERT_FALSE(device_->ReserveOutputBuffer(capture_as_texture_format).get());
EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2,_)).Times(shm_buffers);
EXPECT_CALL(*client_b_, DoMailboxBufferReady(client_b_route_2))
.Times(mailbox_buffers);
@@ -549,8 +542,10 @@ TEST_F(VideoCaptureControllerTest, ErrorBeforeDeviceCreation) {
base::RunLoop().RunUntilIdle();
Mock::VerifyAndClearExpectations(client_b_.get());
+ const media::VideoCaptureFormat capture_format(capture_resolution, 0.0,
+ media::PIXEL_FORMAT_I420);
scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer =
- device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution);
+ device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
device_->OnIncomingCapturedVideoFrame(
@@ -586,8 +581,10 @@ TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) {
Mock::VerifyAndClearExpectations(client_a_.get());
const gfx::Size dims(320, 240);
+ const media::VideoCaptureFormat capture_format(dims, 0.0,
+ media::PIXEL_FORMAT_I420);
scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer =
- device_->ReserveOutputBuffer(media::VideoFrame::I420, dims);
+ device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
device_->OnError("Test error");

Powered by Google App Engine
This is Rietveld 408576698