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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Function to delegate sending to actual sender. | 71 // Function to delegate sending to actual sender. |
71 bool Send(IPC::Message* message) override; | 72 bool Send(IPC::Message* message) override; |
72 | 73 |
73 // Initialize VDAs from the set of VDAs supported for current platform until | 74 // Initialize VDAs from the set of VDAs supported for current platform until |
74 // one of them succeeds for given |config|. Send the |init_done_msg| when | 75 // one of them succeeds for given |config|. Send the |init_done_msg| when |
75 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen | 76 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen |
76 // VDA can decode on IO thread. | 77 // VDA can decode on IO thread. |
77 bool Initialize(const media::VideoDecodeAccelerator::Config& config); | 78 bool Initialize(const media::VideoDecodeAccelerator::Config& config); |
78 | 79 |
79 private: | 80 private: |
80 typedef scoped_ptr<media::VideoDecodeAccelerator> ( | |
81 GpuVideoDecodeAccelerator::*CreateVDAFp)(); | |
82 | |
83 class MessageFilter; | 81 class MessageFilter; |
84 | 82 |
85 #if defined(OS_WIN) | |
86 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(); | |
87 #endif | |
88 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
89 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(); | |
90 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SliceVDA(); | |
91 #endif | |
92 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
93 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(); | |
94 #endif | |
95 #if defined(OS_MACOSX) | |
96 scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA(); | |
97 #endif | |
98 #if !defined(OS_CHROMEOS) && defined(USE_OZONE) | |
99 scoped_ptr<media::VideoDecodeAccelerator> CreateOzoneVDA(); | |
100 #endif | |
101 #if defined(OS_ANDROID) | |
102 scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA(); | |
103 #endif | |
104 | |
105 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. | 83 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. |
106 ~GpuVideoDecodeAccelerator() override; | 84 ~GpuVideoDecodeAccelerator() override; |
107 | 85 |
108 // Handlers for IPC messages. | 86 // Handlers for IPC messages. |
109 void OnSetCdm(int cdm_id); | 87 void OnSetCdm(int cdm_id); |
110 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); | 88 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); |
111 void OnAssignPictureBuffers(const std::vector<int32_t>& buffer_ids, | 89 void OnAssignPictureBuffers(const std::vector<int32_t>& buffer_ids, |
112 const std::vector<uint32_t>& texture_ids); | 90 const std::vector<uint32_t>& texture_ids); |
113 void OnReusePictureBuffer(int32_t picture_buffer_id); | 91 void OnReusePictureBuffer(int32_t picture_buffer_id); |
114 void OnFlush(); | 92 void OnFlush(); |
115 void OnReset(); | 93 void OnReset(); |
116 void OnDestroy(); | 94 void OnDestroy(); |
117 | 95 |
118 // Called on IO thread when |filter_| has been removed. | 96 // Called on IO thread when |filter_| has been removed. |
119 void OnFilterRemoved(); | 97 void OnFilterRemoved(); |
120 | 98 |
121 // Sets the texture to cleared. | 99 // Sets the texture to cleared. |
122 void SetTextureCleared(const media::Picture& picture); | 100 void SetTextureCleared(const media::Picture& picture); |
123 | 101 |
124 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) | |
125 // Helper to bind |image| to the texture specified by |client_texture_id|. If | |
126 // |can_bind_to_sampler| is true, then the image may be used as a sampler | |
127 // directly, otherwise a copy to a staging buffer is required. | |
128 void BindImage(uint32_t client_texture_id, | |
129 uint32_t texture_target, | |
130 scoped_refptr<gl::GLImage> image, | |
131 bool can_bind_to_sampler); | |
132 #endif | |
133 | |
134 // Route ID to communicate with the host. | 102 // Route ID to communicate with the host. |
135 const int32_t host_route_id_; | 103 const int32_t host_route_id_; |
136 | 104 |
137 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is | 105 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is |
138 // registered as a DestuctionObserver of |stub_| and will self-delete when | 106 // registered as a DestuctionObserver of |stub_| and will self-delete when |
139 // |stub_| is destroyed. | 107 // |stub_| is destroyed. |
140 GpuCommandBufferStub* const stub_; | 108 GpuCommandBufferStub* const stub_; |
141 | 109 |
142 // The underlying VideoDecodeAccelerator. | 110 // The underlying VideoDecodeAccelerator. |
143 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 111 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; |
144 | 112 |
| 113 // Callback to return current GLContext, if available. |
| 114 GetGLContextCallback get_gl_context_cb_; |
| 115 |
145 // Callback for making the relevant context current for GL calls. | 116 // Callback for making the relevant context current for GL calls. |
146 // Returns false if failed. | 117 MakeGLContextCurrentCallback make_context_current_cb_; |
147 base::Callback<bool(void)> make_context_current_; | 118 |
| 119 // Callback to bind a GLImage to a given texture id and target. |
| 120 BindGLImageCallback bind_image_cb_; |
| 121 |
| 122 // Callback to return a WeakPtr to GLES2Decoder. |
| 123 GetGLES2DecoderCallback get_gles2_decoder_cb_; |
148 | 124 |
149 // The texture dimensions as requested by ProvidePictureBuffers(). | 125 // The texture dimensions as requested by ProvidePictureBuffers(). |
150 gfx::Size texture_dimensions_; | 126 gfx::Size texture_dimensions_; |
151 | 127 |
152 // The texture target as requested by ProvidePictureBuffers(). | 128 // The texture target as requested by ProvidePictureBuffers(). |
153 uint32_t texture_target_; | 129 uint32_t texture_target_; |
154 | 130 |
155 // The message filter to run VDA::Decode on IO thread if VDA supports it. | 131 // The message filter to run VDA::Decode on IO thread if VDA supports it. |
156 scoped_refptr<MessageFilter> filter_; | 132 scoped_refptr<MessageFilter> filter_; |
157 | 133 |
(...skipping 17 matching lines...) Expand all Loading... |
175 | 151 |
176 // A map from picture buffer ID to TextureRef that have not been cleared. | 152 // A map from picture buffer ID to TextureRef that have not been cleared. |
177 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; | 153 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; |
178 | 154 |
179 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 155 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
180 }; | 156 }; |
181 | 157 |
182 } // namespace content | 158 } // namespace content |
183 | 159 |
184 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 160 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |