| 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 37bb03036c05f14ae80fa123992eb06148fba268..9108234b7a8a6e2d76b2ac579572a87aded1a053 100644
|
| --- a/content/common/gpu/media/video_encode_accelerator_unittest.cc
|
| +++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc
|
| @@ -20,6 +20,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"
|
|
|
| @@ -98,6 +99,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;
|
| @@ -485,7 +491,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));
|
| @@ -710,7 +718,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());
|
| @@ -732,12 +741,19 @@ void VEAClient::CreateEncoder() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| CHECK(!has_encoder());
|
|
|
| +
|
| + if (g_fake_encoder) {
|
| + encoder_.reset(
|
| + new media::FakeVideoEncodeAccelerator(
|
| + 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)
|
| - encoder_.reset(new VaapiVideoEncodeAccelerator());
|
| + encoder_.reset(new VaapiVideoEncodeAccelerator());
|
| #endif
|
| + }
|
|
|
| SetState(CS_ENCODER_SET);
|
|
|
| @@ -883,7 +899,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))
|
| @@ -1322,6 +1342,8 @@ int main(int argc, char** argv) {
|
| if (it->first == "num_frames_to_encode") {
|
| std::string input(it->second.begin(), it->second.end());
|
| CHECK(base::StringToInt(input, &content::g_num_frames_to_encode));
|
| + if (it->first == "fake_encoder") {
|
| + content::g_fake_encoder = true;
|
| continue;
|
| }
|
| if (it->first == "run_at_fps") {
|
|
|