From ac54190c29549017c655bbd7569f103ba7d9ec98 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 20 Jun 2012 09:22:40 +0200 Subject: [PATCH] nettimepacket: make boxed --- libs/gst/net/gstnettimepacket.c | 38 ++++++++++++++++++++++++++++++++++++-- libs/gst/net/gstnettimepacket.h | 6 +++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/libs/gst/net/gstnettimepacket.c b/libs/gst/net/gstnettimepacket.c index 97f10ba..3c8e38d 100644 --- a/libs/gst/net/gstnettimepacket.c +++ b/libs/gst/net/gstnettimepacket.c @@ -43,6 +43,8 @@ #include "gstnettimepacket.h" +G_DEFINE_BOXED_TYPE (GstNetTimePacket, gst_net_time_packet, + gst_net_time_packet_copy, gst_net_time_packet_free); /** * gst_net_time_packet_new: @@ -55,7 +57,7 @@ * If @buffer is #NULL, the local and remote times will be set to * #GST_CLOCK_TIME_NONE. * - * MT safe. Caller owns return value (g_free to free). + * MT safe. Caller owns return value (gst_net_time_packet_free to free). * * Returns: The new #GstNetTimePacket. */ @@ -80,6 +82,38 @@ gst_net_time_packet_new (const guint8 * buffer) } /** + * gst_net_time_packet_free: + * @packet: the #GstNetTimePacket + * + * Free @packet. + */ +void +gst_net_time_packet_free (GstNetTimePacket * packet) +{ + g_free (packet); +} + +/** + * gst_net_time_packet_copy: + * @packet: the #GstNetTimePacket + * + * Make a copy of @packet. + * + * Returns: a copy of @packet, free with gst_net_time_packet_free(). + */ +GstNetTimePacket * +gst_net_time_packet_copy (const GstNetTimePacket * packet) +{ + GstNetTimePacket *ret; + + ret = g_new0 (GstNetTimePacket, 1); + ret->local_time = packet->local_time; + ret->remote_time = packet->remote_time; + + return ret; +} + +/** * gst_net_time_packet_serialize: * @packet: the #GstNetTimePacket * @@ -117,7 +151,7 @@ gst_net_time_packet_serialize (const GstNetTimePacket * packet) * calls, but otherwise returns NULL on error. * * Returns: (transfer full): a new #GstNetTimePacket, or NULL on error. Free - * with g_free() when done. + * with gst_net_time_packet_free() when done. */ GstNetTimePacket * gst_net_time_packet_receive (GSocket * socket, diff --git a/libs/gst/net/gstnettimepacket.h b/libs/gst/net/gstnettimepacket.h index e37342c..8839596 100644 --- a/libs/gst/net/gstnettimepacket.h +++ b/libs/gst/net/gstnettimepacket.h @@ -47,8 +47,12 @@ struct _GstNetTimePacket { GstClockTime remote_time; }; -/* FIXME 0.11: get rid of the packet stuff? add an unref/free function? */ +GType gst_net_time_packet_get_type(void); + GstNetTimePacket* gst_net_time_packet_new (const guint8 *buffer); +GstNetTimePacket* gst_net_time_packet_copy (const GstNetTimePacket *packet); +void gst_net_time_packet_free (GstNetTimePacket *packet); + guint8* gst_net_time_packet_serialize (const GstNetTimePacket *packet); GstNetTimePacket* gst_net_time_packet_receive (GSocket * socket, -- 2.7.4