# HG changeset patch # User lu_zero # Date 1256429191 0 # Node ID 715913c5514fdfe28f0d50ab683ca039bd89b489 # Parent ff45ef768724204c1841e70fde00bf6b178a7c18 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) diff -r ff45ef768724 -r 715913c5514f rtsp.c --- a/rtsp.c Sat Oct 24 20:40:00 2009 +0000 +++ b/rtsp.c Sun Oct 25 00:06:31 2009 +0000 @@ -704,6 +704,9 @@ } 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 @@ 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 @@ 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; } diff -r ff45ef768724 -r 715913c5514f rtsp.h --- a/rtsp.h Sat Oct 24 20:40:00 2009 +0000 +++ b/rtsp.h Sun Oct 25 00:06:31 2009 +0000 @@ -121,6 +121,10 @@ * should be re-transmitted by the client in every RTSP command. */ char session_id[512]; + /** the "Location:" field. This value is used to handle redirection. + */ + char location[4096]; + /** the "RealChallenge1:" field from the server */ char real_challenge[64];