* 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.
+ *
+ * Returns: %TRUE if the transform could be performed
*/
-typedef void (*GstMetaTransformFunction) (GstBuffer *transbuf,
- GstMeta *meta, GstBuffer *buffer,
- GQuark type, gpointer data);
+typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf,
+ GstMeta *meta, GstBuffer *buffer,
+ GQuark type, gpointer data);
/**
* GstMetaInfo:
#include "gstnetaddressmeta.h"
static gboolean
-net_address_meta_init (GstNetAddressMeta * meta, gpointer params,
- GstBuffer * buffer)
+net_address_meta_init (GstMeta * meta, gpointer params, GstBuffer * buffer)
{
- meta->addr = NULL;
+ GstNetAddressMeta *nmeta = (GstNetAddressMeta *) meta;
+
+ nmeta->addr = NULL;
return TRUE;
}
-static void
-net_address_meta_transform (GstBuffer * transbuf, GstNetAddressMeta * meta,
+static gboolean
+net_address_meta_transform (GstBuffer * transbuf, GstMeta * meta,
GstBuffer * buffer, GQuark type, gpointer data)
{
+ GstNetAddressMeta *nmeta = (GstNetAddressMeta *) meta;
+
/* we always copy no matter what transform */
- gst_buffer_add_net_address_meta (transbuf, meta->addr);
+ gst_buffer_add_net_address_meta (transbuf, nmeta->addr);
+
+ return TRUE;
}
static void
-net_address_meta_free (GstNetAddressMeta * meta, GstBuffer * buffer)
+net_address_meta_free (GstMeta * meta, GstBuffer * buffer)
{
- if (meta->addr)
- g_object_unref (meta->addr);
- meta->addr = NULL;
+ GstNetAddressMeta *nmeta = (GstNetAddressMeta *) meta;
+
+ if (nmeta->addr)
+ g_object_unref (nmeta->addr);
+ nmeta->addr = NULL;
}
const GstMetaInfo *
if (meta_info == NULL) {
meta_info = gst_meta_register ("GstNetAddressMeta", "GstNetAddressMeta",
sizeof (GstNetAddressMeta),
- (GstMetaInitFunction) net_address_meta_init,
- (GstMetaFreeFunction) net_address_meta_free,
- (GstMetaTransformFunction) net_address_meta_transform, tags);
+ net_address_meta_init,
+ net_address_meta_free, net_address_meta_transform, tags);
}
return meta_info;
}
}
#endif
-static void
-test_init_func (GstMetaTest * meta, GstBuffer * buffer)
+static gboolean
+test_init_func (GstMeta * meta, gpointer params, GstBuffer * buffer)
{
GST_DEBUG ("init called on buffer %p, meta %p", buffer, meta);
/* nothing to init really, the init function is mostly for allocating
* additional memory or doing special setup as part of adding the metadata to
* the buffer*/
+ return TRUE;
}
static void
-test_free_func (GstMetaTest * meta, GstBuffer * buffer)
+test_free_func (GstMeta * meta, GstBuffer * buffer)
{
GST_DEBUG ("free called on buffer %p, meta %p", buffer, meta);
/* nothing to free really */
}
-static void
-test_transform_func (GstBuffer * transbuf, GstMetaTest * meta,
+static gboolean
+test_transform_func (GstBuffer * transbuf, GstMeta * meta,
GstBuffer * buffer, GQuark type, gpointer data)
{
- GstMetaTest *test;
+ GstMetaTest *test, *tmeta = (GstMetaTest *) meta;
GST_DEBUG ("transform %s called from buffer %p to %p, meta %p",
g_quark_to_string (type), buffer, transbuf, meta);
test = GST_META_TEST_ADD (transbuf);
if (copy_data->offset == 0) {
/* same offset, copy timestamps */
- test->pts = meta->pts;
- test->dts = meta->dts;
+ test->pts = tmeta->pts;
+ test->dts = tmeta->dts;
if (copy_data->size == gst_buffer_get_size (buffer)) {
/* same size, copy duration */
- test->duration = meta->duration;
+ test->duration = tmeta->duration;
} else {
/* else clear */
test->duration = GST_CLOCK_TIME_NONE;
test->dts = -1;
test->duration = -1;
}
- test->clock_rate = meta->clock_rate;
+ test->clock_rate = tmeta->clock_rate;
}
+ return TRUE;
}
static const GstMetaInfo *
if (meta_test_info == NULL) {
meta_test_info = gst_meta_register ("GstMetaTest", "GstMetaTest",
sizeof (GstMetaTest),
- (GstMetaInitFunction) test_init_func,
- (GstMetaFreeFunction) test_free_func,
- (GstMetaTransformFunction) test_transform_func, tags);
+ test_init_func, test_free_func, test_transform_func, tags);
}
return meta_test_info;
}