OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "content/common/gpu/gpu_command_buffer_stub.h" | 18 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 19 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h" |
19 #include "gpu/command_buffer/service/texture_manager.h" | 20 #include "gpu/command_buffer/service/texture_manager.h" |
20 #include "gpu/config/gpu_info.h" | 21 #include "gpu/config/gpu_info.h" |
21 #include "ipc/ipc_listener.h" | 22 #include "ipc/ipc_listener.h" |
22 #include "ipc/ipc_sender.h" | 23 #include "ipc/ipc_sender.h" |
23 #include "media/video/video_decode_accelerator.h" | 24 #include "media/video/video_decode_accelerator.h" |
24 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
25 | 26 |
26 namespace gpu { | 27 namespace gpu { |
27 struct GpuPreferences; | 28 struct GpuPreferences; |
28 } // namespace gpu | 29 } // namespace gpu |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Function to delegate sending to actual sender. | 72 // Function to delegate sending to actual sender. |
72 bool Send(IPC::Message* message) override; | 73 bool Send(IPC::Message* message) override; |
73 | 74 |
74 // Initialize VDAs from the set of VDAs supported for current platform until | 75 // Initialize VDAs from the set of VDAs supported for current platform until |
75 // one of them succeeds for given |config|. Send the |init_done_msg| when | 76 // one of them succeeds for given |config|. Send the |init_done_msg| when |
76 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen | 77 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen |
77 // VDA can decode on IO thread. | 78 // VDA can decode on IO thread. |
78 bool Initialize(const media::VideoDecodeAccelerator::Config& config); | 79 bool Initialize(const media::VideoDecodeAccelerator::Config& config); |
79 | 80 |
80 private: | 81 private: |
81 typedef scoped_ptr<media::VideoDecodeAccelerator> ( | |
82 GpuVideoDecodeAccelerator::*CreateVDAFp)(); | |
83 | |
84 class MessageFilter; | 82 class MessageFilter; |
85 | 83 |
86 #if defined(OS_WIN) | |
87 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(); | |
88 #endif | |
89 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
90 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(); | |
91 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SliceVDA(); | |
92 #endif | |
93 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
94 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(); | |
95 #endif | |
96 #if defined(OS_MACOSX) | |
97 scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA(); | |
98 #endif | |
99 #if !defined(OS_CHROMEOS) && defined(USE_OZONE) | |
100 scoped_ptr<media::VideoDecodeAccelerator> CreateOzoneVDA(); | |
101 #endif | |
102 #if defined(OS_ANDROID) | |
103 scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA(); | |
104 #endif | |
105 | |
106 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. | 84 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. |
107 ~GpuVideoDecodeAccelerator() override; | 85 ~GpuVideoDecodeAccelerator() override; |
108 | 86 |
109 // Handlers for IPC messages. | 87 // Handlers for IPC messages. |
110 void OnSetCdm(int cdm_id); | 88 void OnSetCdm(int cdm_id); |
111 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); | 89 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); |
112 void OnAssignPictureBuffers( | 90 void OnAssignPictureBuffers( |
113 const std::vector<int32_t>& buffer_ids, | 91 const std::vector<int32_t>& buffer_ids, |
114 const std::vector<media::PictureBuffer::TextureIds>& texture_ids); | 92 const std::vector<media::PictureBuffer::TextureIds>& texture_ids); |
115 void OnReusePictureBuffer(int32_t picture_buffer_id); | 93 void OnReusePictureBuffer(int32_t picture_buffer_id); |
116 void OnFlush(); | 94 void OnFlush(); |
117 void OnReset(); | 95 void OnReset(); |
118 void OnDestroy(); | 96 void OnDestroy(); |
119 | 97 |
120 // Called on IO thread when |filter_| has been removed. | 98 // Called on IO thread when |filter_| has been removed. |
121 void OnFilterRemoved(); | 99 void OnFilterRemoved(); |
122 | 100 |
123 // Sets the texture to cleared. | 101 // Sets the texture to cleared. |
124 void SetTextureCleared(const media::Picture& picture); | 102 void SetTextureCleared(const media::Picture& picture); |
125 | 103 |
126 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) | |
127 // Helper to bind |image| to the texture specified by |client_texture_id|. If | |
128 // |can_bind_to_sampler| is true, then the image may be used as a sampler | |
129 // directly, otherwise a copy to a staging buffer is required. | |
130 void BindImage(uint32_t client_texture_id, | |
131 uint32_t texture_target, | |
132 scoped_refptr<gl::GLImage> image, | |
133 bool can_bind_to_sampler); | |
134 #endif | |
135 | |
136 // Route ID to communicate with the host. | 104 // Route ID to communicate with the host. |
137 const int32_t host_route_id_; | 105 const int32_t host_route_id_; |
138 | 106 |
139 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is | 107 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is |
140 // registered as a DestuctionObserver of |stub_| and will self-delete when | 108 // registered as a DestuctionObserver of |stub_| and will self-delete when |
141 // |stub_| is destroyed. | 109 // |stub_| is destroyed. |
142 GpuCommandBufferStub* const stub_; | 110 GpuCommandBufferStub* const stub_; |
143 | 111 |
144 // The underlying VideoDecodeAccelerator. | 112 // The underlying VideoDecodeAccelerator. |
145 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 113 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; |
146 | 114 |
| 115 // Callback to return current GLContext, if available. |
| 116 GetGLContextCallback get_gl_context_cb_; |
| 117 |
147 // Callback for making the relevant context current for GL calls. | 118 // Callback for making the relevant context current for GL calls. |
148 // Returns false if failed. | 119 MakeGLContextCurrentCallback make_context_current_cb_; |
149 base::Callback<bool(void)> make_context_current_; | 120 |
| 121 // Callback to bind a GLImage to a given texture id and target. |
| 122 BindGLImageCallback bind_image_cb_; |
| 123 |
| 124 // Callback to return a WeakPtr to GLES2Decoder. |
| 125 GetGLES2DecoderCallback get_gles2_decoder_cb_; |
150 | 126 |
151 // The texture dimensions as requested by ProvidePictureBuffers(). | 127 // The texture dimensions as requested by ProvidePictureBuffers(). |
152 gfx::Size texture_dimensions_; | 128 gfx::Size texture_dimensions_; |
153 | 129 |
154 // The texture target as requested by ProvidePictureBuffers(). | 130 // The texture target as requested by ProvidePictureBuffers(). |
155 uint32_t texture_target_; | 131 uint32_t texture_target_; |
156 | 132 |
157 // The number of textures per picture buffer as requests by | 133 // The number of textures per picture buffer as requests by |
158 // ProvidePictureBuffers() | 134 // ProvidePictureBuffers() |
159 uint32_t textures_per_buffer_; | 135 uint32_t textures_per_buffer_; |
(...skipping 21 matching lines...) Expand all Loading... |
181 | 157 |
182 // A map from picture buffer ID to TextureRef that have not been cleared. | 158 // A map from picture buffer ID to TextureRef that have not been cleared. |
183 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; | 159 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; |
184 | 160 |
185 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 161 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
186 }; | 162 }; |
187 | 163 |
188 } // namespace content | 164 } // namespace content |
189 | 165 |
190 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 166 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |