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