mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
rtspsrc: Fix usage of IPv6 connections in SETUP
If the SETUP request returns an IPv6 server address in the Transport field, we would generate an incorrect URI, and multiudpsink would fail to initialize: ``` rtspsrc gstrtspsrc.c:9780:dump_key_value:<source> key: 'Transport', value: 'RTP/AVP;unicast;source=fe80::dc27:25ff:fe5e:bd13:8080;client_port=62696-62697;server_port=4000-4001' ... rtspsrc gstrtspsrc.c:4595:gst_rtspsrc_stream_configure_udp_sinks:<source> configure RTP UDP sink for fe80::dc27:25ff:fe5e:bd13:8080:4000 ... multiudpsink gstmultiudpsink.c:1229:gst_multiudpsink_configure_client:<udpsink0> error: Invalid address family (got 23) ``` We can't look at stream->is_ipv6 because we can't rely on the server returning the right value there. In the issue reported about this, server reported itself as `KuP RTSP Server/0.1`, and the SDP was: ``` c=IN IP4 m=video 54608 RTP/AVP 96 a=rtpmap:96 H264/90000 ``` So we need to parse the string value and figure out the family ourselves. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1058 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1819>
This commit is contained in:
parent
f8d56e5df6
commit
0aa9d8ade6
1 changed files with 39 additions and 16 deletions
|
@ -4383,12 +4383,43 @@ gst_rtspsrc_get_transport_info (GstRTSPSrc * src, GstRTSPStream * stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstElement *
|
||||||
|
element_make_from_addr (const GstURIType type, const char *addr_s,
|
||||||
|
int port, const char *name, GError ** error)
|
||||||
|
{
|
||||||
|
GInetAddress *addr;
|
||||||
|
GstElement *element = NULL;
|
||||||
|
char *uri = NULL;
|
||||||
|
|
||||||
|
addr = g_inet_address_new_from_string (addr_s);
|
||||||
|
|
||||||
|
switch (g_inet_address_get_family (addr)) {
|
||||||
|
case G_SOCKET_FAMILY_IPV6:
|
||||||
|
uri = g_strdup_printf ("udp://[%s]:%i", addr_s, port);
|
||||||
|
break;
|
||||||
|
case G_SOCKET_FAMILY_INVALID:
|
||||||
|
GST_ERROR ("Unknown family type for %s", addr_s);
|
||||||
|
goto out;
|
||||||
|
case G_SOCKET_FAMILY_UNIX:
|
||||||
|
GST_ERROR ("Unexpected family type UNIX for %s", addr_s);
|
||||||
|
goto out;
|
||||||
|
case G_SOCKET_FAMILY_IPV4:
|
||||||
|
uri = g_strdup_printf ("udp://%s:%i", addr_s, port);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
element = gst_element_make_from_uri (type, uri, name, error);
|
||||||
|
out:
|
||||||
|
g_object_unref (addr);
|
||||||
|
g_free (uri);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
/* For multicast create UDP sources and join the multicast group. */
|
/* For multicast create UDP sources and join the multicast group. */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
|
gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
|
||||||
GstRTSPTransport * transport, GstPad ** outpad)
|
GstRTSPTransport * transport, GstPad ** outpad)
|
||||||
{
|
{
|
||||||
gchar *uri;
|
|
||||||
const gchar *destination;
|
const gchar *destination;
|
||||||
gint min, max;
|
gint min, max;
|
||||||
|
|
||||||
|
@ -4413,10 +4444,8 @@ gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
|
||||||
|
|
||||||
/* creating UDP source for RTP */
|
/* creating UDP source for RTP */
|
||||||
if (min != -1) {
|
if (min != -1) {
|
||||||
uri = g_strdup_printf ("udp://%s:%d", destination, min);
|
|
||||||
stream->udpsrc[0] =
|
stream->udpsrc[0] =
|
||||||
gst_element_make_from_uri (GST_URI_SRC, uri, NULL, NULL);
|
element_make_from_addr (GST_URI_SRC, destination, min, NULL, NULL);
|
||||||
g_free (uri);
|
|
||||||
if (stream->udpsrc[0] == NULL)
|
if (stream->udpsrc[0] == NULL)
|
||||||
goto no_element;
|
goto no_element;
|
||||||
|
|
||||||
|
@ -4440,10 +4469,8 @@ gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
|
||||||
if (max != -1) {
|
if (max != -1) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
uri = g_strdup_printf ("udp://%s:%d", destination, max);
|
|
||||||
stream->udpsrc[1] =
|
stream->udpsrc[1] =
|
||||||
gst_element_make_from_uri (GST_URI_SRC, uri, NULL, NULL);
|
element_make_from_addr (GST_URI_SRC, destination, max, NULL, NULL);
|
||||||
g_free (uri);
|
|
||||||
if (stream->udpsrc[1] == NULL)
|
if (stream->udpsrc[1] == NULL)
|
||||||
goto no_element;
|
goto no_element;
|
||||||
|
|
||||||
|
@ -4583,7 +4610,7 @@ gst_rtspsrc_stream_configure_udp_sinks (GstRTSPSrc * src,
|
||||||
gint rtp_port, rtcp_port;
|
gint rtp_port, rtcp_port;
|
||||||
gboolean do_rtp, do_rtcp;
|
gboolean do_rtp, do_rtcp;
|
||||||
const gchar *destination;
|
const gchar *destination;
|
||||||
gchar *uri, *name;
|
gchar *name;
|
||||||
guint ttl = 0;
|
guint ttl = 0;
|
||||||
GSocket *socket;
|
GSocket *socket;
|
||||||
|
|
||||||
|
@ -4607,10 +4634,8 @@ gst_rtspsrc_stream_configure_udp_sinks (GstRTSPSrc * src,
|
||||||
GST_DEBUG_OBJECT (src, "configure RTP UDP sink for %s:%d", destination,
|
GST_DEBUG_OBJECT (src, "configure RTP UDP sink for %s:%d", destination,
|
||||||
rtp_port);
|
rtp_port);
|
||||||
|
|
||||||
uri = g_strdup_printf ("udp://%s:%d", destination, rtp_port);
|
stream->udpsink[0] = element_make_from_addr (GST_URI_SINK, destination,
|
||||||
stream->udpsink[0] =
|
rtp_port, NULL, NULL);
|
||||||
gst_element_make_from_uri (GST_URI_SINK, uri, NULL, NULL);
|
|
||||||
g_free (uri);
|
|
||||||
if (stream->udpsink[0] == NULL)
|
if (stream->udpsink[0] == NULL)
|
||||||
goto no_sink_element;
|
goto no_sink_element;
|
||||||
|
|
||||||
|
@ -4672,10 +4697,8 @@ gst_rtspsrc_stream_configure_udp_sinks (GstRTSPSrc * src,
|
||||||
GST_DEBUG_OBJECT (src, "configure RTCP UDP sink for %s:%d", destination,
|
GST_DEBUG_OBJECT (src, "configure RTCP UDP sink for %s:%d", destination,
|
||||||
rtcp_port);
|
rtcp_port);
|
||||||
|
|
||||||
uri = g_strdup_printf ("udp://%s:%d", destination, rtcp_port);
|
stream->udpsink[1] = element_make_from_addr (GST_URI_SINK, destination,
|
||||||
stream->udpsink[1] =
|
rtcp_port, NULL, NULL);
|
||||||
gst_element_make_from_uri (GST_URI_SINK, uri, NULL, NULL);
|
|
||||||
g_free (uri);
|
|
||||||
if (stream->udpsink[1] == NULL)
|
if (stream->udpsink[1] == NULL)
|
||||||
goto no_sink_element;
|
goto no_sink_element;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue