rtsp: Retry authentication if failed due to being stale
authorMartin Storsjö <martin@martin.st>
Mon, 12 Mar 2012 11:59:53 +0000 (13:59 +0200)
committerMartin Storsjö <martin@martin.st>
Tue, 13 Mar 2012 08:36:18 +0000 (10:36 +0200)
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtsp.c

index 4290abbdc1af62408ad5e5789dad77cfe5e93a1e..ecc1cbafef6227ef33606f8e048065c62b0025fc 100644 (file)
@@ -1122,7 +1122,7 @@ int ff_rtsp_send_cmd_with_content(AVFormatContext *s,
 {
     RTSPState *rt = s->priv_data;
     HTTPAuthType cur_auth_type;
-    int ret;
+    int ret, attempts = 0;
 
 retry:
     cur_auth_type = rt->auth_state.auth_type;
@@ -1133,9 +1133,11 @@ retry:
 
     if ((ret = ff_rtsp_read_reply(s, reply, content_ptr, 0, method) ) < 0)
         return ret;
+    attempts++;
 
-    if (reply->status_code == 401 && cur_auth_type == HTTP_AUTH_NONE &&
-        rt->auth_state.auth_type != HTTP_AUTH_NONE)
+    if (reply->status_code == 401 &&
+        (cur_auth_type == HTTP_AUTH_NONE || rt->auth_state.stale) &&
+        rt->auth_state.auth_type != HTTP_AUTH_NONE && attempts < 2)
         goto retry;
 
     if (reply->status_code > 400){