OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
20 #include "base/shared_memory.h" | 20 #include "base/shared_memory.h" |
21 #include "media/video/video_decode_accelerator.h" | 21 #include "media/video/video_decode_accelerator.h" |
22 #include "third_party/angle/include/EGL/egl.h" | 22 #include "third_party/angle/include/EGL/egl.h" |
| 23 #include "third_party/angle/include/EGL/eglext.h" |
23 #include "third_party/openmax/il/OMX_Component.h" | 24 #include "third_party/openmax/il/OMX_Component.h" |
24 #include "third_party/openmax/il/OMX_Core.h" | 25 #include "third_party/openmax/il/OMX_Core.h" |
25 #include "third_party/openmax/il/OMX_Video.h" | 26 #include "third_party/openmax/il/OMX_Video.h" |
26 | 27 |
27 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. | 28 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. |
28 // The implementation assumes an OpenMAX IL 1.1.2 implementation conforming to | 29 // The implementation assumes an OpenMAX IL 1.1.2 implementation conforming to |
29 // http://www.khronos.org/registry/omxil/specs/OpenMAX_IL_1_1_2_Specification.pd
f | 30 // http://www.khronos.org/registry/omxil/specs/OpenMAX_IL_1_1_2_Specification.pd
f |
30 // | 31 // |
31 // This class lives on a single thread and DCHECKs that it is never accessed | 32 // This class lives on a single thread and DCHECKs that it is never accessed |
32 // from any other. OMX callbacks are trampolined from the OMX component's | 33 // from any other. OMX callbacks are trampolined from the OMX component's |
(...skipping 16 matching lines...) Expand all Loading... |
49 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 50 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
50 void Flush() OVERRIDE; | 51 void Flush() OVERRIDE; |
51 void Abort() OVERRIDE; | 52 void Abort() OVERRIDE; |
52 | 53 |
53 void SetEglState(EGLDisplay egl_display, EGLContext egl_context); | 54 void SetEglState(EGLDisplay egl_display, EGLContext egl_context); |
54 | 55 |
55 private: | 56 private: |
56 // Helper struct for keeping track of the relationship between an OMX output | 57 // Helper struct for keeping track of the relationship between an OMX output |
57 // buffer and the GLESBuffer it points to. | 58 // buffer and the GLESBuffer it points to. |
58 struct OutputPicture { | 59 struct OutputPicture { |
59 OutputPicture(media::GLESBuffer g_b, OMX_BUFFERHEADERTYPE* o_b_h) | 60 OutputPicture(media::GLESBuffer g_b, OMX_BUFFERHEADERTYPE* o_b_h, |
60 : gles_buffer(g_b), omx_buffer_header(o_b_h) {} | 61 EGLImageKHR e_i) |
| 62 : gles_buffer(g_b), omx_buffer_header(o_b_h), egl_image(e_i) {} |
61 media::GLESBuffer gles_buffer; | 63 media::GLESBuffer gles_buffer; |
62 OMX_BUFFERHEADERTYPE* omx_buffer_header; | 64 OMX_BUFFERHEADERTYPE* omx_buffer_header; |
| 65 EGLImageKHR egl_image; |
63 }; | 66 }; |
64 typedef std::map<int32, OutputPicture> OutputPictureById; | 67 typedef std::map<int32, OutputPicture> OutputPictureById; |
65 | 68 |
66 MessageLoop* message_loop_; | 69 MessageLoop* message_loop_; |
67 OMX_HANDLETYPE component_handle_; | 70 OMX_HANDLETYPE component_handle_; |
68 | 71 |
69 // Create the Component for OMX. Handles all OMX initialization. | 72 // Create the Component for OMX. Handles all OMX initialization. |
70 bool CreateComponent(); | 73 bool CreateComponent(); |
71 // Buffer allocation/free methods for input and output buffers. | 74 // Buffer allocation/free methods for input and output buffers. |
72 bool AllocateInputBuffers(); | 75 bool AllocateInputBuffers(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // To kick the component from Loaded to Idle before we know the real size of | 135 // To kick the component from Loaded to Idle before we know the real size of |
133 // the video (so can't yet ask for textures) we populate it with fake output | 136 // the video (so can't yet ask for textures) we populate it with fake output |
134 // buffers. Keep track of them here. | 137 // buffers. Keep track of them here. |
135 // TODO(fischman): do away with this madness. | 138 // TODO(fischman): do away with this madness. |
136 std::set<OMX_BUFFERHEADERTYPE*> fake_output_buffers_; | 139 std::set<OMX_BUFFERHEADERTYPE*> fake_output_buffers_; |
137 | 140 |
138 // To expose client callbacks from VideoDecodeAccelerator. | 141 // To expose client callbacks from VideoDecodeAccelerator. |
139 // NOTE: all calls to this object *MUST* be executed in message_loop_. | 142 // NOTE: all calls to this object *MUST* be executed in message_loop_. |
140 Client* client_; | 143 Client* client_; |
141 | 144 |
142 std::vector<uint32> texture_ids_; | |
143 std::vector<uint32> context_ids_; | |
144 // Method to handle events | 145 // Method to handle events |
145 void EventHandlerCompleteTask(OMX_EVENTTYPE event, | 146 void EventHandlerCompleteTask(OMX_EVENTTYPE event, |
146 OMX_U32 data1, | 147 OMX_U32 data1, |
147 OMX_U32 data2); | 148 OMX_U32 data2); |
148 | 149 |
149 // Method to receive buffers from component's input port | 150 // Method to receive buffers from component's input port |
150 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); | 151 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); |
151 | 152 |
152 // Method to receive buffers from component's output port | 153 // Method to receive buffers from component's output port |
153 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); | 154 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); |
(...skipping 18 matching lines...) Expand all Loading... |
172 OMX_PTR event_data); | 173 OMX_PTR event_data); |
173 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, | 174 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, |
174 OMX_PTR priv_data, | 175 OMX_PTR priv_data, |
175 OMX_BUFFERHEADERTYPE* buffer); | 176 OMX_BUFFERHEADERTYPE* buffer); |
176 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, | 177 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, |
177 OMX_PTR priv_data, | 178 OMX_PTR priv_data, |
178 OMX_BUFFERHEADERTYPE* buffer); | 179 OMX_BUFFERHEADERTYPE* buffer); |
179 }; | 180 }; |
180 | 181 |
181 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 182 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |