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__
30 typedef struct _GstMeta GstMeta;
31 typedef struct _GstMetaInfo GstMetaInfo;
33 #define GST_META_CAST(meta) ((GstMeta *)(meta))
37 * @GST_META_FLAG_NONE: no flags
38 * @GST_META_FLAG_READONLY: metadata should not be modified
39 * @GST_META_FLAG_POOLED: metadata is managed by a bufferpool
40 * @GST_META_FLAG_LOCKED: metadata should not be removed
41 * @GST_META_FLAG_LAST: additional flags can be added starting from this flag.
43 * Extra metadata flags.
46 GST_META_FLAG_NONE = 0,
47 GST_META_FLAG_READONLY = (1 << 0),
48 GST_META_FLAG_POOLED = (1 << 1),
49 GST_META_FLAG_LOCKED = (1 << 2),
51 GST_META_FLAG_LAST = (1 << 16)
58 * A flags word containing #GstMetaFlags flags set on @meta
60 #define GST_META_FLAGS(meta) (GST_META_CAST (meta)->flags)
62 * GST_META_FLAG_IS_SET:
64 * @flag: the #GstMetaFlags to check.
66 * Gives the status of a specific flag on a metadata.
68 #define GST_META_FLAG_IS_SET(meta,flag) !!(GST_META_FLAGS (meta) & (flag))
72 * @flag: the #GstMetaFlags to set.
74 * Sets a metadata flag on a metadata.
76 #define GST_META_FLAG_SET(meta,flag) (GST_META_FLAGS (meta) |= (flag))
78 * GST_META_FLAG_UNSET:
80 * @flag: the #GstMetaFlags to clear.
82 * Clears a metadata flag.
84 #define GST_META_FLAG_UNSET(meta,flag) (GST_META_FLAGS (meta) &= ~(flag))
87 * GST_META_TAG_MEMORY_STR:
89 * This metadata stays relevant as long as memory layout is unchanged.
93 #define GST_META_TAG_MEMORY_STR "memory"
97 * @flags: extra flags for the metadata
98 * @info: pointer to the #GstMetaInfo
100 * Base structure for metadata. Custom metadata will put this structure
101 * as the first member of their structure.
105 const GstMetaInfo *info;
108 #include <gst/gstbuffer.h>
111 * GstMetaInitFunction:
113 * @params: parameters passed to the init function
114 * @buffer: a #GstBuffer
116 * Function called when @meta is initialized in @buffer.
118 typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
121 * GstMetaFreeFunction:
123 * @buffer: a #GstBuffer
125 * Function called when @meta is freed in @buffer.
127 typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
130 * gst_meta_transform_copy:
132 * GQuark for the "gst-copy" transform.
135 GST_API GQuark _gst_meta_transform_copy;
138 * GST_META_TRANSFORM_IS_COPY:
139 * @type: a transform type
141 * Check if the transform type is a copy transform
143 #define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
146 * GstMetaTransformCopy:
147 * @region: %TRUE if only region is copied
148 * @offset: the offset to copy, 0 if @region is %FALSE, otherwise > 0
149 * @size: the size to copy, -1 or the buffer size when @region is %FALSE
151 * Extra data passed to a "gst-copy" transform #GstMetaTransformFunction.
157 } GstMetaTransformCopy;
160 * GstMetaTransformFunction:
161 * @transbuf: a #GstBuffer
163 * @buffer: a #GstBuffer
164 * @type: the transform type
165 * @data: transform specific data.
167 * Function called for each @meta in @buffer as a result of performing a
168 * transformation on @transbuf. Additional @type specific transform data
169 * is passed to the function as @data.
171 * Implementations should check the @type of the transform and parse
172 * additional type specific fields in @data that should be used to update
173 * the metadata on @transbuf.
175 * Returns: %TRUE if the transform could be performed
177 typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf,
178 GstMeta *meta, GstBuffer *buffer,
179 GQuark type, gpointer data);
183 * @api: tag identifying the metadata structure and api
184 * @type: type identifying the implementor of the api
185 * @size: size of the metadata
186 * @init_func: function for initializing the metadata
187 * @free_func: function for freeing the metadata
188 * @transform_func: function for transforming the metadata
190 * The #GstMetaInfo provides information about a specific metadata
193 struct _GstMetaInfo {
198 GstMetaInitFunction init_func;
199 GstMetaFreeFunction free_func;
200 GstMetaTransformFunction transform_func;
202 /* No padding needed, GstMetaInfo is always allocated by GStreamer and is
203 * not subclassable or stack-allocatable, so we can extend it as we please
204 * just like interfaces */
208 GType gst_meta_api_type_register (const gchar *api,
211 gboolean gst_meta_api_type_has_tag (GType api, GQuark tag);
214 const GstMetaInfo * gst_meta_register (GType api, const gchar *impl,
216 GstMetaInitFunction init_func,
217 GstMetaFreeFunction free_func,
218 GstMetaTransformFunction transform_func);
220 const GstMetaInfo * gst_meta_get_info (const gchar * impl);
223 const gchar* const* gst_meta_api_type_get_tags (GType api);
226 guint64 gst_meta_get_seqnum (const GstMeta * meta);
229 gint gst_meta_compare_seqnum (const GstMeta * meta1,
230 const GstMeta * meta2);
232 /* some default tags */
234 GST_API GQuark _gst_meta_tag_memory;
237 * GST_META_TAG_MEMORY:
239 * Metadata tagged with this tag depends on the particular memory
240 * or buffer that it is on.
242 * Deprecated: The GQuarks are not exported by any public API, use
243 * GST_META_TAG_MEMORY_STR instead.
245 #ifndef GST_DISABLE_DEPRECATED
246 #define GST_META_TAG_MEMORY (_gst_meta_tag_memory)
251 #endif /* __GST_META_H__ */