gstmeta.h 3.91 KB
Newer Older
1 2 3
/* GStreamer
 * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
 *
Wim Taymans's avatar
Wim Taymans committed
4
 * gstmeta.h: Header for Metadata structures
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


Wim Taymans's avatar
Wim Taymans committed
23 24
#ifndef __GST_META_H__
#define __GST_META_H__
25 26 27

G_BEGIN_DECLS

Wim Taymans's avatar
Wim Taymans committed
28 29
typedef struct _GstMeta GstMeta;
typedef struct _GstMetaInfo GstMetaInfo;
30 31

/**
Wim Taymans's avatar
Wim Taymans committed
32 33
 * GstMeta:
 * @info: pointer to the #GstMetaInfo
34
 *
Wim Taymans's avatar
Wim Taymans committed
35
 * Base structure for metadata. Custom metadata will put this structure
36 37
 * as the first member of their structure.
 */
Wim Taymans's avatar
Wim Taymans committed
38 39
struct _GstMeta {
  const GstMetaInfo *info;
40 41 42
};

/**
Wim Taymans's avatar
Wim Taymans committed
43
 * GST_META_TRACE_NAME:
44 45 46
 *
 * The name used for tracing memory allocations.
 */
Wim Taymans's avatar
Wim Taymans committed
47
#define GST_META_TRACE_NAME           "GstMeta"
48 49 50 51

/**
 * GstMetaInitFunction:
 * @meta: a #GstMeta
Wim Taymans's avatar
Wim Taymans committed
52
 * @params: parameters passed to the init function
53 54 55 56
 * @buffer: a #GstBuffer
 *
 * Function called when @meta is initialized in @buffer.
 */
57
typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
58 59 60 61 62 63 64 65

/**
 * GstMetaFreeFunction:
 * @meta: a #GstMeta
 * @buffer: a #GstBuffer
 *
 * Function called when @meta is freed in @buffer.
 */
Wim Taymans's avatar
Wim Taymans committed
66
typedef void (*GstMetaFreeFunction)     (GstMeta *meta, GstBuffer *buffer);
67

Wim Taymans's avatar
Wim Taymans committed
68 69
typedef void (*GstMetaCopyFunction)     (GstBuffer *dest, GstMeta *meta,
                                         GstBuffer *buffer, gsize offset, gsize size);
70 71 72
/**
 * GstMetaTransformFunction:
 * @transbuf: a #GstBuffer
73 74
 * @meta: a #GstMeta
 * @buffer: a #GstBuffer
75 76 77 78 79 80 81 82
 * @data: transform specific data.
 *
 * Function called for each @meta in @buffer as a result of performing a
 * transformation on @transbuf. Additional type specific transform data
 * is passed to the function.
 *
 * Implementations should check the type of the transform @data and parse
 * additional type specific field that should be used to perform the transform.
83
 */
84
typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf, GstMeta *meta,
Wim Taymans's avatar
Wim Taymans committed
85
                                          GstBuffer *buffer, gpointer data);
86 87

/**
Wim Taymans's avatar
Wim Taymans committed
88 89
 * GstMetaInfo:
 * @api: tag indentifying the metadata structure and api
90
 * @type: type indentifying the implementor of the api
91 92 93
 * @size: size of the metadata
 * @init_func: function for initializing the metadata
 * @free_func: function for freeing the metadata
Wim Taymans's avatar
Wim Taymans committed
94
 * @copy_func: function for copying the metadata
Wim Taymans's avatar
Wim Taymans committed
95
 * @transform_func: function for transforming the metadata
96
 *
Wim Taymans's avatar
Wim Taymans committed
97
 * The #GstMetaInfo provides information about a specific metadata
98 99
 * structure.
 */
Wim Taymans's avatar
Wim Taymans committed
100 101
struct _GstMetaInfo {
  GQuark                     api;
102
  GType                      type;
103 104 105 106
  gsize                      size;

  GstMetaInitFunction        init_func;
  GstMetaFreeFunction        free_func;
Wim Taymans's avatar
Wim Taymans committed
107
  GstMetaCopyFunction        copy_func;
108
  GstMetaTransformFunction   transform_func;
109 110
};

Wim Taymans's avatar
Wim Taymans committed
111 112 113 114
const GstMetaInfo *  gst_meta_register        (const gchar *api, const gchar *impl,
                                               gsize size,
                                               GstMetaInitFunction        init_func,
                                               GstMetaFreeFunction        free_func,
Wim Taymans's avatar
Wim Taymans committed
115
                                               GstMetaCopyFunction        copy_func,
116
                                               GstMetaTransformFunction   transform_func);
Wim Taymans's avatar
Wim Taymans committed
117
const GstMetaInfo *  gst_meta_get_info        (const gchar * impl);
118 119 120

G_END_DECLS

Wim Taymans's avatar
Wim Taymans committed
121
#endif /* __GST_META_H__ */