summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-11-17 12:39:05 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-11-17 12:39:05 +0200
commitffd3b391c8907430dcbabaf0f1e28552b88fa836 (patch)
treeaab25246058ed17a48f65b98b0e9b6a894a7e04c
parentd842ff288a9d01214a046becbfd9cbff3a4acea0 (diff)
udpsrc: Add "loop" property for enabling/disabling multicast loopback
On POSIX, IP_MULTICAST_LOOP is a setting for the sender socket. On Windows it is a setting for the receiver socket. As such we will need it on udpsrc too to allow filtering out our own multicast packets.
-rw-r--r--gst/udp/gstudpsrc.c17
-rw-r--r--gst/udp/gstudpsrc.h1
2 files changed, 17 insertions, 1 deletions
diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c
index 8da3585db..34aa7e464 100644
--- a/gst/udp/gstudpsrc.c
+++ b/gst/udp/gstudpsrc.c
@@ -138,6 +138,7 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
#define UDP_DEFAULT_USED_SOCKET NULL
#define UDP_DEFAULT_AUTO_MULTICAST TRUE
#define UDP_DEFAULT_REUSE TRUE
+#define UDP_DEFAULT_LOOP TRUE
enum
{
@@ -156,7 +157,8 @@ enum
PROP_USED_SOCKET,
PROP_AUTO_MULTICAST,
PROP_REUSE,
- PROP_ADDRESS
+ PROP_ADDRESS,
+ PROP_LOOP
};
static void gst_udpsrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
@@ -266,6 +268,11 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
"Address to receive packets for. This is equivalent to the "
"multicast-group property for now", UDP_DEFAULT_MULTICAST_GROUP,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ 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", UDP_DEFAULT_LOOP,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_template));
@@ -305,6 +312,7 @@ gst_udpsrc_init (GstUDPSrc * udpsrc)
udpsrc->auto_multicast = UDP_DEFAULT_AUTO_MULTICAST;
udpsrc->used_socket = UDP_DEFAULT_USED_SOCKET;
udpsrc->reuse = UDP_DEFAULT_REUSE;
+ udpsrc->loop = UDP_DEFAULT_LOOP;
/* configure basesrc to be a live source */
gst_base_src_set_live (GST_BASE_SRC (udpsrc), TRUE);
@@ -791,6 +799,9 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
case PROP_REUSE:
udpsrc->reuse = g_value_get_boolean (value);
break;
+ case PROP_LOOP:
+ udpsrc->loop = g_value_get_boolean (value);
+ break;
default:
break;
}
@@ -845,6 +856,9 @@ gst_udpsrc_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_REUSE:
g_value_set_boolean (value, udpsrc->reuse);
break;
+ case PROP_LOOP:
+ g_value_set_boolean (value, udpsrc->loop);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -952,6 +966,7 @@ gst_udpsrc_open (GstUDPSrc * src)
goto bind_error;
g_object_unref (bind_saddr);
+ g_socket_set_multicast_loopback (src->used_socket, src->loop);
} else {
GST_DEBUG_OBJECT (src, "using provided socket %p", src->socket);
/* we use the configured socket, try to get some info about it */
diff --git a/gst/udp/gstudpsrc.h b/gst/udp/gstudpsrc.h
index 5d7e340db..a47648322 100644
--- a/gst/udp/gstudpsrc.h
+++ b/gst/udp/gstudpsrc.h
@@ -60,6 +60,7 @@ struct _GstUDPSrc {
gboolean close_socket;
gboolean auto_multicast;
gboolean reuse;
+ gboolean loop;
/* stats */
guint max_size;