| Index: content/browser/renderer_host/media/video_capture_device_client_unittest.cc
|
| diff --git a/content/browser/renderer_host/media/video_capture_device_client_unittest.cc b/content/browser/renderer_host/media/video_capture_device_client_unittest.cc
|
| index 1463b26b68af09810d98474ddc2ea30d67292c25..e5847f19b5f45e63010b91d359ec2807d91d820d 100644
|
| --- a/content/browser/renderer_host/media/video_capture_device_client_unittest.cc
|
| +++ b/content/browser/renderer_host/media/video_capture_device_client_unittest.cc
|
| @@ -5,6 +5,7 @@
|
| #include <stddef.h>
|
|
|
| #include "base/bind.h"
|
| +#include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/run_loop.h"
|
| @@ -79,6 +80,7 @@ TEST_F(VideoCaptureDeviceClientTest, Minimal) {
|
| media::PIXEL_FORMAT_I420,
|
| media::PIXEL_STORAGE_CPU);
|
| DCHECK(device_client_.get());
|
| + EXPECT_CALL(*controller_, DoLogOnIOThread(_)).Times(1);
|
| EXPECT_CALL(*controller_, MockDoIncomingCapturedVideoFrameOnIOThread(_))
|
| .Times(1);
|
| device_client_->OnIncomingCapturedData(data, kScratchpadSizeInBytes,
|
| @@ -100,6 +102,7 @@ TEST_F(VideoCaptureDeviceClientTest, FailsSilentlyGivenInvalidFrameFormat) {
|
| media::VideoPixelStorage::PIXEL_STORAGE_CPU);
|
| DCHECK(device_client_.get());
|
| // Expect the the call to fail silently inside the VideoCaptureDeviceClient.
|
| + EXPECT_CALL(*controller_, DoLogOnIOThread(_)).Times(1);
|
| EXPECT_CALL(*controller_, MockDoIncomingCapturedVideoFrameOnIOThread(_))
|
| .Times(0);
|
| device_client_->OnIncomingCapturedData(data, kScratchpadSizeInBytes,
|
| @@ -119,6 +122,7 @@ TEST_F(VideoCaptureDeviceClientTest, DropsFrameIfNoBuffer) {
|
| media::PIXEL_STORAGE_CPU);
|
| // We expect the second frame to be silently dropped, so these should
|
| // only be called once despite the two frames.
|
| + EXPECT_CALL(*controller_, DoLogOnIOThread(_)).Times(1);
|
| EXPECT_CALL(*controller_, MockDoIncomingCapturedVideoFrameOnIOThread(_))
|
| .Times(1);
|
| // Pass two frames. The second will be dropped.
|
| @@ -132,45 +136,42 @@ TEST_F(VideoCaptureDeviceClientTest, DropsFrameIfNoBuffer) {
|
| Mock::VerifyAndClearExpectations(controller_.get());
|
| }
|
|
|
| -// Tests that buffer-based capture API accepts all memory-backed pixel formats.
|
| -TEST_F(VideoCaptureDeviceClientTest, DataCaptureInEachVideoFormatInSequence) {
|
| +// Tests that buffer-based capture API accepts some memory-backed pixel formats.
|
| +TEST_F(VideoCaptureDeviceClientTest, DataCaptureGoodPixelFormats) {
|
| // The usual ReserveOutputBuffer() -> OnIncomingCapturedVideoFrame() cannot
|
| // be used since it does not accept all pixel formats. The memory backed
|
| // buffer OnIncomingCapturedData() is used instead, with a dummy scratchpad
|
| // buffer.
|
| const size_t kScratchpadSizeInBytes = 400;
|
| unsigned char data[kScratchpadSizeInBytes] = {};
|
| - const gfx::Size capture_resolution(10, 10);
|
| - ASSERT_GE(kScratchpadSizeInBytes, capture_resolution.GetArea() * 4u)
|
| + const gfx::Size kCaptureResolution(10, 10);
|
| + ASSERT_GE(kScratchpadSizeInBytes, kCaptureResolution.GetArea() * 4u)
|
| << "Scratchpad is too small to hold the largest pixel format (ARGB).";
|
|
|
| - for (int format = 0; format < media::PIXEL_FORMAT_MAX;
|
| - ++format) {
|
| - // Conversion from some formats are unsupported.
|
| - if (format == media::PIXEL_FORMAT_UNKNOWN ||
|
| - format == media::PIXEL_FORMAT_YV16 ||
|
| - format == media::PIXEL_FORMAT_YV12A ||
|
| - format == media::PIXEL_FORMAT_YV24 ||
|
| - format == media::PIXEL_FORMAT_ARGB ||
|
| - format == media::PIXEL_FORMAT_XRGB ||
|
| - format == media::PIXEL_FORMAT_MJPEG ||
|
| - format == media::PIXEL_FORMAT_MT21 ||
|
| - format == media::PIXEL_FORMAT_YUV420P9 ||
|
| - format == media::PIXEL_FORMAT_YUV420P10 ||
|
| - format == media::PIXEL_FORMAT_YUV422P9 ||
|
| - format == media::PIXEL_FORMAT_YUV422P10 ||
|
| - format == media::PIXEL_FORMAT_YUV444P9 ||
|
| - format == media::PIXEL_FORMAT_YUV444P10) {
|
| - continue;
|
| - }
|
| -#if !defined(OS_LINUX) && !defined(OS_WIN)
|
| - if (format == media::PIXEL_FORMAT_RGB24) {
|
| - continue;
|
| - }
|
| + media::VideoCaptureParams params;
|
| + params.requested_format = media::VideoCaptureFormat(
|
| + kCaptureResolution, 30.0f, media::PIXEL_FORMAT_UNKNOWN);
|
| +
|
| + // Only use the VideoPixelFormats that we know supported. Do not add
|
| + // PIXEL_FORMAT_MJPEG since it would need a real JPEG header.
|
| + const media::VideoPixelFormat kSupportedFormats[] = {
|
| + media::PIXEL_FORMAT_I420,
|
| + media::PIXEL_FORMAT_YV12,
|
| + media::PIXEL_FORMAT_NV12,
|
| + media::PIXEL_FORMAT_NV21,
|
| + media::PIXEL_FORMAT_YUY2,
|
| + media::PIXEL_FORMAT_UYVY,
|
| +#if defined(OS_WIN) || defined(OS_LINUX)
|
| + media::PIXEL_FORMAT_RGB24,
|
| #endif
|
| - media::VideoCaptureParams params;
|
| - params.requested_format = media::VideoCaptureFormat(
|
| - capture_resolution, 30.0f, media::VideoPixelFormat(format));
|
| + media::PIXEL_FORMAT_RGB32,
|
| + media::PIXEL_FORMAT_ARGB
|
| + };
|
| +
|
| + for (media::VideoPixelFormat format : kSupportedFormats) {
|
| + params.requested_format.pixel_format = format;
|
| +
|
| + EXPECT_CALL(*controller_, DoLogOnIOThread(_)).Times(1);
|
| EXPECT_CALL(*controller_, MockDoIncomingCapturedVideoFrameOnIOThread(_))
|
| .Times(1);
|
| device_client_->OnIncomingCapturedData(
|
| @@ -204,6 +205,8 @@ TEST_F(VideoCaptureDeviceClientTest, CheckRotationsAndCrops) {
|
| const size_t kScratchpadSizeInBytes = 400;
|
| unsigned char data[kScratchpadSizeInBytes] = {};
|
|
|
| + EXPECT_CALL(*controller_, DoLogOnIOThread(_)).Times(1);
|
| +
|
| media::VideoCaptureParams params;
|
| for (const auto& size_and_rotation : kSizeAndRotations) {
|
| ASSERT_GE(kScratchpadSizeInBytes,
|
|
|