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

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

Issue 2772963002: Reland [Mojo Video Capture] Add test coverage for accelerated jpeg decoding (Closed)
Patch Set: Rebase to March 30 Created 3 years, 9 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_browsertest.cc
diff --git a/content/browser/renderer_host/media/video_capture_browsertest.cc b/content/browser/renderer_host/media/video_capture_browsertest.cc
index c9e6963c8140ee4b54ee7d4aa644876999764ba7..13bda0dbfcb04b3ce8bfe15cb15af15be27e1858 100644
--- a/content/browser/renderer_host/media/video_capture_browsertest.cc
+++ b/content/browser/renderer_host/media/video_capture_browsertest.cc
@@ -7,6 +7,7 @@
#include "build/build_config.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
+#include "content/browser/renderer_host/media/video_capture_controller.h"
#include "content/browser/renderer_host/media/video_capture_manager.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/content_browser_test.h"
@@ -64,6 +65,7 @@ struct TestParams {
media::VideoPixelFormat pixel_format_to_use;
gfx::Size resolution_to_use;
float frame_rate_to_use;
+ bool exercise_accelerated_jpeg_decoding;
};
struct FrameInfo {
@@ -116,6 +118,13 @@ class VideoCaptureBrowserTest
switches::kUseFakeDeviceForMediaStream,
GetParam().fake_device_factory_config_string);
command_line->AppendSwitch(switches::kUseFakeUIForMediaStream);
+ if (GetParam().exercise_accelerated_jpeg_decoding) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kUseFakeJpegDecodeAccelerator);
+ } else {
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kDisableAcceleratedMjpegDecode);
+ }
}
// This cannot be part of an override of SetUp(), because at the time when
@@ -188,7 +197,8 @@ IN_PROC_BROWSER_TEST_P(VideoCaptureBrowserTest,
SetUpRequiringBrowserMainLoopOnMainThread();
std::vector<FrameInfo> received_frame_infos;
- static const size_t kNumFramesToReceive = 3;
+ static const size_t kMinFramesToReceive = 5;
+ static const size_t kMaxFramesToReceive = 300;
base::RunLoop run_loop;
auto quit_run_loop_on_current_thread_cb =
@@ -198,20 +208,40 @@ IN_PROC_BROWSER_TEST_P(VideoCaptureBrowserTest,
base::Unretained(this),
std::move(quit_run_loop_on_current_thread_cb), true);
+ bool must_wait_for_gpu_decode_to_start = false;
+ if (GetParam().exercise_accelerated_jpeg_decoding) {
+ // Since the GPU jpeg decoder is created asynchronously while decoding
+ // in software is ongoing, we have to keep pushing frames until a message
+ // arrives that tells us that the GPU decoder is being used. Otherwise,
+ // it may happen that all test frames are decoded using the non-GPU
+ // decoding path before the GPU decoder has started getting used.
+ must_wait_for_gpu_decode_to_start = true;
+ EXPECT_CALL(mock_controller_event_handler_, OnStartedUsingGpuDecode(_))
+ .WillOnce(InvokeWithoutArgs([&must_wait_for_gpu_decode_to_start]() {
+ must_wait_for_gpu_decode_to_start = false;
+ }));
+ }
EXPECT_CALL(mock_controller_event_handler_, DoOnBufferCreated(_, _, _, _))
.Times(AtLeast(1));
EXPECT_CALL(mock_controller_event_handler_, OnBufferReady(_, _, _))
- .WillRepeatedly(
- Invoke([&received_frame_infos, &finish_test_cb](
- VideoCaptureControllerID id, int buffer_id,
- const media::mojom::VideoFrameInfoPtr& frame_info) {
+ .WillRepeatedly(Invoke(
+ [this, &received_frame_infos, &must_wait_for_gpu_decode_to_start,
+ &finish_test_cb](VideoCaptureControllerID id, int buffer_id,
+ const media::mojom::VideoFrameInfoPtr& frame_info) {
FrameInfo received_frame_info;
received_frame_info.pixel_format = frame_info->pixel_format;
received_frame_info.storage_type = frame_info->storage_type;
received_frame_info.size = frame_info->coded_size;
received_frame_info.timestamp = frame_info->timestamp;
received_frame_infos.emplace_back(received_frame_info);
- if (received_frame_infos.size() >= kNumFramesToReceive) {
+
+ const double kArbitraryUtilization = 0.5;
+ controller_->ReturnBuffer(id, &mock_controller_event_handler_,
+ buffer_id, kArbitraryUtilization);
+
+ if ((received_frame_infos.size() >= kMinFramesToReceive &&
+ !must_wait_for_gpu_decode_to_start) ||
+ (received_frame_infos.size() == kMaxFramesToReceive)) {
finish_test_cb.Run();
}
}));
@@ -223,7 +253,9 @@ IN_PROC_BROWSER_TEST_P(VideoCaptureBrowserTest,
base::Unretained(this), std::move(do_nothing)));
run_loop.Run();
- EXPECT_GE(received_frame_infos.size(), kNumFramesToReceive);
+ EXPECT_FALSE(must_wait_for_gpu_decode_to_start);
+ EXPECT_GE(received_frame_infos.size(), kMinFramesToReceive);
+ EXPECT_LT(received_frame_infos.size(), kMaxFramesToReceive);
base::TimeDelta previous_timestamp;
bool first_frame = true;
for (const auto& frame_info : received_frame_infos) {
@@ -242,14 +274,16 @@ INSTANTIATE_TEST_CASE_P(
,
VideoCaptureBrowserTest,
Values(TestParams{"fps=25,device-count=2", 0, media::PIXEL_FORMAT_I420,
- gfx::Size(1280, 720), 25.0f},
+ gfx::Size(1280, 720), 25.0f, false},
// The 2nd device outputs Y16
TestParams{"fps=25,device-count=2", 1, media::PIXEL_FORMAT_Y16,
- gfx::Size(1280, 720), 25.0f},
+ gfx::Size(1280, 720), 25.0f, false},
TestParams{"fps=15,device-count=2", 1, media::PIXEL_FORMAT_Y16,
- gfx::Size(640, 480), 15.0f},
+ gfx::Size(640, 480), 15.0f, false},
// The 3rd device outputs MJPEG, which is converted to I420.
TestParams{"fps=15,device-count=3", 2, media::PIXEL_FORMAT_I420,
- gfx::Size(640, 480), 25.0f}));
+ gfx::Size(640, 480), 25.0f, false},
+ TestParams{"fps=6,device-count=3", 2, media::PIXEL_FORMAT_I420,
+ gfx::Size(640, 480), 6.0f, true}));
} // namespace content
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | content/browser/renderer_host/media/video_capture_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698