OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_ |
| 6 #define CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/threading/thread_checker.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "gpu/config/gpu_info.h" |
| 13 #include "media/video/video_decode_accelerator.h" |
| 14 |
| 15 namespace gfx { |
| 16 class GLContext; |
| 17 } |
| 18 |
| 19 namespace gl { |
| 20 class GLImage; |
| 21 } |
| 22 |
| 23 namespace gpu { |
| 24 struct GpuPreferences; |
| 25 |
| 26 namespace gles2 { |
| 27 class GLES2Decoder; |
| 28 } |
| 29 } |
| 30 |
| 31 namespace content { |
| 32 |
| 33 // This factory allows creation of VideoDecodeAccelerator implementations, |
| 34 // providing the most applicable VDA for current platform and given |
| 35 // configuration. To be used in GPU process only. |
| 36 class CONTENT_EXPORT GpuVideoDecodeAcceleratorFactory { |
| 37 public: |
| 38 ~GpuVideoDecodeAcceleratorFactory(); |
| 39 |
| 40 // Return current GLContext. |
| 41 using GetGLContextCallback = base::Callback<gfx::GLContext*(void)>; |
| 42 |
| 43 // Make the applicable GL context current. To be called by VDAs before |
| 44 // executing any GL calls. Return true on success, false otherwise. |
| 45 using MakeGLContextCurrentCallback = base::Callback<bool(void)>; |
| 46 |
| 47 // Bind |image| to |client_texture_id| given |texture_target|. |
| 48 // Return true on success, false otherwise. |
| 49 using BindGLImageCallback = |
| 50 base::Callback<bool(uint32_t client_texture_id, |
| 51 uint32_t texture_target, |
| 52 const scoped_refptr<gl::GLImage>& image)>; |
| 53 |
| 54 // Return a WeakPtr to a GLES2Decoder, if one is available. |
| 55 using GetGLES2DecoderCallback = |
| 56 base::Callback<base::WeakPtr<gpu::gles2::GLES2Decoder>(void)>; |
| 57 |
| 58 // Create a factory capable of producing VDA instances for current platform. |
| 59 static scoped_ptr<GpuVideoDecodeAcceleratorFactory> Create( |
| 60 const GetGLContextCallback& get_gl_context_cb, |
| 61 const MakeGLContextCurrentCallback& make_context_current_cb, |
| 62 const BindGLImageCallback& bind_image_cb); |
| 63 |
| 64 static scoped_ptr<GpuVideoDecodeAcceleratorFactory> CreateWithGLES2Decoder( |
| 65 const GetGLContextCallback& get_gl_context_cb, |
| 66 const MakeGLContextCurrentCallback& make_context_current_cb, |
| 67 const BindGLImageCallback& bind_image_cb, |
| 68 const GetGLES2DecoderCallback& get_gles2_decoder_cb); |
| 69 |
| 70 // Return decoder capabilities supported on the current platform. |
| 71 static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities( |
| 72 const gpu::GpuPreferences& gpu_preferences); |
| 73 |
| 74 // Create a VDA for the current platform for |client| with the given |config| |
| 75 // and for given |gpu_preferences|. Return nullptr on failure. |
| 76 scoped_ptr<media::VideoDecodeAccelerator> CreateVDA( |
| 77 media::VideoDecodeAccelerator::Client* client, |
| 78 const media::VideoDecodeAccelerator::Config& config, |
| 79 const gpu::GpuPreferences& gpu_preferences); |
| 80 |
| 81 private: |
| 82 GpuVideoDecodeAcceleratorFactory( |
| 83 const GetGLContextCallback& get_gl_context_cb, |
| 84 const MakeGLContextCurrentCallback& make_context_current_cb, |
| 85 const BindGLImageCallback& bind_image_cb, |
| 86 const GetGLES2DecoderCallback& get_gles2_decoder_cb); |
| 87 |
| 88 #if defined(OS_WIN) |
| 89 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA( |
| 90 const gpu::GpuPreferences& gpu_preferences) const; |
| 91 #endif |
| 92 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
| 93 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA( |
| 94 const gpu::GpuPreferences& gpu_preferences) const; |
| 95 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SVDA( |
| 96 const gpu::GpuPreferences& gpu_preferences) const; |
| 97 #endif |
| 98 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 99 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA( |
| 100 const gpu::GpuPreferences& gpu_preferences) const; |
| 101 #endif |
| 102 #if defined(OS_MACOSX) |
| 103 scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA( |
| 104 const gpu::GpuPreferences& gpu_preferences) const; |
| 105 #endif |
| 106 #if !defined(OS_CHROMEOS) && defined(USE_OZONE) |
| 107 scoped_ptr<media::VideoDecodeAccelerator> CreateOzoneVDA( |
| 108 const gpu::GpuPreferences& gpu_preferences) const; |
| 109 #endif |
| 110 #if defined(OS_ANDROID) |
| 111 scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA( |
| 112 const gpu::GpuPreferences& gpu_preferences) const; |
| 113 #endif |
| 114 |
| 115 const GetGLContextCallback get_gl_context_cb_; |
| 116 const MakeGLContextCurrentCallback make_context_current_cb_; |
| 117 const BindGLImageCallback bind_image_cb_; |
| 118 const GetGLES2DecoderCallback get_gles2_decoder_cb_; |
| 119 |
| 120 base::ThreadChecker thread_checker_; |
| 121 |
| 122 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAcceleratorFactory); |
| 123 }; |
| 124 |
| 125 } // namespace content |
| 126 |
| 127 #endif // CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_ |
OLD | NEW |