meta: add metadata flags
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 22 Dec 2011 14:52:08 +0000 (15:52 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 22 Dec 2011 15:02:05 +0000 (16:02 +0100)
Add metadata flags so that we can set extra properties of the metadata

gst/gstbuffer.c
gst/gstmeta.h

index f95a6a7..30b26a0 100644 (file)
@@ -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)
index 343657b..7f786b6 100644 (file)
@@ -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;
 };