OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 // | 4 // |
5 // An object that works with an OpenMAX component for video decoding. | 5 // An object that works with an OpenMAX component for video decoding. |
6 // Operations on this object are all asynchronous and this object | 6 // Operations on this object are all asynchronous and this object |
7 // requires a message loop that it works on. | 7 // requires a message loop that it works on. |
8 // | 8 // |
9 // USAGES | 9 // USAGES |
10 // | 10 // |
11 // // Initialization. | 11 // // Initialization. |
12 // MessageLoop message_loop; | 12 // MessageLoop message_loop; |
13 // OmxVideoDecoder* decoder = new OmxVideoDecoder(&message_loop); | 13 // OmxVideoDecoder* decoder = new OmxVideoDecoder(&message_loop); |
14 // decoder->Setup(kCodecH264); | 14 // decoder->Setup(component_name, kCodecH264); |
15 // decoder->SetErrorCallback(NewCallback(this, &Client::ErrorCallback)); | 15 // decoder->SetErrorCallback(NewCallback(this, &Client::ErrorCallback)); |
16 // | 16 // |
17 // // Start is asynchronous. But we don't need to wait for it to proceed. | 17 // // Start is asynchronous. But we don't need to wait for it to proceed. |
18 // decoder->Start(); | 18 // decoder->Start(); |
19 // | 19 // |
20 // // We can start giving buffer to the decoder right after start. It will | 20 // // We can start giving buffer to the decoder right after start. It will |
21 // // queue the input buffers and output requests and process them until | 21 // // queue the input buffers and output requests and process them until |
22 // // the decoder can actually process them. | 22 // // the decoder can actually process them. |
23 // for (int i = 0; i < kInitialBuffers; ++i) { | 23 // for (int i = 0; i < kInitialBuffers; ++i) { |
24 // InputBuffer* buffer = PrepareInitialInputBuffer(); | 24 // InputBuffer* buffer = PrepareInitialInputBuffer(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 kCodecNone, | 97 kCodecNone, |
98 kCodecH264, | 98 kCodecH264, |
99 kCodecMpeg4, | 99 kCodecMpeg4, |
100 kCodecH263, | 100 kCodecH263, |
101 kCodecVc1, | 101 kCodecVc1, |
102 }; | 102 }; |
103 | 103 |
104 OmxVideoDecoder(MessageLoop* message_loop); | 104 OmxVideoDecoder(MessageLoop* message_loop); |
105 virtual ~OmxVideoDecoder(); | 105 virtual ~OmxVideoDecoder(); |
106 | 106 |
107 // Set the input codec format. | 107 // Set the component name and input codec format. |
108 // TODO(hclam): Add input format and output format. | 108 // TODO(hclam): Add input format and output format. Also remove |component|. |
109 void Setup(Codec codec); | 109 void Setup(const char* component, Codec codec); |
110 | 110 |
111 // Set the error callback. In case of error the callback will be called. | 111 // Set the error callback. In case of error the callback will be called. |
112 void SetErrorCallback(Callback* callback); | 112 void SetErrorCallback(Callback* callback); |
113 | 113 |
114 // Start the decoder, this will start the initialization asynchronously. | 114 // Start the decoder, this will start the initialization asynchronously. |
115 // Client can start feeding to and reading from the decoder. | 115 // Client can start feeding to and reading from the decoder. |
116 void Start(); | 116 void Start(); |
117 | 117 |
118 // Stop the decoder. When the decoder is fully stopped, |callback| | 118 // Stop the decoder. When the decoder is fully stopped, |callback| |
119 // is called. | 119 // is called. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 // |state_| records the current state. During state transition | 283 // |state_| records the current state. During state transition |
284 // |next_state_| is the next state that this machine will transition | 284 // |next_state_| is the next state that this machine will transition |
285 // to. After a state transition is completed and the state becomes | 285 // to. After a state transition is completed and the state becomes |
286 // stable then |next_state_| equals |state_|. Inequality can be | 286 // stable then |next_state_| equals |state_|. Inequality can be |
287 // used to detect a state transition. | 287 // used to detect a state transition. |
288 // These two members are read and written only on |message_loop_|. | 288 // These two members are read and written only on |message_loop_|. |
289 State state_; | 289 State state_; |
290 State next_state_; | 290 State next_state_; |
291 | 291 |
| 292 // TODO(hclam): We should keep a list of component names. |
| 293 const char* component_; |
292 Codec codec_; | 294 Codec codec_; |
293 MessageLoop* message_loop_; | 295 MessageLoop* message_loop_; |
294 | 296 |
295 scoped_ptr<Callback> stop_callback_; | 297 scoped_ptr<Callback> stop_callback_; |
296 scoped_ptr<Callback> error_callback_; | 298 scoped_ptr<Callback> error_callback_; |
297 | 299 |
298 // Input and output queue for encoded data and decoded frames. | 300 // Input and output queue for encoded data and decoded frames. |
299 typedef std::pair<InputBuffer*, FeedCallback*> InputUnit; | 301 typedef std::pair<InputBuffer*, FeedCallback*> InputUnit; |
300 std::queue<InputUnit> input_queue_; | 302 std::queue<InputUnit> input_queue_; |
301 std::queue<ReadCallback*> output_queue_; | 303 std::queue<ReadCallback*> output_queue_; |
302 | 304 |
303 // Input and output buffers that we can use to feed the decoder. | 305 // Input and output buffers that we can use to feed the decoder. |
304 std::queue<OMX_BUFFERHEADERTYPE*> available_input_buffers_; | 306 std::queue<OMX_BUFFERHEADERTYPE*> available_input_buffers_; |
305 std::queue<OMX_BUFFERHEADERTYPE*> available_output_buffers_; | 307 std::queue<OMX_BUFFERHEADERTYPE*> available_output_buffers_; |
306 }; | 308 }; |
307 | 309 |
308 } // namespace media | 310 } // namespace media |
OLD | NEW |