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;
33 * @info: pointer to the #GstMetaInfo
35 * Base structure for metadata. Custom metadata will put this structure
36 * as the first member of their structure.
39 const GstMetaInfo *info;
43 * GST_META_TRACE_NAME:
45 * The name used for tracing memory allocations.
47 #define GST_META_TRACE_NAME "GstMeta"
50 * GstMetaInitFunction:
52 * @buffer: a #GstBuffer
54 * Function called when @meta is initialized in @buffer.
56 typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
59 * GstMetaFreeFunction:
61 * @buffer: a #GstBuffer
63 * Function called when @meta is freed in @buffer.
65 typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
67 typedef void (*GstMetaCopyFunction) (GstBuffer *dest, GstMeta *meta,
68 GstBuffer *buffer, gsize offset, gsize size);
70 * GstMetaTransformFunction:
71 * @transbuf: a #GstBuffer
73 * @buffer: a #GstBuffer
74 * @data: transform specific data.
76 * Function called for each @meta in @buffer as a result of performing a
77 * transformation on @transbuf. Additional type specific transform data
78 * is passed to the function.
80 * Implementations should check the type of the transform @data and parse
81 * additional type specific field that should be used to perform the transform.
83 typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf, GstMeta *meta,
84 GstBuffer *buffer, gpointer data);
88 * @api: tag indentifying the metadata structure and api
89 * @type: type indentifying the implementor of the api
90 * @size: size of the metadata
91 * @init_func: function for initializing the metadata
92 * @free_func: function for freeing the metadata
93 * @copy_func: function for copying the metadata
94 * @transform_func: function for transforming the metadata
96 * The #GstMetaInfo provides information about a specific metadata
104 GstMetaInitFunction init_func;
105 GstMetaFreeFunction free_func;
106 GstMetaCopyFunction copy_func;
107 GstMetaTransformFunction transform_func;
110 void _gst_meta_init (void);
112 const GstMetaInfo * gst_meta_register (const gchar *api, const gchar *impl,
114 GstMetaInitFunction init_func,
115 GstMetaFreeFunction free_func,
116 GstMetaCopyFunction copy_func,
117 GstMetaTransformFunction transform_func);
118 const GstMetaInfo * gst_meta_get_info (const gchar * impl);
120 /* default metadata */
122 /* timing metadata */
123 typedef struct _GstMetaTiming GstMetaTiming;
125 const GstMetaInfo *gst_meta_timing_get_info(void);
126 #define GST_META_TIMING_INFO (gst_meta_timing_get_info())
128 struct _GstMetaTiming {
129 GstMeta meta; /* common meta header */
131 GstClockTime dts; /* decoding timestamp */
132 GstClockTime pts; /* presentation timestamp */
133 GstClockTime duration; /* duration of the data */
134 GstClockTime clock_rate; /* clock rate for the above values */
137 #define gst_buffer_get_meta_timing(b) ((GstMetaTiming*)gst_buffer_get_meta((b),GST_META_TIMING_INFO))
138 #define gst_buffer_add_meta_timing(b) ((GstMetaTiming*)gst_buffer_add_meta((b),GST_META_TIMING_INFO,NULL))
142 #endif /* __GST_META_H__ */