mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
multiudpsink: add multicast-iface property
udpsrc already has support for setting the multicast interface, which is useful for multi-homed machines. This patch adds the same code to the multiudpsink. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=685864
This commit is contained in:
parent
54f049c355
commit
11ed7c0373
2 changed files with 26 additions and 4 deletions
|
@ -85,6 +85,7 @@ enum
|
||||||
* group for sending, if this socket is also used for receiving, it should
|
* group for sending, if this socket is also used for receiving, it should
|
||||||
* be configured in the element that does the receive. */
|
* be configured in the element that does the receive. */
|
||||||
#define DEFAULT_AUTO_MULTICAST TRUE
|
#define DEFAULT_AUTO_MULTICAST TRUE
|
||||||
|
#define DEFAULT_MULTICAST_IFACE NULL
|
||||||
#define DEFAULT_TTL 64
|
#define DEFAULT_TTL 64
|
||||||
#define DEFAULT_TTL_MC 1
|
#define DEFAULT_TTL_MC 1
|
||||||
#define DEFAULT_LOOP TRUE
|
#define DEFAULT_LOOP TRUE
|
||||||
|
@ -103,6 +104,7 @@ enum
|
||||||
PROP_USED_SOCKET,
|
PROP_USED_SOCKET,
|
||||||
PROP_CLIENTS,
|
PROP_CLIENTS,
|
||||||
PROP_AUTO_MULTICAST,
|
PROP_AUTO_MULTICAST,
|
||||||
|
PROP_MULTICAST_IFACE,
|
||||||
PROP_TTL,
|
PROP_TTL,
|
||||||
PROP_TTL_MC,
|
PROP_TTL_MC,
|
||||||
PROP_LOOP,
|
PROP_LOOP,
|
||||||
|
@ -276,6 +278,10 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
|
||||||
"Automatically join/leave the multicast groups, FALSE means user"
|
"Automatically join/leave the multicast groups, FALSE means user"
|
||||||
" has to do it himself", DEFAULT_AUTO_MULTICAST,
|
" has to do it himself", DEFAULT_AUTO_MULTICAST,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
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",
|
||||||
|
DEFAULT_MULTICAST_IFACE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
g_object_class_install_property (gobject_class, PROP_TTL,
|
g_object_class_install_property (gobject_class, PROP_TTL,
|
||||||
g_param_spec_int ("ttl", "Unicast TTL",
|
g_param_spec_int ("ttl", "Unicast TTL",
|
||||||
"Used for setting the unicast TTL parameter",
|
"Used for setting the unicast TTL parameter",
|
||||||
|
@ -362,6 +368,7 @@ gst_multiudpsink_init (GstMultiUDPSink * sink)
|
||||||
sink->force_ipv4 = DEFAULT_FORCE_IPV4;
|
sink->force_ipv4 = DEFAULT_FORCE_IPV4;
|
||||||
sink->qos_dscp = DEFAULT_QOS_DSCP;
|
sink->qos_dscp = DEFAULT_QOS_DSCP;
|
||||||
sink->send_duplicates = DEFAULT_SEND_DUPLICATES;
|
sink->send_duplicates = DEFAULT_SEND_DUPLICATES;
|
||||||
|
sink->multi_iface = g_strdup (DEFAULT_MULTICAST_IFACE);
|
||||||
|
|
||||||
sink->cancellable = g_cancellable_new ();
|
sink->cancellable = g_cancellable_new ();
|
||||||
}
|
}
|
||||||
|
@ -453,6 +460,9 @@ gst_multiudpsink_finalize (GObject * object)
|
||||||
g_object_unref (sink->cancellable);
|
g_object_unref (sink->cancellable);
|
||||||
sink->cancellable = NULL;
|
sink->cancellable = NULL;
|
||||||
|
|
||||||
|
g_free (sink->multi_iface);
|
||||||
|
sink->multi_iface = NULL;
|
||||||
|
|
||||||
g_mutex_clear (&sink->client_lock);
|
g_mutex_clear (&sink->client_lock);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
@ -700,6 +710,14 @@ gst_multiudpsink_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_AUTO_MULTICAST:
|
case PROP_AUTO_MULTICAST:
|
||||||
udpsink->auto_multicast = g_value_get_boolean (value);
|
udpsink->auto_multicast = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MULTICAST_IFACE:
|
||||||
|
g_free (udpsink->multi_iface);
|
||||||
|
|
||||||
|
if (g_value_get_string (value) == NULL)
|
||||||
|
udpsink->multi_iface = g_strdup (DEFAULT_MULTICAST_IFACE);
|
||||||
|
else
|
||||||
|
udpsink->multi_iface = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
case PROP_TTL:
|
case PROP_TTL:
|
||||||
udpsink->ttl = g_value_get_int (value);
|
udpsink->ttl = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
@ -759,6 +777,9 @@ gst_multiudpsink_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
case PROP_AUTO_MULTICAST:
|
case PROP_AUTO_MULTICAST:
|
||||||
g_value_set_boolean (value, udpsink->auto_multicast);
|
g_value_set_boolean (value, udpsink->auto_multicast);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MULTICAST_IFACE:
|
||||||
|
g_value_set_string (value, udpsink->multi_iface);
|
||||||
|
break;
|
||||||
case PROP_TTL:
|
case PROP_TTL:
|
||||||
g_value_set_int (value, udpsink->ttl);
|
g_value_set_int (value, udpsink->ttl);
|
||||||
break;
|
break;
|
||||||
|
@ -800,8 +821,8 @@ gst_multiudpsink_configure_client (GstMultiUDPSink * sink,
|
||||||
GST_DEBUG_OBJECT (sink, "we have a multicast client %p", client);
|
GST_DEBUG_OBJECT (sink, "we have a multicast client %p", client);
|
||||||
if (sink->auto_multicast) {
|
if (sink->auto_multicast) {
|
||||||
GST_DEBUG_OBJECT (sink, "autojoining group");
|
GST_DEBUG_OBJECT (sink, "autojoining group");
|
||||||
if (!g_socket_join_multicast_group (sink->used_socket, addr, FALSE, NULL,
|
if (!g_socket_join_multicast_group (sink->used_socket, addr, FALSE,
|
||||||
&err))
|
sink->multi_iface, &err))
|
||||||
goto join_group_failed;
|
goto join_group_failed;
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (sink, "setting loop to %d", sink->loop);
|
GST_DEBUG_OBJECT (sink, "setting loop to %d", sink->loop);
|
||||||
|
@ -1046,8 +1067,8 @@ gst_multiudpsink_remove (GstMultiUDPSink * sink, const gchar * host, gint port)
|
||||||
&& g_inet_address_get_is_multicast (addr)) {
|
&& g_inet_address_get_is_multicast (addr)) {
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
if (!g_socket_leave_multicast_group (sink->used_socket, addr, FALSE, NULL,
|
if (!g_socket_leave_multicast_group (sink->used_socket, addr, FALSE,
|
||||||
&err)) {
|
sink->multi_iface, &err)) {
|
||||||
GST_DEBUG_OBJECT (sink, "Failed to leave multicast group: %s",
|
GST_DEBUG_OBJECT (sink, "Failed to leave multicast group: %s",
|
||||||
err->message);
|
err->message);
|
||||||
g_clear_error (&err);
|
g_clear_error (&err);
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct _GstMultiUDPSink {
|
||||||
gboolean external_socket;
|
gboolean external_socket;
|
||||||
|
|
||||||
gboolean auto_multicast;
|
gboolean auto_multicast;
|
||||||
|
gchar *multi_iface;
|
||||||
gint ttl;
|
gint ttl;
|
||||||
gint ttl_mc;
|
gint ttl_mc;
|
||||||
gboolean loop;
|
gboolean loop;
|
||||||
|
|
Loading…
Reference in a new issue