Commit c7e23476 authored by Wonchul Lee's avatar Wonchul Lee Committed by Sebastian Dröge
Browse files

updsrc: Add to join multiple multicast interfaces

https://bugzilla.gnome.org/show_bug.cgi?id=776030
parent 8ad0bacc
......@@ -522,7 +522,8 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
#endif
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",
"The network interface on which to join the multicast group."
"This allows multiple interfaces seperated by comma. (\"eth0,eth1\")",
UDP_DEFAULT_MULTICAST_IFACE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_URI,
......@@ -1430,11 +1431,30 @@ gst_udpsrc_open (GstUDPSrc * src)
&&
g_inet_address_get_is_multicast (g_inet_socket_address_get_address
(src->addr))) {
GST_DEBUG_OBJECT (src, "joining multicast group %s", src->address);
if (!g_socket_join_multicast_group (src->used_socket,
g_inet_socket_address_get_address (src->addr),
FALSE, src->multi_iface, &err))
goto membership;
if (src->multi_iface) {
GStrv multi_ifaces = g_strsplit (src->multi_iface, ",", -1);
gchar **ifaces = multi_ifaces;
while (*ifaces) {
g_strstrip (*ifaces);
GST_DEBUG_OBJECT (src, "joining multicast group %s interface %s",
src->address, *ifaces);
if (!g_socket_join_multicast_group (src->used_socket,
g_inet_socket_address_get_address (src->addr),
FALSE, *ifaces, &err)) {
g_strfreev (multi_ifaces);
goto membership;
}
ifaces++;
}
g_strfreev (multi_ifaces);
} else {
GST_DEBUG_OBJECT (src, "joining multicast group %s", src->address);
if (!g_socket_join_multicast_group (src->used_socket,
g_inet_socket_address_get_address (src->addr), FALSE, NULL, &err))
goto membership;
}
if (g_inet_address_get_family (g_inet_socket_address_get_address
(src->addr)) == G_SOCKET_FAMILY_IPV4) {
......@@ -1589,14 +1609,33 @@ gst_udpsrc_close (GstUDPSrc * src)
(src->addr))) {
GError *err = NULL;
GST_DEBUG_OBJECT (src, "leaving multicast group %s", src->address);
if (src->multi_iface) {
GStrv multi_ifaces = g_strsplit (src->multi_iface, ",", -1);
gchar **ifaces = multi_ifaces;
while (*ifaces) {
g_strstrip (*ifaces);
GST_DEBUG_OBJECT (src, "leaving multicast group %s interface %s",
src->address, *ifaces);
if (!g_socket_leave_multicast_group (src->used_socket,
g_inet_socket_address_get_address (src->addr),
FALSE, *ifaces, &err)) {
GST_ERROR_OBJECT (src, "Failed to leave multicast group: %s",
err->message);
g_clear_error (&err);
}
ifaces++;
}
g_strfreev (multi_ifaces);
if (!g_socket_leave_multicast_group (src->used_socket,
g_inet_socket_address_get_address (src->addr), FALSE,
src->multi_iface, &err)) {
GST_ERROR_OBJECT (src, "Failed to leave multicast group: %s",
err->message);
g_clear_error (&err);
} else {
GST_DEBUG_OBJECT (src, "leaving multicast group %s", src->address);
if (!g_socket_leave_multicast_group (src->used_socket,
g_inet_socket_address_get_address (src->addr), FALSE,
NULL, &err)) {
GST_ERROR_OBJECT (src, "Failed to leave multicast group: %s",
err->message);
g_clear_error (&err);
}
}
}
......
Markdown is supported
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