2009-12-17 11:34:42 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
|
|
|
|
*
|
2011-02-25 12:15:25 +00:00
|
|
|
* gstmeta.h: Header for Metadata structures
|
2009-12-17 11:34:42 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2009-12-17 11:34:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-02-25 12:15:25 +00:00
|
|
|
#ifndef __GST_META_H__
|
|
|
|
#define __GST_META_H__
|
2009-12-17 11:34:42 +00:00
|
|
|
|
2015-08-10 22:35:21 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2009-12-17 11:34:42 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2011-02-25 12:15:25 +00:00
|
|
|
typedef struct _GstMeta GstMeta;
|
|
|
|
typedef struct _GstMetaInfo GstMetaInfo;
|
2009-12-17 11:34:42 +00:00
|
|
|
|
2011-12-22 14:52:08 +00:00
|
|
|
#define GST_META_CAST(meta) ((GstMeta *)(meta))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstMetaFlags:
|
|
|
|
* @GST_META_FLAG_NONE: no flags
|
|
|
|
* @GST_META_FLAG_READONLY: metadata should not be modified
|
2012-04-17 13:37:27 +00:00
|
|
|
* @GST_META_FLAG_POOLED: metadata is managed by a bufferpool
|
|
|
|
* @GST_META_FLAG_LOCKED: metadata should not be removed
|
2011-12-22 14:52:08 +00:00
|
|
|
* @GST_META_FLAG_LAST: additional flags can be added starting from this flag.
|
|
|
|
*
|
|
|
|
* Extra metadata flags.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
GST_META_FLAG_NONE = 0,
|
|
|
|
GST_META_FLAG_READONLY = (1 << 0),
|
|
|
|
GST_META_FLAG_POOLED = (1 << 1),
|
2012-04-17 13:37:27 +00:00
|
|
|
GST_META_FLAG_LOCKED = (1 << 2),
|
2011-12-22 14:52:08 +00:00
|
|
|
|
|
|
|
GST_META_FLAG_LAST = (1 << 16)
|
|
|
|
} GstMetaFlags;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GST_META_FLAGS:
|
|
|
|
* @meta: a #GstMeta.
|
|
|
|
*
|
2012-02-13 14:18:28 +00:00
|
|
|
* A flags word containing #GstMetaFlags flags set on @meta
|
2011-12-22 14:52:08 +00:00
|
|
|
*/
|
|
|
|
#define GST_META_FLAGS(meta) (GST_META_CAST (meta)->flags)
|
|
|
|
/**
|
|
|
|
* GST_META_FLAG_IS_SET:
|
|
|
|
* @meta: a #GstMeta.
|
2012-02-13 14:18:28 +00:00
|
|
|
* @flag: the #GstMetaFlags to check.
|
2011-12-22 14:52:08 +00:00
|
|
|
*
|
|
|
|
* Gives the status of a specific flag on a metadata.
|
|
|
|
*/
|
|
|
|
#define GST_META_FLAG_IS_SET(meta,flag) !!(GST_META_FLAGS (meta) & (flag))
|
|
|
|
/**
|
|
|
|
* GST_META_FLAG_SET:
|
|
|
|
* @meta: a #GstMeta.
|
2012-02-13 14:18:28 +00:00
|
|
|
* @flag: the #GstMetaFlags to set.
|
2011-12-22 14:52:08 +00:00
|
|
|
*
|
|
|
|
* Sets a metadata flag on a metadata.
|
|
|
|
*/
|
|
|
|
#define GST_META_FLAG_SET(meta,flag) (GST_META_FLAGS (meta) |= (flag))
|
|
|
|
/**
|
|
|
|
* GST_META_FLAG_UNSET:
|
|
|
|
* @meta: a #GstMeta.
|
2012-02-13 14:18:28 +00:00
|
|
|
* @flag: the #GstMetaFlags to clear.
|
2011-12-22 14:52:08 +00:00
|
|
|
*
|
|
|
|
* Clears a metadata flag.
|
|
|
|
*/
|
|
|
|
#define GST_META_FLAG_UNSET(meta,flag) (GST_META_FLAGS (meta) &= ~(flag))
|
|
|
|
|
2013-08-21 22:02:28 +00:00
|
|
|
/**
|
|
|
|
* GST_META_TAG_MEMORY_STR:
|
2013-11-30 13:52:40 +00:00
|
|
|
*
|
2013-08-21 22:02:28 +00:00
|
|
|
* This metadata stays relevant as long as memory layout is unchanged.
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
#define GST_META_TAG_MEMORY_STR "memory"
|
|
|
|
|
2009-12-17 11:34:42 +00:00
|
|
|
/**
|
2011-02-25 12:15:25 +00:00
|
|
|
* GstMeta:
|
2011-12-22 14:52:08 +00:00
|
|
|
* @flags: extra flags for the metadata
|
2011-02-25 12:15:25 +00:00
|
|
|
* @info: pointer to the #GstMetaInfo
|
2009-12-17 11:34:42 +00:00
|
|
|
*
|
2011-02-25 12:15:25 +00:00
|
|
|
* Base structure for metadata. Custom metadata will put this structure
|
2009-12-17 11:34:42 +00:00
|
|
|
* as the first member of their structure.
|
|
|
|
*/
|
2011-02-25 12:15:25 +00:00
|
|
|
struct _GstMeta {
|
2011-12-22 14:52:08 +00:00
|
|
|
GstMetaFlags flags;
|
2011-02-25 12:15:25 +00:00
|
|
|
const GstMetaInfo *info;
|
2009-12-17 11:34:42 +00:00
|
|
|
};
|
|
|
|
|
2017-01-11 20:25:08 +00:00
|
|
|
#include <gst/gstbuffer.h>
|
|
|
|
|
2009-12-17 11:34:42 +00:00
|
|
|
/**
|
|
|
|
* GstMetaInitFunction:
|
|
|
|
* @meta: a #GstMeta
|
2011-09-26 18:47:35 +00:00
|
|
|
* @params: parameters passed to the init function
|
2009-12-17 11:34:42 +00:00
|
|
|
* @buffer: a #GstBuffer
|
|
|
|
*
|
|
|
|
* Function called when @meta is initialized in @buffer.
|
|
|
|
*/
|
2011-02-27 18:40:45 +00:00
|
|
|
typedef gboolean (*GstMetaInitFunction) (GstMeta *meta, gpointer params, GstBuffer *buffer);
|
2009-12-17 11:34:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstMetaFreeFunction:
|
|
|
|
* @meta: a #GstMeta
|
|
|
|
* @buffer: a #GstBuffer
|
|
|
|
*
|
|
|
|
* Function called when @meta is freed in @buffer.
|
|
|
|
*/
|
2011-02-25 12:15:25 +00:00
|
|
|
typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
|
2009-12-17 11:34:42 +00:00
|
|
|
|
2011-11-14 09:27:01 +00:00
|
|
|
/**
|
2012-02-24 09:23:27 +00:00
|
|
|
* gst_meta_transform_copy:
|
|
|
|
*
|
2012-03-02 10:57:52 +00:00
|
|
|
* GQuark for the "gst-copy" transform.
|
2012-02-24 09:23:27 +00:00
|
|
|
*/
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API GQuark _gst_meta_transform_copy;
|
2012-02-24 09:23:27 +00:00
|
|
|
|
2012-03-29 11:34:50 +00:00
|
|
|
/**
|
|
|
|
* GST_META_TRANSFORM_IS_COPY:
|
|
|
|
* @type: a transform type
|
|
|
|
*
|
|
|
|
* Check if the transform type is a copy transform
|
|
|
|
*/
|
2012-02-24 09:23:27 +00:00
|
|
|
#define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
|
|
|
|
|
|
|
|
/**
|
2012-03-02 10:57:52 +00:00
|
|
|
* GstMetaTransformCopy:
|
2012-03-02 11:45:23 +00:00
|
|
|
* @region: %TRUE if only region is copied
|
|
|
|
* @offset: the offset to copy, 0 if @region is %FALSE, otherwise > 0
|
|
|
|
* @size: the size to copy, -1 or the buffer size when @region is %FALSE
|
2011-11-14 09:27:01 +00:00
|
|
|
*
|
2012-03-02 10:57:52 +00:00
|
|
|
* Extra data passed to a "gst-copy" transform #GstMetaTransformFunction.
|
2011-11-14 09:27:01 +00:00
|
|
|
*/
|
2012-02-24 09:23:27 +00:00
|
|
|
typedef struct {
|
2012-03-02 11:45:23 +00:00
|
|
|
gboolean region;
|
2012-02-24 09:23:27 +00:00
|
|
|
gsize offset;
|
|
|
|
gsize size;
|
|
|
|
} GstMetaTransformCopy;
|
|
|
|
|
2011-03-08 16:58:49 +00:00
|
|
|
/**
|
|
|
|
* GstMetaTransformFunction:
|
|
|
|
* @transbuf: a #GstBuffer
|
2009-12-17 11:34:42 +00:00
|
|
|
* @meta: a #GstMeta
|
|
|
|
* @buffer: a #GstBuffer
|
2012-02-24 09:23:27 +00:00
|
|
|
* @type: the transform type
|
2011-03-08 16:58:49 +00:00
|
|
|
* @data: transform specific data.
|
|
|
|
*
|
|
|
|
* Function called for each @meta in @buffer as a result of performing a
|
2012-02-24 09:23:27 +00:00
|
|
|
* transformation on @transbuf. Additional @type specific transform data
|
|
|
|
* is passed to the function as @data.
|
2011-03-08 16:58:49 +00:00
|
|
|
*
|
2012-02-24 09:23:27 +00:00
|
|
|
* Implementations should check the @type of the transform and parse
|
|
|
|
* additional type specific fields in @data that should be used to update
|
|
|
|
* the metadata on @transbuf.
|
2012-02-28 15:17:47 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the transform could be performed
|
2009-12-17 11:34:42 +00:00
|
|
|
*/
|
2012-02-28 15:17:47 +00:00
|
|
|
typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf,
|
|
|
|
GstMeta *meta, GstBuffer *buffer,
|
|
|
|
GQuark type, gpointer data);
|
2009-12-17 11:34:42 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-25 12:15:25 +00:00
|
|
|
* GstMetaInfo:
|
2013-12-07 14:38:19 +00:00
|
|
|
* @api: tag identifying the metadata structure and api
|
|
|
|
* @type: type identifying the implementor of the api
|
2009-12-17 11:34:42 +00:00
|
|
|
* @size: size of the metadata
|
|
|
|
* @init_func: function for initializing the metadata
|
|
|
|
* @free_func: function for freeing the metadata
|
2011-03-08 18:18:24 +00:00
|
|
|
* @transform_func: function for transforming the metadata
|
2009-12-17 11:34:42 +00:00
|
|
|
*
|
2011-02-25 12:15:25 +00:00
|
|
|
* The #GstMetaInfo provides information about a specific metadata
|
2009-12-17 11:34:42 +00:00
|
|
|
* structure.
|
|
|
|
*/
|
2011-02-25 12:15:25 +00:00
|
|
|
struct _GstMetaInfo {
|
2012-02-29 16:20:23 +00:00
|
|
|
GType api;
|
2011-05-11 17:10:24 +00:00
|
|
|
GType type;
|
2009-12-17 11:34:42 +00:00
|
|
|
gsize size;
|
|
|
|
|
|
|
|
GstMetaInitFunction init_func;
|
|
|
|
GstMetaFreeFunction free_func;
|
2011-03-08 16:58:49 +00:00
|
|
|
GstMetaTransformFunction transform_func;
|
2011-11-11 15:52:41 +00:00
|
|
|
|
2016-12-02 15:30:59 +00:00
|
|
|
/* No padding needed, GstMetaInfo is always allocated by GStreamer and is
|
|
|
|
* not subclassable or stack-allocatable, so we can extend it as we please
|
|
|
|
* just like interfaces */
|
2009-12-17 11:34:42 +00:00
|
|
|
};
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-02-29 16:20:23 +00:00
|
|
|
GType gst_meta_api_type_register (const gchar *api,
|
|
|
|
const gchar **tags);
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-02-29 16:20:23 +00:00
|
|
|
gboolean gst_meta_api_type_has_tag (GType api, GQuark tag);
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-02-29 16:20:23 +00:00
|
|
|
const GstMetaInfo * gst_meta_register (GType api, const gchar *impl,
|
|
|
|
gsize size,
|
|
|
|
GstMetaInitFunction init_func,
|
|
|
|
GstMetaFreeFunction free_func,
|
|
|
|
GstMetaTransformFunction transform_func);
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-02-29 16:20:23 +00:00
|
|
|
const GstMetaInfo * gst_meta_get_info (const gchar * impl);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2013-08-21 22:02:28 +00:00
|
|
|
const gchar* const* gst_meta_api_type_get_tags (GType api);
|
2009-12-17 11:34:42 +00:00
|
|
|
|
2012-03-01 14:17:37 +00:00
|
|
|
/* some default tags */
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API GQuark _gst_meta_tag_memory;
|
2012-03-01 14:17:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GST_META_TAG_MEMORY:
|
|
|
|
*
|
|
|
|
* Metadata tagged with this tag depends on the particular memory
|
|
|
|
* or buffer that it is on.
|
2013-09-09 13:40:25 +00:00
|
|
|
*
|
|
|
|
* Deprecated: The GQuarks are not exported by any public API, use
|
|
|
|
* GST_META_TAG_MEMORY_STR instead.
|
2012-03-01 14:17:37 +00:00
|
|
|
*/
|
2014-01-31 08:14:41 +00:00
|
|
|
#ifndef GST_DISABLE_DEPRECATED
|
2012-03-01 14:17:37 +00:00
|
|
|
#define GST_META_TAG_MEMORY (_gst_meta_tag_memory)
|
2014-01-31 08:14:41 +00:00
|
|
|
#endif
|
2012-02-28 11:52:00 +00:00
|
|
|
|
2009-12-17 11:34:42 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
2011-02-25 12:15:25 +00:00
|
|
|
#endif /* __GST_META_H__ */
|