Chromium Code Reviews| 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..279a89d649ed5691014a64e2651ba61da1715195 100644 |
| --- a/content/common/gpu/media/video_encode_accelerator_unittest.cc |
| +++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc |
| @@ -26,6 +26,8 @@ |
| #include "ui/gfx/x/x11_types.h" |
| #endif |
| +#include "media/video/fake_video_encode_accelerator.h" |
|
wuchengli
2014/12/09 14:29:24
move this before #include "media/video/video_encod
hellner1
2014/12/10 22:38:59
Done.
|
| + |
| #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
| #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
| @@ -128,7 +130,8 @@ struct TestStream { |
| requested_bitrate(0), |
| requested_framerate(0), |
| requested_subsequent_bitrate(0), |
| - requested_subsequent_framerate(0) {} |
| + requested_subsequent_framerate(0), |
| + fake_encoder(0) {} |
|
wuchengli
2014/12/09 14:29:24
Do you want to use different encoders for differen
hellner1
2014/12/10 22:38:58
I made fake_encoder selection a command line argum
|
| ~TestStream() {} |
| gfx::Size visible_size; |
| @@ -158,6 +161,7 @@ struct TestStream { |
| unsigned int requested_framerate; |
| unsigned int requested_subsequent_bitrate; |
| unsigned int requested_subsequent_framerate; |
| + int fake_encoder; |
|
wuchengli
2014/12/09 14:29:24
Use bool.
hellner1
2014/12/10 22:38:58
Done.
|
| }; |
| inline static size_t Align64Bytes(size_t value) { |
| @@ -304,7 +308,7 @@ static void ParseAndReadTestStreamData(const base::FilePath::StringType& data, |
| std::vector<base::FilePath::StringType> fields; |
| base::SplitString(test_streams_data[index], ':', &fields); |
| CHECK_GE(fields.size(), 4U) << data; |
| - CHECK_LE(fields.size(), 9U) << data; |
| + CHECK_LE(fields.size(), 10U) << data; |
| TestStream* test_stream = new TestStream(); |
| test_stream->in_filename = fields[0]; |
| @@ -338,6 +342,9 @@ static void ParseAndReadTestStreamData(const base::FilePath::StringType& data, |
| CHECK(base::StringToUint(fields[8], |
| &test_stream->requested_subsequent_framerate)); |
| } |
| + if (fields.size() >= 10 && !fields[9].empty()) { |
| + CHECK(base::StringToInt(fields[9], &test_stream->fake_encoder)); |
| + } |
| test_streams->push_back(test_stream); |
| } |
| } |
| @@ -367,7 +374,8 @@ class StreamValidator { |
| // Provide a StreamValidator instance for the given |profile|. |
| static scoped_ptr<StreamValidator> Create(media::VideoCodecProfile profile, |
| - const FrameFoundCallback& frame_cb); |
| + const FrameFoundCallback& frame_cb, |
| + bool fake_stream); |
| // Process and verify contents of a bitstream buffer. |
| virtual void ProcessStreamBuffer(const uint8* stream, size_t size) = 0; |
| @@ -379,6 +387,20 @@ class StreamValidator { |
| FrameFoundCallback frame_cb_; |
| }; |
| +class PassThroughValidator : public StreamValidator { |
| + public: |
| + explicit PassThroughValidator(const FrameFoundCallback& frame_cb) |
| + : StreamValidator(frame_cb) {} |
| + void ProcessStreamBuffer(const uint8* stream, size_t size) override; |
| +}; |
| + |
| +void PassThroughValidator::ProcessStreamBuffer( |
| + const uint8* stream, |
| + size_t size) { |
| + const bool keyframe = !(stream[0] & 0x01); |
|
wuchengli
2014/12/09 14:29:25
This is a hidden dependency to FakeVideoEncodeAcce
hellner1
2014/12/10 22:38:58
Removed the need for this as suggested in other co
|
| + frame_cb_.Run(keyframe); |
| +} |
| + |
| class H264Validator : public StreamValidator { |
| public: |
| explicit H264Validator(const FrameFoundCallback& frame_cb) |
| @@ -477,10 +499,13 @@ void VP8Validator::ProcessStreamBuffer(const uint8* stream, size_t size) { |
| // static |
| scoped_ptr<StreamValidator> StreamValidator::Create( |
| media::VideoCodecProfile profile, |
| - const FrameFoundCallback& frame_cb) { |
| + const FrameFoundCallback& frame_cb, |
| + bool fake_stream) { |
| scoped_ptr<StreamValidator> validator; |
| - if (IsH264(profile)) { |
| + if (fake_stream) { |
| + validator.reset(new PassThroughValidator(frame_cb)); |
| + } else if (IsH264(profile)) { |
| validator.reset(new H264Validator(frame_cb)); |
| } else if (IsVP8(profile)) { |
| validator.reset(new VP8Validator(frame_cb)); |
| @@ -689,7 +714,8 @@ VEAClient::VEAClient(TestStream* test_stream, |
| validator_ = StreamValidator::Create( |
| test_stream_->requested_profile, |
| - base::Bind(&VEAClient::HandleEncodedFrame, base::Unretained(this))); |
| + base::Bind(&VEAClient::HandleEncodedFrame, base::Unretained(this)), |
| + test_stream_->fake_encoder); |
| CHECK(validator_.get()); |
| @@ -713,12 +739,22 @@ void VEAClient::CreateEncoder() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| CHECK(!has_encoder()); |
| + |
| + if (test_stream_->fake_encoder) { |
| + std::vector<uint32> no_stored_bitrates; |
| + encoder_.reset( |
| + new media::FakeVideoEncodeAccelerator( |
| + scoped_refptr<base::SingleThreadTaskRunner>( |
| + base::MessageLoopProxy::current()), |
| + no_stored_bitrates)); |
| + } 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); |