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