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

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

Issue 1179323002: Video Capture: extract storage info from pixel format in VideoCaptureFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 6693f8bf429e8dde013344dc54edad6e73418da6..13e6f624b9df71b5902213a75b47b29eb6fd81c2 100644
--- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
@@ -296,6 +296,12 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
const gfx::Size capture_resolution(444, 200);
+ const media::VideoCaptureFormat capture_format(capture_resolution, 0.0f,
+ media::PIXEL_FORMAT_I420);
+ const media::VideoCaptureFormat capture_format_texture(
+ capture_resolution, 0.0f, media::PIXEL_FORMAT_ARGB,
+ media::PIXEL_STORAGE_TEXTURE);
+
// The device format needn't match the VideoCaptureParams (the camera can do
// what it wants). Pick something random.
media::VideoCaptureFormat device_format(
@@ -328,8 +334,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
// side effect this will cause the first buffer to be shared with clients.
uint8 buffer_no = 1;
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer(
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution));
+ device_->ReserveOutputBuffer(capture_format));
ASSERT_TRUE(buffer.get());
memset(buffer->data(), buffer_no++, buffer->size());
{
@@ -371,8 +376,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
// case pretend that the Buffer pointer is held by the device for a long
// delay. This shouldn't affect anything.
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer2 =
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution);
+ device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer2.get());
memset(buffer2->data(), buffer_no++, buffer2->size());
video_frame =
@@ -410,8 +414,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++) {
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer =
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution);
+ device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
memset(buffer->data(), buffer_no++, buffer->size());
video_frame =
@@ -420,8 +423,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
base::TimeTicks());
}
// ReserveOutputBuffer ought to fail now, because the pool is depleted.
- ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_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);
@@ -447,8 +449,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
controller_->StopSession(300);
// Queue up another buffer.
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer3 =
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution);
+ device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer3.get());
memset(buffer3->data(), buffer_no++, buffer3->size());
video_frame =
@@ -457,8 +458,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
base::TimeTicks());
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer4 =
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution);
+ 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).
@@ -493,8 +493,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
for (int i = 0; i < shm_buffers; ++i) {
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer =
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution);
+ device_->ReserveOutputBuffer(capture_format);
ASSERT_TRUE(buffer.get());
video_frame =
WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data()));
@@ -505,8 +504,7 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
std::vector<uint32> release_syncpoints(mailbox_buffers);
for (int i = 0; i < mailbox_buffers; ++i) {
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer =
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE,
- capture_resolution);
+ device_->ReserveOutputBuffer(capture_format_texture);
ASSERT_TRUE(buffer.get());
#if !defined(OS_ANDROID)
mailbox_syncpoints[i] =
@@ -522,10 +520,8 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
}
// ReserveOutputBuffers ought to fail now regardless of buffer format, because
// the pool is depleted.
- ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution).get());
- ASSERT_FALSE(device_->ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE,
- capture_resolution).get());
+ ASSERT_FALSE(device_->ReserveOutputBuffer(capture_format).get());
+ ASSERT_FALSE(device_->ReserveOutputBuffer(capture_format_texture).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);
@@ -557,6 +553,8 @@ TEST_F(VideoCaptureControllerTest, ErrorBeforeDeviceCreation) {
media::VideoCaptureParams session_200 = session_100;
const gfx::Size capture_resolution(320, 240);
+ const media::VideoCaptureFormat capture_format(capture_resolution, 0.0f,
+ media::PIXEL_FORMAT_I420);
const VideoCaptureControllerID route_id(0x99);
@@ -577,8 +575,7 @@ TEST_F(VideoCaptureControllerTest, ErrorBeforeDeviceCreation) {
Mock::VerifyAndClearExpectations(client_b_.get());
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer(
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420,
- capture_resolution));
+ device_->ReserveOutputBuffer(capture_format));
ASSERT_TRUE(buffer.get());
scoped_refptr<media::VideoFrame> video_frame =
WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data()));
@@ -612,8 +609,10 @@ TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) {
Mock::VerifyAndClearExpectations(client_a_.get());
const gfx::Size dims(320, 240);
+ const media::VideoCaptureFormat capture_format(dims, 0.0f,
+ media::PIXEL_FORMAT_I420);
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer(
- device_->ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dims));
+ device_->ReserveOutputBuffer(capture_format));
ASSERT_TRUE(buffer.get());
scoped_refptr<media::VideoFrame> video_frame =
@@ -649,8 +648,8 @@ TEST_F(VideoCaptureControllerTest, DataCaptureInEachVideoFormatInSequence) {
<< "Scratchpad is too small to hold the largest pixel format (ARGB).";
const int kSessionId = 100;
- // This Test skips PIXEL_FORMAT_TEXTURE and PIXEL_FORMAT_UNKNOWN.
- for (int format = 0; format < media::PIXEL_FORMAT_TEXTURE; ++format) {
+ // This Test skips PIXEL_FORMAT_UNKNOWN.
+ for (int format = 0; format < media::PIXEL_FORMAT_UNKNOWN; ++format) {
media::VideoCaptureParams params;
params.requested_format = media::VideoCaptureFormat(
capture_resolution, 30, media::VideoPixelFormat(format));

Powered by Google App Engine
This is Rietveld 408576698