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 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 // Helper function to call NotifyError in the |child_task_runner_| thread. | 97 // Helper function to call NotifyError in the |child_task_runner_| thread. |
113 void CallOrPostNotifyError(media::VideoDecodeAccelerator::Error error); | 98 void CallOrPostNotifyError(media::VideoDecodeAccelerator::Error error); |
114 | 99 |
115 // Route ID to communicate with the host. | 100 // Route ID to communicate with the host. |
116 const int32_t host_route_id_; | 101 const int32_t host_route_id_; |
117 | 102 |
118 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is | 103 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is |
119 // registered as a DestuctionObserver of |stub_| and will self-delete when | 104 // registered as a DestuctionObserver of |stub_| and will self-delete when |
120 // |stub_| is destroyed. | 105 // |stub_| is destroyed. |
121 GpuCommandBufferStub* const stub_; | 106 GpuCommandBufferStub* const stub_; |
122 | 107 |
123 // The underlying VideoDecodeAccelerator. | 108 // The underlying VideoDecodeAccelerator. |
124 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 109 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; |
125 | 110 |
| 111 // Callback to return current GLContext, if available. |
| 112 GetGLContextCallback get_gl_context_cb_; |
| 113 |
126 // Callback for making the relevant context current for GL calls. | 114 // Callback for making the relevant context current for GL calls. |
127 // Returns false if failed. | 115 MakeGLContextCurrentCallback make_context_current_cb_; |
128 base::Callback<bool(void)> make_context_current_; | 116 |
| 117 // Callback to bind a GLImage to a given texture id and target. |
| 118 BindGLImageCallback bind_image_cb_; |
| 119 |
| 120 // Callback to return a WeakPtr to GLES2Decoder. |
| 121 GetGLES2DecoderCallback get_gles2_decoder_cb_; |
129 | 122 |
130 // The texture dimensions as requested by ProvidePictureBuffers(). | 123 // The texture dimensions as requested by ProvidePictureBuffers(). |
131 gfx::Size texture_dimensions_; | 124 gfx::Size texture_dimensions_; |
132 | 125 |
133 // The texture target as requested by ProvidePictureBuffers(). | 126 // The texture target as requested by ProvidePictureBuffers(). |
134 uint32_t texture_target_; | 127 uint32_t texture_target_; |
135 | 128 |
136 // The message filter to run VDA::Decode on IO thread if VDA supports it. | 129 // The message filter to run VDA::Decode on IO thread if VDA supports it. |
137 scoped_refptr<MessageFilter> filter_; | 130 scoped_refptr<MessageFilter> filter_; |
138 | 131 |
(...skipping 17 matching lines...) Expand all Loading... |
156 | 149 |
157 // A map from picture buffer ID to TextureRef that have not been cleared. | 150 // A map from picture buffer ID to TextureRef that have not been cleared. |
158 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; | 151 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; |
159 | 152 |
160 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 153 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
161 }; | 154 }; |
162 | 155 |
163 } // namespace content | 156 } // namespace content |
164 | 157 |
165 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 158 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |