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
+ * @GST_META_FLAG_LOCKED: metadata 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_LOCKED = (1 << 2),
+
+ GST_META_FLAG_LAST = (1 << 16)
+} GstMetaFlags;
+
+/**
+ * GST_META_FLAGS:
+ * @meta: a #GstMeta.
+ *
+ * A flags word containing #GstMetaFlags flags set on @meta
+ */
+#define GST_META_FLAGS(meta) (GST_META_CAST (meta)->flags)
+/**
+ * GST_META_FLAG_IS_SET:
+ * @meta: a #GstMeta.
+ * @flag: the #GstMetaFlags 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 #GstMetaFlags 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 #GstMetaFlags 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;
};
/**
- * GST_META_TRACE_NAME:
- *
- * The name used for tracing memory allocations.
- */
-#define GST_META_TRACE_NAME "GstMeta"
-
-/**
* GstMetaInitFunction:
* @meta: a #GstMeta
* @params: parameters passed to the init function
*/
typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
-typedef void (*GstMetaCopyFunction) (GstBuffer *dest, GstMeta *meta,
- GstBuffer *buffer, gsize offset, gsize size);
+/**
+ * gst_meta_transform_copy:
+ *
+ * GQuark for the "gst-copy" transform.
+ */
+GST_EXPORT GQuark _gst_meta_transform_copy;
+
+/**
+ * GST_META_TRANSFORM_IS_COPY:
+ * @type: a transform type
+ *
+ * Check if the transform type is a copy transform
+ */
+#define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
+
+/**
+ * GstMetaTransformCopy:
+ * @region: %TRUE if only region is copied
+ * @offset: the offset to copy, 0 if @region is %FALSE, otherwise > 0
+ * @size: the size to copy, -1 or the buffer size when @region is %FALSE
+ *
+ * Extra data passed to a "gst-copy" transform #GstMetaTransformFunction.
+ */
+typedef struct {
+ gboolean region;
+ gsize offset;
+ gsize size;
+} GstMetaTransformCopy;
+
/**
* GstMetaTransformFunction:
* @transbuf: a #GstBuffer
* @meta: a #GstMeta
* @buffer: a #GstBuffer
+ * @type: the transform type
* @data: transform specific data.
*
* Function called for each @meta in @buffer as a result of performing a
- * transformation on @transbuf. Additional type specific transform data
- * is passed to the function.
+ * transformation on @transbuf. Additional @type specific transform data
+ * is passed to the function as @data.
*
- * Implementations should check the type of the transform @data and parse
- * additional type specific field that should be used to perform the transform.
+ * Implementations should check the @type of the transform and parse
+ * additional type specific fields in @data that should be used to update
+ * the metadata on @transbuf.
+ *
+ * Returns: %TRUE if the transform could be performed
*/
-typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf, GstMeta *meta,
- GstBuffer *buffer, gpointer data);
+typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf,
+ GstMeta *meta, GstBuffer *buffer,
+ GQuark type, gpointer data);
/**
* GstMetaInfo:
* @size: size of the metadata
* @init_func: function for initializing the metadata
* @free_func: function for freeing the metadata
- * @copy_func: function for copying the metadata
* @transform_func: function for transforming the metadata
*
* The #GstMetaInfo provides information about a specific metadata
* structure.
*/
struct _GstMetaInfo {
- GQuark api;
+ GType api;
GType type;
gsize size;
GstMetaInitFunction init_func;
GstMetaFreeFunction free_func;
- GstMetaCopyFunction copy_func;
GstMetaTransformFunction transform_func;
-};
-const GstMetaInfo * gst_meta_register (const gchar *api, const gchar *impl,
- gsize size,
- GstMetaInitFunction init_func,
- GstMetaFreeFunction free_func,
- GstMetaCopyFunction copy_func,
- GstMetaTransformFunction transform_func);
-const GstMetaInfo * gst_meta_get_info (const gchar * impl);
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
-/* default metadata */
+GType gst_meta_api_type_register (const gchar *api,
+ const gchar **tags);
+gboolean gst_meta_api_type_has_tag (GType api, GQuark tag);
-/* timing metadata */
-typedef struct _GstMetaTiming GstMetaTiming;
+const GstMetaInfo * gst_meta_register (GType api, const gchar *impl,
+ gsize size,
+ GstMetaInitFunction init_func,
+ GstMetaFreeFunction free_func,
+ GstMetaTransformFunction transform_func);
+const GstMetaInfo * gst_meta_get_info (const gchar * impl);
-const GstMetaInfo *gst_meta_timing_get_info(void);
-#define GST_META_TIMING_INFO (gst_meta_timing_get_info())
+/* some default tags */
+GST_EXPORT GQuark _gst_meta_tag_memory;
/**
- * GstMetaTiming:
- * @meta: parent metadata
- * @dts: the decoding timestamp
- * @pts: the presentation timestamp
- * @duration: the duration
- * @clock_rate: the clock rate of the dts, pts and duration values
- *
- * Extra timing metadata
+ * GST_META_TAG_MEMORY:
+ *
+ * Metadata tagged with this tag depends on the particular memory
+ * or buffer that it is on.
*/
-struct _GstMetaTiming {
- GstMeta meta; /* common meta header */
-
- GstClockTime dts; /* decoding timestamp */
- GstClockTime pts; /* presentation timestamp */
- GstClockTime duration; /* duration of the data */
- GstClockTime clock_rate; /* clock rate for the above values */
-};
-
-#define gst_buffer_get_meta_timing(b) ((GstMetaTiming*)gst_buffer_get_meta((b),GST_META_TIMING_INFO))
-#define gst_buffer_add_meta_timing(b) ((GstMetaTiming*)gst_buffer_add_meta((b),GST_META_TIMING_INFO,NULL))
+#define GST_META_TAG_MEMORY (_gst_meta_tag_memory)
G_END_DECLS