[farsight2/master] Store the address of the remote end in a GstNetAddress so we can compare

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


---
 transmitters/rawudp/Makefile.am           |    1 +
 transmitters/rawudp/fs-rawudp-component.c |   30 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/transmitters/rawudp/Makefile.am b/transmitters/rawudp/Makefile.am
index f3cd60a..a77472f 100644
--- a/transmitters/rawudp/Makefile.am
+++ b/transmitters/rawudp/Makefile.am
@@ -21,6 +21,7 @@ librawudp_transmitter_la_LDFLAGS = $(FS2_PLUGIN_LDFLAGS)
 librawudp_transmitter_la_LIBADD = \
 	$(top_builddir)/gst-libs/gst/farsight/libgstfarsight-0.10.la \
 	$(FS2_LIBS) \
+	-lgstnetbuffer- at GST_MAJORMINOR@ \
 	$(GST_BASE_LIBS) \
 	$(GST_LIBS)
 
diff --git a/transmitters/rawudp/fs-rawudp-component.c b/transmitters/rawudp/fs-rawudp-component.c
index 5c15326..40e8c22 100644
--- a/transmitters/rawudp/fs-rawudp-component.c
+++ b/transmitters/rawudp/fs-rawudp-component.c
@@ -36,6 +36,8 @@
 #include <gst/farsight/fs-conference-iface.h>
 #include <gst/farsight/fs-interfaces.h>
 
+#include <gst/netbuffer/gstnetbuffer.h>
+
 #include <string.h>
 #include <sys/types.h>
 
@@ -106,6 +108,7 @@ struct _FsRawUdpComponentPrivate
   /* This is protected by the mutex */
 
   FsCandidate *remote_candidate;
+  GstNetAddress remote_address;
 
   FsCandidate *local_active_candidate;
   FsCandidate *local_forced_candidate;
@@ -648,6 +651,9 @@ fs_rawudp_component_set_remote_candidate (FsRawUdpComponent *self,
 {
   FsCandidate *old_candidate = NULL;
   gboolean sending;
+  struct addrinfo hints = {0};
+  struct addrinfo *res = NULL;
+  int rv;
 
   if (candidate->component_id != self->priv->component)
   {
@@ -658,12 +664,36 @@ fs_rawudp_component_set_remote_candidate (FsRawUdpComponent *self,
     return FALSE;
   }
 
+  hints.ai_flags = AI_NUMERICHOST;
+  rv = getaddrinfo (candidate->ip, NULL, &hints, &res);
+  if (rv != 0)
+  {
+    g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
+        "Invalid address passed: %s", gai_strerror (rv));
+    return FALSE;
+  }
+
   FS_RAWUDP_COMPONENT_LOCK (self);
   old_candidate = self->priv->remote_candidate;
   self->priv->remote_candidate = fs_candidate_copy (candidate);
   sending = self->priv->sending;
+
+  switch (res->ai_family)
+  {
+    case AF_INET:
+      gst_netaddress_set_ip4_address (&self->priv->remote_address,
+          ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr,
+          g_htons(candidate->port));
+      break;
+    case AF_INET6:
+      gst_netaddress_set_ip6_address (&self->priv->remote_address,
+          ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr.s6_addr,
+          g_htons(candidate->port));
+      break;
+  }
   FS_RAWUDP_COMPONENT_UNLOCK (self);
 
+  freeaddrinfo (res);
 
   if (sending)
     fs_rawudp_transmitter_udpport_add_dest (self->priv->udpport,
-- 
1.5.6.5




More information about the farsight-commits mailing list