[farsight2/master] Add GArray for known addresses and mutex to protect it to the rawudp udpport

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:23:51 PST 2008


---
 transmitters/rawudp/fs-rawudp-transmitter.c |   18 ++++++++++++++++++
 transmitters/rawudp/fs-rawudp-transmitter.h |    5 +++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/transmitters/rawudp/fs-rawudp-transmitter.c b/transmitters/rawudp/fs-rawudp-transmitter.c
index 3c22018..999fae4 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-transmitter.c
@@ -517,6 +517,16 @@ struct _UdpPort {
   GstElement *tee;
 
   guint component_id;
+
+  /* Everything below is protected by the mutex */
+  GMutex *mutex;
+  GArray *known_addresses;
+};
+
+struct KnownAddress {
+  FsRawUdpAddressUniqueCallbackFunc callback;
+  gpointer user_data;
+  GstNetAddress addr;
 };
 
 static gint
@@ -724,6 +734,9 @@ fs_rawudp_transmitter_get_udpport (FsRawUdpTransmitter *trans,
   udpport->requested_port = requested_port;
   udpport->fd = -1;
   udpport->component_id = component_id;
+  udpport->mutex = g_mutex_new ();
+  udpport->known_addresses = g_array_new (TRUE, FALSE,
+      sizeof (struct KnownAddress));
 
   /* Now lets bind both ports */
 
@@ -825,6 +838,11 @@ fs_rawudp_transmitter_put_udpport (FsRawUdpTransmitter *trans,
   if (udpport->fd >= 0)
     close (udpport->fd);
 
+  if (udpport->mutex)
+    g_mutex_free (udpport->mutex);
+  if (udpport->known_addresses)
+    g_array_free (udpport->known_addresses, TRUE);
+
   g_free (udpport->requested_ip);
   g_slice_free (UdpPort, udpport);
 }
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.h b/transmitters/rawudp/fs-rawudp-transmitter.h
index b4a594f..3dd5e93 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.h
+++ b/transmitters/rawudp/fs-rawudp-transmitter.h
@@ -27,6 +27,8 @@
 
 #include <gst/farsight/fs-transmitter.h>
 
+#include <gst/netbuffer/gstnetbuffer.h>
+
 #include <gst/gst.h>
 
 #ifdef G_OS_WIN32
@@ -90,6 +92,9 @@ struct _FsRawUdpTransmitter
 /* Private declaration */
 typedef struct _UdpPort UdpPort;
 
+typedef void (*FsRawUdpAddressUniqueCallbackFunc) (gboolean unique,
+    const GstNetAddress *address, gpointer user_data);
+
 GType fs_rawudp_transmitter_get_type (void);
 
 GST_DEBUG_CATEGORY_EXTERN (fs_rawudp_transmitter_debug);
-- 
1.5.6.5




More information about the farsight-commits mailing list