summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2017-02-15 00:13:30 +0200
committerSebastian Dröge <sebastian@centricular.com>2017-02-19 12:55:36 +0200
commit61699900d423393e4e31445a5eb5e2bff998b9e8 (patch)
tree66ae579596ed5753b597b8d296d403951376655f /gst
parent856473b215520e42f4748e01f94ed97f17fa0482 (diff)
downloadgstreamer-plugins-good-61699900d423393e4e31445a5eb5e2bff998b9e8.tar.gz
udpsrc: Use IP_MULTICAST_ALL for filtering IPv4 packets if available
This goes around the inefficient control message based filtering and does all the filtering kernel-side. Unfortunately this is Linux-only and there is no IPv6 variant of it (yet).
Diffstat (limited to 'gst')
-rw-r--r--gst/udp/gstudpsrc.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c
index 36ff1d6dd..71d11ad82 100644
--- a/gst/udp/gstudpsrc.c
+++ b/gst/udp/gstudpsrc.c
@@ -855,10 +855,16 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
if (!gst_udpsrc_ensure_mem (udpsrc))
goto memory_alloc_error;
- /* optimization: use messages only in multicast mode */
+ /* optimization: use messages only in multicast mode and
+ * if we can't let the kernel do the filtering for us */
p_msgs =
(g_inet_address_get_is_multicast (g_inet_socket_address_get_address
(udpsrc->addr))) ? &msgs : NULL;
+#ifdef IP_MULTICAST_ALL
+ if (g_inet_address_get_family (g_inet_socket_address_get_address
+ (udpsrc->addr)) == G_SOCKET_FAMILY_IPV4)
+ p_msgs = NULL;
+#endif
/* Retrieve sender address unless we've been configured not to do so */
p_saddr = (udpsrc->retrieve_sender_address) ? &saddr : NULL;
@@ -1445,7 +1451,14 @@ gst_udpsrc_open (GstUDPSrc * src)
if (g_inet_address_get_family (g_inet_socket_address_get_address
(src->addr)) == G_SOCKET_FAMILY_IPV4) {
-#if defined(IP_PKTINFO)
+#if defined(IP_MULTICAST_ALL)
+ if (!g_socket_set_option (src->used_socket, IPPROTO_IP, IP_MULTICAST_ALL,
+ 0, &err)) {
+ GST_WARNING_OBJECT (src, "Failed to disable IP_MULTICAST_ALL: %s",
+ err->message);
+ g_clear_error (&err);
+ }
+#elif defined(IP_PKTINFO)
if (!g_socket_set_option (src->used_socket, IPPROTO_IP, IP_PKTINFO, TRUE,
&err)) {
GST_WARNING_OBJECT (src, "Failed to enable IP_PKTINFO: %s",