Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Unified Diff: content/common/gpu/media/gpu_video_decode_accelerator.cc

Issue 826663002: Support multiple video decoders and encoders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..44fad80158aa719b3c4d4a749048056118f7bc84 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,16 @@ void GpuVideoDecodeAccelerator::NotifyError(
}
}
+bool GpuVideoDecodeAccelerator::InitialDecoder(
+ const media::VideoCodecProfile profile) {
+ if (video_decode_accelerator_->CanDecodeOnIOThread()) {
+ filter_ = new MessageFilter(this, host_route_id_);
+ stub_->channel()->AddFilter(filter_.get());
Pawel Osciak 2014/12/26 01:11:35 Unless I'm missing something, if vda->Initialize()
henryhsu 2014/12/26 08:40:40 I'd like to move AddFilter after VDA initialize. T
+ }
+
+ return video_decode_accelerator_->Initialize(profile, this);
+}
+
void GpuVideoDecodeAccelerator::Initialize(
const media::VideoCodecProfile profile,
IPC::Message* init_done_msg) {
@@ -259,30 +271,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)
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 +301,32 @@ void GpuVideoDecodeAccelerator::Initialize(
return;
#endif
- if (video_decode_accelerator_->CanDecodeOnIOThread()) {
- filter_ = new MessageFilter(this, host_route_id_);
- stub_->channel()->AddFilter(filter_.get());
+ if (video_decode_accelerator_.get() && InitialDecoder(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)
Pawel Osciak 2014/12/26 01:11:35 What's the latency of failing to create a V4L2 dec
henryhsu 2014/12/26 08:40:40 I tested on Squawks and the latency is 149 microse
+ // 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 (InitialDecoder(profile)) {
+ SendCreateDecoderReply(init_done_msg, true);
+ return;
+ }
+
+ SendCreateDecoderReply(init_done_msg, false);
+#endif
}
// Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is

Powered by Google App Engine
This is Rietveld 408576698