mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
meta: add return vale to transform
Add a boolean return value so that we can see when a transform fails.
This commit is contained in:
parent
6e0e782025
commit
f0105dd81f
3 changed files with 41 additions and 33 deletions
|
@ -148,10 +148,12 @@ typedef struct {
|
|||
* 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:
|
||||
|
|
|
@ -33,28 +33,35 @@
|
|||
#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 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, nmeta->addr);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
net_address_meta_transform (GstBuffer * transbuf, GstNetAddressMeta * meta,
|
||||
GstBuffer * buffer, GQuark type, gpointer data)
|
||||
net_address_meta_free (GstMeta * meta, GstBuffer * buffer)
|
||||
{
|
||||
/* we always copy no matter what transform */
|
||||
gst_buffer_add_net_address_meta (transbuf, meta->addr);
|
||||
}
|
||||
GstNetAddressMeta *nmeta = (GstNetAddressMeta *) meta;
|
||||
|
||||
static void
|
||||
net_address_meta_free (GstNetAddressMeta * meta, GstBuffer * buffer)
|
||||
{
|
||||
if (meta->addr)
|
||||
g_object_unref (meta->addr);
|
||||
meta->addr = NULL;
|
||||
if (nmeta->addr)
|
||||
g_object_unref (nmeta->addr);
|
||||
nmeta->addr = NULL;
|
||||
}
|
||||
|
||||
const GstMetaInfo *
|
||||
|
@ -66,9 +73,8 @@ gst_net_address_meta_get_info (void)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -63,27 +63,28 @@ gst_meta_test_init (GstMetaTest * meta)
|
|||
}
|
||||
#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);
|
||||
|
@ -94,11 +95,11 @@ test_transform_func (GstBuffer * transbuf, GstMetaTest * 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;
|
||||
|
@ -108,8 +109,9 @@ test_transform_func (GstBuffer * transbuf, GstMetaTest * meta,
|
|||
test->dts = -1;
|
||||
test->duration = -1;
|
||||
}
|
||||
test->clock_rate = meta->clock_rate;
|
||||
test->clock_rate = tmeta->clock_rate;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const GstMetaInfo *
|
||||
|
@ -121,9 +123,7 @@ gst_meta_test_get_info (void)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue