GstMeta *meta = &walk->meta;
const GstMetaInfo *info = meta->info;
- if (info->copy_func)
- info->copy_func (dest, meta, src, offset, size);
+ if (info->transform_func) {
+ GstMetaTransformCopy copy_data;
+
+ copy_data.offset = offset;
+ copy_data.size = size;
+
+ info->transform_func (dest, meta, src,
+ _gst_meta_transform_copy, ©_data);
+ }
}
}
}
static GHashTable *metainfo = NULL;
static GRWLock lock;
+GQuark _gst_meta_transform_copy;
+
void
_priv_gst_meta_initialize (void)
{
g_rw_lock_init (&lock);
metainfo = g_hash_table_new (g_str_hash, g_str_equal);
+
+ _gst_meta_transform_copy = g_quark_from_static_string ("copy");
}
/**
* @size: the size of the #GstMeta structure
* @init_func: a #GstMetaInitFunction
* @free_func: a #GstMetaFreeFunction
- * @copy_func: a #GstMetaCopyFunction
* @transform_func: a #GstMetaTransformFunction
*
* Register a new #GstMeta implementation.
const GstMetaInfo *
gst_meta_register (const gchar * api, const gchar * impl, gsize size,
GstMetaInitFunction init_func, GstMetaFreeFunction free_func,
- GstMetaCopyFunction copy_func, GstMetaTransformFunction transform_func)
+ GstMetaTransformFunction transform_func)
{
GstMetaInfo *info;
info->size = size;
info->init_func = init_func;
info->free_func = free_func;
- info->copy_func = copy_func;
info->transform_func = transform_func;
GST_DEBUG ("register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT,
typedef void (*GstMetaFreeFunction) (GstMeta *meta, GstBuffer *buffer);
/**
- * GstMetaCopyFunction:
- * @dest: a destination #GstBuffer
- * @meta: a #GstMeta
- * @buffer: a #GstBuffer
- * @offset: an offset
- * @size: a size
+ * gst_meta_transform_copy:
+ *
+ * GQuark for the "copy" transform.
+ */
+GST_EXPORT GQuark _gst_meta_transform_copy;
+
+#define GST_META_TRANSFORM_IS_COPY(type) ((type) == _gst_meta_transform_copy)
+
+/**
+ * GstMetaTransformDataCopy:
+ * @offset: the offset to copy
+ * @size: the size to copy
*
- * Function called when the region at @offset and @size in @buffer is copied
- * into @dest. The function should update the metadata on @dest using @meta.
+ * Extra data passed to a "copy" transform #GstMetaTransformFunction.
*/
-typedef void (*GstMetaCopyFunction) (GstBuffer *dest, GstMeta *meta,
- GstBuffer *buffer, gsize offset, gsize size);
+typedef struct {
+ gsize offset;
+ gsize size;
+} GstMetaTransformCopy;
+
/**
* GstMetaTransformFunction:
* @transbuf: a #GstBuffer
* @meta: a #GstMeta
* @buffer: a #GstBuffer
+ * @type: the transform type
* @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.
+ * transformation on @transbuf. Additional @type specific transform data
+ * is passed to the function as @data.
*
- * Implementations should check the type of the transform @data and parse
- * additional type specific field that should be used to perform the transform.
+ * 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.
*/
-typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf, GstMeta *meta,
- GstBuffer *buffer, gpointer data);
+typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf,
+ GstMeta *meta, GstBuffer *buffer,
+ GQuark type, gpointer data);
/**
* GstMetaInfo:
* @size: size of the metadata
* @init_func: function for initializing the metadata
* @free_func: function for freeing the metadata
- * @copy_func: function for copying the metadata
* @transform_func: function for transforming the metadata
*
* The #GstMetaInfo provides information about a specific metadata
GstMetaInitFunction init_func;
GstMetaFreeFunction free_func;
- GstMetaCopyFunction copy_func;
GstMetaTransformFunction transform_func;
/*< private >*/
gsize size,
GstMetaInitFunction init_func,
GstMetaFreeFunction free_func,
- GstMetaCopyFunction copy_func,
GstMetaTransformFunction transform_func);
const GstMetaInfo * gst_meta_get_info (const gchar * impl);
}
static void
-net_address_meta_copy (GstBuffer * copybuf, GstNetAddressMeta * meta,
- GstBuffer * buffer, gsize offset, gsize size)
+net_address_meta_transform (GstBuffer * transbuf, GstNetAddressMeta * meta,
+ GstBuffer * buffer, GQuark type, gpointer data)
{
- gst_buffer_add_net_address_meta (copybuf, meta->addr);
+ /* we always copy no matter what transform */
+ gst_buffer_add_net_address_meta (transbuf, meta->addr);
}
static void
sizeof (GstNetAddressMeta),
(GstMetaInitFunction) net_address_meta_init,
(GstMetaFreeFunction) net_address_meta_free,
- (GstMetaCopyFunction) net_address_meta_copy,
- (GstMetaTransformFunction) NULL);
+ (GstMetaTransformFunction) net_address_meta_transform);
}
return meta_info;
}
}
static void
-test_copy_func (GstBuffer * copybuf, GstMetaTest * meta,
- GstBuffer * buffer, gsize offset, gsize size)
+test_transform_func (GstBuffer * transbuf, GstMetaTest * meta,
+ GstBuffer * buffer, GQuark type, gpointer data)
{
GstMetaTest *test;
- GST_DEBUG ("copy called from buffer %p to %p, meta %p, %u-%u", buffer,
- copybuf, meta, offset, size);
-
- test = GST_META_TEST_ADD (copybuf);
- if (offset == 0) {
- /* same offset, copy timestamps */
- test->pts = meta->pts;
- test->dts = meta->dts;
- if (size == gst_buffer_get_size (buffer)) {
- /* same size, copy duration */
- test->duration = meta->duration;
+ GST_DEBUG ("transform %s called from buffer %p to %p, meta %p",
+ g_quark_to_string (type), buffer, transbuf, meta);
+
+ if (GST_META_TRANSFORM_IS_COPY (type)) {
+ GstMetaTransformCopy *copy_data = data;
+
+ test = GST_META_TEST_ADD (transbuf);
+ if (copy_data->offset == 0) {
+ /* same offset, copy timestamps */
+ test->pts = meta->pts;
+ test->dts = meta->dts;
+ if (copy_data->size == gst_buffer_get_size (buffer)) {
+ /* same size, copy duration */
+ test->duration = meta->duration;
+ } else {
+ /* else clear */
+ test->duration = GST_CLOCK_TIME_NONE;
+ }
} else {
- /* else clear */
- test->duration = GST_CLOCK_TIME_NONE;
+ test->pts = -1;
+ test->dts = -1;
+ test->duration = -1;
}
- } else {
- test->pts = -1;
- test->dts = -1;
- test->duration = -1;
+ test->clock_rate = meta->clock_rate;
}
- test->clock_rate = meta->clock_rate;
}
static const GstMetaInfo *
sizeof (GstMetaTest),
(GstMetaInitFunction) test_init_func,
(GstMetaFreeFunction) test_free_func,
- (GstMetaCopyFunction) test_copy_func, (GstMetaTransformFunction) NULL);
+ (GstMetaTransformFunction) test_transform_func);
}
return meta_test_info;
}
_gst_disable_registry_cache DATA
_gst_element_error_printf
_gst_event_type DATA
+ _gst_meta_transform_copy DATA
_gst_plugin_loader_client_run
_gst_sample_type DATA
_gst_structure_type DATA