summaryrefslogtreecommitdiff
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2009-10-25 00:06:31 +0000
committerLuca Barbato <lu_zero@gentoo.org>2009-10-25 00:06:31 +0000
commitd243ba30b824513e75f5836c6dde789034152976 (patch)
tree2c5c1287fd2860a44fab4a681aaeb6e28111137f /libavformat/rtsp.c
parentc5898e862302090fee82c9eee230b6aa6e5d4e45 (diff)
Support 3xx redirection in rtsp
All the error codes 3xx got managed the same way. After setup/early play redirection will not be managed REDIRECT method is yet to be supported (if somebody knows a server implementing it please contact me) Originally committed as revision 20369 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index c366ff1faa..59e537a14f 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -704,6 +704,9 @@ void rtsp_parse_line(RTSPMessageHeader *reply, const char *buf)
} else if (av_stristart(p, "Notice:", &p) ||
av_stristart(p, "X-Notice:", &p)) {
reply->notice = strtol(p, NULL, 10);
+ } else if (av_stristart(p, "Location:", &p)) {
+ skip_spaces(&p);
+ av_strlcpy(reply->location, p , sizeof(reply->location));
}
}
@@ -1180,7 +1183,7 @@ static int rtsp_read_header(AVFormatContext *s,
unsigned char *content = NULL;
int lower_transport_mask = 0;
char real_challenge[64];
-
+ redirect:
/* extract hostname and port */
url_split(NULL, 0, auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->filename);
@@ -1338,6 +1341,13 @@ static int rtsp_read_header(AVFormatContext *s,
av_freep(&content);
url_close(rt->rtsp_hd);
av_freep(&rt->auth_b64);
+ if (reply->status_code >=300 && reply->status_code < 400) {
+ av_strlcpy(s->filename, reply->location, sizeof(s->filename));
+ av_log(s, AV_LOG_INFO, "Status %d: Redirecting to %s\n",
+ reply->status_code,
+ s->filename);
+ goto redirect;
+ }
return err;
}