| Index: content/public/gpu/gpu_video_decode_accelerator_factory.h
|
| diff --git a/content/public/gpu/gpu_video_decode_accelerator_factory.h b/content/public/gpu/gpu_video_decode_accelerator_factory.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..28ffa6512ba6c5e801bbc3440944204479bf5142
|
| --- /dev/null
|
| +++ b/content/public/gpu/gpu_video_decode_accelerator_factory.h
|
| @@ -0,0 +1,127 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_
|
| +#define CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "content/common/content_export.h"
|
| +#include "gpu/config/gpu_info.h"
|
| +#include "media/video/video_decode_accelerator.h"
|
| +
|
| +namespace gfx {
|
| +class GLContext;
|
| +}
|
| +
|
| +namespace gl {
|
| +class GLImage;
|
| +}
|
| +
|
| +namespace gpu {
|
| +struct GpuPreferences;
|
| +
|
| +namespace gles2 {
|
| +class GLES2Decoder;
|
| +}
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +// This factory allows creation of VideoDecodeAccelerator implementations,
|
| +// providing the most applicable VDA for current platform and given
|
| +// configuration. To be used in GPU process only.
|
| +class CONTENT_EXPORT GpuVideoDecodeAcceleratorFactory {
|
| + public:
|
| + ~GpuVideoDecodeAcceleratorFactory();
|
| +
|
| + // Return current GLContext.
|
| + using GetGLContextCallback = base::Callback<gfx::GLContext*(void)>;
|
| +
|
| + // Make the applicable GL context current. To be called by VDAs before
|
| + // executing any GL calls. Return true on success, false otherwise.
|
| + using MakeGLContextCurrentCallback = base::Callback<bool(void)>;
|
| +
|
| + // Bind |image| to |client_texture_id| given |texture_target|.
|
| + // Return true on success, false otherwise.
|
| + using BindGLImageCallback =
|
| + base::Callback<bool(uint32_t client_texture_id,
|
| + uint32_t texture_target,
|
| + const scoped_refptr<gl::GLImage>& image)>;
|
| +
|
| + // Return a WeakPtr to a GLES2Decoder, if one is available.
|
| + using GetGLES2DecoderCallback =
|
| + base::Callback<base::WeakPtr<gpu::gles2::GLES2Decoder>(void)>;
|
| +
|
| + // Create a factory capable of producing VDA instances for current platform.
|
| + static scoped_ptr<GpuVideoDecodeAcceleratorFactory> Create(
|
| + const GetGLContextCallback& get_gl_context_cb,
|
| + const MakeGLContextCurrentCallback& make_context_current_cb,
|
| + const BindGLImageCallback& bind_image_cb);
|
| +
|
| + static scoped_ptr<GpuVideoDecodeAcceleratorFactory> CreateWithGLES2Decoder(
|
| + const GetGLContextCallback& get_gl_context_cb,
|
| + const MakeGLContextCurrentCallback& make_context_current_cb,
|
| + const BindGLImageCallback& bind_image_cb,
|
| + const GetGLES2DecoderCallback& get_gles2_decoder_cb);
|
| +
|
| + // Return decoder capabilities supported on the current platform.
|
| + static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities(
|
| + const gpu::GpuPreferences& gpu_preferences);
|
| +
|
| + // Create a VDA for the current platform for |client| with the given |config|
|
| + // and for given |gpu_preferences|. Return nullptr on failure.
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateVDA(
|
| + media::VideoDecodeAccelerator::Client* client,
|
| + const media::VideoDecodeAccelerator::Config& config,
|
| + const gpu::GpuPreferences& gpu_preferences);
|
| +
|
| + private:
|
| + GpuVideoDecodeAcceleratorFactory(
|
| + const GetGLContextCallback& get_gl_context_cb,
|
| + const MakeGLContextCurrentCallback& make_context_current_cb,
|
| + const BindGLImageCallback& bind_image_cb,
|
| + const GetGLES2DecoderCallback& get_gles2_decoder_cb);
|
| +
|
| +#if defined(OS_WIN)
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(
|
| + const gpu::GpuPreferences& gpu_preferences) const;
|
| +#endif
|
| +#if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(
|
| + const gpu::GpuPreferences& gpu_preferences) const;
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SVDA(
|
| + const gpu::GpuPreferences& gpu_preferences) const;
|
| +#endif
|
| +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(
|
| + const gpu::GpuPreferences& gpu_preferences) const;
|
| +#endif
|
| +#if defined(OS_MACOSX)
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA(
|
| + const gpu::GpuPreferences& gpu_preferences) const;
|
| +#endif
|
| +#if !defined(OS_CHROMEOS) && defined(USE_OZONE)
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateOzoneVDA(
|
| + const gpu::GpuPreferences& gpu_preferences) const;
|
| +#endif
|
| +#if defined(OS_ANDROID)
|
| + scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA(
|
| + const gpu::GpuPreferences& gpu_preferences) const;
|
| +#endif
|
| +
|
| + const GetGLContextCallback get_gl_context_cb_;
|
| + const MakeGLContextCurrentCallback make_context_current_cb_;
|
| + const BindGLImageCallback bind_image_cb_;
|
| + const GetGLES2DecoderCallback get_gles2_decoder_cb_;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAcceleratorFactory);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_
|
|
|