meta: add support to tagging the metadata

Add support for adding tags to the metadata. with some standard keys, this
should make it possible to describe what the metadata refers to. We should be
able to use this information to decide if a transformation destroys the metadata
or not.
This commit is contained in:
Wim Taymans 2012-02-28 11:34:48 +01:00
parent 825bc829b1
commit 166cfadb71
3 changed files with 20 additions and 3 deletions

View file

@ -54,6 +54,8 @@ _priv_gst_meta_initialize (void)
* @init_func: a #GstMetaInitFunction
* @free_func: a #GstMetaFreeFunction
* @transform_func: a #GstMetaTransformFunction
* @tags: a NULL terminated array of strings describing what the metadata
* contains info about.
*
* Register a new #GstMeta implementation.
*
@ -66,13 +68,16 @@ _priv_gst_meta_initialize (void)
const GstMetaInfo *
gst_meta_register (const gchar * api, const gchar * impl, gsize size,
GstMetaInitFunction init_func, GstMetaFreeFunction free_func,
GstMetaTransformFunction transform_func)
GstMetaTransformFunction transform_func, const gchar ** tags)
{
GstMetaInfo *info;
guint len, i;
GQuark *qtags;
g_return_val_if_fail (api != NULL, NULL);
g_return_val_if_fail (impl != NULL, NULL);
g_return_val_if_fail (size != 0, NULL);
g_return_val_if_fail (tags != NULL, NULL);
info = g_slice_new (GstMetaInfo);
info->api = g_quark_from_string (api);
@ -82,6 +87,12 @@ gst_meta_register (const gchar * api, const gchar * impl, gsize size,
info->free_func = free_func;
info->transform_func = transform_func;
len = g_strv_length ((gchar **) tags);
qtags = g_new0 (GQuark, len);
for (i = 0; i < len; i++)
qtags[i] = g_quark_from_static_string (tags[i]);
info->tags = qtags;
GST_DEBUG ("register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT,
api, impl, size);

View file

@ -161,6 +161,8 @@ typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf,
* @init_func: function for initializing the metadata
* @free_func: function for freeing the metadata
* @transform_func: function for transforming the metadata
* @tags: 0 terminated array of GQuarks describing what the metadata
* contains info about
*
* The #GstMetaInfo provides information about a specific metadata
* structure.
@ -174,6 +176,8 @@ struct _GstMetaInfo {
GstMetaFreeFunction free_func;
GstMetaTransformFunction transform_func;
const GQuark *tags;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
@ -182,7 +186,8 @@ const GstMetaInfo * gst_meta_register (const gchar *api, const gchar *im
gsize size,
GstMetaInitFunction init_func,
GstMetaFreeFunction free_func,
GstMetaTransformFunction transform_func);
GstMetaTransformFunction transform_func,
const gchar **tags);
const GstMetaInfo * gst_meta_get_info (const gchar * impl);
G_END_DECLS

View file

@ -61,13 +61,14 @@ const GstMetaInfo *
gst_net_address_meta_get_info (void)
{
static const GstMetaInfo *meta_info = NULL;
static const gchar *tags[] = { "origin", NULL };
if (meta_info == NULL) {
meta_info = gst_meta_register ("GstNetAddressMeta", "GstNetAddressMeta",
sizeof (GstNetAddressMeta),
(GstMetaInitFunction) net_address_meta_init,
(GstMetaFreeFunction) net_address_meta_free,
(GstMetaTransformFunction) net_address_meta_transform);
(GstMetaTransformFunction) net_address_meta_transform, tags);
}
return meta_info;
}