[farsight2/master] Use the gst debug category everywhere!

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


---
 transmitters/rawudp/fs-interfaces.c                |   47 +++++++++----------
 transmitters/rawudp/fs-rawudp-stream-transmitter.c |   16 +++++--
 transmitters/rawudp/fs-rawudp-transmitter.c        |   10 ++--
 3 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/transmitters/rawudp/fs-interfaces.c b/transmitters/rawudp/fs-interfaces.c
index c5b2eba..82ed2d7 100644
--- a/transmitters/rawudp/fs-interfaces.c
+++ b/transmitters/rawudp/fs-interfaces.c
@@ -28,13 +28,6 @@
  #include "config.h"
 #endif
 
-#if 0
-#define DEBUG(args...) g_debug (args)
-#else
-#define DEBUG(args...) while(0) {}
-#endif
-
-
 #ifdef G_OS_UNIX
 
 #include <stdio.h>
@@ -51,6 +44,10 @@
 #include <net/if.h>
 #include <net/if_arp.h>
 #include <arpa/inet.h>
+#include <gst/gst.h>
+
+GST_DEBUG_CATEGORY_EXTERN (fs_rawudp_transmitter_debug);
+#define GST_CAT_DEFAULT fs_rawudp_transmitter_debug
 
 /**
  * farsight_get_local_interfaces:
@@ -82,7 +79,7 @@ farsight_get_local_interfaces(void)
     if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET)
       continue;
 
-    DEBUG("Found interface : %s", ifa->ifa_name);
+    GST_DEBUG("Found interface : %s", ifa->ifa_name);
     interfaces = g_list_prepend (interfaces, g_strdup(ifa->ifa_name));
   }
 
@@ -101,7 +98,7 @@ farsight_get_local_interfaces (void)
   struct ifconf ifc;
 
   if (0 > (sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
-    g_warning ("Cannot open socket to retreive interface list");
+    GST_ERROR ("Cannot open socket to retreive interface list");
     return NULL;
   }
 
@@ -113,7 +110,7 @@ farsight_get_local_interfaces (void)
     size += sizeof(struct ifreq);
     /* realloc buffer size until no overflow occurs  */
     if (NULL == (ifc.ifc_req = realloc (ifc.ifc_req, size))) {
-      g_warning ("Out of memory while allocation interface configuration structure");
+      GST_ERROR ("Out of memory while allocation interface configuration structure");
       close (sockfd);
       return NULL;
     }
@@ -131,7 +128,7 @@ farsight_get_local_interfaces (void)
   for (ifr = ifc.ifc_req;
        (gchar *) ifr < (gchar *) ifc.ifc_req + ifc.ifc_len;
        ++ifr) {
-    DEBUG ("Found interface : %s", ifr->ifr_name);
+    GST_DEBUG ("Found interface : %s", ifr->ifr_name);
     interfaces = g_list_prepend (interfaces, g_strdup(ifr->ifr_name));
   }
 
@@ -199,14 +196,14 @@ farsight_get_local_ips (gboolean include_loopback)
 
     sa = (struct sockaddr_in *) ifa->ifa_addr;
 
