From 712cd620af861bfef8344cb2febb45942613594b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 25 Sep 2008 11:30:35 +0000 Subject: gst/udp/gstudpsrc.c: Switch on the socket family to get the addrlen size right. Original commit message from CVS: * gst/udp/gstudpsrc.c: (gst_udpsrc_class_init), (gst_udpsrc_set_uri), (gst_udpsrc_start): Switch on the socket family to get the addrlen size right. --- gst/udp/gstudpsrc.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'gst/udp') diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c index 0f2af457..b15ed6ec 100644 --- a/gst/udp/gstudpsrc.c +++ b/gst/udp/gstudpsrc.c @@ -247,9 +247,7 @@ static void gst_udpsrc_class_init (GstUDPSrcClass * klass) { GObjectClass *gobject_class; - GstBaseSrcClass *gstbasesrc_class; - GstPushSrcClass *gstpushsrc_class; gobject_class = (GObjectClass *) klass; @@ -582,9 +580,7 @@ static gboolean gst_udpsrc_set_uri (GstUDPSrc * src, const gchar * uri) { gchar *protocol; - gchar *location; - gchar *colptr; protocol = gst_uri_get_protocol (uri); @@ -743,17 +739,11 @@ static gboolean gst_udpsrc_start (GstBaseSrc * bsrc) { guint bc_val; - gint reuse; - int port; - GstUDPSrc *src; - gint ret; - int rcvsize; - guint len; src = GST_UDPSRC (bsrc); @@ -779,8 +769,20 @@ gst_udpsrc_start (GstBaseSrc * bsrc) goto setsockopt_error; GST_DEBUG_OBJECT (src, "binding on port %d", src->port); - /* Mac OS is picky about the size */ - len = sizeof (struct sockaddr_in); + + /* Mac OS is picky about the size for the bind so we switch on the family */ + switch (src->myaddr.ss_family) { + case AF_INET: + len = sizeof (struct sockaddr_in); + break; + case AF_INET6: + len = sizeof (struct sockaddr_in6); + break; + default: + /* don't know, Screw MacOS and use the full length */ + len = sizeof (src->myaddr); + break; + } if ((ret = bind (src->sock.fd, (struct sockaddr *) &src->myaddr, len)) < 0) goto bind_error; -- cgit