nettimepacket: make boxed
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 20 Jun 2012 07:22:40 +0000 (09:22 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 20 Jun 2012 07:22:40 +0000 (09:22 +0200)
libs/gst/net/gstnettimepacket.c
libs/gst/net/gstnettimepacket.h

index 97f10bab6616da99f46f5b3fc9614b61f45dccc2..3c8e38d20984f396891d6a2615204c268fb889f8 100644 (file)
@@ -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.
  */
@@ -79,6 +81,38 @@ gst_net_time_packet_new (const guint8 * buffer)
   return ret;
 }
 
+/**
+ * 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,
index e37342cb296311d92846401bbb26632a5d48b32e..88395967d898bfc6e7a141c7d1ace6a5e4218d04 100644 (file)
@@ -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,