From e2518fedbe8f6eb9cf1cf456381a5e350e2c4001 Mon Sep 17 00:00:00 2001 From: Jarkko Palviainen Date: Mon, 31 Aug 2009 12:13:07 +0200 Subject: udp: split out TTL and loop options Split setting the TTL and loop parameters in 2 methods as they are not related. Fix setting the TTL correctly for multicast streams. See #588245 --- gst/udp/gstmultiudpsink.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'gst/udp/gstmultiudpsink.c') diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c index a6afc9ae..6b5ca4d4 100644 --- a/gst/udp/gstmultiudpsink.c +++ b/gst/udp/gstmultiudpsink.c @@ -723,14 +723,26 @@ 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 appropriately */ + /* look for multicast clients and join multicast groups appropriately + set also ttl and multicast loopback delivery appropriately */ for (clients = sink->clients; clients; clients = g_list_next (clients)) { client = (GstUDPClient *) clients->data; - if (sink->auto_multicast && gst_udp_is_multicast (&client->theiraddr)) - gst_udp_join_group (*(client->sock), &client->theiraddr, NULL); + if (gst_udp_is_multicast (&client->theiraddr)) { + if (sink->auto_multicast) { + if (gst_udp_join_group (*(client->sock), &client->theiraddr, NULL) + != 0) + goto join_group_failed; + } + if (gst_udp_set_loop (sink->sock, sink->loop) != 0) + goto loop_failed; + if (gst_udp_set_ttl (sink->sock, sink->ttl, TRUE) != 0) + goto ttl_failed; + } else { + if (gst_udp_set_ttl (sink->sock, sink->ttl, FALSE) != 0) + goto ttl_failed; + } } return TRUE; @@ -749,6 +761,29 @@ no_broadcast: g_strerror (errno))); return FALSE; } +join_group_failed: + { + CLOSE_IF_REQUESTED (sink); + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL), + ("Could not join multicast group (%d): %s", errno, g_strerror (errno))); + return FALSE; + } +ttl_failed: + { + CLOSE_IF_REQUESTED (sink); + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL), + ("Could not set TTL socket option (%d): %s", errno, + g_strerror (errno))); + return FALSE; + } +loop_failed: + { + CLOSE_IF_REQUESTED (sink); + GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL), + ("Could not set loopback socket option (%d): %s", errno, + g_strerror (errno))); + return FALSE; + } } static void -- cgit