Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst / gstmeta.h
1 /* GStreamer
2  * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
3  *
4  * gstmeta.h: Header for Metadata structures
5  *
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.
10  *
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.
15  *
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.
20  */
21
22
23 #ifndef __GST_META_H__
24 #define __GST_META_H__
25
26 G_BEGIN_DECLS
27
28 typedef struct _GstMeta GstMeta;
29 typedef struct _GstMetaInfo GstMetaInfo;
30
31 /**
32  * GstMeta:
33  * @info: pointer to the #GstMetaInfo
34  *
35  * Base structure for metadata. Custom metadata will put this structure
36  * as the first member of their structure.
37  */
38 struct _GstMeta {
39   const GstMetaInfo *info;
40 };
41
42 /**
43  * GST_META_TRACE_NAME:
44  *
45  * The name used for tracing memory allocations.
46  */
47 #define GST_META_TRACE_NAME           "GstMeta"
48
49 /**
50  * GstMetaInitFunction:
51  * @meta: a #GstMeta
52  * @params: parameters passed to the init function
53  * @buffer: a #GstBuffer
54  *
55  * Function called when @meta is initialized in @buffer.
56  */
57 typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
58
59 /**
60  * GstMetaFreeFunction:
61  * @meta: a #GstMeta
62  * @buffer: a #GstBuffer
63  *
64  * Function called when @meta is freed in @buffer.
65  */
66 typedef void (*GstMetaFreeFunction)     (GstMeta *meta, GstBuffer *buffer);
67
68 typedef void (*GstMetaCopyFunction)     (GstBuffer *dest, GstMeta *meta,
69                                          GstBuffer *buffer, gsize offset, gsize size);
70 /**
71  * GstMetaTransformFunction:
72  * @transbuf: a #GstBuffer
73  * @meta: a #GstMeta
74  * @buffer: a #GstBuffer
75  * @data: transform specific data.
76  *
77  * Function called for each @meta in @buffer as a result of performing a
78  * transformation on @transbuf. Additional type specific transform data
79  * is passed to the function.
80  *
81  * Implementations should check the type of the transform @data and parse
82  * additional type specific field that should be used to perform the transform.
83  */
84 typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf, GstMeta *meta,
85                                           GstBuffer *buffer, gpointer data);
86
87 /**
88  * GstMetaInfo:
89  * @api: tag indentifying the metadata structure and api
90  * @type: type indentifying the implementor of the api
91  * @size: size of the metadata
92  * @init_func: function for initializing the metadata
93  * @free_func: function for freeing the metadata
94  * @copy_func: function for copying the metadata
95  * @transform_func: function for transforming the metadata
96  *
97  * The #GstMetaInfo provides information about a specific metadata
98  * structure.
99  */
100 struct _GstMetaInfo {
101   GQuark                     api;
102   GType                      type;
103   gsize                      size;
104
105   GstMetaInitFunction        init_func;
106   GstMetaFreeFunction        free_func;
107   GstMetaCopyFunction        copy_func;
108   GstMetaTransformFunction   transform_func;
109 };
110
111 const GstMetaInfo *  gst_meta_register        (const gchar *api, const gchar *impl,
112                                                gsize size,
113                                                GstMetaInitFunction        init_func,
114                                                GstMetaFreeFunction        free_func,
115                                                GstMetaCopyFunction        copy_func,
116                                                GstMetaTransformFunction   transform_func);
117 const GstMetaInfo *  gst_meta_get_info        (const gchar * impl);
118
119 G_END_DECLS
120
121 #endif /* __GST_META_H__ */