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..c2aa2557986f21f2b5d1a5ad732b95766491fa1d 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" |
@@ -225,6 +227,19 @@ void GpuVideoDecodeAccelerator::NotifyError( |
} |
} |
+bool GpuVideoDecodeAccelerator::InitializeDecoder( |
wuchengli
2014/12/26 09:26:25
Use the same order as the header file. Move this b
henryhsu
2014/12/26 09:52:11
Done.
|
+ media::VideoCodecProfile profile) { |
+ if (video_decode_accelerator_.get() && |
+ video_decode_accelerator_->Initialize(profile, this)) { |
+ if (video_decode_accelerator_->CanDecodeOnIOThread()) { |
+ filter_ = new MessageFilter(this, host_route_id_); |
+ stub_->channel()->AddFilter(filter_.get()); |
+ } |
+ return true; |
+ } |
+ return false; |
+} |
+ |
void GpuVideoDecodeAccelerator::Initialize( |
wuchengli
2014/12/26 09:26:25
This function is getting big. But I don't see a wa
|
const media::VideoCodecProfile profile, |
IPC::Message* init_done_msg) { |
@@ -259,30 +274,17 @@ 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) |
wuchengli
2014/12/26 09:26:25
Are there others CPU other than ARCH_CPU_ARMEL and
henryhsu
2014/12/26 09:52:11
Done.
|
scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
- if (!device.get()) { |
- SendCreateDecoderReply(init_done_msg, false); |
- return; |
- } |
- 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; |
+ 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_)); |
} |
- 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 +304,31 @@ 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)) { |
+ 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, |
+ // try VAAPI device again. |
+ 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_)); |
- SendCreateDecoderReply(init_done_msg, true); |
+ if (InitializeDecoder(profile)) { |
+ SendCreateDecoderReply(init_done_msg, true); |
+ return; |
+ } |
+#endif |
+ SendCreateDecoderReply(init_done_msg, false); |
} |
// Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |