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" | |
20 #include "gpu/command_buffer/service/texture_manager.h" | 19 #include "gpu/command_buffer/service/texture_manager.h" |
21 #include "gpu/config/gpu_info.h" | 20 #include "gpu/config/gpu_info.h" |
22 #include "ipc/ipc_listener.h" | 21 #include "ipc/ipc_listener.h" |
23 #include "ipc/ipc_sender.h" | 22 #include "ipc/ipc_sender.h" |
24 #include "media/video/video_decode_accelerator.h" | 23 #include "media/video/video_decode_accelerator.h" |
25 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
26 | 25 |
27 namespace gpu { | 26 namespace gpu { |
28 struct GpuPreferences; | 27 struct GpuPreferences; |
29 } // namespace gpu | 28 } // namespace gpu |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Function to delegate sending to actual sender. | 70 // Function to delegate sending to actual sender. |
72 bool Send(IPC::Message* message) override; | 71 bool Send(IPC::Message* message) override; |
73 | 72 |
74 // Initialize VDAs from the set of VDAs supported for current platform until | 73 // 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 | 74 // 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 | 75 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen |
77 // VDA can decode on IO thread. | 76 // VDA can decode on IO thread. |
78 bool Initialize(const media::VideoDecodeAccelerator::Config& config); | 77 bool Initialize(const media::VideoDecodeAccelerator::Config& config); |
79 | 78 |
80 private: | 79 private: |
| 80 typedef scoped_ptr<media::VideoDecodeAccelerator> ( |
| 81 GpuVideoDecodeAccelerator::*CreateVDAFp)(); |
| 82 |
81 class MessageFilter; | 83 class MessageFilter; |
82 | 84 |
| 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 |
83 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. | 105 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. |
84 ~GpuVideoDecodeAccelerator() override; | 106 ~GpuVideoDecodeAccelerator() override; |
85 | 107 |
86 // Handlers for IPC messages. | 108 // Handlers for IPC messages. |
87 void OnSetCdm(int cdm_id); | 109 void OnSetCdm(int cdm_id); |
88 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); | 110 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); |
89 void OnAssignPictureBuffers(const std::vector<int32_t>& buffer_ids, | 111 void OnAssignPictureBuffers(const std::vector<int32_t>& buffer_ids, |
90 const std::vector<uint32_t>& texture_ids); | 112 const std::vector<uint32_t>& texture_ids); |
91 void OnReusePictureBuffer(int32_t picture_buffer_id); | 113 void OnReusePictureBuffer(int32_t picture_buffer_id); |
92 void OnFlush(); | 114 void OnFlush(); |
93 void OnReset(); | 115 void OnReset(); |
94 void OnDestroy(); | 116 void OnDestroy(); |
95 | 117 |
96 // Called on IO thread when |filter_| has been removed. | 118 // Called on IO thread when |filter_| has been removed. |
97 void OnFilterRemoved(); | 119 void OnFilterRemoved(); |
98 | 120 |
99 // Sets the texture to cleared. | 121 // Sets the texture to cleared. |
100 void SetTextureCleared(const media::Picture& picture); | 122 void SetTextureCleared(const media::Picture& picture); |
101 | 123 |
| 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 |
102 // Route ID to communicate with the host. | 134 // Route ID to communicate with the host. |
103 const int32_t host_route_id_; | 135 const int32_t host_route_id_; |
104 | 136 |
105 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is | 137 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is |
106 // registered as a DestuctionObserver of |stub_| and will self-delete when | 138 // registered as a DestuctionObserver of |stub_| and will self-delete when |
107 // |stub_| is destroyed. | 139 // |stub_| is destroyed. |
108 GpuCommandBufferStub* const stub_; | 140 GpuCommandBufferStub* const stub_; |
109 | 141 |
110 // The underlying VideoDecodeAccelerator. | 142 // The underlying VideoDecodeAccelerator. |
111 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 143 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; |
112 | 144 |
113 // Callback to return current GLContext, if available. | |
114 GetGLContextCallback get_gl_context_cb_; | |
115 | |
116 // Callback for making the relevant context current for GL calls. | 145 // Callback for making the relevant context current for GL calls. |
117 MakeGLContextCurrentCallback make_context_current_cb_; | 146 // Returns false if failed. |
118 | 147 base::Callback<bool(void)> make_context_current_; |
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_; | |
124 | 148 |
125 // The texture dimensions as requested by ProvidePictureBuffers(). | 149 // The texture dimensions as requested by ProvidePictureBuffers(). |
126 gfx::Size texture_dimensions_; | 150 gfx::Size texture_dimensions_; |
127 | 151 |
128 // The texture target as requested by ProvidePictureBuffers(). | 152 // The texture target as requested by ProvidePictureBuffers(). |
129 uint32_t texture_target_; | 153 uint32_t texture_target_; |
130 | 154 |
131 // The message filter to run VDA::Decode on IO thread if VDA supports it. | 155 // The message filter to run VDA::Decode on IO thread if VDA supports it. |
132 scoped_refptr<MessageFilter> filter_; | 156 scoped_refptr<MessageFilter> filter_; |
133 | 157 |
(...skipping 17 matching lines...) Expand all Loading... |
151 | 175 |
152 // A map from picture buffer ID to TextureRef that have not been cleared. | 176 // A map from picture buffer ID to TextureRef that have not been cleared. |
153 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; | 177 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; |
154 | 178 |
155 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 179 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
156 }; | 180 }; |
157 | 181 |
158 } // namespace content | 182 } // namespace content |
159 | 183 |
160 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 184 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |