Chromium Code Reviews| 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 3d3a437751177dc61f38356e8e6d6ac9faf5911d..4943b97994524e841f7cf9dc669a71a6b59d9114 100644 |
| --- a/content/common/gpu/media/gpu_video_decode_accelerator.cc |
| +++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc |
| @@ -28,12 +28,15 @@ |
| #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| #elif defined(OS_MACOSX) |
| #include "content/common/gpu/media/vt_video_decode_accelerator.h" |
| -#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
| +#elif defined(OS_CHROMEOS) |
| +#if defined(USE_OZONE) || defined(ARCH_CPU_ARMEL) |
| #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) |
| +#endif // defined(USE_OZONE) || defined(ARCH_CPU_ARMEL) |
| +#if defined(ARCH_CPU_X86_FAMILY) |
| #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
| #include "ui/gl/gl_implementation.h" |
| +#endif // defined(ARCH_CPU_X86_FAMILY) |
| #elif defined(USE_OZONE) |
| #include "media/ozone/media_ozone_platform.h" |
| #elif defined(OS_ANDROID) |
| @@ -244,66 +247,118 @@ 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; |
|
piman
2015/01/05 23:50:05
This seems overkill to allocate a vector and fill
henryhsu
2015/01/06 08:13:40
CreateDXVAVDA functions are private and not static
|
| + 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::CreateOzoneVDA, base::Unretained(this))); |
| + create_vda_cbs.push_back(base::Bind( |
| + &GpuVideoDecodeAccelerator::CreateAndroidVDA, |
| + 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_OZONE) || 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) |
| - video_decode_accelerator_.reset( |
| - new VaapiVideoDecodeAccelerator(make_context_current_)); |
| -#elif defined(USE_OZONE) |
| +#endif |
| + return decoder.Pass(); |
| +} |
| + |
| +scoped_ptr<media::VideoDecodeAccelerator> |
| +GpuVideoDecodeAccelerator::CreateVaapiVDA() { |
| + scoped_ptr<media::VideoDecodeAccelerator> decoder; |
| +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| + decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_)); |
| +#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_)); |
| +#endif |
| + return decoder.Pass(); |
| +} |
| + |
| +scoped_ptr<media::VideoDecodeAccelerator> |
| +GpuVideoDecodeAccelerator::CreateOzoneVDA() { |
| + scoped_ptr<media::VideoDecodeAccelerator> decoder; |
| +#if !defined(OS_CHROMEOS) && defined(USE_OZONE) |
| media::MediaOzonePlatform* platform = |
| media::MediaOzonePlatform::GetInstance(); |
| - video_decode_accelerator_.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( |
| + decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); |
| +#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 |
| - |
| - 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 decoder.Pass(); |
| } |
| // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |