summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorPeter Kjellerstedt <pkj@axis.com>2007-05-12 16:27:51 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-05-12 16:27:51 +0000
commit02a64fe5add29cb6733a7be4e7519a1acf557347 (patch)
tree8ea4abfe4360b6d8268acb59aa9f354e7a492c81 /gst
parent5f9984e8666595f5de228ebe238ed06a5265870a (diff)
gst/rtsp/rtspurl.*: Add support for query parameters to RTSP URLs.
Original commit message from CVS: Patch by: Peter Kjellerstedt <pkj at axis com> * gst/rtsp/rtspurl.c: (rtsp_url_parse), (rtsp_url_free), (rtsp_url_get_request_uri): * gst/rtsp/rtspurl.h: Add support for query parameters to RTSP URLs.
Diffstat (limited to 'gst')
-rw-r--r--gst/rtsp/rtspurl.c57
-rw-r--r--gst/rtsp/rtspurl.h1
2 files changed, 37 insertions, 21 deletions
diff --git a/gst/rtsp/rtspurl.c b/gst/rtsp/rtspurl.c
index cc2047c3..a1955e08 100644
--- a/gst/rtsp/rtspurl.c
+++ b/gst/rtsp/rtspurl.c
@@ -52,13 +52,13 @@
#define RTSPT_PROTO "rtspt://"
#define RTSPT_PROTO_LEN 8
-/* format is rtsp[u]://[user:passwd@]host[:port]/abspath */
+/* format is rtsp[u]://[user:passwd@]host[:port]/abspath[?query] */
RTSPResult
rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
{
RTSPUrl *res;
- gchar *p, *slash, *at, *col;
+ gchar *p, *delim, *at, *col;
g_return_val_if_fail (urlstr != NULL, RTSP_EINVAL);
g_return_val_if_fail (url != NULL, RTSP_EINVAL);
@@ -80,14 +80,14 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
} else
goto invalid;
- slash = strstr (p, "/");
- at = strstr (p, "@");
+ delim = strpbrk (p, "/?");
+ at = strchr (p, '@');
- if (at && slash && at > slash)
+ if (at && delim && at > delim)
at = NULL;
if (at) {
- col = strstr (p, ":");
+ col = strchr (p, ':');
/* must have a ':' and it must be before the '@' */
if (col == NULL || col > at)
@@ -101,32 +101,45 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
p = at + 1;
}
- col = strstr (p, ":");
- /* we have a ':' and a slash but the ':' is after the slash, it's not really
- * part of the hostname */
- if (col && slash && col >= slash)
+ col = strchr (p, ':');
+ /* we have a ':' and a delimiter but the ':' is after the delimiter, it's
+ * not really part of the hostname */
+ if (col && delim && col >= delim)
col = NULL;
if (col) {
res->host = g_strndup (p, col - p);
p = col + 1;
res->port = strtoul (p, (char **) &p, 10);
- if (slash)
- p = slash + 1;
+ if (delim)
+ p = delim;
} else {
/* no port specified, set to 0. _get_port() will return the default port. */
res->port = 0;
- if (!slash) {
+ if (!delim) {
res->host = g_strdup (p);
p = NULL;
} else {
- res->host = g_strndup (p, slash - p);
- p = slash + 1;
+ res->host = g_strndup (p, delim - p);
+ p = delim;
}
}
- /* FIXME, this strips the slash from the absolute path */
- if (p)
- res->abspath = g_strdup (p);
+
+ if (p && *p == '/') {
+ delim = strchr (p, '?');
+ if (!delim) {
+ res->abspath = g_strdup (p);
+ p = NULL;
+ } else {
+ res->abspath = g_strndup (p, delim - p);
+ p = delim;
+ }
+ } else {
+ res->abspath = g_strdup ("/");
+ }
+
+ if (p && *p == '?')
+ res->query = g_strdup (p + 1);
*url = res;
@@ -150,6 +163,7 @@ rtsp_url_free (RTSPUrl * url)
g_free (url->passwd);
g_free (url->host);
g_free (url->abspath);
+ g_free (url->query);
g_free (url);
}
@@ -186,10 +200,11 @@ rtsp_url_get_request_uri (RTSPUrl * url)
g_return_val_if_fail (url != NULL, NULL);
if (url->port != 0) {
- uri = g_strdup_printf ("rtsp://%s:%u/%s", url->host, url->port,
- url->abspath);
+ uri = g_strdup_printf ("rtsp://%s:%u/%s%s%s", url->host, url->port,
+ url->abspath, url->query ? "?" : "", url->query ? url->query : "");
} else {
- uri = g_strdup_printf ("rtsp://%s/%s", url->host, url->abspath);
+ uri = g_strdup_printf ("rtsp://%s/%s%s%s", url->host, url->abspath,
+ url->query ? "?" : "", url->query ? url->query : "");
}
return uri;
diff --git a/gst/rtsp/rtspurl.h b/gst/rtsp/rtspurl.h
index ce144f46..c58bdca9 100644
--- a/gst/rtsp/rtspurl.h
+++ b/gst/rtsp/rtspurl.h
@@ -60,6 +60,7 @@ typedef struct _RTSPUrl {
gchar *host;
guint16 port;
gchar *abspath;
+ gchar *query;
} RTSPUrl;
RTSPResult rtsp_url_parse (const gchar *urlstr, RTSPUrl **url);