diff options
Diffstat (limited to 'omx/gstomx_util.h')
-rw-r--r-- | omx/gstomx_util.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h index ce0156c..593b491 100644 --- a/omx/gstomx_util.h +++ b/omx/gstomx_util.h @@ -145,4 +145,48 @@ void g_omx_port_enable (GOmxPort *port); void g_omx_port_disable (GOmxPort *port); void g_omx_port_finish (GOmxPort *port); +/* Utility Macros */ + +/** + * Basically like GST_BOILERPLATE / GST_BOILERPLATE_FULL, but follows the + * init fxn naming conventions used by gst-openmax. It expects the following + * functions to be defined in the same src file following this macro + * <ul> + * <li> type_base_init(gpointer g_class) + * <li> type_class_init(gpointer g_class, gpointer class_data) + * <li> type_instance_init(GTypeInstance *instance, gpointer g_class) + * </ul> + */ +#define GSTOMX_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations) \ +static void type_base_init (gpointer g_class); \ +static void type_class_init (gpointer g_class, gpointer class_data); \ +static void type_instance_init (GTypeInstance *instance, gpointer g_class); \ +static parent_type ## Class *parent_class; \ +static void type_class_init_trampoline (gpointer g_class, gpointer class_data)\ +{ \ + parent_class = g_type_class_ref (parent_type_macro); \ + type_class_init (g_class, class_data); \ +} \ +GType type_as_function ## _get_type (void) \ +{ \ + static GType _type = 0; \ + if (G_UNLIKELY (_type == 0)) \ + { \ + GTypeInfo *type_info; \ + type_info = g_new0 (GTypeInfo, 1); \ + type_info->class_size = sizeof (type ## Class); \ + type_info->base_init = type_base_init; \ + type_info->class_init = type_class_init_trampoline; \ + type_info->instance_size = sizeof (type); \ + type_info->instance_init = type_instance_init; \ + _type = g_type_register_static (parent_type_macro, #type, type_info, 0);\ + g_free (type_info); \ + additional_initializations (_type); \ + } \ + return _type; \ +} +#define GSTOMX_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro) \ + GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \ + __GST_DO_NOTHING) + #endif /* GSTOMX_UTIL_H */ |