? gst/udp/gstudpsrc.c.agrimaud.15012009
? gst/udp/gstudpsrc.c.patch_POLLERR_patch_connected
Index: gst/udp/gstudpsrc.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v
retrieving revision 1.96
diff -u -r1.96 gstudpsrc.c
--- gst/udp/gstudpsrc.c	20 Nov 2008 22:56:58 -0000	1.96
+++ gst/udp/gstudpsrc.c	16 Jan 2009 10:43:39 -0000
@@ -164,6 +164,7 @@
 #define UDP_DEFAULT_CLOSEFD            TRUE
 #define UDP_DEFAULT_SOCK                -1
 #define UDP_DEFAULT_AUTO_MULTICAST     TRUE
+#define UDP_DEFAULT_ISCONNECTED	       FALSE
 
 enum
 {
@@ -180,6 +181,7 @@
   PROP_CLOSEFD,
   PROP_SOCK,
   PROP_AUTO_MULTICAST,
+  PROP_ISCONNECTED,
 
   PROP_LAST
 };
@@ -301,6 +303,10 @@
       g_param_spec_boolean ("auto-multicast", "Auto Multicast",
           "Automatically join/leave multicast groups",
           UDP_DEFAULT_AUTO_MULTICAST, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, PROP_ISCONNECTED,
+      g_param_spec_boolean ("isconnected", "Socket is connected",
+          "Do not set sockaddr in recvfrom.",
+          UDP_DEFAULT_ISCONNECTED, G_PARAM_READWRITE));
 
   gstbasesrc_class->start = gst_udpsrc_start;
   gstbasesrc_class->stop = gst_udpsrc_stop;
@@ -326,6 +332,7 @@
   udpsrc->closefd = UDP_DEFAULT_CLOSEFD;
   udpsrc->externalfd = (udpsrc->sockfd != -1);
   udpsrc->auto_multicast = UDP_DEFAULT_AUTO_MULTICAST;
+  udpsrc->isconnected = UDP_DEFAULT_ISCONNECTED;
   udpsrc->sock.fd = UDP_DEFAULT_SOCK;
 
   /* configure basesrc to be a live source */
@@ -376,6 +383,7 @@
   GstUDPSrc *udpsrc;
   GstNetBuffer *outbuf;
   struct sockaddr_storage tmpaddr;
+  struct sockaddr_storage *ptmpaddr;
   socklen_t len;
   guint8 *pktdata;
   gint pktsize;
@@ -456,14 +464,26 @@
   pktdata = g_malloc (readsize);
   pktsize = readsize;
 
-  while (TRUE) {
-    len = sizeof (struct sockaddr);
+  while (TRUE) { 
+    /* No need for address in recvfrom for connected udp socket */
+    if ( udpsrc->isconnected ) 
+      {
+        ptmpaddr = NULL ;
+        len = 0 ;
+      }
+    else
+      {
+        ptmpaddr = &tmpaddr ;
+        len = sizeof (struct sockaddr);
+      }
+
 #ifdef G_OS_WIN32
     ret = recvfrom (udpsrc->sock.fd, (char *) pktdata, pktsize,
 #else
     ret = recvfrom (udpsrc->sock.fd, pktdata, pktsize,
 #endif
-        0, (struct sockaddr *) &tmpaddr, &len);
+        0, (struct sockaddr *) ptmpaddr, &len);
+
     if (G_UNLIKELY (ret < 0)) {
 #ifdef G_OS_WIN32
       /* WSAECONNRESET for a UDP socket means that a packet sent with udpsink
@@ -499,6 +519,9 @@
   GST_BUFFER_DATA (outbuf) = pktdata;
   GST_BUFFER_SIZE (outbuf) = ret;
 
+  if ( udpsrc->isconnected )
+    goto done ;
+
   switch (tmpaddr.ss_family) {
     case AF_INET:
     {
@@ -525,6 +548,8 @@
 #endif
       goto receive_error;
   }
+
+done:
   GST_LOG_OBJECT (udpsrc, "read %d bytes", (int) readsize);
 
   *buf = GST_BUFFER_CAST (outbuf);
@@ -687,6 +712,9 @@
     case PROP_AUTO_MULTICAST:
       udpsrc->auto_multicast = g_value_get_boolean (value);
       break;
+    case PROP_ISCONNECTED:
+      udpsrc->isconnected = g_value_get_boolean (value);
+      break;
     default:
       break;
   }
@@ -732,6 +760,9 @@
     case PROP_AUTO_MULTICAST:
       g_value_set_boolean (value, udpsrc->auto_multicast);
       break;
+    case PROP_ISCONNECTED:
+      g_value_set_boolean (value, udpsrc->isconnected);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
Index: gst/udp/gstudpsrc.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.h,v
retrieving revision 1.25
diff -u -r1.25 gstudpsrc.h
--- gst/udp/gstudpsrc.h	13 Jun 2008 11:54:05 -0000	1.25
+++ gst/udp/gstudpsrc.h	16 Jan 2009 10:43:39 -0000
@@ -71,6 +71,9 @@
   gboolean   externalfd;
 
   struct   sockaddr_storage myaddr;
+
+  /* We are connected */
+  gboolean isconnected ;
 };
 
 struct _GstUDPSrcClass {
