From 4bc7ff8e3e669e4bd173b0e6eb411e190a1275ae Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 22 Dec 2011 15:52:08 +0100 Subject: [PATCH] meta: add metadata flags Add metadata flags so that we can set extra properties of the metadata --- gst/gstbuffer.c | 8 +++++--- gst/gstmeta.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index f95a6a7b71..30b26a0975 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -1514,13 +1514,15 @@ gst_buffer_add_meta (GstBuffer * buffer, const GstMetaInfo * info, g_return_val_if_fail (info != NULL, NULL); /* create a new slice */ - GST_CAT_DEBUG (GST_CAT_BUFFER, "alloc metadata %s of size %" G_GSIZE_FORMAT, - g_type_name (info->type), info->size); - size = ITEM_SIZE (info); item = g_slice_alloc (size); result = &item->meta; result->info = info; + result->flags = GST_META_FLAG_NONE; + + GST_CAT_DEBUG (GST_CAT_BUFFER, + "alloc metadata %p (%s) of size %" G_GSIZE_FORMAT, result, + g_type_name (info->type), info->size); /* call the init_func when needed */ if (info->init_func) diff --git a/gst/gstmeta.h b/gst/gstmeta.h index 343657b32a..7f786b6815 100644 --- a/gst/gstmeta.h +++ b/gst/gstmeta.h @@ -28,14 +28,68 @@ G_BEGIN_DECLS typedef struct _GstMeta GstMeta; typedef struct _GstMetaInfo GstMetaInfo; +#define GST_META_CAST(meta) ((GstMeta *)(meta)) + +/** + * GstMetaFlags: + * @GST_META_FLAG_NONE: no flags + * @GST_META_FLAG_READONLY: metadata should not be modified + * @GST_META_FLAG_POOLED: metadata is managed by a bufferpool and should not + * be removed + * @GST_META_FLAG_LAST: additional flags can be added starting from this flag. + * + * Extra metadata flags. + */ +typedef enum { + GST_META_FLAG_NONE = 0, + GST_META_FLAG_READONLY = (1 << 0), + GST_META_FLAG_POOLED = (1 << 1), + + GST_META_FLAG_LAST = (1 << 16) +} GstMetaFlags; + +/** + * GST_META_FLAGS: + * @meta: a #GstMeta. + * + * A flags word containing #GstMetaFlag flags set on @meta + */ +#define GST_META_FLAGS(meta) (GST_META_CAST (meta)->flags) +/** + * GST_META_FLAG_IS_SET: + * @meta: a #GstMeta. + * @flag: the #GstMetaFlag to check. + * + * Gives the status of a specific flag on a metadata. + */ +#define GST_META_FLAG_IS_SET(meta,flag) !!(GST_META_FLAGS (meta) & (flag)) +/** + * GST_META_FLAG_SET: + * @meta: a #GstMeta. + * @flag: the #GstMetaFlag to set. + * + * Sets a metadata flag on a metadata. + */ +#define GST_META_FLAG_SET(meta,flag) (GST_META_FLAGS (meta) |= (flag)) +/** + * GST_META_FLAG_UNSET: + * @meta: a #GstMeta. + * @flag: the #GstMetaFlag to clear. + * + * Clears a metadata flag. + */ +#define GST_META_FLAG_UNSET(meta,flag) (GST_META_FLAGS (meta) &= ~(flag)) + /** * GstMeta: + * @flags: extra flags for the metadata * @info: pointer to the #GstMetaInfo * * Base structure for metadata. Custom metadata will put this structure * as the first member of their structure. */ struct _GstMeta { + GstMetaFlags flags; const GstMetaInfo *info; };