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

Unified Diff: content/common/gpu/media/video_encode_accelerator_unittest.cc

Issue 760963003: Adds fake hardware video encoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates according to comments. Created 6 years 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
« no previous file with comments | « no previous file | media/cast/cast_testing.gypi » ('j') | media/video/fake_video_encode_accelerator.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/video_encode_accelerator_unittest.cc
diff --git a/content/common/gpu/media/video_encode_accelerator_unittest.cc b/content/common/gpu/media/video_encode_accelerator_unittest.cc
index 2921ed07483cb97db93d3c343833b9e8d1c34456..cb3630c6d94775d7d0e60001207a0f948c94adf0 100644
--- a/content/common/gpu/media/video_encode_accelerator_unittest.cc
+++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc
@@ -19,6 +19,7 @@
#include "media/base/bitstream_buffer.h"
#include "media/base/test_data_util.h"
#include "media/filters/h264_parser.h"
+#include "media/video/fake_video_encode_accelerator.h"
#include "media/video/video_encode_accelerator.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -97,6 +98,9 @@ const unsigned int kMinFramesForBitrateTests = 300;
// Bitrate is only forced for tests that test bitrate.
const char* g_default_in_filename = "bear_320x192_40frames.yuv";
const char* g_default_in_parameters = ":320:192:1:out.h264:200000";
+
+bool g_fake_encoder = false;
wuchengli 2014/12/11 02:14:31 Please document this.
hellner1 2014/12/11 19:34:19 Done.
+
// Environment to store test stream data for all test cases.
class VideoEncodeAcceleratorTestEnvironment;
VideoEncodeAcceleratorTestEnvironment* g_env;
@@ -480,7 +484,9 @@ scoped_ptr<StreamValidator> StreamValidator::Create(
const FrameFoundCallback& frame_cb) {
scoped_ptr<StreamValidator> validator;
- if (IsH264(profile)) {
+ if (g_fake_encoder) {
+ validator.reset(NULL);
+ } else if (IsH264(profile)) {
validator.reset(new H264Validator(frame_cb));
} else if (IsVP8(profile)) {
validator.reset(new VP8Validator(frame_cb));
@@ -691,7 +697,8 @@ VEAClient::VEAClient(TestStream* test_stream,
test_stream_->requested_profile,
base::Bind(&VEAClient::HandleEncodedFrame, base::Unretained(this)));
- CHECK(validator_.get());
+
+ CHECK(g_fake_encoder || validator_.get());
if (save_to_file_) {
CHECK(!test_stream_->out_filename.empty());
@@ -713,12 +720,20 @@ void VEAClient::CreateEncoder() {
DCHECK(thread_checker_.CalledOnValidThread());
CHECK(!has_encoder());
+
+ if (g_fake_encoder) {
+ encoder_.reset(
+ new media::FakeVideoEncodeAccelerator(
+ scoped_refptr<base::SingleThreadTaskRunner>(
+ base::MessageLoopProxy::current())));
+ } else {
#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
- scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder);
- encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass()));
+ scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder);
+ encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass()));
#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
- encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay()));
+ encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay()));
#endif
+ }
SetState(CS_ENCODER_SET);
@@ -852,7 +867,11 @@ void VEAClient::BitstreamBufferReady(int32 bitstream_buffer_id,
const uint8* stream_ptr = static_cast<const uint8*>(shm->memory());
if (payload_size > 0) {
- validator_->ProcessStreamBuffer(stream_ptr, payload_size);
+ if (validator_) {
+ validator_->ProcessStreamBuffer(stream_ptr, payload_size);
+ } else {
+ HandleEncodedFrame(key_frame);
+ }
if (save_to_file_) {
if (IsVP8(test_stream_->requested_profile))
@@ -1269,6 +1288,10 @@ int main(int argc, char** argv) {
test_stream_data->assign(it->second.c_str());
continue;
}
+ if (it->first == "fake_encoder") {
+ content::g_fake_encoder = true;
+ continue;
+ }
if (it->first == "v" || it->first == "vmodule")
continue;
LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
« no previous file with comments | « no previous file | media/cast/cast_testing.gypi » ('j') | media/video/fake_video_encode_accelerator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698