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:
87 * This metadata stays relevant as long as memory layout is unchanged.
91 #define GST_META_TAG_MEMORY_STR "memory"
95 * @flags: extra flags for the metadata
96 * @info: pointer to the #GstMetaInfo
98 * Base structure for metadata. Custom metadata will put this structure
99 * as the first member of their structure.
103 const GstMetaInfo *info;
107 * GstMetaInitFunction:
109 * @params: parameters passed to the init function
110 * @buffer: a #GstBuffer
112 * Function called when @meta is initialized in @buffer.
114 typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
117 * GstMetaFreeFunction:
119 * @buffer: a #GstBuffer
121 * Function called when @meta is freed in @buffer.
123 typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
126 * gst_meta_transform_copy:
128 * GQuark for the "gst-copy" transform.
130 GST_EXPORT GQuark _gst_meta_transform_copy;
133 * GST_META_TRANSFORM_IS_COPY:
134 * @type: a transform type
136 * Check if the transform type is a copy transform
138 #define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
141 * GstMetaTransformCopy:
142 * @region: %TRUE if only region is copied
143 * @offset: the offset to copy, 0 if @region is %FALSE, otherwise > 0
144 * @size: the size to copy, -1 or the buffer size when @region is %FALSE
146 * Extra data passed to a "gst-copy" transform #GstMetaTransformFunction.
152 } GstMetaTransformCopy;
155 * GstMetaTransformFunction:
156 * @transbuf: a #GstBuffer
158 * @buffer: a #GstBuffer
159 * @type: the transform type
160 * @data: transform specific data.
162 * Function called for each @meta in @buffer as a result of performing a
163 * transformation on @transbuf. Additional @type specific transform data
164 * is passed to the function as @data.
166 * Implementations should check the @type of the transform and parse
167 * additional type specific fields in @data that should be used to update
168 * the metadata on @transbuf.
170 * Returns: %TRUE if the transform could be performed
172 typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf,
173 GstMeta *meta, GstBuffer *buffer,
174 GQuark type, gpointer data);
178 * @api: tag indentifying the metadata structure and api
179 * @type: type indentifying the implementor of the api
180 * @size: size of the metadata
181 * @init_func: function for initializing the metadata
182 * @free_func: function for freeing the metadata
183 * @transform_func: function for transforming the metadata
185 * The #GstMetaInfo provides information about a specific metadata
188 struct _GstMetaInfo {
193 GstMetaInitFunction init_func;
194 GstMetaFreeFunction free_func;
195 GstMetaTransformFunction transform_func;
198 gpointer _gst_reserved[GST_PADDING];
201 GType gst_meta_api_type_register (const gchar *api,
203 gboolean gst_meta_api_type_has_tag (GType api, GQuark tag);
205 const GstMetaInfo * gst_meta_register (GType api, const gchar *impl,
207 GstMetaInitFunction init_func,
208 GstMetaFreeFunction free_func,
209 GstMetaTransformFunction transform_func);
210 const GstMetaInfo * gst_meta_get_info (const gchar * impl);
211 const gchar* const* gst_meta_api_type_get_tags (GType api);
213 /* some default tags */
214 GST_EXPORT GQuark _gst_meta_tag_memory;
217 * GST_META_TAG_MEMORY:
219 * Metadata tagged with this tag depends on the particular memory
220 * or buffer that it is on.
222 * Deprecated: The GQuarks are not exported by any public API, use
223 * GST_META_TAG_MEMORY_STR instead.
225 #define GST_META_TAG_MEMORY (_gst_meta_tag_memory)
229 #endif /* __GST_META_H__ */