2 * Copyright (C) 2011 Wim Taymans <wim.taymans@gmail.com>
4 * gstmeta.c: metadata operations
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.
24 * @short_description: Buffer metadata
26 * Last reviewed on December 17th, 2009 (0.10.26)
28 #include "gst_private.h"
30 #include "gstbuffer.h"
35 static GHashTable *metainfo = NULL;
36 static GStaticRWLock lock = G_STATIC_RW_LOCK_INIT;
39 _priv_gst_meta_initialize (void)
41 metainfo = g_hash_table_new (g_str_hash, g_str_equal);
46 * @api: the name of the #GstMeta API
47 * @impl: the name of the #GstMeta implementation
48 * @size: the size of the #GstMeta structure
49 * @init_func: a #GstMetaInitFunction
50 * @free_func: a #GstMetaFreeFunction
51 * @copy_func: a #GstMetaCopyFunction
52 * @transform_func: a #GstMetaTransformFunction
54 * Register a new #GstMeta implementation.
56 * The same @info can be retrieved later with gst_meta_get_info() by using
59 * Returns: (transfer none): a #GstMetaInfo that can be used to access metadata.
63 gst_meta_register (const gchar * api, const gchar * impl, gsize size,
64 GstMetaInitFunction init_func, GstMetaFreeFunction free_func,
65 GstMetaCopyFunction copy_func, GstMetaTransformFunction transform_func)
69 g_return_val_if_fail (api != NULL, NULL);
70 g_return_val_if_fail (impl != NULL, NULL);
71 g_return_val_if_fail (size != 0, NULL);
73 info = g_slice_new (GstMetaInfo);
74 info->api = g_quark_from_string (api);
75 info->type = g_pointer_type_register_static (impl);
77 info->init_func = init_func;
78 info->free_func = free_func;
79 info->copy_func = copy_func;
80 info->transform_func = transform_func;
82 GST_DEBUG ("register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT,
85 g_static_rw_lock_writer_lock (&lock);
86 g_hash_table_insert (metainfo, (gpointer) impl, (gpointer) info);
87 g_static_rw_lock_writer_unlock (&lock);
96 * Lookup a previously registered meta info structure by its implementation name
99 * Returns: (transfer none): a #GstMetaInfo with @impl, or #NULL when no such
103 gst_meta_get_info (const gchar * impl)
107 g_return_val_if_fail (impl != NULL, NULL);
109 g_static_rw_lock_reader_lock (&lock);
110 info = g_hash_table_lookup (metainfo, impl);
111 g_static_rw_lock_reader_unlock (&lock);