Index: content/common/gpu/media/gpu_video_decode_accelerator.cc |
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc |
index f741cb20418fbecfa99b83d54dd814f131c33892..410cc14a0fa3989dc9dec18f00784411bb06e3a4 100644 |
--- a/content/common/gpu/media/gpu_video_decode_accelerator.cc |
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc |
@@ -32,6 +32,8 @@ |
#include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
#include "content/common/gpu/media/v4l2_video_device.h" |
#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
+#include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
+#include "content/common/gpu/media/v4l2_video_device.h" |
#include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
#include "ui/gl/gl_context_glx.h" |
#include "ui/gl/gl_implementation.h" |
@@ -259,30 +261,18 @@ void GpuVideoDecodeAccelerator::Initialize( |
static_cast<CGLContextObj>( |
stub_->decoder()->GetGLContext()->GetHandle()), |
make_context_current_)); |
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
+#elif defined(OS_CHROMEOS) && defined(USE_X11) && \ |
+ (defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL)) |
Pawel Osciak
2014/12/28 23:28:02
I don't think it would hurt to not check for arch
henryhsu
2014/12/29 09:43:26
How to check we have EGL? I think we cannot use 'g
Pawel Osciak
2014/12/30 06:14:38
We'll have a separate CL for this, so we can skip
|
scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
- if (!device.get()) { |
- SendCreateDecoderReply(init_done_msg, false); |
- return; |
+ if (device.get()) { |
+ video_decode_accelerator_.reset(new V4L2VideoDecodeAccelerator( |
+ gfx::GLSurfaceEGL::GetHardwareDisplay(), |
+ stub_->decoder()->GetGLContext()->GetHandle(), |
+ weak_factory_for_io_.GetWeakPtr(), |
+ make_context_current_, |
+ device.Pass(), |
+ io_message_loop_)); |
} |
- video_decode_accelerator_.reset(new V4L2VideoDecodeAccelerator( |
- gfx::GLSurfaceEGL::GetHardwareDisplay(), |
- stub_->decoder()->GetGLContext()->GetHandle(), |
- weak_factory_for_io_.GetWeakPtr(), |
- make_context_current_, |
- device.Pass(), |
- io_message_loop_)); |
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
- if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) { |
- VLOG(1) << "HW video decode acceleration not available without " |
- "DesktopGL (GLX)."; |
- SendCreateDecoderReply(init_done_msg, false); |
- return; |
- } |
- gfx::GLContextGLX* glx_context = |
- static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext()); |
- video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator( |
- glx_context->display(), make_context_current_)); |
#elif defined(USE_OZONE) |
media::MediaOzonePlatform* platform = |
media::MediaOzonePlatform::GetInstance(); |
@@ -302,17 +292,44 @@ void GpuVideoDecodeAccelerator::Initialize( |
return; |
#endif |
- if (video_decode_accelerator_->CanDecodeOnIOThread()) { |
- filter_ = new MessageFilter(this, host_route_id_); |
- stub_->channel()->AddFilter(filter_.get()); |
+ if (InitializeDecoder(profile)) { |
Pawel Osciak
2014/12/28 23:28:02
I think the code would be simpler and more extensi
henryhsu
2014/12/29 09:43:26
yes. But ScopedVector does not support DefaultDele
|
+ SendCreateDecoderReply(init_done_msg, true); |
+ return; |
} |
- if (!video_decode_accelerator_->Initialize(profile, this)) { |
+#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
+ // X86 platforms try V4L2 device first. If V4L2 device initialization fails, |
Pawel Osciak
2014/12/28 23:28:02
s/X86/x86/
s/V4L2 device/V4L2 VDA/
henryhsu
2014/12/29 09:43:26
Done.
|
+ // try VAAPI device again. |
Pawel Osciak
2014/12/28 23:28:01
s/VAAPI device/VAAPI VDA/
s/ again//
henryhsu
2014/12/29 09:43:26
Done.
|
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) { |
+ VLOG(1) << "HW video decode acceleration not available without " |
+ "DesktopGL (GLX)."; |
SendCreateDecoderReply(init_done_msg, false); |
return; |
} |
+ gfx::GLContextGLX* glx_context = |
+ static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext()); |
+ video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator( |
+ glx_context->display(), make_context_current_)); |
+ |
+ if (InitializeDecoder(profile)) { |
+ SendCreateDecoderReply(init_done_msg, true); |
+ return; |
+ } |
+#endif |
+ SendCreateDecoderReply(init_done_msg, false); |
+} |
- SendCreateDecoderReply(init_done_msg, true); |
+bool GpuVideoDecodeAccelerator::InitializeDecoder( |
+ media::VideoCodecProfile profile) { |
+ if (video_decode_accelerator_.get() && |
+ video_decode_accelerator_->Initialize(profile, this)) { |
+ if (video_decode_accelerator_->CanDecodeOnIOThread()) { |
Pawel Osciak
2014/12/28 23:28:01
if (!vda_.get() || !vda_->Initialize())
return f
henryhsu
2014/12/29 09:43:26
Done.
|
+ filter_ = new MessageFilter(this, host_route_id_); |
+ stub_->channel()->AddFilter(filter_.get()); |
+ } |
+ return true; |
+ } |
+ return false; |
} |
// Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |