Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: content/common/gpu/omx_video_decode_accelerator.h

Issue 7057027: Updated OMX decoder for recent PPAPI changes, and added to the build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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,
34 const std::vector<uint32>& prototype_config); 34 std::vector<uint32>* matched_configs) OVERRIDE;
35 bool Initialize(const std::vector<uint32>& config); 35 bool Initialize(const std::vector<uint32>& config) OVERRIDE;
36 bool Decode(const media::BitstreamBuffer& bitstream_buffer, 36 bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
37 const media::VideoDecodeAcceleratorCallback& callback); 37 virtual void AssignGLESBuffers(
38 void AssignPictureBuffer(std::vector<PictureBuffer*> picture_buffers); 38 const std::vector<media::GLESBuffer>& buffers) OVERRIDE;
39 void ReusePictureBuffer(int32 picture_buffer_id); 39 virtual void AssignSysmemBuffers(
40 bool Flush(const media::VideoDecodeAcceleratorCallback& callback); 40 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE;
41 bool Abort(const media::VideoDecodeAcceleratorCallback& callback); 41 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
42 bool Flush() OVERRIDE;
43 bool Abort() OVERRIDE;
42 44
43 private: 45 private:
44 MessageLoop* message_loop_; 46 MessageLoop* message_loop_;
45 OMX_HANDLETYPE component_handle_; 47 OMX_HANDLETYPE component_handle_;
46 48
49 // Common initialization code for Assign{GLES,Sysmem}Buffers.
50 void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers);
51
47 // Create the Component for OMX. Handles all OMX initialization. 52 // Create the Component for OMX. Handles all OMX initialization.
48 bool CreateComponent(); 53 bool CreateComponent();
49 // Buffer allocation/free methods for input and output buffers. 54 // Buffer allocation/free methods for input and output buffers.
50 bool AllocateInputBuffers(); 55 bool AllocateInputBuffers();
51 bool AllocateOutputBuffers(); 56 bool AllocateOutputBuffers();
52 void FreeInputBuffers(); 57 void FreeInputBuffers();
53 void FreeOutputBuffers(); 58 void FreeOutputBuffers();
54 59
55 // Methods to handle OMX state transitions. 60 // Methods to handle OMX state transitions.
56 bool TransitionToState(OMX_STATETYPE new_state); 61 bool TransitionToState(OMX_STATETYPE new_state);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 int output_buffer_count_; 100 int output_buffer_count_;
96 int output_buffer_size_; 101 int output_buffer_size_;
97 int output_port_; 102 int output_port_;
98 int output_buffers_at_component_; 103 int output_buffers_at_component_;
99 104
100 bool uses_egl_image_; 105 bool uses_egl_image_;
101 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. 106 // Free input OpenMAX buffers that can be used to take bitstream from demuxer.
102 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; 107 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_;
103 108
104 // For output buffer recycling cases. 109 // For output buffer recycling cases.
105 std::vector<media::VideoDecodeAccelerator::PictureBuffer*> 110 std::vector<media::BaseBuffer*> assigned_picture_buffers_;
106 assigned_picture_buffers_; 111 typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture;
107 typedef std::pair<PictureBuffer*,
108 OMX_BUFFERHEADERTYPE*> OutputPicture;
109 std::vector<OutputPicture> output_pictures_; 112 std::vector<OutputPicture> output_pictures_;
110 113
111 // To expose client callbacks from VideoDecodeAccelerator. 114 // To expose client callbacks from VideoDecodeAccelerator.
112 Client* client_; 115 Client* client_;
113 116
114 media::VideoDecodeAcceleratorCallback flush_done_callback_;
115 media::VideoDecodeAcceleratorCallback abort_done_callback_;
116
117 std::vector<uint32> texture_ids_; 117 std::vector<uint32> texture_ids_;
118 std::vector<uint32> context_ids_; 118 std::vector<uint32> context_ids_;
119 // Method to handle events 119 // Method to handle events
120 void EventHandlerCompleteTask(OMX_EVENTTYPE event, 120 void EventHandlerCompleteTask(OMX_EVENTTYPE event,
121 OMX_U32 data1, 121 OMX_U32 data1,
122 OMX_U32 data2); 122 OMX_U32 data2);
123 123
124 // Method to receive buffers from component's input port 124 // Method to receive buffers from component's input port
125 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); 125 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer);
126 126
127 // Method to receive buffers from component's output port 127 // Method to receive buffers from component's output port
128 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); 128 void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer);
129 typedef std::pair<OMX_BUFFERHEADERTYPE*, uint32> OMXbufferTexture; 129 typedef std::pair<OMX_BUFFERHEADERTYPE*, uint32> OMXbufferTexture;
130 // void pointer to hold EGLImage handle.
131 void* egl_image_;
132 130
133 typedef std::map< 131 typedef std::map<OMX_BUFFERHEADERTYPE*,
134 OMX_BUFFERHEADERTYPE*, 132 std::pair<base::SharedMemory*, int32> > OMXBufferIdMap;
135 std::pair<base::SharedMemory*, 133 OMXBufferIdMap omx_buff_ids_;
136 media::VideoDecodeAcceleratorCallback> > OMXBufferCallbackMap;
137 OMXBufferCallbackMap omx_buff_cb_;
138 134
139 // Method used the change the state of the port. 135 // Method used the change the state of the port.
140 void ChangePort(OMX_COMMANDTYPE cmd, int port_index); 136 void ChangePort(OMX_COMMANDTYPE cmd, int port_index);
141 137
142 // Member function pointers to respond to events 138 // Member function pointers to respond to events
143 void (OmxVideoDecodeAccelerator::*on_port_disable_event_func_)(int port); 139 void (OmxVideoDecodeAccelerator::*on_port_disable_event_func_)(int port);
144 void (OmxVideoDecodeAccelerator::*on_port_enable_event_func_)(int port); 140 void (OmxVideoDecodeAccelerator::*on_port_enable_event_func_)(int port);
145 void (OmxVideoDecodeAccelerator::*on_state_event_func_)(OMX_STATETYPE state); 141 void (OmxVideoDecodeAccelerator::*on_state_event_func_)(OMX_STATETYPE state);
146 void (OmxVideoDecodeAccelerator::*on_flush_event_func_)(int port); 142 void (OmxVideoDecodeAccelerator::*on_flush_event_func_)(int port);
147 void (OmxVideoDecodeAccelerator::*on_buffer_flag_event_func_)(); 143 void (OmxVideoDecodeAccelerator::*on_buffer_flag_event_func_)();
148 144
149 // Callback methods for the OMX component. 145 // Callback methods for the OMX component.
150 // When these callbacks are received, the 146 // When these callbacks are received, the
151 // call is delegated to the three internal methods above. 147 // call is delegated to the three internal methods above.
152 static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE component, 148 static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE component,
153 OMX_PTR priv_data, 149 OMX_PTR priv_data,
154 OMX_EVENTTYPE event, 150 OMX_EVENTTYPE event,
155 OMX_U32 data1, OMX_U32 data2, 151 OMX_U32 data1, OMX_U32 data2,
156 OMX_PTR event_data); 152 OMX_PTR event_data);
157 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, 153 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component,
158 OMX_PTR priv_data, 154 OMX_PTR priv_data,
159 OMX_BUFFERHEADERTYPE* buffer); 155 OMX_BUFFERHEADERTYPE* buffer);
160 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, 156 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component,
161 OMX_PTR priv_data, 157 OMX_PTR priv_data,
162 OMX_BUFFERHEADERTYPE* buffer); 158 OMX_BUFFERHEADERTYPE* buffer);
163 }; 159 };
164 160
165 #endif // CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ 161 #endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_video_service.cc ('k') | content/common/gpu/omx_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698