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_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_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 <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
19 #include "base/shared_memory.h" | 19 #include "base/shared_memory.h" |
20 #include "media/video/video_decode_accelerator.h" | 20 #include "media/video/video_decode_accelerator.h" |
21 #include "third_party/openmax/il/OMX_Component.h" | 21 #include "third_party/openmax/il/OMX_Component.h" |
22 #include "third_party/openmax/il/OMX_Core.h" | 22 #include "third_party/openmax/il/OMX_Core.h" |
23 #include "third_party/openmax/il/OMX_Video.h" | 23 #include "third_party/openmax/il/OMX_Video.h" |
24 | 24 |
25 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. | 25 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. |
26 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { | 26 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { |
27 public: | 27 public: |
28 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client, | 28 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client, |
29 MessageLoop* message_loop); | 29 MessageLoop* message_loop); |
30 virtual ~OmxVideoDecodeAccelerator(); | 30 virtual ~OmxVideoDecodeAccelerator(); |
31 | 31 |
32 // media::VideoDecodeAccelerator implementation. | 32 // media::VideoDecodeAccelerator implementation. |
33 const std::vector<uint32>& GetConfig( | 33 void GetConfigs(const std::vector<uint32>& requested_configs, |
vrk (LEFT CHROMIUM)
2011/05/23 23:35:00
Can you add the OVERRIDE macro (in base/compiler_s
Ami GONE FROM CHROMIUM
2011/05/24 05:31:50
Done.
| |
34 const std::vector<uint32>& prototype_config); | 34 std::vector<uint32>* matched_configs); |
35 bool Initialize(const std::vector<uint32>& config); | 35 bool Initialize(const std::vector<uint32>& config); |
36 bool Decode(const media::BitstreamBuffer& bitstream_buffer, | 36 bool Decode(const media::BitstreamBuffer& bitstream_buffer); |
37 const media::VideoDecodeAcceleratorCallback& callback); | 37 virtual void AssignGLESBuffers(const std::vector<media::GLESBuffer>& buffers); |
38 void AssignPictureBuffer(std::vector<PictureBuffer*> picture_buffers); | 38 virtual void AssignSysmemBuffers( |
39 const std::vector<media::SysmemBuffer>& buffers); | |
39 void ReusePictureBuffer(int32 picture_buffer_id); | 40 void ReusePictureBuffer(int32 picture_buffer_id); |
40 bool Flush(const media::VideoDecodeAcceleratorCallback& callback); | 41 bool Flush(); |
41 bool Abort(const media::VideoDecodeAcceleratorCallback& callback); | 42 bool Abort(); |
42 | 43 |
43 private: | 44 private: |
44 MessageLoop* message_loop_; | 45 MessageLoop* message_loop_; |
45 OMX_HANDLETYPE component_handle_; | 46 OMX_HANDLETYPE component_handle_; |
46 | 47 |
48 // Common initialization code for Assign{GLES,Sysmem}Buffers. | |
49 void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers); | |
50 | |
47 // Create the Component for OMX. Handles all OMX initialization. | 51 // Create the Component for OMX. Handles all OMX initialization. |
48 bool CreateComponent(); | 52 bool CreateComponent(); |
49 // Buffer allocation/free methods for input and output buffers. | 53 // Buffer allocation/free methods for input and output buffers. |
50 bool AllocateInputBuffers(); | 54 bool AllocateInputBuffers(); |
51 bool AllocateOutputBuffers(); | 55 bool AllocateOutputBuffers(); |
52 void FreeInputBuffers(); | 56 void FreeInputBuffers(); |
53 void FreeOutputBuffers(); | 57 void FreeOutputBuffers(); |
54 | 58 |
55 // Methods to handle OMX state transitions. | 59 // Methods to handle OMX state transitions. |
56 bool TransitionToState(OMX_STATETYPE new_state); | 60 bool TransitionToState(OMX_STATETYPE new_state); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 int output_buffer_count_; | 99 int output_buffer_count_; |
96 int output_buffer_size_; | 100 int output_buffer_size_; |
97 int output_port_; | 101 int output_port_; |
98 int output_buffers_at_component_; | 102 int output_buffers_at_component_; |
99 | 103 |
100 bool uses_egl_image_; | 104 bool uses_egl_image_; |
101 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. | 105 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. |
102 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; | 106 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; |
103 | 107 |
104 // For output buffer recycling cases. | 108 // For output buffer recycling cases. |
105 std::vector<media::VideoDecodeAccelerator::PictureBuffer*> | 109 std::vector<media::BaseBuffer*> assigned_picture_buffers_; |
106 assigned_picture_buffers_; | 110 typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture; |
107 typedef std::pair<PictureBuffer*, | |
108 OMX_BUFFERHEADERTYPE*> OutputPicture; | |
109 std::vector<OutputPicture> output_pictures_; | 111 std::vector<OutputPicture> output_pictures_; |
110 | 112 |
111 // To expose client callbacks from VideoDecodeAccelerator. | 113 // To expose client callbacks from VideoDecodeAccelerator. |
112 Client* client_; | 114 Client* client_; |
113 | 115 |
114 media::VideoDecodeAcceleratorCallback flush_done_callback_; | |
115 media::VideoDecodeAcceleratorCallback abort_done_callback_; | |
116 | |
117 std::vector<uint32> texture_ids_; | 116 std::vector<uint32> texture_ids_; |
118 std::vector<uint32> context_ids_; | 117 std::vector<uint32> context_ids_; |
119 // Method to handle events | 118 // Method to handle events |
120 void EventHandlerCompleteTask(OMX_EVENTTYPE event, | 119 void EventHandlerCompleteTask(OMX_EVENTTYPE event, |
121 OMX_U32 data1, | 120 OMX_U32 data1, |
122 OMX_U32 data2); | 121 OMX_U32 data2); |
123 | 122 |
124 // Method to receive buffers from component's input port | 123 // Method to receive buffers from component's input port |
125 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); | 124 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); |
126 | 125 |
127 // Method to receive buffers from component's output port | 126 // Method to receive buffers from component's output port |
128 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); | 127 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); |
129 typedef std::pair<OMX_BUFFERHEADERTYPE*, uint32> OMXbufferTexture; | 128 typedef std::pair<OMX_BUFFERHEADERTYPE*, uint32> OMXbufferTexture; |
130 // void pointer to hold EGLImage handle. | |
131 void* egl_image_; | |
132 | 129 |
133 typedef std::map< | 130 typedef std::map<OMX_BUFFERHEADERTYPE*, |
134 OMX_BUFFERHEADERTYPE*, | 131 std::pair<base::SharedMemory*, int32> > OMXBufferIdMap; |
135 std::pair<base::SharedMemory*, | 132 OMXBufferIdMap omx_buff_ids_; |
136 media::VideoDecodeAcceleratorCallback> > OMXBufferCallbackMap; | |
137 OMXBufferCallbackMap omx_buff_cb_; | |
138 | 133 |
139 // Method used the change the state of the port. | 134 // Method used the change the state of the port. |
140 void ChangePort(OMX_COMMANDTYPE cmd, int port_index); | 135 void ChangePort(OMX_COMMANDTYPE cmd, int port_index); |
141 | 136 |
142 // Member function pointers to respond to events | 137 // Member function pointers to respond to events |
143 void (OmxVideoDecodeAccelerator::*on_port_disable_event_func_)(int port); | 138 void (OmxVideoDecodeAccelerator::*on_port_disable_event_func_)(int port); |
144 void (OmxVideoDecodeAccelerator::*on_port_enable_event_func_)(int port); | 139 void (OmxVideoDecodeAccelerator::*on_port_enable_event_func_)(int port); |
145 void (OmxVideoDecodeAccelerator::*on_state_event_func_)(OMX_STATETYPE state); | 140 void (OmxVideoDecodeAccelerator::*on_state_event_func_)(OMX_STATETYPE state); |
146 void (OmxVideoDecodeAccelerator::*on_flush_event_func_)(int port); | 141 void (OmxVideoDecodeAccelerator::*on_flush_event_func_)(int port); |
147 void (OmxVideoDecodeAccelerator::*on_buffer_flag_event_func_)(); | 142 void (OmxVideoDecodeAccelerator::*on_buffer_flag_event_func_)(); |
148 | 143 |
149 // Callback methods for the OMX component. | 144 // Callback methods for the OMX component. |
150 // When these callbacks are received, the | 145 // When these callbacks are received, the |
151 // call is delegated to the three internal methods above. | 146 // call is delegated to the three internal methods above. |
152 static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE component, | 147 static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE component, |
153 OMX_PTR priv_data, | 148 OMX_PTR priv_data, |
154 OMX_EVENTTYPE event, | 149 OMX_EVENTTYPE event, |
155 OMX_U32 data1, OMX_U32 data2, | 150 OMX_U32 data1, OMX_U32 data2, |
156 OMX_PTR event_data); | 151 OMX_PTR event_data); |
157 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, | 152 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, |
158 OMX_PTR priv_data, | 153 OMX_PTR priv_data, |
159 OMX_BUFFERHEADERTYPE* buffer); | 154 OMX_BUFFERHEADERTYPE* buffer); |
160 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, | 155 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, |
161 OMX_PTR priv_data, | 156 OMX_PTR priv_data, |
162 OMX_BUFFERHEADERTYPE* buffer); | 157 OMX_BUFFERHEADERTYPE* buffer); |
163 }; | 158 }; |
164 | 159 |
165 #endif // CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 160 #endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |