From 13723198a1ba2d927f5014fdf459d53a0800c462 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 16 Nov 2022 13:33:39 +0530 Subject: [PATCH] rtspsrc: Fix regression when using hostname in the location property When the address can't be parsed as an IP address, it should just be treated as a hostname and used as-is. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1576 Part-of: --- .../gst-plugins-good/gst/rtsp/gstrtspsrc.c | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c index 9ef30ebdfe..bcaf9b0511 100644 --- a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c +++ b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c @@ -4469,25 +4469,29 @@ element_make_from_addr (const GstURIType type, const char *addr_s, 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; + if (addr == NULL) { + /* Address is a hostname, not an IP address */ + uri = g_strdup_printf ("udp://%s:%i", addr_s, port); + } else { + 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_clear_object (&addr); g_free (uri); return element; }