-    DEBUG("Interface:  %s", ifa->ifa_name);
-    DEBUG("IP Address: %s", inet_ntoa(sa->sin_addr));
+    GST_DEBUG("Interface:  %s", ifa->ifa_name);
+    GST_DEBUG("IP Address: %s", inet_ntoa(sa->sin_addr));
     if ((ifa->ifa_flags & IFF_LOOPBACK) == IFF_LOOPBACK)
     {
       if (include_loopback)
         loopback = g_strdup (inet_ntoa (sa->sin_addr));
       else
-        DEBUG("Ignoring loopback interface");
+        GST_DEBUG("Ignoring loopback interface");
     }
     else
     {
@@ -238,7 +235,7 @@ farsight_get_local_ips (gboolean include_loopback)
   struct sockaddr_in *sa;
 
   if (0 > (sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
-    g_warning("Cannot open socket to retreive interface list");
+    GST_ERROR("Cannot open socket to retreive interface list");
     return NULL;
   }
 
@@ -250,7 +247,7 @@ farsight_get_local_ips (gboolean include_loopback)
     size += sizeof(struct ifreq);
     /* realloc buffer size until no overflow occurs  */
     if (NULL == (ifc.ifc_req = realloc (ifc.ifc_req, size))) {
-      g_warning ("Out of memory while allocation interface configuration"
+      GST_ERROR ("Out of memory while allocation interface configuration"
         " structure");
       close (sockfd);
       return NULL;
@@ -271,15 +268,15 @@ farsight_get_local_ips (gboolean include_loopback)
        ++ifr) {
 
     if (ioctl (sockfd, SIOCGIFFLAGS, ifr)) {
-      g_warning ("Unable to get IP information for interface %s. Skipping...",
+      GST_ERROR ("Unable to get IP information for interface %s. Skipping...",
         ifr->ifr_name);
       continue;  /* failed to get flags, skip it */
     }
     sa = (struct sockaddr_in *) &ifr->ifr_addr;
-    DEBUG("Interface:  %s", ifr->ifr_name);
-    DEBUG("IP Address: %s", inet_ntoa(sa->sin_addr));
+    GST_DEBUG("Interface:  %s", ifr->ifr_name);
+    GST_DEBUG("IP Address: %s", inet_ntoa(sa->sin_addr));
     if (!include_loopback && (ifr->ifr_flags & IFF_LOOPBACK) == IFF_LOOPBACK){
-      DEBUG("Ignoring loopback interface");
+      GST_DEBUG("Ignoring loopback interface");
     } else {
       if (farsight_is_private_ip (sa->sin_addr)) {
         ips = g_list_append (ips, g_strdup (inet_ntoa (sa->sin_addr)));
@@ -318,12 +315,12 @@ farsight_get_ip_for_interface (gchar *interface_name)
   strcpy (ifr.ifr_name, interface_name);
 
   if (0 > (sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
-    g_warning("Cannot open socket to retreive interface list");
+    GST_ERROR("Cannot open socket to retreive interface list");
     return NULL;
   }
 
   if (ioctl (sockfd, SIOCGIFADDR, &ifr) < 0) {
-    g_warning ("Unable to get IP information for interface %s",
+    GST_ERROR ("Unable to get IP information for interface %s",
       interface_name);
     close (sockfd);
     return NULL;
@@ -331,7 +328,7 @@ farsight_get_ip_for_interface (gchar *interface_name)
 
   close (sockfd);
   sa = (struct sockaddr_in *) &ifr.ifr_addr;
-  DEBUG ("Address for %s: %s", interface_name, inet_ntoa (sa->sin_addr));
+  GST_DEBUG ("Address for %s: %s", interface_name, inet_ntoa (sa->sin_addr));
   return inet_ntoa(sa->sin_addr);
 }
 
@@ -361,7 +358,7 @@ SOCKET farsight_get_WSA_socket() {
 
     err = WSAStartup( wVersionRequested, &wsaData );
     if ( err != 0 ) {
-      g_warning("Could not start the winsocket engine");
+      GST_ERROR("Could not start the winsocket engine");
       return INVALID_SOCKET;
     }
     started_wsa_engine = TRUE;
@@ -369,7 +366,7 @@ SOCKET farsight_get_WSA_socket() {
 
 
   if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) {
-    g_warning("Could not open socket to retreive interface list, error no : %d", WSAGetLastError());
+    GST_ERROR("Could not open socket to retreive interface list, error no : %d", WSAGetLastError());
     return INVALID_SOCKET;
   }
 
diff --git a/transmitters/rawudp/fs-rawudp-stream-transmitter.c b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
index 18d4ffb..8a49526 100644
--- a/transmitters/rawudp/fs-rawudp-stream-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
@@ -52,6 +52,9 @@
 #include <netdb.h>
 #include <unistd.h>
 
+GST_DEBUG_CATEGORY_EXTERN (fs_rawudp_transmitter_debug);
+#define GST_CAT_DEFAULT fs_rawudp_transmitter_debug
+
 /* Signals */
 enum
 {
@@ -851,7 +854,7 @@ fs_rawudp_stream_transmitter_stun_recv_cb (GstPad *pad, GstBuffer *buffer,
       candidate->proto = FS_NETWORK_PROTOCOL_UDP;
       candidate->type = FS_CANDIDATE_TYPE_SRFLX;
 
-      g_debug ("Stun server says we are %u.%u.%u.%u %u\n",
+      GST_DEBUG ("Stun server says we are %u.%u.%u.%u %u\n",
           ((*attr)->address.ip & 0xff000000) >> 24,
           ((*attr)->address.ip & 0x00ff0000) >> 16,
           ((*attr)->address.ip & 0x0000ff00) >>  8,
@@ -972,16 +975,19 @@ fs_rawudp_stream_transmitter_start_stun (FsRawUdpStreamTransmitter *self,
   data->component_id = component_id;
 
   g_mutex_lock (data->self->priv->sources_mutex);
-  /*
-   * This is broken in GLib 2.14
+#if 1
+  /* This is MAY broken in GLib 2.14 (gnome bug #448943) */
+  /* If the test does not stop (and times out), this may be the cause
+   * and in this case should be investigated further
+   */
   self->priv->stun_timeout_id[component_id] = g_timeout_add_seconds_full (
       G_PRIORITY_DEFAULT, self->priv->stun_timeout,
       fs_rawudp_stream_transmitter_stun_timeout_cb, data, g_free);
-  */
+#else
   self->priv->stun_timeout_id[component_id] = g_timeout_add_full (
       G_PRIORITY_DEFAULT, self->priv->stun_timeout * 1000,
       fs_rawudp_stream_transmitter_stun_timeout_cb, data, g_free);
-
+#endif
   g_assert (self->priv->stun_timeout_id[component_id]);
   g_mutex_unlock (data->self->priv->sources_mutex);
 
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.c b/transmitters/rawudp/fs-rawudp-transmitter.c
index 127c69a..6b84b50 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-transmitter.c
@@ -533,7 +533,7 @@ _bind_port (const gchar *ip, guint port, guint *used_port, GError **error)
     retval = bind (sock, (struct sockaddr *) &address, sizeof (address));
     if (retval != 0)
     {
-      g_debug ("could not bind port %d", port);
+      GST_INFO ("could not bind port %d", port);
       port += 2;
       if (port > 65535) {
         g_set_error (error, FS_ERROR, FS_ERROR_NETWORK,
@@ -628,7 +628,7 @@ _create_sinksource (gchar *elementname, GstBin *bin,
   gst_bin_remove (bin, elem);
   state_ret = gst_element_set_state (elem, GST_STATE_NULL);
   if (state_ret != GST_STATE_CHANGE_SUCCESS) {
-    g_warning ("On error, could not reset %s to state NULL (%s)", elementname,
+    GST_ERROR ("On error, could not reset %s to state NULL (%s)", elementname,
       gst_element_state_change_return_get_name (state_ret));
   }
   gst_object_unref (elem);
@@ -731,7 +731,7 @@ fs_rawudp_transmitter_put_udpport (FsRawUdpTransmitter *trans,
     gst_bin_remove (GST_BIN (trans->priv->gst_src), udpport->udpsrc);
     ret = gst_element_set_state (udpport->udpsrc, GST_STATE_NULL);
     if (ret != GST_STATE_CHANGE_SUCCESS) {
-      g_warning ("Error changing state of udpsrc: %s",
+      GST_ERROR ("Error changing state of udpsrc: %s",
         gst_element_state_change_return_get_name (ret));
     }
     gst_object_unref (udpport->udpsrc);
@@ -750,7 +750,7 @@ fs_rawudp_transmitter_put_udpport (FsRawUdpTransmitter *trans,
     gst_bin_remove (GST_BIN (trans->priv->gst_sink), udpport->udpsink);
     ret = gst_element_set_state (udpport->udpsink, GST_STATE_NULL);
     if (ret != GST_STATE_CHANGE_SUCCESS) {
-      g_warning ("Error changing state of udpsink: %s",
+      GST_ERROR ("Error changing state of udpsink: %s",
         gst_element_state_change_return_get_name (ret));
     }
     gst_object_unref (udpport->udpsink);
@@ -773,7 +773,7 @@ void
 fs_rawudp_transmitter_udpport_add_dest (UdpPort *udpport,
   const gchar *ip, gint port)
 {
-  g_debug ("Adding dest %s:%d", ip, port);
+  GST_DEBUG ("Adding dest %s:%d", ip, port);
   g_signal_emit_by_name (udpport->udpsink, "add", ip, port);
 }
 
-- 
1.5.6.5




More information about the farsight-commits mailing list