2 * Copyright (C) 2006-2007 Texas Instruments, Incorporated
3 * Copyright (C) 2007-2009 Nokia Corporation.
5 * Author: Felipe Contreras <felipe.contreras@nokia.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation
10 * version 2.1 of the License.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 #include <OMX_Component.h>
30 #include <async_queue.h>
35 typedef struct GOmxCore GOmxCore;
36 typedef struct GOmxPort GOmxPort;
37 typedef struct GOmxImp GOmxImp;
38 typedef struct GOmxSymbolTable GOmxSymbolTable;
39 typedef enum GOmxPortType GOmxPortType;
40 /* MODIFICATION: omx vender */
41 typedef enum GOmxVendor GOmxVendor;
43 typedef void (*GOmxCb) (GOmxCore * core);
44 typedef void (*GOmxPortCb) (GOmxPort * port);
46 /* MODIFICATION: ignore init fail when going to stop. for S.LSI case.*/
47 #define OMX_ErrorMFCInit 0x90000004
48 #define OMX_UNRECOVERABLE_ERROR_MAX_COUNT 10
58 /* Add_component_vendor */
68 struct GOmxSymbolTable
70 OMX_ERRORTYPE (*init) (void);
71 OMX_ERRORTYPE (*deinit) (void);
72 OMX_ERRORTYPE (*get_handle) (OMX_HANDLETYPE * handle,
73 OMX_STRING name, OMX_PTR data, OMX_CALLBACKTYPE * callbacks);
74 OMX_ERRORTYPE (*free_handle) (OMX_HANDLETYPE handle);
81 GOmxSymbolTable sym_table;
87 gpointer object; /**< GStreamer element. */
89 OMX_HANDLETYPE omx_handle;
90 OMX_ERRORTYPE omx_error;
92 OMX_STATETYPE omx_state;
93 GCond *omx_state_condition;
94 GMutex *omx_state_mutex;
102 GOmxCb settings_changed_cb;
108 gchar *component_name;
109 gchar *component_role;
111 /* MODIFICATION: omx vender */
112 GOmxVendor component_vendor;
114 /* MODIFICATION: handle continuous MFC init fails */
115 gint omx_unrecover_err_cnt;
117 /* MODIFICATION: to do GST_ELEMENT_ERROR only one time */
118 gboolean post_gst_element_error;
129 OMX_BUFFERHEADERTYPE **buffers;
133 gboolean omx_allocate; /**< Setup with OMX_AllocateBuffer rather than OMX_UseBuffer */
136 gboolean shared_buffer; /* Modification */
141 void g_omx_init (void);
142 void g_omx_deinit (void);
144 GOmxCore *g_omx_core_new (void *object);
145 void g_omx_core_free (GOmxCore * core);
146 void g_omx_core_init (GOmxCore * core);
147 void g_omx_core_prepare (GOmxCore * core);
148 void g_omx_core_start (GOmxCore * core);
149 void g_omx_core_pause (GOmxCore * core);
150 void g_omx_core_stop (GOmxCore * core);
151 void g_omx_core_unload (GOmxCore * core);
152 void g_omx_core_set_done (GOmxCore * core);
153 void g_omx_core_wait_for_done (GOmxCore * core);
154 void g_omx_core_flush_start (GOmxCore * core);
155 void g_omx_core_flush_stop (GOmxCore * core);
156 GOmxPort *g_omx_core_new_port (GOmxCore * core, guint index);
158 GOmxPort *g_omx_port_new (GOmxCore * core, guint index);
159 void g_omx_port_free (GOmxPort * port);
160 void g_omx_port_setup (GOmxPort * port);
161 void g_omx_port_push_buffer (GOmxPort * port,
162 OMX_BUFFERHEADERTYPE * omx_buffer);
163 OMX_BUFFERHEADERTYPE *g_omx_port_request_buffer (GOmxPort * port);
164 void g_omx_port_release_buffer (GOmxPort * port,
165 OMX_BUFFERHEADERTYPE * omx_buffer);
166 void g_omx_port_resume (GOmxPort * port);
167 void g_omx_port_pause (GOmxPort * port);
168 void g_omx_port_flush (GOmxPort * port);
169 void g_omx_port_enable (GOmxPort * port);
170 void g_omx_port_disable (GOmxPort * port);
171 void g_omx_port_finish (GOmxPort * port);
176 * Basically like GST_BOILERPLATE / GST_BOILERPLATE_FULL, but follows the
177 * init fxn naming conventions used by gst-openmax. It expects the following
178 * functions to be defined in the same src file following this macro
180 * <li> type_base_init(gpointer g_class)
181 * <li> type_class_init(gpointer g_class, gpointer class_data)
182 * <li> type_instance_init(GTypeInstance *instance, gpointer g_class)
185 #define GSTOMX_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations) \
186 static void type_base_init (gpointer g_class); \
187 static void type_class_init (gpointer g_class, gpointer class_data); \
188 static void type_instance_init (GTypeInstance *instance, gpointer g_class); \
189 static parent_type ## Class *parent_class; \
190 static void type_class_init_trampoline (gpointer g_class, gpointer class_data)\
192 parent_class = g_type_class_ref (parent_type_macro); \
193 type_class_init (g_class, class_data); \
195 GType type_as_function ## _get_type (void) \
197 /* The typedef for GType may be gulong or gsize, depending on the \
198 * system and whether the compiler is c++ or not. The g_once_init_* \
199 * functions always take a gsize * though ... */ \
200 static volatile gsize gonce_data = 0; \
201 if (g_once_init_enter (&gonce_data)) { \
203 GTypeInfo *type_info; \
204 type_info = g_new0 (GTypeInfo, 1); \
205 type_info->class_size = sizeof (type ## Class); \
206 type_info->base_init = type_base_init; \
207 type_info->class_init = type_class_init_trampoline; \
208 type_info->instance_size = sizeof (type); \
209 type_info->instance_init = type_instance_init; \
210 _type = g_type_register_static (parent_type_macro, #type, type_info, 0);\
211 g_free (type_info); \
212 additional_initializations (_type); \
213 g_once_init_leave (&gonce_data, (gsize) _type); \
215 return (GType) gonce_data; \
218 #define GSTOMX_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro) \
219 GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
222 #include <string.h> /* for memset */
223 #define G_OMX_INIT_PARAM(param) G_STMT_START { \
224 memset (&(param), 0, sizeof ((param))); \
225 (param).nSize = sizeof (param); \
226 (param).nVersion.s.nVersionMajor = 1; \
227 (param).nVersion.s.nVersionMinor = 1; \
231 #endif /* GSTOMX_UTIL_H */