2011-02-25 12:15:25 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2011 Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
*
|
|
|
|
* gstmeta.c: metadata operations
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-02-25 12:15:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gstmeta
|
2017-01-16 14:26:16 +00:00
|
|
|
* @title: GstMeta
|
2011-02-25 12:15:25 +00:00
|
|
|
* @short_description: Buffer metadata
|
|
|
|
*
|
2012-03-29 11:34:50 +00:00
|
|
|
* The #GstMeta structure should be included as the first member of a #GstBuffer
|
|
|
|
* metadata structure. The structure defines the API of the metadata and should
|
|
|
|
* be accessible to all elements using the metadata.
|
|
|
|
*
|
|
|
|
* A metadata API is registered with gst_meta_api_type_register() which takes a
|
|
|
|
* name for the metadata API and some tags associated with the metadata.
|
|
|
|
* With gst_meta_api_type_has_tag() one can check if a certain metadata API
|
|
|
|
* contains a given tag.
|
|
|
|
*
|
|
|
|
* Multiple implementations of a metadata API can be registered.
|
|
|
|
* To implement a metadata API, gst_meta_register() should be used. This
|
|
|
|
* function takes all parameters needed to create, free and transform metadata
|
|
|
|
* along with the size of the metadata. The function returns a #GstMetaInfo
|
|
|
|
* structure that contains the information for the implementation of the API.
|
|
|
|
*
|
|
|
|
* A specific implementation can be retrieved by name with gst_meta_get_info().
|
|
|
|
*
|
|
|
|
* See #GstBuffer for how the metadata can be added, retrieved and removed from
|
|
|
|
* buffers.
|
2011-02-25 12:15:25 +00:00
|
|
|
*/
|
|
|
|
#include "gst_private.h"
|
|
|
|
|
|
|
|
#include "gstbuffer.h"
|
|
|
|
#include "gstmeta.h"
|
|
|
|
#include "gstinfo.h"
|
|
|
|
#include "gstutils.h"
|
2019-06-17 07:50:32 +00:00
|
|
|
#include "gstquark.h"
|
2011-02-25 12:15:25 +00:00
|
|
|
|
|
|
|
static GHashTable *metainfo = NULL;
|
2012-01-19 08:27:04 +00:00
|
|
|
static GRWLock lock;
|
2011-02-25 12:15:25 +00:00
|
|
|
|
2012-02-24 09:23:27 +00:00
|
|
|
GQuark _gst_meta_transform_copy;
|
2012-03-01 14:17:37 +00:00
|
|
|
GQuark _gst_meta_tag_memory;
|
2012-02-24 09:23:27 +00:00
|
|
|
|
2020-09-01 21:03:18 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstCustomMeta meta;
|
|
|
|
|
|
|
|
GstStructure *structure;
|
|
|
|
} GstCustomMetaImpl;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstMetaInfo info;
|
|
|
|
GstCustomMetaTransformFunction custom_transform_func;
|
|
|
|
gpointer custom_transform_user_data;
|
|
|
|
GDestroyNotify custom_transform_destroy_notify;
|
|
|
|
gboolean is_custom;
|
|
|
|
} GstMetaInfoImpl;
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_info (gpointer data)
|
|
|
|
{
|
|
|
|
g_slice_free (GstMetaInfoImpl, data);
|
|
|
|
}
|
|
|
|
|
2011-02-25 12:15:25 +00:00
|
|
|
void
|
2011-08-29 13:34:30 +00:00
|
|
|
_priv_gst_meta_initialize (void)
|
2011-02-25 12:15:25 +00:00
|
|
|
{
|
2012-01-19 08:27:04 +00:00
|
|
|
g_rw_lock_init (&lock);
|
2020-09-01 21:03:18 +00:00
|
|
|
metainfo = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, free_info);
|
2012-02-24 09:23:27 +00:00
|
|
|
|
2012-03-02 10:57:52 +00:00
|
|
|
_gst_meta_transform_copy = g_quark_from_static_string ("gst-copy");
|
2012-03-01 14:17:37 +00:00
|
|
|
_gst_meta_tag_memory = g_quark_from_static_string ("memory");
|
2011-02-25 12:15:25 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 21:03:18 +00:00
|
|
|
static gboolean
|
|
|
|
notify_custom (gchar * key, GstMetaInfo * info, gpointer unused)
|
|
|
|
{
|
|
|
|
GstMetaInfoImpl *impl = (GstMetaInfoImpl *) info;
|
|
|
|
|
|
|
|
if (impl->is_custom) {
|
|
|
|
if (impl->custom_transform_destroy_notify)
|
|
|
|
impl->custom_transform_destroy_notify (impl->custom_transform_user_data);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_priv_gst_meta_cleanup (void)
|
|
|
|
{
|
|
|
|
if (metainfo != NULL) {
|
|
|
|
g_hash_table_foreach_remove (metainfo, (GHRFunc) notify_custom, NULL);
|
|
|
|
g_hash_table_unref (metainfo);
|
|
|
|
metainfo = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-29 16:20:23 +00:00
|
|
|
/**
|
|
|
|
* gst_meta_api_type_register:
|
|
|
|
* @api: an API to register
|
2018-05-21 07:14:37 +00:00
|
|
|
* @tags: (array zero-terminated=1): tags for @api
|
2012-02-29 16:20:23 +00:00
|
|
|
*
|
|
|
|
* Register and return a GType for the @api and associate it with
|
|
|
|
* @tags.
|
|
|
|
*
|
|
|
|
* Returns: a unique GType for @api.
|
|
|
|
*/
|
|
|
|
GType
|
|
|
|
gst_meta_api_type_register (const gchar * api, const gchar ** tags)
|
|
|
|
{
|
|
|
|
GType type;
|
|
|
|
|
|
|
|
g_return_val_if_fail (api != NULL, 0);
|
|
|
|
g_return_val_if_fail (tags != NULL, 0);
|
|
|
|
|
2012-03-01 16:39:17 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_META, "register API \"%s\"", api);
|
2012-02-29 16:20:23 +00:00
|
|
|
type = g_pointer_type_register_static (api);
|
|
|
|
|
|
|
|
if (type != 0) {
|
|
|
|
gint i;
|
|
|
|
|
2012-03-01 16:39:17 +00:00
|
|
|
for (i = 0; tags[i]; i++) {
|
|
|
|
GST_CAT_DEBUG (GST_CAT_META, " adding tag \"%s\"", tags[i]);
|
2012-02-29 16:20:23 +00:00
|
|
|
g_type_set_qdata (type, g_quark_from_string (tags[i]),
|
|
|
|
GINT_TO_POINTER (TRUE));
|
2012-03-01 16:39:17 +00:00
|
|
|
}
|
2012-02-29 16:20:23 +00:00
|
|
|
}
|
2013-08-22 19:32:36 +00:00
|
|
|
|
2019-06-17 07:50:32 +00:00
|
|
|
g_type_set_qdata (type, GST_QUARK (TAGS), g_strdupv ((gchar **) tags));
|
2013-08-22 19:32:36 +00:00
|
|
|
|
2012-02-29 16:20:23 +00:00
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2020-09-01 21:03:18 +00:00
|
|
|
static gboolean
|
|
|
|
custom_init_func (GstMeta * meta, gpointer params, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstCustomMetaImpl *cmeta = (GstCustomMetaImpl *) meta;
|
|
|
|
|
|
|
|
cmeta->structure = gst_structure_new_empty (g_type_name (meta->info->type));
|
|
|
|
|
|
|
|
gst_structure_set_parent_refcount (cmeta->structure,
|
|
|
|
&GST_MINI_OBJECT_REFCOUNT (buffer));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
custom_free_func (GstMeta * meta, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstCustomMetaImpl *cmeta = (GstCustomMetaImpl *) meta;
|
|
|
|
|
|
|
|
gst_structure_set_parent_refcount (cmeta->structure, NULL);
|
|
|
|
gst_structure_free (cmeta->structure);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
custom_transform_func (GstBuffer * transbuf, GstMeta * meta,
|
|
|
|
GstBuffer * buffer, GQuark type, gpointer data)
|
|
|
|
{
|
|
|
|
GstCustomMetaImpl *custom, *cmeta = (GstCustomMetaImpl *) meta;
|
|
|
|
GstMetaInfoImpl *info = (GstMetaInfoImpl *) meta->info;
|
|
|
|
|
|
|
|
if (info->custom_transform_func)
|
|
|
|
return info->custom_transform_func (transbuf, (GstCustomMeta *) meta,
|
|
|
|
buffer, type, data, info->custom_transform_user_data);
|
|
|
|
|
|
|
|
if (GST_META_TRANSFORM_IS_COPY (type)) {
|
|
|
|
custom =
|
|
|
|
(GstCustomMetaImpl *) gst_buffer_add_meta (transbuf, meta->info, NULL);
|
|
|
|
gst_structure_set_parent_refcount (custom->structure, NULL);
|
|
|
|
gst_structure_take (&custom->structure,
|
|
|
|
gst_structure_copy (cmeta->structure));
|
|
|
|
gst_structure_set_parent_refcount (custom->structure,
|
|
|
|
&GST_MINI_OBJECT_REFCOUNT (buffer));
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_custom_meta_get_structure:
|
|
|
|
*
|
|
|
|
* Retrieve the #GstStructure backing a custom meta, the structure's mutability
|
|
|
|
* is conditioned to the writability of the #GstBuffer @meta is attached to.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): the #GstStructure backing @meta
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
GstStructure *
|
|
|
|
gst_custom_meta_get_structure (GstCustomMeta * meta)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (meta != NULL, NULL);
|
|
|
|
g_return_val_if_fail (gst_meta_info_is_custom (((GstMeta *) meta)->info),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return ((GstCustomMetaImpl *) meta)->structure;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_custom_meta_has_name:
|
|
|
|
*
|
|
|
|
* Checks whether the name of the custom meta is @name
|
|
|
|
*
|
|
|
|
* Returns: Whether @name is the name of the custom meta
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_custom_meta_has_name (GstCustomMeta * meta, const gchar * name)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (meta != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (gst_meta_info_is_custom (((GstMeta *) meta)->info),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
return gst_structure_has_name (((GstCustomMetaImpl *) meta)->structure, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_meta_register_custom:
|
|
|
|
* @name: the name of the #GstMeta implementation
|
|
|
|
* @tags: (array zero-terminated=1): tags for @api
|
|
|
|
* @transform_func: (scope notified) (nullable): a #GstMetaTransformFunction
|
|
|
|
* @user_data: (closure): user data passed to @transform_func
|
|
|
|
* @destroy_data: #GDestroyNotify for user_data
|
|
|
|
*
|
|
|
|
* Register a new custom #GstMeta implementation, backed by an opaque
|
|
|
|
* structure holding a #GstStructure.
|
|
|
|
*
|
|
|
|
* The registered info can be retrieved later with gst_meta_get_info() by using
|
|
|
|
* @name as the key.
|
|
|
|
*
|
|
|
|
* The backing #GstStructure can be retrieved with
|
|
|
|
* gst_custom_meta_get_structure(), its mutability is conditioned by the
|
|
|
|
* writability of the buffer the meta is attached to.
|
|
|
|
*
|
|
|
|
* When @transform_func is %NULL, the meta and its backing #GstStructure
|
|
|
|
* will always be copied when the transform operation is copy, other operations
|
|
|
|
* are discarded, copy regions are ignored.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): a #GstMetaInfo that can be used to
|
|
|
|
* access metadata.
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
const GstMetaInfo *
|
|
|
|
gst_meta_register_custom (const gchar * name, const gchar ** tags,
|
|
|
|
GstCustomMetaTransformFunction transform_func,
|
|
|
|
gpointer user_data, GDestroyNotify destroy_data)
|
|
|
|
{
|
|
|
|
gchar *api_name = g_strdup_printf ("%s-api", name);
|
|
|
|
GType api;
|
|
|
|
GstMetaInfoImpl *info;
|
|
|
|
GstMetaInfo *ret = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (tags != NULL, NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
api = gst_meta_api_type_register (api_name, tags);
|
|
|
|
g_free (api_name);
|
|
|
|
if (api == G_TYPE_INVALID)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
info = (GstMetaInfoImpl *) gst_meta_register (api, name,
|
|
|
|
sizeof (GstCustomMetaImpl),
|
|
|
|
custom_init_func, custom_free_func, custom_transform_func);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
info->is_custom = TRUE;
|
|
|
|
info->custom_transform_func = transform_func;
|
|
|
|
info->custom_transform_user_data = user_data;
|
|
|
|
info->custom_transform_destroy_notify = destroy_data;
|
|
|
|
|
|
|
|
ret = (GstMetaInfo *) info;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_meta_info_is_custom:
|
|
|
|
*
|
|
|
|
* Returns: whether @info was registered as a #GstCustomMeta with
|
|
|
|
* gst_meta_register_custom()
|
|
|
|
* Since:1.20
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_meta_info_is_custom (const GstMetaInfo * info)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (info != NULL, FALSE);
|
|
|
|
|
|
|
|
return ((GstMetaInfoImpl *) info)->is_custom;
|
|
|
|
}
|
|
|
|
|
2012-02-29 16:20:23 +00:00
|
|
|
/**
|
|
|
|
* gst_meta_api_type_has_tag:
|
|
|
|
* @api: an API
|
|
|
|
* @tag: the tag to check
|
|
|
|
*
|
|
|
|
* Check if @api was registered with @tag.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @api was registered with @tag.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_meta_api_type_has_tag (GType api, GQuark tag)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (api != 0, FALSE);
|
|
|
|
g_return_val_if_fail (tag != 0, FALSE);
|
|
|
|
|
|
|
|
return g_type_get_qdata (api, tag) != NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-22 19:32:36 +00:00
|
|
|
/**
|
|
|
|
* gst_meta_api_type_get_tags:
|
|
|
|
* @api: an API
|
|
|
|
*
|
|
|
|
* Returns: (transfer none) (array zero-terminated=1) (element-type utf8): an array of tags as strings.
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
const gchar *const *
|
|
|
|
gst_meta_api_type_get_tags (GType api)
|
|
|
|
{
|
|
|
|
const gchar **tags;
|
|
|
|
g_return_val_if_fail (api != 0, FALSE);
|
|
|
|
|
2019-06-17 07:50:32 +00:00
|
|
|
tags = g_type_get_qdata (api, GST_QUARK (TAGS));
|
2013-08-22 19:32:36 +00:00
|
|
|
|
2013-08-21 22:01:44 +00:00
|
|
|
if (!tags[0])
|
|
|
|
return NULL;
|
|
|
|
|
2013-08-22 19:32:36 +00:00
|
|
|
return (const gchar * const *) tags;
|
|
|
|
}
|
|
|
|
|
2011-02-25 12:15:25 +00:00
|
|
|
/**
|
2011-11-28 10:15:27 +00:00
|
|
|
* gst_meta_register:
|
2012-02-29 16:20:23 +00:00
|
|
|
* @api: the type of the #GstMeta API
|
2011-11-28 10:15:27 +00:00
|
|
|
* @impl: the name of the #GstMeta implementation
|
|
|
|
* @size: the size of the #GstMeta structure
|
2014-03-02 16:55:45 +00:00
|
|
|
* @init_func: (scope async): a #GstMetaInitFunction
|
|
|
|
* @free_func: (scope async): a #GstMetaFreeFunction
|
|
|
|
* @transform_func: (scope async): a #GstMetaTransformFunction
|
2011-02-25 12:15:25 +00:00
|
|
|
*
|
2011-11-28 10:15:27 +00:00
|
|
|
* Register a new #GstMeta implementation.
|
2011-02-25 12:15:25 +00:00
|
|
|
*
|
2011-11-28 10:15:27 +00:00
|
|
|
* The same @info can be retrieved later with gst_meta_get_info() by using
|
|
|
|
* @impl as the key.
|
|
|
|
*
|
2020-09-01 21:03:18 +00:00
|
|
|
* Returns: (transfer none): a #GstMetaInfo that can be used to
|
2017-10-22 12:35:30 +00:00
|
|
|
* access metadata.
|
2011-02-25 12:15:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
const GstMetaInfo *
|
2012-02-29 16:20:23 +00:00
|
|
|
gst_meta_register (GType api, const gchar * impl, gsize size,
|
2011-02-25 12:15:25 +00:00
|
|
|
GstMetaInitFunction init_func, GstMetaFreeFunction free_func,
|
2012-02-29 16:20:23 +00:00
|
|
|
GstMetaTransformFunction transform_func)
|
2011-02-25 12:15:25 +00:00
|
|
|
{
|
|
|
|
GstMetaInfo *info;
|
2012-10-03 11:35:20 +00:00
|
|
|
GType type;
|
2011-02-25 12:15:25 +00:00
|
|
|
|
2012-02-29 16:20:23 +00:00
|
|
|
g_return_val_if_fail (api != 0, NULL);
|
2011-02-25 12:15:25 +00:00
|
|
|
g_return_val_if_fail (impl != NULL, NULL);
|
|
|
|
g_return_val_if_fail (size != 0, NULL);
|
|
|
|
|
2016-04-13 07:21:15 +00:00
|
|
|
if (init_func == NULL)
|
|
|
|
g_critical ("Registering meta implementation '%s' without init function",
|
|
|
|
impl);
|
|
|
|
|
2012-10-03 11:35:20 +00:00
|
|
|
/* first try to register the implementation name. It's possible
|
2012-10-03 11:49:34 +00:00
|
|
|
* that this fails because it was already registered. Don't warn,
|
|
|
|
* glib did this for us already. */
|
2012-10-03 11:35:20 +00:00
|
|
|
type = g_pointer_type_register_static (impl);
|
2012-10-03 11:49:34 +00:00
|
|
|
if (type == 0)
|
|
|
|
return NULL;
|
2012-10-03 11:35:20 +00:00
|
|
|
|
2020-09-01 21:03:18 +00:00
|
|
|
info = (GstMetaInfo *) g_slice_new (GstMetaInfoImpl);
|
2012-02-29 16:20:23 +00:00
|
|
|
info->api = api;
|
2012-10-03 11:35:20 +00:00
|
|
|
info->type = type;
|
2011-02-25 12:15:25 +00:00
|
|
|
info->size = size;
|
|
|
|
info->init_func = init_func;
|
|
|
|
info->free_func = free_func;
|
2011-03-08 16:58:49 +00:00
|
|
|
info->transform_func = transform_func;
|
2020-09-01 21:03:18 +00:00
|
|
|
((GstMetaInfoImpl *) info)->is_custom = FALSE;
|
2011-02-25 12:15:25 +00:00
|
|
|
|
2012-03-01 16:39:17 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_META,
|
|
|
|
"register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT, impl,
|
|
|
|
g_type_name (api), size);
|
2011-02-25 12:15:25 +00:00
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
g_rw_lock_writer_lock (&lock);
|
2020-09-16 00:16:52 +00:00
|
|
|
g_hash_table_insert (metainfo, (gpointer) g_intern_string (impl),
|
|
|
|
(gpointer) info);
|
2012-01-19 08:27:04 +00:00
|
|
|
g_rw_lock_writer_unlock (&lock);
|
2011-02-25 12:15:25 +00:00
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_meta_get_info:
|
2011-03-30 17:01:13 +00:00
|
|
|
* @impl: the name
|
2011-02-25 12:15:25 +00:00
|
|
|
*
|
2011-11-28 10:15:27 +00:00
|
|
|
* Lookup a previously registered meta info structure by its implementation name
|
2011-03-30 17:01:13 +00:00
|
|
|
* @impl.
|
2011-02-25 12:15:25 +00:00
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer none) (nullable): a #GstMetaInfo with @impl, or
|
|
|
|
* %NULL when no such metainfo exists.
|
2011-02-25 12:15:25 +00:00
|
|
|
*/
|
|
|
|
const GstMetaInfo *
|
|
|
|
gst_meta_get_info (const gchar * impl)
|
|
|
|
{
|
|
|
|
GstMetaInfo *info;
|
|
|
|
|
|
|
|
g_return_val_if_fail (impl != NULL, NULL);
|
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
g_rw_lock_reader_lock (&lock);
|
2011-02-25 12:15:25 +00:00
|
|
|
info = g_hash_table_lookup (metainfo, impl);
|
2012-01-19 08:27:04 +00:00
|
|
|
g_rw_lock_reader_unlock (&lock);
|
2011-02-25 12:15:25 +00:00
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
2016-12-02 17:56:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_meta_get_seqnum:
|
|
|
|
* @meta: a #GstMeta
|
|
|
|
*
|
|
|
|
* Gets seqnum for this meta.
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
guint64
|
|
|
|
gst_meta_get_seqnum (const GstMeta * meta)
|
|
|
|
{
|
|
|
|
GstMetaItem *meta_item;
|
|
|
|
guint8 *p;
|
|
|
|
|
|
|
|
g_return_val_if_fail (meta != NULL, 0);
|
|
|
|
|
|
|
|
p = (guint8 *) meta;
|
|
|
|
p -= G_STRUCT_OFFSET (GstMetaItem, meta);
|
|
|
|
meta_item = (GstMetaItem *) p;
|
|
|
|
return meta_item->seq_num;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_meta_compare_seqnum:
|
|
|
|
* @meta1: a #GstMeta
|
|
|
|
* @meta2: a #GstMeta
|
|
|
|
*
|
|
|
|
* Meta sequence number compare function. Can be used as #GCompareFunc
|
|
|
|
* or a #GCompareDataFunc.
|
|
|
|
*
|
|
|
|
* Returns: a negative number if @meta1 comes before @meta2, 0 if both metas
|
|
|
|
* have an equal sequence number, or a positive integer if @meta1 comes
|
|
|
|
* after @meta2.
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gst_meta_compare_seqnum (const GstMeta * meta1, const GstMeta * meta2)
|
|
|
|
{
|
|
|
|
guint64 seqnum1 = gst_meta_get_seqnum (meta1);
|
|
|
|
guint64 seqnum2 = gst_meta_get_seqnum (meta2);
|
|
|
|
|
|
|
|
if (seqnum1 == seqnum2)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (seqnum1 < seqnum2) ? -1 : 1;
|
|
|
|
}
|