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__
27 #include <gst/gstbuffer.h>
31 typedef struct _GstMeta GstMeta;
32 typedef struct _GstMetaInfo GstMetaInfo;
34 #define GST_META_CAST(meta) ((GstMeta *)(meta))
38 * @GST_META_FLAG_NONE: no flags
39 * @GST_META_FLAG_READONLY: metadata should not be modified
40 * @GST_META_FLAG_POOLED: metadata is managed by a bufferpool
41 * @GST_META_FLAG_LOCKED: metadata should not be removed
42 * @GST_META_FLAG_LAST: additional flags can be added starting from this flag.
44 * Extra metadata flags.
47 GST_META_FLAG_NONE = 0,
48 GST_META_FLAG_READONLY = (1 << 0),
49 GST_META_FLAG_POOLED = (1 << 1),
50 GST_META_FLAG_LOCKED = (1 << 2),
52 GST_META_FLAG_LAST = (1 << 16)
59 * A flags word containing #GstMetaFlags flags set on @meta
61 #define GST_META_FLAGS(meta) (GST_META_CAST (meta)->flags)
63 * GST_META_FLAG_IS_SET:
65 * @flag: the #GstMetaFlags to check.
67 * Gives the status of a specific flag on a metadata.
69 #define GST_META_FLAG_IS_SET(meta,flag) !!(GST_META_FLAGS (meta) & (flag))
73 * @flag: the #GstMetaFlags to set.
75 * Sets a metadata flag on a metadata.
77 #define GST_META_FLAG_SET(meta,flag) (GST_META_FLAGS (meta) |= (flag))
79 * GST_META_FLAG_UNSET:
81 * @flag: the #GstMetaFlags to clear.
83 * Clears a metadata flag.
85 #define GST_META_FLAG_UNSET(meta,flag) (GST_META_FLAGS (meta) &= ~(flag))
88 * GST_META_TAG_MEMORY_STR:
90 * This metadata stays relevant as long as memory layout is unchanged.
94 #define GST_META_TAG_MEMORY_STR "memory"
98 * @flags: extra flags for the metadata
99 * @info: pointer to the #GstMetaInfo
101 * Base structure for metadata. Custom metadata will put this structure
102 * as the first member of their structure.
106 const GstMetaInfo *info;
110 * GstMetaInitFunction:
112 * @params: parameters passed to the init function
113 * @buffer: a #GstBuffer
115 * Function called when @meta is initialized in @buffer.
117 typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
120 * GstMetaFreeFunction:
122 * @buffer: a #GstBuffer
124 * Function called when @meta is freed in @buffer.
126 typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
129 * gst_meta_transform_copy:
131 * GQuark for the "gst-copy" transform.
133 GST_EXPORT GQuark _gst_meta_transform_copy;
136 * GST_META_TRANSFORM_IS_COPY:
137 * @type: a transform type
139 * Check if the transform type is a copy transform
141 #define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
144 * GstMetaTransformCopy:
145 * @region: %TRUE if only region is copied
146 * @offset: the offset to copy, 0 if @region is %FALSE, otherwise > 0
147 * @size: the size to copy, -1 or the buffer size when @region is %FALSE
149 * Extra data passed to a "gst-copy" transform #GstMetaTransformFunction.
155 } GstMetaTransformCopy;
158 * GstMetaTransformFunction:
159 * @transbuf: a #GstBuffer
161 * @buffer: a #GstBuffer
162 * @type: the transform type
163 * @data: transform specific data.
165 * Function called for each @meta in @buffer as a result of performing a
166 * transformation on @transbuf. Additional @type specific transform data
167 * is passed to the function as @data.
169 * Implementations should check the @type of the transform and parse
170 * additional type specific fields in @data that should be used to update
171 * the metadata on @transbuf.
173 * Returns: %TRUE if the transform could be performed
175 typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf,
176 GstMeta *meta, GstBuffer *buffer,
177 GQuark type, gpointer data);
181 * @api: tag identifying the metadata structure and api
182 * @type: type identifying the implementor of the api
183 * @size: size of the metadata
184 * @init_func: function for initializing the metadata
185 * @free_func: function for freeing the metadata
186 * @transform_func: function for transforming the metadata
188 * The #GstMetaInfo provides information about a specific metadata
191 struct _GstMetaInfo {
196 GstMetaInitFunction init_func;
197 GstMetaFreeFunction free_func;
198 GstMetaTransformFunction transform_func;
201 gpointer _gst_reserved[GST_PADDING];
204 GType gst_meta_api_type_register (const gchar *api,
206 gboolean gst_meta_api_type_has_tag (GType api, GQuark tag);
208 const GstMetaInfo * gst_meta_register (GType api, const gchar *impl,
210 GstMetaInitFunction init_func,
211 GstMetaFreeFunction free_func,
212 GstMetaTransformFunction transform_func);
213 const GstMetaInfo * gst_meta_get_info (const gchar * impl);
214 const gchar* const* gst_meta_api_type_get_tags (GType api);
216 /* some default tags */
217 GST_EXPORT GQuark _gst_meta_tag_memory;
220 * GST_META_TAG_MEMORY:
222 * Metadata tagged with this tag depends on the particular memory
223 * or buffer that it is on.
225 * Deprecated: The GQuarks are not exported by any public API, use
226 * GST_META_TAG_MEMORY_STR instead.
228 #ifndef GST_DISABLE_DEPRECATED
229 #define GST_META_TAG_MEMORY (_gst_meta_tag_memory)
234 #endif /* __GST_META_H__ */