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

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: address patch set 4 review comments 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..4a3edfb2c43a77b2e12b9c3f0a7e42f0100954f6 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"
@@ -236,6 +238,9 @@ void GpuVideoDecodeAccelerator::Initialize(
SendCreateDecoderReply(init_done_msg, false);
}
+ scoped_ptr<media::VideoDecodeAccelerator> decoders[2];
+ size_t n_decoders = 0;
+
#if !defined(OS_WIN)
// Ensure we will be able to get a GL context at all before initializing
// non-Windows VDAs.
@@ -252,27 +257,27 @@ void GpuVideoDecodeAccelerator::Initialize(
return;
}
DVLOG(0) << "Initializing DXVA HW decoder for windows.";
- video_decode_accelerator_.reset(
+ decoders[n_decoders++].reset(
new DXVAVideoDecodeAccelerator(make_context_current_));
#elif defined(OS_MACOSX)
- video_decode_accelerator_.reset(new VTVideoDecodeAccelerator(
+ decoders[n_decoders++].reset(new VTVideoDecodeAccelerator(
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))
scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
- if (!device.get()) {
- SendCreateDecoderReply(init_done_msg, false);
- return;
+ if (device.get()) {
+ decoders[n_decoders++].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 defined(ARCH_CPU_X86_FAMILY)
+ // x86 CrOS platforms may have multiple decoders.
if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {
VLOG(1) << "HW video decode acceleration not available without "
"DesktopGL (GLX).";
@@ -281,19 +286,16 @@ void GpuVideoDecodeAccelerator::Initialize(
}
gfx::GLContextGLX* glx_context =
static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext());
- video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator(
+ decoders[n_decoders++].reset(new VaapiVideoDecodeAccelerator(
glx_context->display(), make_context_current_));
+#endif
#elif defined(USE_OZONE)
media::MediaOzonePlatform* platform =
media::MediaOzonePlatform::GetInstance();
- video_decode_accelerator_.reset(platform->CreateVideoDecodeAccelerator(
+ decoders[n_decoders++].reset(platform->CreateVideoDecodeAccelerator(
make_context_current_));
- if (!video_decode_accelerator_) {
- SendCreateDecoderReply(init_done_msg, false);
- return;
- }
#elif defined(OS_ANDROID)
- video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator(
+ decoders[n_decoders++].reset(new AndroidVideoDecodeAccelerator(
stub_->decoder()->AsWeakPtr(),
make_context_current_));
#else
@@ -302,17 +304,30 @@ void GpuVideoDecodeAccelerator::Initialize(
return;
#endif
+ for (size_t i = 0; i < n_decoders; ++i) {
+ if (!decoders[i])
+ continue;
+ video_decode_accelerator_ = decoders[i].Pass();
+ if (InitializeDecoder(profile)) {
+ SendCreateDecoderReply(init_done_msg, true);
+ return;
+ }
+ }
+
+ SendCreateDecoderReply(init_done_msg, false);
+}
+
+bool GpuVideoDecodeAccelerator::InitializeDecoder(
+ media::VideoCodecProfile profile) {
+ if (!video_decode_accelerator_.get() ||
+ !video_decode_accelerator_->Initialize(profile, this))
+ return false;
+
if (video_decode_accelerator_->CanDecodeOnIOThread()) {
filter_ = new MessageFilter(this, host_route_id_);
stub_->channel()->AddFilter(filter_.get());
}
-
- if (!video_decode_accelerator_->Initialize(profile, this)) {
- SendCreateDecoderReply(init_done_msg, false);
- return;
- }
-
- SendCreateDecoderReply(init_done_msg, true);
+ return true;
}
// Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is

Powered by Google App Engine
This is Rietveld 408576698