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_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> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 47 void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
48 virtual void AssignPictureBuffers( | 48 virtual void AssignPictureBuffers( |
49 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 49 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
50 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 50 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
51 void Flush() OVERRIDE; | 51 void Flush() OVERRIDE; |
52 void Reset() OVERRIDE; | 52 void Reset() OVERRIDE; |
53 void Destroy() OVERRIDE; | 53 void Destroy() OVERRIDE; |
54 | 54 |
55 base::WeakPtr<OmxVideoDecodeAccelerator> weak_this() { return weak_this_; } | 55 base::WeakPtr<OmxVideoDecodeAccelerator> weak_this() { return weak_this_; } |
56 | 56 |
57 // Do any necessary initialization before the sandbox is enabled. | |
58 static void PreSandboxInitialization(); | |
59 | |
60 private: | 57 private: |
61 // Because OMX state-transitions are described solely by the "state reached" | 58 // Because OMX state-transitions are described solely by the "state reached" |
62 // (3.1.2.9.1, table 3-7 of the spec), we track what transition was requested | 59 // (3.1.2.9.1, table 3-7 of the spec), we track what transition was requested |
63 // using this enum. Note that it is an error to request a transition while | 60 // using this enum. Note that it is an error to request a transition while |
64 // |*this| is in any state other than NO_TRANSITION, unless requesting | 61 // |*this| is in any state other than NO_TRANSITION, unless requesting |
65 // DESTROYING or ERRORING. | 62 // DESTROYING or ERRORING. |
66 enum CurrentStateChange { | 63 enum CurrentStateChange { |
67 NO_TRANSITION, // Not in the middle of a transition. | 64 NO_TRANSITION, // Not in the middle of a transition. |
68 INITIALIZING, | 65 INITIALIZING, |
69 FLUSHING, | 66 FLUSHING, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Whenever port settings change, the first thing we must do is disable the | 136 // Whenever port settings change, the first thing we must do is disable the |
140 // port (see Figure 3-18 of the OpenMAX IL spec linked to above). When the | 137 // port (see Figure 3-18 of the OpenMAX IL spec linked to above). When the |
141 // port is disabled, the component will call us back here. We then re-enable | 138 // port is disabled, the component will call us back here. We then re-enable |
142 // the port once we have textures, and that's the second method below. | 139 // the port once we have textures, and that's the second method below. |
143 void OnOutputPortDisabled(); | 140 void OnOutputPortDisabled(); |
144 void OnOutputPortEnabled(); | 141 void OnOutputPortEnabled(); |
145 | 142 |
146 // Decode bitstream buffers that were queued (see queued_bitstream_buffers_). | 143 // Decode bitstream buffers that were queued (see queued_bitstream_buffers_). |
147 void DecodeQueuedBitstreamBuffers(); | 144 void DecodeQueuedBitstreamBuffers(); |
148 | 145 |
149 // Lazily initialize static data after sandbox is enabled. Return false on | |
150 // init failure. | |
151 static bool PostSandboxInitialization(); | |
152 | |
153 // Weak pointer to |this|; used to safely trampoline calls from the OMX thread | 146 // Weak pointer to |this|; used to safely trampoline calls from the OMX thread |
154 // to the ChildThread. Since |this| is kept alive until OMX is fully shut | 147 // to the ChildThread. Since |this| is kept alive until OMX is fully shut |
155 // down, only the OMX->Child thread direction needs to be guarded this way. | 148 // down, only the OMX->Child thread direction needs to be guarded this way. |
156 base::WeakPtr<OmxVideoDecodeAccelerator> weak_this_; | 149 base::WeakPtr<OmxVideoDecodeAccelerator> weak_this_; |
157 | 150 |
158 // True once Initialize() has returned true; before this point there's never a | 151 // True once Initialize() has returned true; before this point there's never a |
159 // point in calling client_->NotifyError(). | 152 // point in calling client_->NotifyError(). |
160 bool init_begun_; | 153 bool init_begun_; |
161 | 154 |
162 // IL-client state. | 155 // IL-client state. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // NOTE: all calls to this object *MUST* be executed in message_loop_. | 200 // NOTE: all calls to this object *MUST* be executed in message_loop_. |
208 Client* client_; | 201 Client* client_; |
209 | 202 |
210 scoped_ptr<Gles2TextureToEglImageTranslator> texture_to_egl_image_translator_; | 203 scoped_ptr<Gles2TextureToEglImageTranslator> texture_to_egl_image_translator_; |
211 | 204 |
212 // These members are only used during Initialization. | 205 // These members are only used during Initialization. |
213 Codec codec_; | 206 Codec codec_; |
214 uint32 h264_profile_; // OMX_AVCProfile requested during Initialization. | 207 uint32 h264_profile_; // OMX_AVCProfile requested during Initialization. |
215 bool component_name_is_nvidia_h264ext_; | 208 bool component_name_is_nvidia_h264ext_; |
216 | 209 |
217 // Has static initialization of pre-sandbox components completed successfully? | |
218 static bool pre_sandbox_init_done_; | |
219 | |
220 // Method to handle events | 210 // Method to handle events |
221 void EventHandlerCompleteTask(OMX_EVENTTYPE event, | 211 void EventHandlerCompleteTask(OMX_EVENTTYPE event, |
222 OMX_U32 data1, | 212 OMX_U32 data1, |
223 OMX_U32 data2); | 213 OMX_U32 data2); |
224 | 214 |
225 // Method to receive buffers from component's input port | 215 // Method to receive buffers from component's input port |
226 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); | 216 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); |
227 | 217 |
228 // Method to receive buffers from component's output port | 218 // Method to receive buffers from component's output port |
229 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); | 219 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); |
(...skipping 12 matching lines...) Expand all Loading... |
242 OMX_PTR event_data); | 232 OMX_PTR event_data); |
243 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, | 233 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, |
244 OMX_PTR priv_data, | 234 OMX_PTR priv_data, |
245 OMX_BUFFERHEADERTYPE* buffer); | 235 OMX_BUFFERHEADERTYPE* buffer); |
246 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, | 236 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, |
247 OMX_PTR priv_data, | 237 OMX_PTR priv_data, |
248 OMX_BUFFERHEADERTYPE* buffer); | 238 OMX_BUFFERHEADERTYPE* buffer); |
249 }; | 239 }; |
250 | 240 |
251 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 241 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |