multiudpsink: allow binding to IPv6 address

When the sink is configured to create sockets with an explicit bind
address, then the created socket gets set to the udp_socket field
irregardless of whether the bind address indicated that the socket
family should be IPv4 or IPv6.  When binding to an IPv6 address, this
results in the following error:

gstmultiudpsink.c:1285:gst_multiudpsink_configure_client:<rtcpsink>
error: Invalid address family (got 10)

This patch adds a check of the address family being bound to and sets
the created socket to used_socket or used_socket_v6, accordingly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1551>
This commit is contained in:
Jonas Bonn 2022-01-21 14:21:18 +01:00 committed by GStreamer Marge Bot
parent 5eadde319c
commit 2f6ad787b2

View file

@ -1299,14 +1299,26 @@ gst_multiudpsink_start (GstBaseSink * bsink)
g_object_unref (bind_iaddr);
family = g_socket_address_get_family (G_SOCKET_ADDRESS (bind_addr));
if ((sink->used_socket =
g_socket_new (family, G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_UDP, &err)) == NULL) {
g_object_unref (bind_addr);
goto no_socket;
if (family == G_SOCKET_FAMILY_IPV4) {
if ((sink->used_socket =
g_socket_new (family, G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_UDP, &err)) == NULL) {
g_object_unref (bind_addr);
goto no_socket;
}
g_socket_bind (sink->used_socket, bind_addr, TRUE, &err);
} else {
if ((sink->used_socket_v6 =
g_socket_new (family, G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_UDP, &err)) == NULL) {
g_object_unref (bind_addr);
goto no_socket;
}
g_socket_bind (sink->used_socket_v6, bind_addr, TRUE, &err);
}
g_socket_bind (sink->used_socket, bind_addr, TRUE, &err);
g_object_unref (bind_addr);
if (err != NULL)
goto bind_error;