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..5b57a12df8aa7a1ccb4f0bc3b1ed67a5b9674519 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,11 @@ 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"; |
+ |
+// Enabled by including a --fake_encoder flag to the command line invoking the |
+// test. |
+bool g_fake_encoder = false; |
+ |
// Environment to store test stream data for all test cases. |
class VideoEncodeAcceleratorTestEnvironment; |
VideoEncodeAcceleratorTestEnvironment* g_env; |
@@ -480,7 +486,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 +699,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 +722,20 @@ void VEAClient::CreateEncoder() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
CHECK(!has_encoder()); |
+ |
+ if (g_fake_encoder) { |
+ encoder_.reset( |
+ new media::FakeVideoEncodeAccelerator( |
+ scoped_refptr<base::SingleThreadTaskRunner>( |
wuchengli
2014/12/12 03:35:50
do we need this casting?
hellner1
2014/12/12 19:24:40
Done.
|
+ 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 +869,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 +1290,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; |