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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, 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 and should not
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),
48 GST_META_FLAG_LAST = (1 << 16)
55 * A flags word containing #GstMetaFlags flags set on @meta
57 #define GST_META_FLAGS(meta) (GST_META_CAST (meta)->flags)
59 * GST_META_FLAG_IS_SET:
61 * @flag: the #GstMetaFlags to check.
63 * Gives the status of a specific flag on a metadata.
65 #define GST_META_FLAG_IS_SET(meta,flag) !!(GST_META_FLAGS (meta) & (flag))
69 * @flag: the #GstMetaFlags to set.
71 * Sets a metadata flag on a metadata.
73 #define GST_META_FLAG_SET(meta,flag) (GST_META_FLAGS (meta) |= (flag))
75 * GST_META_FLAG_UNSET:
77 * @flag: the #GstMetaFlags to clear.
79 * Clears a metadata flag.
81 #define GST_META_FLAG_UNSET(meta,flag) (GST_META_FLAGS (meta) &= ~(flag))
85 * @flags: extra flags for the metadata
86 * @info: pointer to the #GstMetaInfo
88 * Base structure for metadata. Custom metadata will put this structure
89 * as the first member of their structure.
93 const GstMetaInfo *info;
97 * GstMetaInitFunction:
99 * @params: parameters passed to the init function
100 * @buffer: a #GstBuffer
102 * Function called when @meta is initialized in @buffer.
104 typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
107 * GstMetaFreeFunction:
109 * @buffer: a #GstBuffer
111 * Function called when @meta is freed in @buffer.
113 typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
116 * gst_meta_transform_copy:
118 * GQuark for the "copy" transform.
120 GST_EXPORT GQuark _gst_meta_transform_copy;
122 #define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
125 * GstMetaTransformDataCopy:
126 * @offset: the offset to copy
127 * @size: the size to copy
129 * Extra data passed to a "copy" transform #GstMetaTransformFunction.
134 } GstMetaTransformCopy;
137 * GstMetaTransformFunction:
138 * @transbuf: a #GstBuffer
140 * @buffer: a #GstBuffer
141 * @type: the transform type
142 * @data: transform specific data.
144 * Function called for each @meta in @buffer as a result of performing a
145 * transformation on @transbuf. Additional @type specific transform data
146 * is passed to the function as @data.
148 * Implementations should check the @type of the transform and parse
149 * additional type specific fields in @data that should be used to update
150 * the metadata on @transbuf.
152 typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf,
153 GstMeta *meta, GstBuffer *buffer,
154 GQuark type, gpointer data);
158 * @api: tag indentifying the metadata structure and api
159 * @type: type indentifying the implementor of the api
160 * @size: size of the metadata
161 * @init_func: function for initializing the metadata
162 * @free_func: function for freeing the metadata
163 * @transform_func: function for transforming the metadata
165 * The #GstMetaInfo provides information about a specific metadata
168 struct _GstMetaInfo {
173 GstMetaInitFunction init_func;
174 GstMetaFreeFunction free_func;
175 GstMetaTransformFunction transform_func;
178 gpointer _gst_reserved[GST_PADDING];
181 const GstMetaInfo * gst_meta_register (const gchar *api, const gchar *impl,
183 GstMetaInitFunction init_func,
184 GstMetaFreeFunction free_func,
185 GstMetaTransformFunction transform_func);
186 const GstMetaInfo * gst_meta_get_info (const gchar * impl);
190 #endif /* __GST_META_H__ */