2 * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
4 * gstmeta.h: Header for Metadata structures
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef __GST_META_H__
24 #define __GST_META_H__
28 typedef struct _GstMeta GstMeta;
29 typedef struct _GstMetaInfo GstMetaInfo;
31 #define GST_META_CAST(meta) ((GstMeta *)(meta))
35 * @GST_META_FLAG_NONE: no flags
36 * @GST_META_FLAG_READONLY: metadata should not be modified
37 * @GST_META_FLAG_POOLED: metadata is managed by a bufferpool
38 * @GST_META_FLAG_LOCKED: metadata should not be removed
39 * @GST_META_FLAG_LAST: additional flags can be added starting from this flag.
41 * Extra metadata flags.
44 GST_META_FLAG_NONE = 0,
45 GST_META_FLAG_READONLY = (1 << 0),
46 GST_META_FLAG_POOLED = (1 << 1),
47 GST_META_FLAG_LOCKED = (1 << 2),
49 GST_META_FLAG_LAST = (1 << 16)
56 * A flags word containing #GstMetaFlags flags set on @meta
58 #define GST_META_FLAGS(meta) (GST_META_CAST (meta)->flags)
60 * GST_META_FLAG_IS_SET:
62 * @flag: the #GstMetaFlags to check.
64 * Gives the status of a specific flag on a metadata.
66 #define GST_META_FLAG_IS_SET(meta,flag) !!(GST_META_FLAGS (meta) & (flag))
70 * @flag: the #GstMetaFlags to set.
72 * Sets a metadata flag on a metadata.
74 #define GST_META_FLAG_SET(meta,flag) (GST_META_FLAGS (meta) |= (flag))
76 * GST_META_FLAG_UNSET:
78 * @flag: the #GstMetaFlags to clear.
80 * Clears a metadata flag.
82 #define GST_META_FLAG_UNSET(meta,flag) (GST_META_FLAGS (meta) &= ~(flag))
85 * GST_META_TAG_MEMORY_STR:
86 * This metadata stays relevant as long as memory layout is unchanged.
90 #define GST_META_TAG_MEMORY_STR "memory"
94 * @flags: extra flags for the metadata
95 * @info: pointer to the #GstMetaInfo
97 * Base structure for metadata. Custom metadata will put this structure
98 * as the first member of their structure.
102 const GstMetaInfo *info;
106 * GstMetaInitFunction:
108 * @params: parameters passed to the init function
109 * @buffer: a #GstBuffer
111 * Function called when @meta is initialized in @buffer.
113 typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
116 * GstMetaFreeFunction:
118 * @buffer: a #GstBuffer
120 * Function called when @meta is freed in @buffer.
122 typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
125 * gst_meta_transform_copy:
127 * GQuark for the "gst-copy" transform.
129 GST_EXPORT GQuark _gst_meta_transform_copy;
132 * GST_META_TRANSFORM_IS_COPY:
133 * @type: a transform type
135 * Check if the transform type is a copy transform
137 #define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
140 * GstMetaTransformCopy:
141 * @region: %TRUE if only region is copied
142 * @offset: the offset to copy, 0 if @region is %FALSE, otherwise > 0
143 * @size: the size to copy, -1 or the buffer size when @region is %FALSE
145 * Extra data passed to a "gst-copy" transform #GstMetaTransformFunction.
151 } GstMetaTransformCopy;
154 * GstMetaTransformFunction:
155 * @transbuf: a #GstBuffer
157 * @buffer: a #GstBuffer
158 * @type: the transform type
159 * @data: transform specific data.
161 * Function called for each @meta in @buffer as a result of performing a
162 * transformation on @transbuf. Additional @type specific transform data
163 * is passed to the function as @data.
165 * Implementations should check the @type of the transform and parse
166 * additional type specific fields in @data that should be used to update
167 * the metadata on @transbuf.
169 * Returns: %TRUE if the transform could be performed
171 typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf,
172 GstMeta *meta, GstBuffer *buffer,
173 GQuark type, gpointer data);
177 * @api: tag indentifying the metadata structure and api
178 * @type: type indentifying the implementor of the api
179 * @size: size of the metadata
180 * @init_func: function for initializing the metadata
181 * @free_func: function for freeing the metadata
182 * @transform_func: function for transforming the metadata
184 * The #GstMetaInfo provides information about a specific metadata
187 struct _GstMetaInfo {
192 GstMetaInitFunction init_func;
193 GstMetaFreeFunction free_func;
194 GstMetaTransformFunction transform_func;
197 gpointer _gst_reserved[GST_PADDING];
200 GType gst_meta_api_type_register (const gchar *api,
202 gboolean gst_meta_api_type_has_tag (GType api, GQuark tag);
204 const GstMetaInfo * gst_meta_register (GType api, const gchar *impl,
206 GstMetaInitFunction init_func,
207 GstMetaFreeFunction free_func,
208 GstMetaTransformFunction transform_func);
209 const GstMetaInfo * gst_meta_get_info (const gchar * impl);
210 const gchar* const* gst_meta_api_type_get_tags (GType api);
212 /* some default tags */
213 GST_EXPORT GQuark _gst_meta_tag_memory;
216 * GST_META_TAG_MEMORY:
218 * Metadata tagged with this tag depends on the particular memory
219 * or buffer that it is on.
221 * Deprecated: The GQuarks are not exported by any public API, use
222 * GST_META_TAG_MEMORY_STR instead.
224 #define GST_META_TAG_MEMORY (_gst_meta_tag_memory)
228 #endif /* __GST_META_H__ */