Commit 49be64e5 authored by Sebastian Dröge's avatar Sebastian Dröge

udpsrc: Fix multicast group joining with provided sockets on Windows

On Windows the socket will be bound to ANY instead of the multicast group,
as binding to a multicast group does not work. Which would mean that we
override src->addr to become ANY and won't automatically join a multicast
group anymore on Windows.

On Linux we would automatically join a multicast group, keep it consistent.
parent b6e10be2
...@@ -968,18 +968,47 @@ gst_udpsrc_open (GstUDPSrc * src) ...@@ -968,18 +968,47 @@ gst_udpsrc_open (GstUDPSrc * src)
g_object_unref (bind_saddr); g_object_unref (bind_saddr);
g_socket_set_multicast_loopback (src->used_socket, src->loop); g_socket_set_multicast_loopback (src->used_socket, src->loop);
} else { } else {
GInetSocketAddress *local_addr;
GST_DEBUG_OBJECT (src, "using provided socket %p", src->socket); GST_DEBUG_OBJECT (src, "using provided socket %p", src->socket);
/* we use the configured socket, try to get some info about it */ /* we use the configured socket, try to get some info about it */
src->used_socket = G_SOCKET (g_object_ref (src->socket)); src->used_socket = G_SOCKET (g_object_ref (src->socket));
src->external_socket = TRUE; src->external_socket = TRUE;
if (src->addr) local_addr =
g_object_unref (src->addr);
src->addr =
G_INET_SOCKET_ADDRESS (g_socket_get_local_address (src->used_socket, G_INET_SOCKET_ADDRESS (g_socket_get_local_address (src->used_socket,
&err)); &err));
if (!src->addr) if (!local_addr)
goto getsockname_error; goto getsockname_error;
/* See above for the reasons. Without this we would behave different on
* Windows and Linux, joining multicast groups below for provided sockets
* on Linux but not on Windows
#ifdef G_OS_WIN32
addr = gst_udpsrc_resolve (src, src->address);
if (!addr)
goto name_resolve;
if (!src->auto_multicast ||
!g_inet_address_get_is_any (g_inet_socket_address_get_address
|| !g_inet_address_get_is_multicast (addr)) {
g_object_unref (addr);
if (src->addr)
g_object_unref (src->addr);
src->addr = local_addr;
#ifdef G_OS_WIN32
} else {
g_object_unref (local_addr);
if (src->addr)
g_object_unref (src->addr);
src->addr =
G_INET_SOCKET_ADDRESS (g_inet_socket_address_new (addr, src->port));
g_object_unref (addr);
} }
{ {
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