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 5f606343dd455e59defe08102811492979f6f3f0..32476903f772723ca7caa03986accbc3024b906b 100644 |
--- a/content/common/gpu/media/video_encode_accelerator_unittest.cc |
+++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc |
@@ -13,7 +13,6 @@ |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_split.h" |
#include "base/time/time.h" |
-#include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
#include "content/common/gpu/media/video_accelerator_unittest_helpers.h" |
#include "media/base/bind_to_current_loop.h" |
#include "media/base/bitstream_buffer.h" |
@@ -22,6 +21,18 @@ |
#include "media/video/video_encode_accelerator.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#if defined(USE_X11) |
+#include "ui/gfx/x/x11_types.h" |
+#endif |
+ |
+#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
+#include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
wuchengli
2014/06/18 03:34:14
This should be the first include. Move this before
Pawel Osciak
2014/06/18 07:05:09
"Exception: sometimes, system-specific code needs
|
+#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
+#include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
+#else |
+#error The VideoEncodeAcceleratorUnittest is not supported on this platform. |
+#endif |
+ |
using media::VideoEncodeAccelerator; |
namespace content { |
@@ -251,17 +262,18 @@ class H264Validator : public StreamValidator { |
bool seen_sps_; |
bool seen_pps_; |
bool seen_idr_; |
+ |
+ media::H264Parser h264_parser_; |
}; |
void H264Validator::ProcessStreamBuffer(const uint8* stream, size_t size) { |
- media::H264Parser h264_parser; |
- h264_parser.SetStream(stream, size); |
+ h264_parser_.SetStream(stream, size); |
while (1) { |
media::H264NALU nalu; |
media::H264Parser::Result result; |
- result = h264_parser.AdvanceToNextNALU(&nalu); |
+ result = h264_parser_.AdvanceToNextNALU(&nalu); |
if (result == media::H264Parser::kEOStream) |
break; |
@@ -273,22 +285,35 @@ void H264Validator::ProcessStreamBuffer(const uint8* stream, size_t size) { |
case media::H264NALU::kIDRSlice: |
ASSERT_TRUE(seen_sps_); |
ASSERT_TRUE(seen_pps_); |
- seen_idr_ = keyframe = true; |
+ seen_idr_ = true; |
// fallthrough |
- case media::H264NALU::kNonIDRSlice: |
+ case media::H264NALU::kNonIDRSlice: { |
ASSERT_TRUE(seen_idr_); |
+ |
+ media::H264SliceHeader shdr; |
+ ASSERT_EQ(h264_parser_.ParseSliceHeader(nalu, &shdr), |
wuchengli
2014/06/18 03:34:13
The expectation (media::H264Parser::kOk) should be
Pawel Osciak
2014/06/18 07:05:09
Done.
|
+ media::H264Parser::kOk); |
+ keyframe = shdr.IsISlice() || shdr.IsSISlice(); |
+ |
if (!frame_cb_.Run(keyframe)) |
return; |
break; |
+ } |
- case media::H264NALU::kSPS: |
+ case media::H264NALU::kSPS: { |
+ int sps_id; |
+ ASSERT_EQ(h264_parser_.ParseSPS(&sps_id), media::H264Parser::kOk); |
seen_sps_ = true; |
break; |
+ } |
- case media::H264NALU::kPPS: |
+ case media::H264NALU::kPPS: { |
ASSERT_TRUE(seen_sps_); |
+ int pps_id; |
+ ASSERT_EQ(h264_parser_.ParsePPS(&pps_id), media::H264Parser::kOk); |
seen_pps_ = true; |
break; |
+ } |
default: |
break; |
@@ -559,8 +584,13 @@ void VEAClient::CreateEncoder() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
CHECK(!has_encoder()); |
+#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
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(gfx::GetXDisplay())); |
+#endif |
+ |
SetState(CS_ENCODER_SET); |
DVLOG(1) << "Profile: " << test_stream_.requested_profile |