Commit 31861b09 authored by Marc Leeman's avatar Marc Leeman Committed by GStreamer Marge Bot
Browse files

rtpmanagerbad: allow setting multicast-iface

Allowing the UDP elements to bind on an interface is needed in more
complex networks where there are mutiple networks interfaces without
default gateway
parent c7393af0
Pipeline #80481 passed with stages
in 49 minutes and 23 seconds
......@@ -58,6 +58,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_rtp_sink_debug);
#define DEFAULT_PROP_ADDRESS "0.0.0.0"
#define DEFAULT_PROP_PORT 5004
#define DEFAULT_PROP_URI "rtp://"DEFAULT_PROP_ADDRESS":"G_STRINGIFY(DEFAULT_PROP_PORT)
#define DEFAULT_PROP_MULTICAST_IFACE NULL
enum
{
......@@ -68,6 +69,7 @@ enum
PROP_PORT,
PROP_TTL,
PROP_TTL_MC,
PROP_MULTICAST_IFACE,
PROP_LAST
};
......@@ -149,6 +151,14 @@ gst_rtp_sink_set_property (GObject * object, guint prop_id,
g_object_set (self->rtp_sink, "ttl-mc", self->ttl_mc, NULL);
g_object_set (self->rtcp_sink, "ttl-mc", self->ttl_mc, NULL);
break;
case PROP_MULTICAST_IFACE:
g_free (self->multi_iface);
if (g_value_get_string (value) == NULL)
self->multi_iface = g_strdup (DEFAULT_PROP_MULTICAST_IFACE);
else
self->multi_iface = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -182,6 +192,9 @@ gst_rtp_sink_get_property (GObject * object, guint prop_id,
case PROP_TTL_MC:
g_value_set_int (value, self->ttl_mc);
break;
case PROP_MULTICAST_IFACE:
g_value_set_string (value, self->multi_iface);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -196,6 +209,8 @@ gst_rtp_sink_finalize (GObject * gobject)
if (self->uri)
gst_uri_unref (self->uri);
g_free (self->multi_iface);
g_mutex_clear (&self->lock);
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
......@@ -330,6 +345,17 @@ gst_rtp_sink_class_init (GstRtpSinkClass * klass)
"Used for setting the multicast TTL parameter", 0, 255,
DEFAULT_PROP_TTL_MC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* GstRtpSink:multicast-iface:
*
* The networkinterface on which to join the multicast group
*/
g_object_class_install_property (gobject_class, PROP_MULTICAST_IFACE,
g_param_spec_string ("multicast-iface", "Multicast Interface",
"The network interface on which to join the multicast group."
"This allows multiple interfaces separated by comma. (\"eth0,eth1\")",
DEFAULT_PROP_MULTICAST_IFACE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_template));
......@@ -446,6 +472,11 @@ gst_rtp_sink_start (GstRtpSink * self)
if (g_inet_address_get_is_multicast (iaddr)) {
g_object_set (self->rtcp_src, "address", remote_addr, "port",
gst_uri_get_port (self->uri) + 1, NULL);
/* set multicast-iface on the udpsrc and udpsink elements */
g_object_set (self->rtcp_src, "multicast-iface", self->multi_iface, NULL);
g_object_set (self->rtcp_sink, "multicast-iface", self->multi_iface, NULL);
g_object_set (self->rtp_sink, "multicast-iface", self->multi_iface, NULL);
} else {
const gchar *any_addr;
......@@ -537,6 +568,7 @@ gst_rtp_sink_init (GstRtpSink * self)
self->uri = gst_uri_from_string (DEFAULT_PROP_URI);
self->ttl = DEFAULT_PROP_TTL;
self->ttl_mc = DEFAULT_PROP_TTL_MC;
self->multi_iface = g_strdup (DEFAULT_PROP_MULTICAST_IFACE);
g_mutex_init (&self->lock);
......
......@@ -49,6 +49,7 @@ struct _GstRtpSink
GstUri *uri;
gint ttl;
gint ttl_mc;
gchar *multi_iface;
/* Internal elements */
GstElement *rtpbin;
......
......@@ -62,6 +62,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_rtp_src_debug);
#define DEFAULT_PROP_ADDRESS "0.0.0.0"
#define DEFAULT_PROP_PORT 5004
#define DEFAULT_PROP_URI "rtp://"DEFAULT_PROP_ADDRESS":"G_STRINGIFY(DEFAULT_PROP_PORT)
#define DEFAULT_PROP_MULTICAST_IFACE NULL
enum
{
......@@ -74,6 +75,7 @@ enum
PROP_TTL_MC,
PROP_ENCODING_NAME,
PROP_LATENCY,
PROP_MULTICAST_IFACE,
PROP_LAST
};
......@@ -227,6 +229,14 @@ gst_rtp_src_set_property (GObject * object, guint prop_id,
case PROP_LATENCY:
g_object_set (self->rtpbin, "latency", g_value_get_uint (value), NULL);
break;
case PROP_MULTICAST_IFACE:
g_free (self->multi_iface);
if (g_value_get_string (value) == NULL)
self->multi_iface = g_strdup (DEFAULT_PROP_MULTICAST_IFACE);
else
self->multi_iface = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -266,6 +276,9 @@ gst_rtp_src_get_property (GObject * object, guint prop_id,
case PROP_LATENCY:
g_object_get_property (G_OBJECT (self->rtpbin), "latency", value);
break;
case PROP_MULTICAST_IFACE:
g_value_set_string (value, self->multi_iface);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -281,6 +294,8 @@ gst_rtp_src_finalize (GObject * gobject)
gst_uri_unref (self->uri);
g_free (self->encoding_name);
g_free (self->multi_iface);
g_mutex_clear (&self->lock);
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
......@@ -374,6 +389,17 @@ gst_rtp_src_class_init (GstRtpSrcClass * klass)
G_MAXUINT, DEFAULT_PROP_LATENCY,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* GstRtpSink:multicast-iface:
*
* The networkinterface on which to join the multicast group
*/
g_object_class_install_property (gobject_class, PROP_MULTICAST_IFACE,
g_param_spec_string ("multicast-iface", "Multicast Interface",
"The network interface on which to join the multicast group."
"This allows multiple interfaces separated by comma. (\"eth0,eth1\")",
DEFAULT_PROP_MULTICAST_IFACE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_template));
......@@ -547,6 +573,11 @@ gst_rtp_src_start (GstRtpSrc * self)
/* In multicast, send RTCP to the multicast group */
self->rtcp_send_addr =
g_inet_socket_address_new (addr, gst_uri_get_port (self->uri) + 1);
/* set multicast-iface on the udpsrc and udpsink elements */
g_object_set (self->rtcp_src, "multicast-iface", self->multi_iface, NULL);
g_object_set (self->rtcp_sink, "multicast-iface", self->multi_iface, NULL);
g_object_set (self->rtp_src, "multicast-iface", self->multi_iface, NULL);
} else {
/* In unicast, send RTCP to the detected sender address */
g_socket_set_ttl (socket, self->ttl);
......@@ -641,6 +672,7 @@ gst_rtp_src_init (GstRtpSrc * self)
self->rtp_src = NULL;
self->rtcp_src = NULL;
self->rtcp_sink = NULL;
self->multi_iface = g_strdup (DEFAULT_PROP_MULTICAST_IFACE);
self->uri = gst_uri_from_string (DEFAULT_PROP_URI);
self->ttl = DEFAULT_PROP_TTL;
......
......@@ -50,6 +50,7 @@ struct _GstRtpSrc
gint ttl;
gint ttl_mc;
gchar *encoding_name;
gchar *multi_iface;
/* Internal elements */
GstElement *rtpbin;
......
Supports Markdown
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