From: <wt...@ke...> - 2008-03-07 15:54:20
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Fri Mar 07 2008 15:54:24 UTC Log message: * gst/udp/gstudpsrc.c: (gst_udpsrc_start): Fix compilation after removing the GstPollMode from the constructor. Modified files: . : ChangeLog gst/udp : gstudpsrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3346&r2=1.3347 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c.diff?r1=1.82&r2=1.83 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3346 retrieving revision 1.3347 diff -u -d -r1.3346 -r1.3347 --- ChangeLog 7 Mar 2008 13:08:32 -0000 1.3346 +++ ChangeLog 7 Mar 2008 15:54:08 -0000 1.3347 @@ -1,3 +1,9 @@ +2008-03-07 Wim Taymans <wim...@co...> + + * gst/udp/gstudpsrc.c: (gst_udpsrc_start): + Fix compilation after removing the GstPollMode from the + constructor. 2008-03-07 Sebastian Dröge <sl...@ci...> * configure.ac: Index: gstudpsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- gstudpsrc.c 7 Mar 2008 10:01:40 -0000 1.82 +++ gstudpsrc.c 7 Mar 2008 15:54:09 -0000 1.83 @@ -761,7 +761,7 @@ src->myaddr.sin_port = htons (src->port + 1); - if ((src->fdset = gst_poll_new (GST_POLL_MODE_AUTO, TRUE)) == NULL) + if ((src->fdset = gst_poll_new (TRUE)) == NULL) goto no_fdset; gst_poll_add_fd (src->fdset, &src->sock); |
From: <wt...@ke...> - 2008-05-21 09:56:10
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Wed May 21 2008 09:56:18 UTC Log message: Patch by: Bruno Santos <brunof at ua dot pt> * gst/udp/gstudpnetutils.c: (gst_udp_get_addr), (gst_udp_join_group), (gst_udp_leave_group), (gst_udp_is_multicast): * gst/udp/gstudpnetutils.h: Provide a bunch of helper methods to deal with IPv4 and IPv6 transparently. * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), (gst_multiudpsink_init), (gst_multiudpsink_set_property), (gst_multiudpsink_get_property), (join_multicast), (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal), (gst_multiudpsink_remove): * gst/udp/gstmultiudpsink.h: Add multicast TTL and loopback properties. Use the helper methods to implement ip4 and ip6. * gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start): * gst/udp/gstudpsrc.h: Use the helper methods to implement ip4 and ip6. Fixes #515962. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c gstmultiudpsink.h gstudpnetutils.c gstudpnetutils.h gstudpsrc.c gstudpsrc.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3474&r2=1.3475 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.28&r2=1.29 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h.diff?r1=1.10&r2=1.11 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.h.diff?r1=1.2&r2=1.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c.diff?r1=1.85&r2=1.86 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.h.diff?r1=1.23&r2=1.24 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3474 retrieving revision 1.3475 diff -u -d -r1.3474 -r1.3475 --- ChangeLog 21 May 2008 09:38:46 -0000 1.3474 +++ ChangeLog 21 May 2008 09:56:01 -0000 1.3475 @@ -1,5 +1,30 @@ 2008-05-21 Wim Taymans <wim...@co...> + Patch by: Bruno Santos <brunof at ua dot pt> + + * gst/udp/gstudpnetutils.c: (gst_udp_get_addr), + (gst_udp_join_group), (gst_udp_leave_group), + (gst_udp_is_multicast): + * gst/udp/gstudpnetutils.h: + Provide a bunch of helper methods to deal with IPv4 and IPv6 + transparently. + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), + (gst_multiudpsink_init), (gst_multiudpsink_set_property), + (gst_multiudpsink_get_property), (join_multicast), + (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal), + (gst_multiudpsink_remove): + * gst/udp/gstmultiudpsink.h: + Add multicast TTL and loopback properties. + Use the helper methods to implement ip4 and ip6. + * gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start): + * gst/udp/gstudpsrc.h: + Fixes #515962. +2008-05-21 Wim Taymans <wim...@co...> Patch by: Patrick Radizi <patrick dot radizi at axis dot com> * gst/multipart/multipartdemux.c: (gst_multipart_demux_class_init), Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- gstmultiudpsink.c 25 Apr 2008 13:31:48 -0000 1.28 +++ gstmultiudpsink.c 21 May 2008 09:56:02 -0000 1.29 @@ -81,6 +81,8 @@ #define DEFAULT_SOCK -1 #define DEFAULT_CLIENTS NULL #define DEFAULT_AUTO_MULTICAST TRUE +#define DEFAULT_TTL 64 +#define DEFAULT_LOOP TRUE enum { @@ -91,7 +93,9 @@ PROP_CLOSEFD, PROP_SOCK, PROP_CLIENTS, - PROP_AUTO_MULTICAST + PROP_AUTO_MULTICAST, + PROP_TTL, + PROP_LOOP /* FILL ME */ }; @@ -292,6 +296,14 @@ "Automatically join/leave multicast groups", "Automatically join/leave the multicast groups, FALSE means user" " has to do it himself", DEFAULT_AUTO_MULTICAST, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, PROP_TTL, + g_param_spec_int ("ttl", "Multicast TTL", + "Used for setting the multicast TTL parameter", + 0, 255, DEFAULT_TTL, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, PROP_LOOP, + g_param_spec_boolean ("loop", "Multicast Loopback", + "Used for setting the multicast loop parameter. TRUE = enable," + " FALSE = disable", DEFAULT_LOOP, G_PARAM_READWRITE)); gstelement_class->change_state = gst_multiudpsink_change_state; @@ -316,6 +328,8 @@ sink->closefd = DEFAULT_CLOSEFD; sink->externalfd = (sink->sockfd != -1); sink->auto_multicast = DEFAULT_AUTO_MULTICAST; + sink->ttl = DEFAULT_TTL; + sink->loop = DEFAULT_LOOP; } static void @@ -473,6 +487,12 @@ case PROP_AUTO_MULTICAST: udpsink->auto_multicast = g_value_get_boolean (value); break; + case PROP_TTL: + udpsink->ttl = g_value_get_int (value); + break; + case PROP_LOOP: + udpsink->loop = g_value_get_boolean (value); default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -510,6 +530,12 @@ g_value_set_boolean (value, udpsink->auto_multicast); + g_value_set_int (value, udpsink->ttl); + g_value_set_boolean (value, udpsink->loop); @@ -517,33 +543,13 @@ -join_multicast (GstUDPClient * client) +join_multicast (GstUDPClient * client, gboolean loop, int ttl) - unsigned char ttl = 64; - unsigned char loop = 1; - /* Joining the multicast group */ /* FIXME, can we use multicast and unicast over the same * socket? if not, search for socket of this multicast group or * create a new one. */ - if (setsockopt (*(client->sock), IPPROTO_IP, IP_ADD_MEMBERSHIP, - &(client->multi_addr), sizeof (client->multi_addr)) < 0) - perror ("setsockopt IP_ADD_MEMBERSHIP\n"); - if (setsockopt (*(client->sock), IPPROTO_IP, IP_MULTICAST_TTL, &ttl, - sizeof (ttl)) < 0) - perror ("setsockopt IP_MULTICAST_TTL\n"); - if (setsockopt (*(client->sock), IPPROTO_IP, IP_MULTICAST_LOOP, &loop, - sizeof (loop)) < 0) - perror ("setsockopt IP_MULTICAST_LOOP\n"); -} -static void -leave_multicast (GstUDPClient * client) -{ - if (setsockopt (*(client->sock), IPPROTO_IP, IP_DROP_MEMBERSHIP, - GST_WARNING ("setsockopt IP_DROP_MEMBERSHIP failed '%s'", - g_strerror (errno)); + gst_udp_join_group (*(client->sock), loop, ttl, &client->theiraddr); /* create a socket for sending to remote machine */ @@ -557,8 +563,9 @@ if (sink->sockfd == -1) { /* create sender socket */ - if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1) - goto no_socket; + if ((sink->sock = socket (AF_INET6, SOCK_DGRAM, 0)) == -1) + if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1) + goto no_socket; sink->externalfd = FALSE; } else { @@ -580,8 +587,8 @@ for (clients = sink->clients; clients; clients = g_list_next (clients)) { client = (GstUDPClient *) clients->data; - if (client->multi_addr.imr_multiaddr.s_addr && sink->auto_multicast) - join_multicast (client); + if (gst_udp_is_multicast (&client->theiraddr) && sink->auto_multicast) + join_multicast (client, sink->loop, sink->ttl); } return TRUE; @@ -612,8 +619,6 @@ gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host, gint port, gboolean lock) - struct hostent *he; - struct in_addr addr; GstUDPClient *client; GTimeVal now; @@ -623,42 +628,19 @@ client->port = port; client->sock = &sink->sock; - memset (&client->theiraddr, 0, sizeof (client->theiraddr)); - memset (&client->multi_addr, 0, sizeof (client->multi_addr)); - client->theiraddr.sin_family = AF_INET; /* host byte order */ - client->theiraddr.sin_port = g_htons (port); /* short, network byte order */ + if (gst_udp_get_addr (host, port, &client->theiraddr) < 0) + goto getaddrinfo_error; g_get_current_time (&now); client->connect_time = GST_TIMEVAL_TO_TIME (now); - /* if its an IP address */ - if (inet_aton (host, &addr)) { - /* check if its a multicast address */ - if ((g_ntohl (addr.s_addr) & 0xf0000000) == 0xe0000000) { - GST_DEBUG_OBJECT (sink, "multicast address detected"); - client->multi_addr.imr_multiaddr.s_addr = addr.s_addr; - client->multi_addr.imr_interface.s_addr = INADDR_ANY; - client->theiraddr.sin_addr = client->multi_addr.imr_multiaddr; - } else { - GST_DEBUG_OBJECT (sink, "normal address detected"); - client->theiraddr.sin_addr = *((struct in_addr *) &addr); - } - /* if init_send has already been called, set sockopts for multicast */ - if (*client->sock > 0 && client->multi_addr.imr_multiaddr.s_addr && - sink->auto_multicast) - } - /* we dont need to lookup for localhost */ - else if (strcmp (host, "localhost") == 0 && inet_aton ("127.0.0.1", &addr)) { - client->theiraddr.sin_addr = *((struct in_addr *) &addr); - /* if its a hostname */ - else if ((he = gethostbyname (host))) { - client->theiraddr.sin_addr = *((struct in_addr *) he->h_addr); + /* check if its a multicast address */ + if (*client->sock > 0 && gst_udp_is_multicast (&client->theiraddr) && + sink->auto_multicast) { + GST_DEBUG_OBJECT (sink, "multicast address detected"); + join_multicast (client, sink->loop, sink->ttl); - goto host_error; + GST_DEBUG_OBJECT (sink, "normal address detected"); if (lock) @@ -673,9 +655,9 @@ return; /* ERRORS */ -host_error: +getaddrinfo_error: { - GST_WARNING_OBJECT (sink, "hostname lookup error?"); + GST_WARNING_OBJECT (sink, "getaddrinfo lookup error?"); g_free (client->host); g_free (client); return; @@ -728,9 +710,9 @@ client->disconnect_time = GST_TIMEVAL_TO_TIME (now); - if (*(client->sock) != -1 && client->multi_addr.imr_multiaddr.s_addr + if (*(client->sock) != -1 && gst_udp_is_multicast (&client->theiraddr) && sink->auto_multicast) - leave_multicast (client); + gst_udp_leave_group (*(client->sock), &client->theiraddr); /* Unlock to emit signal before we delete the actual client */ g_mutex_unlock (sink->client_lock); Index: gstmultiudpsink.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- gstmultiudpsink.h 17 Jan 2008 11:13:16 -0000 1.10 +++ gstmultiudpsink.h 21 May 2008 09:56:02 -0000 1.11 @@ -40,8 +40,7 @@ typedef struct { int *sock; - struct sockaddr_in theiraddr; - struct ip_mreq multi_addr; + struct sockaddr_storage theiraddr; gchar *host; gint port; @@ -72,6 +71,8 @@ gboolean externalfd; gboolean auto_multicast; + gint ttl; + gboolean loop; struct _GstMultiUDPSinkClass { Index: gstudpnetutils.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gstudpnetutils.c 24 Jul 2006 11:48:03 -0000 1.1 +++ gstudpnetutils.c 21 May 2008 09:56:02 -0000 1.2 @@ -22,21 +22,14 @@ #include "config.h" #endif +#include <errno.h> +#include <stdio.h> +#include <memory.h> #include "gstudpnetutils.h" #ifdef G_OS_WIN32 -int -gst_udp_net_utils_win32_inet_aton (const char *c, struct in_addr *paddr) - paddr->s_addr = inet_addr (c); - if (paddr->s_addr == INADDR_NONE) - return 0; - return 1; gboolean gst_udp_net_utils_win32_wsa_startup (GstObject * obj) @@ -60,3 +53,178 @@ +int +gst_udp_get_addr (const char *hostname, int port, struct sockaddr_storage *addr) +{ + struct addrinfo hints, *res, *nres; + char service[NI_MAXSERV]; + int ret; + memset (&hints, 0, sizeof (hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; + snprintf (service, sizeof (service) - 1, "%d", port); + service[sizeof (service) - 1] = '\0'; + if ((ret = getaddrinfo (hostname, (port == -1) ? NULL : service, &hints, + &res)) < 0) { + return ret; + } + nres = res; + while (nres) { + if (nres->ai_family == AF_INET || nres->ai_family == AF_INET6) + nres = nres->ai_next; + if (nres) { + memcpy (addr, nres->ai_addr, nres->ai_addrlen); + } else { + errno = EAI_ADDRFAMILY; + ret = -1; + freeaddrinfo (res); + return ret; +} +gst_udp_join_group (int sockfd, gboolean loop, int ttl, + struct sockaddr_storage *addr) + int ret = -1; + int l = (loop == FALSE) ? 0 : 1; + switch (addr->ss_family) { + case AF_INET: + { + struct ip_mreq mreq4; + mreq4.imr_multiaddr.s_addr = + ((struct sockaddr_in *) addr)->sin_addr.s_addr; + mreq4.imr_interface.s_addr = INADDR_ANY; + if ((ret = + setsockopt (sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, &l, + sizeof (l))) < 0) + return ret; + setsockopt (sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, + sizeof (ttl))) < 0) + setsockopt (sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, + (const void *) &mreq4, sizeof (mreq4))) < 0) + } + case AF_INET6: + struct ipv6_mreq mreq6; + memcpy (&mreq6.ipv6mr_multiaddr, + &(((struct sockaddr_in6 *) addr)->sin6_addr), + sizeof (struct in6_addr)); + mreq6.ipv6mr_interface = 0; + setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &l, + setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl, + setsockopt (sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, + (const void *) &mreq6, sizeof (mreq6))) < 0) + default: + errno = EAFNOSUPPORT; +gst_udp_leave_group (int sockfd, struct sockaddr_storage *addr) + setsockopt (sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, + setsockopt (sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, +gst_udp_is_multicast (struct sockaddr_storage *addr) + struct sockaddr_in *addr4 = (struct sockaddr_in *) addr; + ret = IN_MULTICAST (ntohl (addr4->sin_addr.s_addr)); + struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr; + ret = IN6_IS_ADDR_MULTICAST (&addr6->sin6_addr); Index: gstudpnetutils.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.h,v retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstudpnetutils.h 11 Feb 2007 12:57:47 -0000 1.2 +++ gstudpnetutils.h 21 May 2008 09:56:02 -0000 1.3 @@ -52,7 +52,6 @@ #define IOCTL_SOCKET ioctlsocket #define CLOSE_SOCKET(sock) closesocket(sock) #define setsockopt(sock,l,opt,val,len) setsockopt(sock,l,opt,(char *)(val),len) -#define inet_aton(c,addr) gst_udp_net_utils_win32_inet_aton ((c),(addr)) #define WSA_STARTUP(obj) gst_udp_net_utils_win32_wsa_startup(GST_OBJECT(obj)) #define WSA_CLEANUP(obj) WSACleanup () @@ -68,10 +67,15 @@ -int gst_udp_net_utils_win32_inet_aton (const char *c, struct in_addr * addr); gboolean gst_udp_net_utils_win32_wsa_startup (GstObject * obj); +int gst_udp_get_addr (const char *hostname, int port, struct sockaddr_storage *addr); +int gst_udp_is_multicast (struct sockaddr_storage *addr); +int gst_udp_join_group (int sockfd, gboolean loop, int ttl, struct sockaddr_storage *addr); +int gst_udp_leave_group (int sockfd, struct sockaddr_storage *addr); #endif /* __GST_UDP_NET_UTILS_H__*/ Index: gstudpsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- gstudpsrc.c 1 May 2008 10:52:11 -0000 1.85 +++ gstudpsrc.c 21 May 2008 09:56:02 -0000 1.86 @@ -349,7 +349,7 @@ GstUDPSrc *udpsrc; GstNetBuffer *outbuf; - struct sockaddr_in tmpaddr; + struct sockaddr_storage tmpaddr; socklen_t len; guint8 *pktdata; gint pktsize; @@ -468,8 +468,28 @@ GST_BUFFER_DATA (outbuf) = pktdata; GST_BUFFER_SIZE (outbuf) = ret; - gst_netaddress_set_ip4_address (&outbuf->from, tmpaddr.sin_addr.s_addr, - tmpaddr.sin_port); + switch (tmpaddr.ss_family) { + gst_netaddress_set_ip4_address (&outbuf->from, + ((struct sockaddr_in *) &tmpaddr)->sin_addr.s_addr, + ((struct sockaddr_in *) &tmpaddr)->sin_port); + guint8 ip6[16]; + memcpy (ip6, &((struct sockaddr_in6 *) &tmpaddr)->sin6_addr, + sizeof (ip6)); + gst_netaddress_set_ip6_address (&outbuf->from, ip6, + goto receive_error; gst_buffer_set_caps (GST_BUFFER_CAST (outbuf), udpsrc->caps); @@ -681,7 +701,7 @@ guint bc_val; gint reuse; - struct sockaddr_in my_addr; + struct sockaddr_storage my_addr; guint len; int port; GstUDPSrc *src; @@ -690,12 +710,12 @@ src = GST_UDPSRC (bsrc); - if (!inet_aton (src->multi_group, &(src->multi_addr.imr_multiaddr))) - src->multi_addr.imr_multiaddr.s_addr = 0; if (src->sockfd == -1) { /* need to allocate a socket */ - if ((ret = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) + if ((ret = + gst_udp_get_addr (src->multi_group, src->port, &src->myaddr)) < 0) + goto getaddrinfo_error; + if ((ret = socket (src->myaddr.ss_family, SOCK_DGRAM, IPPROTO_UDP)) < 0) goto no_socket; src->sock.fd = ret; @@ -707,15 +727,6 @@ sizeof (reuse))) < 0) goto setsockopt_error; - memset (&src->myaddr, 0, sizeof (src->myaddr)); - src->myaddr.sin_family = AF_INET; /* host byte order */ - src->myaddr.sin_port = g_htons (src->port); /* short, network byte order */ - if (src->multi_addr.imr_multiaddr.s_addr) - src->myaddr.sin_addr.s_addr = src->multi_addr.imr_multiaddr.s_addr; - else - src->myaddr.sin_addr.s_addr = INADDR_ANY; GST_DEBUG_OBJECT (src, "binding on port %d", src->port); if ((ret = bind (src->sock.fd, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr))) < 0) @@ -726,11 +737,9 @@ src->externalfd = TRUE; - if (src->multi_addr.imr_multiaddr.s_addr) { - src->multi_addr.imr_interface.s_addr = INADDR_ANY; - if ((ret = - setsockopt (src->sock.fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, - &src->multi_addr, sizeof (src->multi_addr))) < 0) + if (gst_udp_is_multicast (&src->myaddr)) { + ret = gst_udp_join_group (src->sock.fd, TRUE, src->ttl, &src->myaddr); + if (ret < 0) goto membership; @@ -769,7 +778,9 @@ sizeof (bc_val))) < 0) goto no_broadcast; - port = g_ntohs (my_addr.sin_port); + /* NOTE: sockaddr_in.sin_port works for ipv4 and ipv6 because sin_port + * follows ss_family on both */ + port = ntohs (((struct sockaddr_in *) &my_addr)->sin_port); GST_DEBUG_OBJECT (src, "bound, on port %d", port); if (port != src->port) { src->port = port; @@ -777,7 +788,7 @@ g_object_notify (G_OBJECT (src), "port"); - src->myaddr.sin_port = g_htons (src->port + 1); + ((struct sockaddr_in *) &src->myaddr)->sin_port = htons (src->port + 1); if ((src->fdset = gst_poll_new (TRUE)) == NULL) goto no_fdset; @@ -788,6 +799,12 @@ + { + GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL), + ("getaddrinfo failed %d: %s (%d)", ret, g_strerror (errno), errno)); + return FALSE; no_socket: GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), Index: gstudpsrc.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- gstudpsrc.h 28 Feb 2008 11:51:24 -0000 1.23 +++ gstudpsrc.h 21 May 2008 09:56:02 -0000 1.24 @@ -68,8 +68,7 @@ GstPoll *fdset; gboolean externalfd; - struct sockaddr_in myaddr; - struct ip_mreq multi_addr; + struct sockaddr_storage myaddr; struct _GstUDPSrcClass { |
From: <wt...@ke...> - 2008-05-21 10:52:00
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Wed May 21 2008 10:52:06 UTC Log message: Patch by: Henrik Eriksson <henriken at axis dot com> * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), (gst_multiudpsink_init), (gst_multiudpsink_setup_qos_dscp), (gst_multiudpsink_set_property), (gst_multiudpsink_get_property), (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal): * gst/udp/gstmultiudpsink.h: Add qos-dscp property to manage the Quality of service. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c gstmultiudpsink.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3476&r2=1.3477 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.29&r2=1.30 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h.diff?r1=1.11&r2=1.12 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3476 retrieving revision 1.3477 diff -u -d -r1.3476 -r1.3477 --- ChangeLog 21 May 2008 10:09:21 -0000 1.3476 +++ ChangeLog 21 May 2008 10:51:50 -0000 1.3477 @@ -1,5 +1,16 @@ 2008-05-21 Wim Taymans <wim...@co...> + Patch by: Henrik Eriksson <henriken at axis dot com> + + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), + (gst_multiudpsink_init), (gst_multiudpsink_setup_qos_dscp), + (gst_multiudpsink_set_property), (gst_multiudpsink_get_property), + (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal): + * gst/udp/gstmultiudpsink.h: + Add qos-dscp property to manage the Quality of service. +2008-05-21 Wim Taymans <wim...@co...> * gst/rtp/gstrtptheoradepay.c: (gst_rtp_theora_depay_process): Improve debugging of the ident. Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- gstmultiudpsink.c 21 May 2008 09:56:02 -0000 1.29 +++ gstmultiudpsink.c 21 May 2008 10:51:51 -0000 1.30 @@ -83,6 +83,7 @@ #define DEFAULT_AUTO_MULTICAST TRUE #define DEFAULT_TTL 64 #define DEFAULT_LOOP TRUE +#define DEFAULT_QOS_DSCP 0 enum { @@ -95,8 +96,9 @@ PROP_CLIENTS, PROP_AUTO_MULTICAST, PROP_TTL, - PROP_LOOP - /* FILL ME */ + PROP_LOOP, + PROP_QOS_DSCP, + PROP_LAST }; #define CLOSE_IF_REQUESTED(udpctx) \ @@ -304,6 +306,10 @@ g_param_spec_boolean ("loop", "Multicast Loopback", "Used for setting the multicast loop parameter. TRUE = enable," " FALSE = disable", DEFAULT_LOOP, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_QOS_DSCP, + g_param_spec_uint ("qos-dscp", "QoS diff srv code point", + "Quality of Service, differentiated services code point", 0, 63, + DEFAULT_QOS_DSCP, G_PARAM_READWRITE)); gstelement_class->change_state = gst_multiudpsink_change_state; @@ -330,6 +336,7 @@ sink->auto_multicast = DEFAULT_AUTO_MULTICAST; sink->ttl = DEFAULT_TTL; sink->loop = DEFAULT_LOOP; + sink->qos_dscp = DEFAULT_QOS_DSCP; } static void @@ -466,6 +473,29 @@ +gst_multiudpsink_setup_qos_dscp (GstMultiUDPSink * sink) +{ + gint tos; + if (sink->sock < 0) + return; + GST_DEBUG_OBJECT (sink, "setting TOS to %d", sink->qos_dscp); + /* Extract and shift 6 bits of DSFIELD */ + tos = (sink->qos_dscp & 0x3f) << 2; + if (setsockopt (sink->sock, SOL_IP, IP_TOS, &tos, sizeof (tos)) < 0) { + GST_ERROR_OBJECT (sink, "could not set TOS: %s", g_strerror (errno)); + } +#ifdef IPV6_TCLASS + if (setsockopt (sink->sock, SOL_IPV6, IPV6_TCLASS, &tos, sizeof (tos)) < 0) { + GST_ERROR_OBJECT (sink, "could not set TCLASS: %s", g_strerror (errno)); +#endif +} +static void gst_multiudpsink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -493,6 +523,10 @@ case PROP_LOOP: udpsink->loop = g_value_get_boolean (value); break; + case PROP_QOS_DSCP: + udpsink->qos_dscp = g_value_get_uint (value); + gst_multiudpsink_setup_qos_dscp (udpsink); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -536,22 +570,15 @@ g_value_set_boolean (value, udpsink->loop); + g_value_set_int (value, udpsink->qos_dscp); } -static void -join_multicast (GstUDPClient * client, gboolean loop, int ttl) -{ - /* Joining the multicast group */ - /* FIXME, can we use multicast and unicast over the same - * socket? if not, search for socket of this multicast group or - * create a new one. */ - gst_udp_join_group (*(client->sock), loop, ttl, &client->theiraddr); -} - /* create a socket for sending to remote machine */ static gboolean gst_multiudpsink_init_send (GstMultiUDPSink * sink) @@ -562,7 +589,7 @@ GstUDPClient *client; if (sink->sockfd == -1) { - /* create sender socket */ + /* create sender socket try IP6, fall back to IP4 */ if ((sink->sock = socket (AF_INET6, SOCK_DGRAM, 0)) == -1) if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1) goto no_socket; @@ -583,12 +610,14 @@ sink->bytes_to_serve = 0; sink->bytes_served = 0; - /* look for multicast clients and join multicast groups approptiately */ + gst_multiudpsink_setup_qos_dscp (sink); + /* look for multicast clients and join multicast groups approptiately */ for (clients = sink->clients; clients; clients = g_list_next (clients)) { client = (GstUDPClient *) clients->data; if (gst_udp_is_multicast (&client->theiraddr) && sink->auto_multicast) - join_multicast (client, sink->loop, sink->ttl); + gst_udp_join_group (*(client->sock), sink->loop, sink->ttl, + &client->theiraddr); return TRUE; @@ -638,7 +667,8 @@ if (*client->sock > 0 && gst_udp_is_multicast (&client->theiraddr) && sink->auto_multicast) { GST_DEBUG_OBJECT (sink, "multicast address detected"); - join_multicast (client, sink->loop, sink->ttl); + gst_udp_join_group (*(client->sock), sink->loop, sink->ttl, + &client->theiraddr); } else { GST_DEBUG_OBJECT (sink, "normal address detected"); Index: gstmultiudpsink.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- gstmultiudpsink.h 21 May 2008 09:56:02 -0000 1.11 +++ gstmultiudpsink.h 21 May 2008 10:51:52 -0000 1.12 @@ -73,6 +73,7 @@ gboolean auto_multicast; gint ttl; gboolean loop; + guint qos_dscp; struct _GstMultiUDPSinkClass { |
From: <wt...@ke...> - 2008-05-21 11:38:30
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Wed May 21 2008 11:38:31 UTC Log message: Patch by: Gustaf Räntilä <g dot rantila at gmail dot com> * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render): Ignore EPERM errors from sendto. Fixes #533619. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3477&r2=1.3478 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.30&r2=1.31 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3477 retrieving revision 1.3478 diff -u -d -r1.3477 -r1.3478 --- ChangeLog 21 May 2008 10:51:50 -0000 1.3477 +++ ChangeLog 21 May 2008 11:38:15 -0000 1.3478 @@ -1,5 +1,12 @@ 2008-05-21 Wim Taymans <wim...@co...> + Patch by: Gustaf Räntilä <g dot rantila at gmail dot com> + + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render): + Ignore EPERM errors from sendto. Fixes #533619. +2008-05-21 Wim Taymans <wim...@co...> Patch by: Henrik Eriksson <henriken at axis dot com> * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- gstmultiudpsink.c 21 May 2008 10:51:51 -0000 1.30 +++ gstmultiudpsink.c 21 May 2008 11:38:17 -0000 1.31 @@ -388,6 +388,10 @@ (struct sockaddr *) &client->theiraddr, sizeof (client->theiraddr)); if (ret < 0) { + /* we get a non-posix EPERM on Linux when a firewall rule blocks this + * destination. We will simply ignore this. */ + if (errno == EPERM) + break; if (errno != EINTR && errno != EAGAIN) { goto send_error; } |
From: <wt...@ke...> - 2008-05-21 13:47:53
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Wed May 21 2008 13:47:57 UTC Log message: * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), (gst_multiudpsink_setup_qos_dscp), (gst_multiudpsink_add_internal): * gst/udp/gstmultiudpsink.h: Add a fixme for the auto-multicast property. Fix some confusing debug messages. Disable setting a qos value by default. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c gstmultiudpsink.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3478&r2=1.3479 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.31&r2=1.32 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h.diff?r1=1.12&r2=1.13 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3478 retrieving revision 1.3479 diff -u -d -r1.3478 -r1.3479 --- ChangeLog 21 May 2008 11:38:15 -0000 1.3478 +++ ChangeLog 21 May 2008 13:47:41 -0000 1.3479 @@ -1,5 +1,14 @@ 2008-05-21 Wim Taymans <wim...@co...> + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), + (gst_multiudpsink_setup_qos_dscp), (gst_multiudpsink_add_internal): + * gst/udp/gstmultiudpsink.h: + Add a fixme for the auto-multicast property. + Fix some confusing debug messages. + Disable setting a qos value by default. + +2008-05-21 Wim Taymans <wim...@co...> Patch by: Gustaf Räntilä <g dot rantila at gmail dot com> * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render): @@ -14,7 +23,7 @@ (gst_multiudpsink_set_property), (gst_multiudpsink_get_property), (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal): * gst/udp/gstmultiudpsink.h: - Add qos-dscp property to manage the Quality of service. + Add qos-dscp property to manage the Quality of service. Fixes #469917. Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- gstmultiudpsink.c 21 May 2008 11:38:17 -0000 1.31 +++ gstmultiudpsink.c 21 May 2008 13:47:43 -0000 1.32 @@ -80,10 +80,13 @@ #define DEFAULT_CLOSEFD TRUE #define DEFAULT_SOCK -1 #define DEFAULT_CLIENTS NULL +/* FIXME, this should be disabled by default, we don't need to join a multicast + * group for sending, if this socket is also used for receiving, it should + * be configured in the element that does the receive. */ #define DEFAULT_AUTO_MULTICAST TRUE #define DEFAULT_TTL 64 #define DEFAULT_LOOP TRUE -#define DEFAULT_QOS_DSCP 0 +#define DEFAULT_QOS_DSCP -1 enum { @@ -307,9 +310,9 @@ "Used for setting the multicast loop parameter. TRUE = enable," " FALSE = disable", DEFAULT_LOOP, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_QOS_DSCP, - g_param_spec_uint ("qos-dscp", "QoS diff srv code point", - "Quality of Service, differentiated services code point", 0, 63, - DEFAULT_QOS_DSCP, G_PARAM_READWRITE)); + g_param_spec_int ("qos-dscp", "QoS diff srv code point", + "Quality of Service, differentiated services code point (-1 default)", + -1, 63, DEFAULT_QOS_DSCP, G_PARAM_READWRITE)); gstelement_class->change_state = gst_multiudpsink_change_state; @@ -481,6 +484,10 @@ gint tos; + /* don't touch on -1 */ + if (sink->qos_dscp < 0) + return; if (sink->sock < 0) return; @@ -667,14 +674,18 @@ g_get_current_time (&now); client->connect_time = GST_TIMEVAL_TO_TIME (now); - /* check if its a multicast address */ - if (*client->sock > 0 && gst_udp_is_multicast (&client->theiraddr) && - sink->auto_multicast) { - GST_DEBUG_OBJECT (sink, "multicast address detected"); - gst_udp_join_group (*(client->sock), sink->loop, sink->ttl, - &client->theiraddr); - } else { - GST_DEBUG_OBJECT (sink, "normal address detected"); + if (*client->sock > 0) { + /* check if its a multicast address */ + if (gst_udp_is_multicast (&client->theiraddr)) { + GST_DEBUG_OBJECT (sink, "multicast address detected"); + if (sink->auto_multicast) { + GST_DEBUG_OBJECT (sink, "joining multicast group"); + gst_udp_join_group (*(client->sock), sink->loop, sink->ttl, + &client->theiraddr); + } + } else { + GST_DEBUG_OBJECT (sink, "normal address detected"); + } } if (lock) Index: gstmultiudpsink.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- gstmultiudpsink.h 21 May 2008 10:51:52 -0000 1.12 +++ gstmultiudpsink.h 21 May 2008 13:47:43 -0000 1.13 @@ -73,7 +73,7 @@ gboolean auto_multicast; gint ttl; gboolean loop; - guint qos_dscp; + gint qos_dscp; }; struct _GstMultiUDPSinkClass { |
From: <wt...@ke...> - 2008-05-21 17:41:15
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Wed May 21 2008 17:36:04 UTC Log message: * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal): * gst/udp/gstudpnetutils.c: (gst_udp_set_loop_ttl), (gst_udp_join_group): * gst/udp/gstudpnetutils.h: * gst/udp/gstudpsrc.c: (gst_udpsrc_start): Joining a multicast group and setting the loop/ttl properties are totally unrelated tasks are must be separated. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c gstudpnetutils.c gstudpnetutils.h gstudpsrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3480&r2=1.3481 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.32&r2=1.33 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.c.diff?r1=1.2&r2=1.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.h.diff?r1=1.3&r2=1.4 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c.diff?r1=1.86&r2=1.87 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3480 retrieving revision 1.3481 diff -u -d -r1.3480 -r1.3481 --- ChangeLog 21 May 2008 14:09:39 -0000 1.3480 +++ ChangeLog 21 May 2008 17:35:48 -0000 1.3481 @@ -1,3 +1,14 @@ +2008-05-21 Wim Taymans <wim...@co...> + + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init_send), + (gst_multiudpsink_add_internal): + * gst/udp/gstudpnetutils.c: (gst_udp_set_loop_ttl), + (gst_udp_join_group): + * gst/udp/gstudpnetutils.h: + * gst/udp/gstudpsrc.c: (gst_udpsrc_start): + Joining a multicast group and setting the loop/ttl properties are + totally unrelated tasks are must be separated. 2008-05-21 Stefan Kost <en...@us...> * gst/avi/gstavimux.c: Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- gstmultiudpsink.c 21 May 2008 13:47:43 -0000 1.32 +++ gstmultiudpsink.c 21 May 2008 17:35:50 -0000 1.33 @@ -621,14 +621,14 @@ sink->bytes_to_serve = 0; sink->bytes_served = 0; + gst_udp_set_loop_ttl (sink->sock, sink->loop, sink->ttl); gst_multiudpsink_setup_qos_dscp (sink); /* look for multicast clients and join multicast groups approptiately */ for (clients = sink->clients; clients; clients = g_list_next (clients)) { client = (GstUDPClient *) clients->data; if (gst_udp_is_multicast (&client->theiraddr) && sink->auto_multicast) - gst_udp_join_group (*(client->sock), sink->loop, sink->ttl, - &client->theiraddr); + gst_udp_join_group (*(client->sock), &client->theiraddr); } return TRUE; @@ -680,8 +680,7 @@ GST_DEBUG_OBJECT (sink, "multicast address detected"); if (sink->auto_multicast) { GST_DEBUG_OBJECT (sink, "joining multicast group"); - gst_udp_join_group (*(client->sock), sink->loop, sink->ttl, - &client->theiraddr); + gst_udp_join_group (*(client->sock), &client->theiraddr); } } else { GST_DEBUG_OBJECT (sink, "normal address detected"); Index: gstudpnetutils.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstudpnetutils.c 21 May 2008 09:56:02 -0000 1.2 +++ gstudpnetutils.c 21 May 2008 17:35:50 -0000 1.3 @@ -91,21 +91,16 @@ } int -gst_udp_join_group (int sockfd, gboolean loop, int ttl, - struct sockaddr_storage *addr) +gst_udp_set_loop_ttl (int sockfd, gboolean loop, int ttl) { int ret = -1; +#if 0 int l = (loop == FALSE) ? 0 : 1; switch (addr->ss_family) { case AF_INET: { - struct ip_mreq mreq4; - - mreq4.imr_multiaddr.s_addr = - ((struct sockaddr_in *) addr)->sin_addr.s_addr; - mreq4.imr_interface.s_addr = INADDR_ANY; if ((ret = setsockopt (sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, &l, sizeof (l))) < 0) @@ -115,14 +110,50 @@ setsockopt (sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof (ttl))) < 0) return ret; + break; + } + case AF_INET6: + { + if ((ret = + setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &l, + sizeof (l))) < 0) + return ret; + setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl, + sizeof (ttl))) < 0) + default: + errno = EAFNOSUPPORT; + } +#endif + return ret; +} +int +gst_udp_join_group (int sockfd, struct sockaddr_storage *addr) +{ + int ret = -1; + switch (addr->ss_family) { + case AF_INET: + struct ip_mreq mreq4; + mreq4.imr_multiaddr.s_addr = + ((struct sockaddr_in *) addr)->sin_addr.s_addr; + mreq4.imr_interface.s_addr = INADDR_ANY; setsockopt (sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *) &mreq4, sizeof (mreq4))) < 0) - } - break; case AF_INET6: struct ipv6_mreq mreq6; @@ -133,26 +164,15 @@ mreq6.ipv6mr_interface = 0; - setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &l, - sizeof (l))) < 0) - return ret; - if ((ret = - setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl, - sizeof (ttl))) < 0) setsockopt (sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (const void *) &mreq6, sizeof (mreq6))) < 0) default: errno = EAFNOSUPPORT; return ret; Index: gstudpnetutils.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.h,v retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gstudpnetutils.h 21 May 2008 09:56:02 -0000 1.3 +++ gstudpnetutils.h 21 May 2008 17:35:50 -0000 1.4 @@ -74,7 +74,9 @@ int gst_udp_get_addr (const char *hostname, int port, struct sockaddr_storage *addr); int gst_udp_is_multicast (struct sockaddr_storage *addr); -int gst_udp_join_group (int sockfd, gboolean loop, int ttl, struct sockaddr_storage *addr); +int gst_udp_set_loop_ttl (int sockfd, gboolean loop, int ttl); +int gst_udp_join_group (int sockfd, struct sockaddr_storage *addr); int gst_udp_leave_group (int sockfd, struct sockaddr_storage *addr); #endif /* __GST_UDP_NET_UTILS_H__*/ Index: gstudpsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- gstudpsrc.c 21 May 2008 09:56:02 -0000 1.86 +++ gstudpsrc.c 21 May 2008 17:35:50 -0000 1.87 @@ -738,7 +738,7 @@ if (gst_udp_is_multicast (&src->myaddr)) { - ret = gst_udp_join_group (src->sock.fd, TRUE, src->ttl, &src->myaddr); + ret = gst_udp_join_group (src->sock.fd, &src->myaddr); if (ret < 0) goto membership; |
From: <wt...@ke...> - 2008-06-13 11:46:05
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Fri Jun 13 2008 11:46:10 UTC Log message: * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init_send), (gst_multiudpsink_remove): Fix a typo and do some small cleanups. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3537&r2=1.3538 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.34&r2=1.35 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3537 retrieving revision 1.3538 diff -u -d -r1.3537 -r1.3538 --- ChangeLog 13 Jun 2008 09:39:38 -0000 1.3537 +++ ChangeLog 13 Jun 2008 11:45:52 -0000 1.3538 @@ -1,5 +1,11 @@ 2008-06-13 Wim Taymans <wim...@co...> + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init_send), + (gst_multiudpsink_remove): + Fix a typo and do some small cleanups. + +2008-06-13 Wim Taymans <wim...@co...> Patch by: Olivier Crete <tester at tester dot ca> * gst/rtp/gstrtptheoradepay.c: (gst_rtp_theora_depay_setcaps): Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- gstmultiudpsink.c 22 May 2008 11:19:03 -0000 1.34 +++ gstmultiudpsink.c 13 Jun 2008 11:45:54 -0000 1.35 @@ -625,10 +625,10 @@ gst_udp_set_loop_ttl (sink->sock, sink->loop, sink->ttl); gst_multiudpsink_setup_qos_dscp (sink); - /* look for multicast clients and join multicast groups approptiately */ + /* look for multicast clients and join multicast groups appropriately */ for (clients = sink->clients; clients; clients = g_list_next (clients)) { client = (GstUDPClient *) clients->data; - if (gst_udp_is_multicast (&client->theiraddr) && sink->auto_multicast) + if (sink->auto_multicast && gst_udp_is_multicast (&client->theiraddr)) gst_udp_join_group (*(client->sock), &client->theiraddr); } return TRUE; @@ -755,8 +755,8 @@ g_get_current_time (&now); client->disconnect_time = GST_TIMEVAL_TO_TIME (now); - if (*(client->sock) != -1 && gst_udp_is_multicast (&client->theiraddr) - && sink->auto_multicast) + if (*(client->sock) != -1 && sink->auto_multicast + && gst_udp_is_multicast (&client->theiraddr)) gst_udp_leave_group (*(client->sock), &client->theiraddr); /* Unlock to emit signal before we delete the actual client */ |
From: <wt...@ke...> - 2008-06-13 11:47:41
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Fri Jun 13 2008 11:47:42 UTC Log message: * gst/udp/gstudpnetutils.c: (gst_udp_is_multicast): Use g_ntohl for better portability. Modified files: . : ChangeLog gst/udp : gstudpnetutils.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3538&r2=1.3539 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.c.diff?r1=1.4&r2=1.5 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3538 retrieving revision 1.3539 diff -u -d -r1.3538 -r1.3539 --- ChangeLog 13 Jun 2008 11:45:52 -0000 1.3538 +++ ChangeLog 13 Jun 2008 11:47:26 -0000 1.3539 @@ -1,5 +1,10 @@ 2008-06-13 Wim Taymans <wim...@co...> + * gst/udp/gstudpnetutils.c: (gst_udp_is_multicast): + Use g_ntohl for better portability. + +2008-06-13 Wim Taymans <wim...@co...> * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init_send), (gst_multiudpsink_remove): Fix a typo and do some small cleanups. Index: gstudpnetutils.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpnetutils.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstudpnetutils.c 22 May 2008 11:19:03 -0000 1.4 +++ gstudpnetutils.c 13 Jun 2008 11:47:28 -0000 1.5 @@ -230,7 +230,7 @@ { struct sockaddr_in *addr4 = (struct sockaddr_in *) addr; - ret = IN_MULTICAST (ntohl (addr4->sin_addr.s_addr)); + ret = IN_MULTICAST (g_ntohl (addr4->sin_addr.s_addr)); } break; |
From: <wt...@ke...> - 2008-06-13 11:54:10
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Fri Jun 13 2008 11:54:19 UTC Log message: * gst/udp/gstudpsrc.c: (gst_udpsrc_class_init), (gst_udpsrc_init), (gst_udpsrc_create), (gst_udpsrc_set_property), (gst_udpsrc_get_property), (gst_udpsrc_start), (gst_udpsrc_stop): * gst/udp/gstudpsrc.h: Add property to control automatic join/leave of multicast groups. Add G_LIKELY. Remove setting caps on buffers explicitly, basesrc does that for us now. Improve debug info. Convert some non-fatal error into warnings. Use g_ntohs for better portability. Leave multicast groups when stopping. When using external sockets, use getsockname() on them to fill up the addr structure before calling methods that use the structure. Should all fix #536903. API: GstUDPSrc::auto-multicast property Modified files: . : ChangeLog gst/udp : gstudpsrc.c gstudpsrc.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3539&r2=1.3540 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c.diff?r1=1.87&r2=1.88 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.h.diff?r1=1.24&r2=1.25 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3539 retrieving revision 1.3540 diff -u -d -r1.3539 -r1.3540 --- ChangeLog 13 Jun 2008 11:47:26 -0000 1.3539 +++ ChangeLog 13 Jun 2008 11:54:03 -0000 1.3540 @@ -1,5 +1,23 @@ 2008-06-13 Wim Taymans <wim...@co...> + * gst/udp/gstudpsrc.c: (gst_udpsrc_class_init), (gst_udpsrc_init), + (gst_udpsrc_create), (gst_udpsrc_set_property), + (gst_udpsrc_get_property), (gst_udpsrc_start), (gst_udpsrc_stop): + * gst/udp/gstudpsrc.h: + Add property to control automatic join/leave of multicast groups. + Add G_LIKELY. + Remove setting caps on buffers explicitly, basesrc does that for us now. + Improve debug info. + Convert some non-fatal error into warnings. + Use g_ntohs for better portability. + Leave multicast groups when stopping. + When using external sockets, use getsockname() on them to fill up the + addr structure before calling methods that use the structure. + Should all fix #536903. + API: GstUDPSrc::auto-multicast property + +2008-06-13 Wim Taymans <wim...@co...> * gst/udp/gstudpnetutils.c: (gst_udp_is_multicast): Use g_ntohl for better portability. Index: gstudpsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- gstudpsrc.c 21 May 2008 17:35:50 -0000 1.87 +++ gstudpsrc.c 13 Jun 2008 11:54:04 -0000 1.88 @@ -170,10 +170,12 @@ #define UDP_DEFAULT_SKIP_FIRST_BYTES 0 #define UDP_DEFAULT_CLOSEFD TRUE #define UDP_DEFAULT_SOCK -1 +#define UDP_DEFAULT_AUTO_MULTICAST TRUE enum { PROP_0, PROP_PORT, PROP_MULTICAST_GROUP, PROP_URI, @@ -183,7 +185,10 @@ PROP_TIMEOUT, PROP_SKIP_FIRST_BYTES, PROP_CLOSEFD, - PROP_SOCK + PROP_SOCK, + PROP_AUTO_MULTICAST, + PROP_LAST }; static void gst_udpsrc_uri_handler_init (gpointer g_iface, gpointer iface_data); @@ -283,6 +288,10 @@ g_param_spec_int ("sock", "Socket Handle", "Socket currently in use for UDP reception. (-1 = no socket)", -1, G_MAXINT, UDP_DEFAULT_SOCK, G_PARAM_READABLE)); + g_object_class_install_property (gobject_class, PROP_AUTO_MULTICAST, + g_param_spec_boolean ("auto-multicast", "Auto Multicast", + "Automatically join/leave multicast groups", + UDP_DEFAULT_AUTO_MULTICAST, G_PARAM_READWRITE)); gstbasesrc_class->start = gst_udpsrc_start; gstbasesrc_class->stop = gst_udpsrc_stop; @@ -298,7 +307,6 @@ WSA_STARTUP (udpsrc); - gst_base_src_set_live (GST_BASE_SRC (udpsrc), TRUE); udpsrc->port = UDP_DEFAULT_PORT; udpsrc->sockfd = UDP_DEFAULT_SOCKFD; udpsrc->multi_group = g_strdup (UDP_DEFAULT_MULTICAST_GROUP); @@ -308,9 +316,15 @@ udpsrc->skip_first_bytes = UDP_DEFAULT_SKIP_FIRST_BYTES; udpsrc->closefd = UDP_DEFAULT_CLOSEFD; udpsrc->externalfd = (udpsrc->sockfd != -1); - + udpsrc->auto_multicast = UDP_DEFAULT_AUTO_MULTICAST; udpsrc->sock.fd = UDP_DEFAULT_SOCK; + /* configure basesrc to be a live source */ + gst_base_src_set_live (GST_BASE_SRC (udpsrc), TRUE); + /* make basesrc output a segment in time */ gst_base_src_set_format (GST_BASE_SRC (udpsrc), GST_FORMAT_TIME); + /* make basesrc set timestamps on outgoing buffers based on the running_time + * when they were captured */ gst_base_src_set_do_timestamp (GST_BASE_SRC (udpsrc), TRUE); } @@ -363,12 +377,13 @@ gint ret; gboolean try_again; - udpsrc = GST_UDPSRC (psrc); + udpsrc = GST_UDPSRC_CAST (psrc); retry: /* quick check, avoid going in select when we already have data */ readsize = 0; - if ((ret = IOCTL_SOCKET (udpsrc->sock.fd, FIONREAD, &readsize)) < 0) + if (G_UNLIKELY ((ret = + IOCTL_SOCKET (udpsrc->sock.fd, FIONREAD, &readsize)) < 0)) goto ioctl_failed; if (readsize > 0) @@ -388,7 +403,7 @@ ret = gst_poll_wait (udpsrc->fdset, timeout); GST_LOG_OBJECT (udpsrc, "select returned %d", ret); - if (ret < 0) { + if (G_UNLIKELY (ret < 0)) { if (errno == EBUSY) goto stopped; #ifdef G_OS_WIN32 @@ -399,7 +414,7 @@ goto select_error; #endif try_again = TRUE; - } else if (ret == 0) { + } else if (G_UNLIKELY (ret == 0)) { /* timeout, post element message */ gst_element_post_message (GST_ELEMENT_CAST (udpsrc), gst_message_new_element (GST_OBJECT_CAST (udpsrc), @@ -407,20 +422,21 @@ "timeout", G_TYPE_UINT64, udpsrc->timeout, NULL))); } - } while (try_again); + } while (G_UNLIKELY (try_again)); /* ask how much is available for reading on the socket, this should be exactly * one UDP packet. We will check the return value, though, because in some * case it can return 0 and we don't want a 0 sized buffer. */ /* if we get here and there is nothing to read from the socket, the select got - * woken up by activity on the socket but it was not a read. We how someone + * woken up by activity on the socket but it was not a read. We know someone * will also do something with the socket so that we don't go into an infinite * loop in the select(). */ - if (!readsize) + if (G_UNLIKELY (!readsize)) goto retry; no_select: @@ -433,7 +449,7 @@ len = sizeof (struct sockaddr); ret = recvfrom (udpsrc->sock.fd, pktdata, pktsize, 0, (struct sockaddr *) &tmpaddr, &len); /* WSAECONNRESET for a UDP socket means that a packet sent with udpsink * generated a "port unreachable" ICMP response. We ignore that and try @@ -458,7 +474,7 @@ GST_BUFFER_MALLOCDATA (outbuf) = pktdata; /* patch pktdata and len when stripping off the headers */ - if (udpsrc->skip_first_bytes != 0) { + if (G_UNLIKELY (udpsrc->skip_first_bytes != 0)) { if (G_UNLIKELY (readsize <= udpsrc->skip_first_bytes)) goto skip_error; @@ -490,9 +506,6 @@ errno = EAFNOSUPPORT; goto receive_error; } - gst_buffer_set_caps (GST_BUFFER_CAST (outbuf), udpsrc->caps); GST_LOG_OBJECT (udpsrc, "read %d bytes", (int) readsize); *buf = GST_BUFFER_CAST (outbuf); @@ -647,6 +660,9 @@ case PROP_CLOSEFD: udpsrc->closefd = g_value_get_boolean (value); break; + case PROP_AUTO_MULTICAST: + udpsrc->auto_multicast = g_value_get_boolean (value); + break; default: @@ -689,6 +705,9 @@ case PROP_SOCK: g_value_set_int (value, udpsrc->sock.fd); + g_value_set_boolean (value, udpsrc->auto_multicast); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -701,20 +720,22 @@ guint bc_val; gint reuse; - struct sockaddr_storage my_addr; - guint len; int port; GstUDPSrc *src; int rcvsize; + guint len; src = GST_UDPSRC (bsrc); if (src->sockfd == -1) { /* need to allocate a socket */ + GST_DEBUG_OBJECT (src, "allocating socket for %s:%d", src->multi_group, + src->port); if ((ret = gst_udp_get_addr (src->multi_group, src->port, &src->myaddr)) < 0) goto getaddrinfo_error; if ((ret = socket (src->myaddr.ss_family, SOCK_DGRAM, IPPROTO_UDP)) < 0) goto no_socket; @@ -732,22 +753,18 @@ sizeof (src->myaddr))) < 0) goto bind_error; } else { - /* we use the configured socket */ + GST_DEBUG_OBJECT (src, "using provided socket %d", src->sockfd); + /* we use the configured socket, try to get some info about it */ + len = sizeof (src->myaddr); + if ((ret = + getsockname (src->sockfd, (struct sockaddr *) &src->myaddr, + &len)) < 0) + goto getsockname_error; src->sock.fd = src->sockfd; src->externalfd = TRUE; - if (gst_udp_is_multicast (&src->myaddr)) { - ret = gst_udp_join_group (src->sock.fd, &src->myaddr); - if (ret < 0) - goto membership; - } - len = sizeof (my_addr); - if ((ret = - getsockname (src->sock.fd, (struct sockaddr *) &my_addr, &len)) < 0) - goto getsockname_error; len = sizeof (rcvsize); if (src->buffer_size != 0) { rcvsize = src->buffer_size; @@ -759,8 +776,11 @@ ret = setsockopt (src->sock.fd, SOL_SOCKET, SO_RCVBUF, (void *) &rcvsize, len); - if (ret != 0) - goto udpbuffer_error; + if (ret != 0) { + GST_ELEMENT_WARNING (src, RESOURCE, SETTINGS, (NULL), + ("Could not create a buffer of requested %d bytes, %d: %s (%d)", + rcvsize, ret, g_strerror (errno), errno)); + } /* read the value of the receive buffer. Note that on linux this returns 2x the @@ -775,21 +795,29 @@ bc_val = 1; if ((ret = setsockopt (src->sock.fd, SOL_SOCKET, SO_BROADCAST, &bc_val, - sizeof (bc_val))) < 0) - goto no_broadcast; + sizeof (bc_val))) < 0) { + GST_ELEMENT_WARNING (src, RESOURCE, SETTINGS, (NULL), + ("could not configure socket for broadcast %d: %s (%d)", ret, + g_strerror (errno), errno)); + } + if (src->auto_multicast && gst_udp_is_multicast (&src->myaddr)) { + GST_DEBUG_OBJECT (src, "joining multicast group %s", src->multi_group); + ret = gst_udp_join_group (src->sock.fd, &src->myaddr); + if (ret < 0) + goto membership; /* NOTE: sockaddr_in.sin_port works for ipv4 and ipv6 because sin_port * follows ss_family on both */ - port = ntohs (((struct sockaddr_in *) &my_addr)->sin_port); + port = g_ntohs (((struct sockaddr_in *) &src->myaddr)->sin_port); GST_DEBUG_OBJECT (src, "bound, on port %d", port); if (port != src->port) { src->port = port; - GST_DEBUG_OBJECT (src, "notifying %d", port); + GST_DEBUG_OBJECT (src, "notifying port %d", port); g_object_notify (G_OBJECT (src), "port"); - ((struct sockaddr_in *) &src->myaddr)->sin_port = htons (src->port + 1); if ((src->fdset = gst_poll_new (TRUE)) == NULL) goto no_fdset; @@ -839,22 +867,6 @@ ("getsockname failed %d: %s (%d)", ret, g_strerror (errno), errno)); return FALSE; -udpbuffer_error: - { - CLOSE_IF_REQUESTED (src); - GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL), - ("Could not create a buffer of the size requested, %d: %s (%d)", ret, - g_strerror (errno), errno)); - return FALSE; -no_broadcast: - ("could not configure socket for broadcast %d: %s (%d)", ret, no_fdset: { CLOSE_IF_REQUESTED (src); @@ -901,6 +913,10 @@ GST_DEBUG ("stopping, closing sockets"); if (src->sock.fd >= 0) { + if (src->auto_multicast && gst_udp_is_multicast (&src->myaddr)) { + GST_DEBUG_OBJECT (src, "leaving multicast group %s", src->multi_group); + gst_udp_leave_group (src->sock.fd, &src->myaddr); Index: gstudpsrc.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- gstudpsrc.h 21 May 2008 09:56:02 -0000 1.24 +++ gstudpsrc.h 13 Jun 2008 11:54:05 -0000 1.25 @@ -44,6 +44,7 @@ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_UDPSRC)) #define GST_IS_UDPSRC_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_UDPSRC)) +#define GST_UDPSRC_CAST(obj) ((GstUDPSrc *)(obj)) typedef struct _GstUDPSrc GstUDPSrc; typedef struct _GstUDPSrcClass GstUDPSrcClass; @@ -62,6 +63,7 @@ gint skip_first_bytes; int sockfd; gboolean closefd; + gboolean auto_multicast; /* our sockets */ GstPollFD sock; |
From: <wt...@ke...> - 2008-08-20 11:51:41
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Wed Aug 20 2008 11:51:52 UTC Log message: Patch by: Peter Kjellerstedt <pkj at axis com> * gst/udp/gstdynudpsink.c: (gst_dynudpsink_init), (gst_dynudpsink_finalize), (gst_dynudpsink_set_property), (gst_dynudpsink_init_send), (gst_dynudpsink_close): * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init), (gst_multiudpsink_finalize), (gst_multiudpsink_set_property): * gst/udp/gstudpsrc.c: (gst_udpsrc_finalize), (gst_udpsrc_set_property): Avoid leaking internally allocated file descriptors when setting custom file descriptors. Fixes #543101. Modified files: . : ChangeLog gst/udp : gstdynudpsink.c gstmultiudpsink.c gstudpsrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3684&r2=1.3685 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstdynudpsink.c.diff?r1=1.13&r2=1.14 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.36&r2=1.37 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c.diff?r1=1.91&r2=1.92 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3684 retrieving revision 1.3685 diff -u -d -r1.3684 -r1.3685 --- ChangeLog 20 Aug 2008 11:48:44 -0000 1.3684 +++ ChangeLog 20 Aug 2008 11:51:36 -0000 1.3685 @@ -1,5 +1,19 @@ 2008-08-20 Wim Taymans <wim...@co...> + Patch by: Peter Kjellerstedt <pkj at axis com> + + * gst/udp/gstdynudpsink.c: (gst_dynudpsink_init), + (gst_dynudpsink_finalize), (gst_dynudpsink_set_property), + (gst_dynudpsink_init_send), (gst_dynudpsink_close): + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init), + (gst_multiudpsink_finalize), (gst_multiudpsink_set_property): + * gst/udp/gstudpsrc.c: (gst_udpsrc_finalize), + (gst_udpsrc_set_property): + Avoid leaking internally allocated file descriptors when setting + custom file descriptors. Fixes #543101. +2008-08-20 Wim Taymans <wim...@co...> * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_stream_configure_udp_sink): Don't try to configure RTCP back to the server when the server did not give us a valid port number. Index: gstdynudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstdynudpsink.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- gstdynudpsink.c 2 Nov 2007 21:16:07 -0000 1.13 +++ gstdynudpsink.c 20 Aug 2008 11:51:38 -0000 1.14 @@ -41,11 +41,6 @@ GST_DEBUG_CATEGORY_STATIC (dynudpsink_debug); #define GST_CAT_DEFAULT (dynudpsink_debug) -#define CLOSE_IF_REQUESTED(udpctx) \ - if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) \ - CLOSE_SOCKET(udpctx->sock); \ - udpctx->sock = -1; - static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, @@ -80,6 +75,16 @@ PROP_CLOSEFD }; +#define CLOSE_IF_REQUESTED(udpctx) \ +G_STMT_START { \ + if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) { \ + CLOSE_SOCKET(udpctx->sock); \ + if (udpctx->sock == udpctx->sockfd) \ + udpctx->sockfd = UDP_DEFAULT_SOCKFD; \ + } \ + udpctx->sock = -1; \ +} G_STMT_END static void gst_dynudpsink_base_init (gpointer g_class); static void gst_dynudpsink_class_init (GstDynUDPSink * klass); static void gst_dynudpsink_init (GstDynUDPSink * udpsink); @@ -179,12 +184,8 @@ static void gst_dynudpsink_init (GstDynUDPSink * sink) { - GstDynUDPSink *udpsink; WSA_STARTUP (sink); - udpsink = GST_DYNUDPSINK (sink); sink->sockfd = UDP_DEFAULT_SOCKFD; sink->closefd = UDP_DEFAULT_CLOSEFD; sink->externalfd = FALSE; @@ -195,6 +196,13 @@ gst_dynudpsink_finalize (GObject * object) + GstDynUDPSink *udpsink; + udpsink = GST_DYNUDPSINK (object); + if (udpsink->sockfd >= 0 && udpsink->closefd) + CLOSE_SOCKET (udpsink->sockfd); G_OBJECT_CLASS (parent_class)->finalize (object); WSA_CLEANUP (object); @@ -265,6 +273,9 @@ switch (prop_id) { case PROP_SOCKFD: + if (udpsink->sockfd >= 0 && udpsink->sockfd != udpsink->sock && + udpsink->closefd) + CLOSE_SOCKET (udpsink->sockfd); udpsink->sockfd = g_value_get_int (value); GST_DEBUG ("setting SOCKFD to %d", udpsink->sockfd); break; @@ -309,7 +320,7 @@ if (sink->sockfd == -1) { /* create sender socket if none available */ - if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1) + if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) < 0) goto no_socket; bc_val = 1; @@ -348,8 +359,7 @@ gst_dynudpsink_close (GstDynUDPSink * sink) - if (sink->sock != -1) - CLOSE_IF_REQUESTED (sink); + CLOSE_IF_REQUESTED (sink); } static GstStateChangeReturn Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- gstmultiudpsink.c 20 Jun 2008 16:24:11 -0000 1.36 +++ gstmultiudpsink.c 20 Aug 2008 11:51:38 -0000 1.37 @@ -105,9 +105,14 @@ #define CLOSE_IF_REQUESTED(udpctx) \ - if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) \ CLOSE_SOCKET(udpctx->sock); \ + udpctx->sockfd = DEFAULT_SOCKFD; \ + udpctx->sock = DEFAULT_SOCK; \ static void gst_multiudpsink_base_init (gpointer g_class); static void gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass); @@ -332,7 +337,7 @@ sink->client_lock = g_mutex_new (); - sink->sock = -1; + sink->sock = DEFAULT_SOCK; sink->sockfd = DEFAULT_SOCKFD; sink->closefd = DEFAULT_CLOSEFD; sink->externalfd = (sink->sockfd != -1); @@ -352,6 +357,9 @@ g_list_foreach (sink->clients, (GFunc) free_client, NULL); g_list_free (sink->clients); + if (sink->sockfd >= 0 && sink->closefd) + CLOSE_SOCKET (sink->sockfd); g_mutex_free (sink->client_lock); @@ -517,6 +525,9 @@ GST_DEBUG_OBJECT (udpsink, "setting SOCKFD to %d", udpsink->sockfd); Index: gstudpsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -r1.91 -r1.92 --- gstudpsrc.c 23 Jul 2008 22:01:20 -0000 1.91 +++ gstudpsrc.c 20 Aug 2008 11:51:38 -0000 1.92 @@ -141,13 +141,6 @@ GST_DEBUG_CATEGORY_STATIC (udpsrc_debug); #define GST_CAT_DEFAULT (udpsrc_debug) -#define CLOSE_IF_REQUESTED(udpctx) \ -G_STMT_START { \ - CLOSE_SOCKET(udpctx->sock.fd); \ - udpctx->sock.fd = -1; \ -} G_STMT_END static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, @@ -191,6 +184,16 @@ PROP_LAST + CLOSE_SOCKET(udpctx->sock.fd); \ + if (udpctx->sock.fd == udpctx->sockfd) \ + udpctx->sock.fd = UDP_DEFAULT_SOCK; \ static void gst_udpsrc_uri_handler_init (gpointer g_iface, gpointer iface_data); static GstCaps *gst_udpsrc_getcaps (GstBaseSrc * src); @@ -348,7 +351,10 @@ g_free (udpsrc->multi_group); g_free (udpsrc->uri); - WSA_CLEANUP (src); + if (udpsrc->sockfd >= 0 && udpsrc->closefd) + CLOSE_SOCKET (udpsrc->sockfd); + WSA_CLEANUP (object); @@ -671,6 +677,9 @@ } + if (udpsrc->sockfd >= 0 && udpsrc->sockfd != udpsrc->sock.fd && + udpsrc->closefd) + CLOSE_SOCKET (udpsrc->sockfd); udpsrc->sockfd = g_value_get_int (value); GST_DEBUG ("setting SOCKFD to %d", udpsrc->sockfd); |
From: <wt...@ke...> - 2008-09-23 17:31:48
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Tue Sep 23 2008 17:31:37 UTC Log message: * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_set_property): Fix setting the qos. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3737&r2=1.3738 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.37&r2=1.38 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3737 retrieving revision 1.3738 diff -u -d -r1.3737 -r1.3738 --- ChangeLog 17 Sep 2008 14:50:40 -0000 1.3737 +++ ChangeLog 23 Sep 2008 17:31:21 -0000 1.3738 @@ -1,3 +1,8 @@ +2008-09-23 Wim Taymans <wim...@co...> + + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_set_property): + Fix setting the qos. 2008-09-17 Edward Hervey <edw...@co...> * gst/qtdemux/qtdemux.c: (gst_qtdemux_loop_state_header), Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- gstmultiudpsink.c 20 Aug 2008 11:51:38 -0000 1.37 +++ gstmultiudpsink.c 23 Sep 2008 17:31:22 -0000 1.38 @@ -547,7 +547,7 @@ udpsink->loop = g_value_get_boolean (value); break; case PROP_QOS_DSCP: - udpsink->qos_dscp = g_value_get_uint (value); + udpsink->qos_dscp = g_value_get_int (value); gst_multiudpsink_setup_qos_dscp (udpsink); default: |
From: <wt...@ke...> - 2008-09-25 10:34:59
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Thu Sep 25 2008 10:34:53 UTC Log message: Patch by: Daniel Franke <df at dfranke dot us> * gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start): OS X's bind() implementation is picky about its addrlen parameter and fails with EINVAL if it is larger than expected for the socket's address family. Set the length to the expected length instead. Fixes #553191. Modified files: . : ChangeLog gst/udp : gstudpsrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3739&r2=1.3740 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c.diff?r1=1.92&r2=1.93 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3739 retrieving revision 1.3740 diff -u -d -r1.3739 -r1.3740 --- ChangeLog 23 Sep 2008 18:08:55 -0000 1.3739 +++ ChangeLog 25 Sep 2008 10:34:37 -0000 1.3740 @@ -1,3 +1,12 @@ +2008-09-25 Wim Taymans <wim...@co...> + + Patch by: Daniel Franke <df at dfranke dot us> + * gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start): + OS X's bind() implementation is picky about its addrlen parameter and + fails with EINVAL if it is larger than expected for the socket's address + family. Set the length to the expected length instead. Fixes #553191. 2008-09-23 Wim Taymans <wim...@co...> * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_open): Index: gstudpsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- gstudpsrc.c 20 Aug 2008 11:51:38 -0000 1.92 +++ gstudpsrc.c 25 Sep 2008 10:34:39 -0000 1.93 @@ -376,26 +376,18 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf) { GstUDPSrc *udpsrc; - GstNetBuffer *outbuf; struct sockaddr_storage tmpaddr; socklen_t len; guint8 *pktdata; gint pktsize; #ifdef G_OS_UNIX gint readsize; #elif defined G_OS_WIN32 gulong readsize; #endif GstClockTime timeout; gint ret; gboolean try_again; udpsrc = GST_UDPSRC_CAST (psrc); @@ -787,8 +779,9 @@ goto setsockopt_error; GST_DEBUG_OBJECT (src, "binding on port %d", src->port); - if ((ret = bind (src->sock.fd, (struct sockaddr *) &src->myaddr, - sizeof (src->myaddr))) < 0) + /* Mac OS is picky about the size */ + len = sizeof (struct sockaddr_in); + if ((ret = bind (src->sock.fd, (struct sockaddr *) &src->myaddr, len)) < 0) goto bind_error; len = sizeof (src->myaddr); |
From: <wt...@ke...> - 2008-09-25 12:06:24
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Thu Sep 25 2008 11:30:49 UTC Log message: * 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. Modified files: . : ChangeLog gst/udp : gstudpsrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3740&r2=1.3741 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c.diff?r1=1.93&r2=1.94 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3740 retrieving revision 1.3741 diff -u -d -r1.3740 -r1.3741 --- ChangeLog 25 Sep 2008 10:34:37 -0000 1.3740 +++ ChangeLog 25 Sep 2008 11:30:33 -0000 1.3741 @@ -1,5 +1,11 @@ 2008-09-25 Wim Taymans <wim...@co...> + * 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. + +2008-09-25 Wim Taymans <wim...@co...> Patch by: Daniel Franke <df at dfranke dot us> * gst/udp/gstudpsrc.c: (gst_udpsrc_create), (gst_udpsrc_start): Index: gstudpsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- gstudpsrc.c 25 Sep 2008 10:34:39 -0000 1.93 +++ gstudpsrc.c 25 Sep 2008 11:30:35 -0000 1.94 @@ -247,9 +247,7 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass) { GObjectClass *gobject_class; - GstBaseSrcClass *gstbasesrc_class; GstPushSrcClass *gstpushsrc_class; gobject_class = (GObjectClass *) klass; @@ -582,9 +580,7 @@ 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 @@ 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 @@ 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); + default: + /* don't know, Screw MacOS and use the full length */ + len = sizeof (src->myaddr); + } if ((ret = bind (src->sock.fd, (struct sockaddr *) &src->myaddr, len)) < 0) goto bind_error; |
From: <wt...@ke...> - 2008-11-28 15:11:15
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Fri Nov 28 2008 15:11:04 UTC Log message: Patch by: Peter Kjellerstedt <pkj at axis com> * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render): Make gst_multiudpsink_render() ignore errors from sendto() instead of breaking streaming. Emit a warning instead. Fixes #562572. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3840&r2=1.3841 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.40&r2=1.41 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3840 retrieving revision 1.3841 diff -u -d -r1.3840 -r1.3841 --- ChangeLog 27 Nov 2008 16:43:22 -0000 1.3840 +++ ChangeLog 28 Nov 2008 15:10:48 -0000 1.3841 @@ -1,3 +1,11 @@ +2008-11-28 Wim Taymans <wim...@co...> + + Patch by: Peter Kjellerstedt <pkj at axis com> + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render): + Make gst_multiudpsink_render() ignore errors from sendto() instead of + breaking streaming. Emit a warning instead. Fixes #562572. 2008-11-27 Sebastian Dröge <seb...@co...> Patch by: Ron McOuat <rmcouat at smartt dot com> Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- gstmultiudpsink.c 20 Nov 2008 22:56:57 -0000 1.40 +++ gstmultiudpsink.c 28 Nov 2008 15:10:50 -0000 1.41 @@ -371,7 +371,7 @@ gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer) { GstMultiUDPSink *sink; - gint ret, size, num = 0; + gint ret, size, num = 0, no_clients = 0; guint8 *data; GList *clients; gint len; @@ -392,26 +392,30 @@ GstUDPClient *client; client = (GstUDPClient *) clients->data; - num++; + no_clients++; GST_LOG_OBJECT (sink, "sending %d bytes to client %p", size, client); while (TRUE) { len = gst_udp_get_sockaddr_length (&client->theiraddr); + ret = sendto (*client->sock, #ifdef G_OS_WIN32 - ret = sendto (*client->sock, (char *) data, size, 0, + (char *) data, #else - ret = sendto (*client->sock, data, size, 0, + data, #endif - (struct sockaddr *) &client->theiraddr, len); + size, 0, (struct sockaddr *) &client->theiraddr, len); if (ret < 0) { - /* we get a non-posix EPERM on Linux when a firewall rule blocks this - * destination. We will simply ignore this. */ - if (errno == EPERM) - break; + /* some error, just warn, it's likely recoverable and we don't want to + * break streaming. We break so that we stop retrying for this client. */ if (errno != EINTR && errno != EAGAIN) { - goto send_error; + GST_WARNING_OBJECT (sink, "client %p gave error %d (%s)", errno, + g_strerror (errno)); + break; } } else { + num++; client->bytes_sent += ret; client->packets_sent++; sink->bytes_served += ret; @@ -421,20 +425,10 @@ } g_mutex_unlock (sink->client_lock); - GST_LOG_OBJECT (sink, "sent %d bytes to %d clients", size, num); + GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num, + no_clients); return GST_FLOW_OK; - - /* ERRORS */ -send_error: - { - /* if sendto returns an error, something is seriously wrong */ - g_mutex_unlock (sink->client_lock); - GST_DEBUG_OBJECT (sink, "got send error %d: %s", errno, g_strerror (errno)); - GST_ELEMENT_ERROR (sink, STREAM, FAILED, (NULL), - ("Got send error %d: %s", errno, g_strerror (errno))); - return GST_FLOW_ERROR; - } } static void |