Commit e206f74b authored by Wim Taymans's avatar Wim Taymans

gst/udp/: Joining a multicast group and setting the loop/ttl properties are...

gst/udp/: Joining a multicast group and setting the loop/ttl properties are totally unrelated tasks are must be separ...

Original commit message from CVS:
* 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.
parent 961eed53
2008-05-21 Wim Taymans <wim.taymans@collabora.co.uk>
* 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 <ensonic@users.sf.net>
* gst/avi/gstavimux.c:
......
common @ 5e771924
Subproject commit d0749502b0e891038593866f619a75305367b409
Subproject commit 5e771924d59d9ac912237ea466d0c60ad95df5ab
......@@ -621,14 +621,14 @@ gst_multiudpsink_init_send (GstMultiUDPSink * sink)
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_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host,
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");
......
......@@ -91,21 +91,16 @@ gst_udp_get_addr (const char *hostname, int port, struct sockaddr_storage *addr)
}
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 @@ gst_udp_join_group (int sockfd, gboolean loop, int ttl,
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;
if ((ret =
setsockopt (sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl,
sizeof (ttl))) < 0)
return ret;
break;
}
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;
if ((ret =
setsockopt (sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(const void *) &mreq4, sizeof (mreq4))) < 0)
return ret;
}
break;
break;
}
case AF_INET6:
{
struct ipv6_mreq mreq6;
......@@ -132,27 +163,16 @@ gst_udp_join_group (int sockfd, gboolean loop, int ttl,
sizeof (struct in6_addr));
mreq6.ipv6mr_interface = 0;
if ((ret =
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)
return ret;
if ((ret =
setsockopt (sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
(const void *) &mreq6, sizeof (mreq6))) < 0)
return ret;
}
break;
break;
}
default:
errno = EAFNOSUPPORT;
}
return ret;
}
......
......@@ -74,7 +74,9 @@ 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_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__*/
......
......@@ -738,7 +738,7 @@ gst_udpsrc_start (GstBaseSrc * bsrc)
}
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment