| 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..ba055148b100d2dcdca73fe7f264ffe531ccfdb1 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"
|
| @@ -245,74 +247,127 @@ void GpuVideoDecodeAccelerator::Initialize(
|
| }
|
| #endif
|
|
|
| + std::vector<GpuVideoDecodeAccelerator::CreateVDACb>
|
| + create_vda_cbs = CreateVDACbs();
|
| +
|
| + for (size_t i = 0; i < create_vda_cbs.size(); ++i) {
|
| + video_decode_accelerator_ = create_vda_cbs[i].Run();
|
| + if (!video_decode_accelerator_ ||
|
| + !video_decode_accelerator_->Initialize(profile, this))
|
| + continue;
|
| +
|
| + if (video_decode_accelerator_->CanDecodeOnIOThread()) {
|
| + filter_ = new MessageFilter(this, host_route_id_);
|
| + stub_->channel()->AddFilter(filter_.get());
|
| + }
|
| + SendCreateDecoderReply(init_done_msg, true);
|
| + return;
|
| + }
|
| + video_decode_accelerator_.reset();
|
| + NOTIMPLEMENTED() << "HW video decode acceleration not available.";
|
| + SendCreateDecoderReply(init_done_msg, false);
|
| +}
|
| +
|
| +std::vector<GpuVideoDecodeAccelerator::CreateVDACb>
|
| +GpuVideoDecodeAccelerator::CreateVDACbs() {
|
| + std::vector<GpuVideoDecodeAccelerator::CreateVDACb> create_vda_cbs;
|
| + create_vda_cbs.push_back(base::Bind(
|
| + &GpuVideoDecodeAccelerator::CreateDXVAVDA, base::Unretained(this)));
|
| + create_vda_cbs.push_back(base::Bind(
|
| + &GpuVideoDecodeAccelerator::CreateV4L2VDA, base::Unretained(this)));
|
| + create_vda_cbs.push_back(base::Bind(
|
| + &GpuVideoDecodeAccelerator::CreateVaapiVDA, base::Unretained(this)));
|
| + create_vda_cbs.push_back(base::Bind(
|
| + &GpuVideoDecodeAccelerator::CreateVTVDA, base::Unretained(this)));
|
| + create_vda_cbs.push_back(base::Bind(
|
| + &GpuVideoDecodeAccelerator::CreateAndroidVDA,
|
| + base::Unretained(this)));
|
| + create_vda_cbs.push_back(base::Bind(
|
| + &GpuVideoDecodeAccelerator::CreateOzoneVDA, base::Unretained(this)));
|
| + return create_vda_cbs;
|
| +}
|
| +
|
| +scoped_ptr<media::VideoDecodeAccelerator>
|
| +GpuVideoDecodeAccelerator::CreateDXVAVDA() {
|
| + scoped_ptr<media::VideoDecodeAccelerator> decoder;
|
| #if defined(OS_WIN)
|
| - if (base::win::GetVersion() < base::win::VERSION_WIN7) {
|
| + if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
|
| + DVLOG(0) << "Initializing DXVA HW decoder for windows.";
|
| + decoder.reset(new DXVAVideoDecodeAccelerator(make_context_current_));
|
| + } else {
|
| NOTIMPLEMENTED() << "HW video decode acceleration not available.";
|
| - SendCreateDecoderReply(init_done_msg, false);
|
| - return;
|
| }
|
| - DVLOG(0) << "Initializing DXVA HW decoder for windows.";
|
| - video_decode_accelerator_.reset(
|
| - new DXVAVideoDecodeAccelerator(make_context_current_));
|
| -#elif defined(OS_MACOSX)
|
| - video_decode_accelerator_.reset(new VTVideoDecodeAccelerator(
|
| - static_cast<CGLContextObj>(
|
| - stub_->decoder()->GetGLContext()->GetHandle()),
|
| - make_context_current_));
|
| -#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
|
| +#endif
|
| + return decoder.Pass();
|
| +}
|
| +
|
| +scoped_ptr<media::VideoDecodeAccelerator>
|
| +GpuVideoDecodeAccelerator::CreateV4L2VDA() {
|
| + scoped_ptr<media::VideoDecodeAccelerator> decoder;
|
| +#if 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()) {
|
| + decoder.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)
|
| +#endif
|
| + return decoder.Pass();
|
| +}
|
| +
|
| +scoped_ptr<media::VideoDecodeAccelerator>
|
| +GpuVideoDecodeAccelerator::CreateVaapiVDA() {
|
| + scoped_ptr<media::VideoDecodeAccelerator> decoder;
|
| +#if defined(OS_CHROMEOS) && defined(USE_X11) && defined(ARCH_CPU_X86_FAMILY)
|
| if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {
|
| VLOG(1) << "HW video decode acceleration not available without "
|
| "DesktopGL (GLX).";
|
| - SendCreateDecoderReply(init_done_msg, false);
|
| - return;
|
| + return decoder.Pass();
|
| }
|
| gfx::GLContextGLX* glx_context =
|
| static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext());
|
| - video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator(
|
| + decoder.reset(new VaapiVideoDecodeAccelerator(
|
| glx_context->display(), make_context_current_));
|
| -#elif defined(USE_OZONE)
|
| - media::MediaOzonePlatform* platform =
|
| - media::MediaOzonePlatform::GetInstance();
|
| - video_decode_accelerator_.reset(platform->CreateVideoDecodeAccelerator(
|
| +#endif
|
| + return decoder.Pass();
|
| +}
|
| +
|
| +scoped_ptr<media::VideoDecodeAccelerator>
|
| +GpuVideoDecodeAccelerator::CreateVTVDA() {
|
| + scoped_ptr<media::VideoDecodeAccelerator> decoder;
|
| +#if defined(OS_MACOSX)
|
| + decoder.reset(new VTVideoDecodeAccelerator(
|
| + static_cast<CGLContextObj>(stub_->decoder()->GetGLContext()->GetHandle()),
|
| make_context_current_));
|
| - if (!video_decode_accelerator_) {
|
| - SendCreateDecoderReply(init_done_msg, false);
|
| - return;
|
| - }
|
| -#elif defined(OS_ANDROID)
|
| - video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator(
|
| +#endif
|
| + return decoder.Pass();
|
| +}
|
| +
|
| +scoped_ptr<media::VideoDecodeAccelerator>
|
| +GpuVideoDecodeAccelerator::CreateAndroidVDA() {
|
| + scoped_ptr<media::VideoDecodeAccelerator> decoder;
|
| +#if defined(OS_ANDROID)
|
| + decoder.reset(new AndroidVideoDecodeAccelerator(
|
| stub_->decoder()->AsWeakPtr(),
|
| make_context_current_));
|
| -#else
|
| - NOTIMPLEMENTED() << "HW video decode acceleration not available.";
|
| - SendCreateDecoderReply(init_done_msg, false);
|
| - return;
|
| #endif
|
| + return decoder.Pass();
|
| +}
|
|
|
| - 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);
|
| +scoped_ptr<media::VideoDecodeAccelerator>
|
| +GpuVideoDecodeAccelerator::CreateOzoneVDA() {
|
| + scoped_ptr<media::VideoDecodeAccelerator> decoder;
|
| +#if defined(USE_OZONE)
|
| + media::MediaOzonePlatform* platform =
|
| + media::MediaOzonePlatform::GetInstance();
|
| + decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_));
|
| +#endif
|
| + return decoder.Pass();
|
| }
|
|
|
| // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is
|
|
|