Commit 55ac105a authored by mstorsjo's avatar mstorsjo

RTSP: Propagate errors up from ff_rtsp_send_cmd*

Patch by Josh Allmann, joshua dot allmann at gmail


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@23497 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent e57c955d
...@@ -1001,7 +1001,7 @@ int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply, ...@@ -1001,7 +1001,7 @@ int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
return 0; return 0;
} }
void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, int ff_rtsp_send_cmd_with_content_async(AVFormatContext *s,
const char *method, const char *url, const char *method, const char *url,
const char *headers, const char *headers,
const unsigned char *send_content, const unsigned char *send_content,
...@@ -1036,23 +1036,25 @@ void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, ...@@ -1036,23 +1036,25 @@ void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s,
if (send_content_length > 0 && send_content) if (send_content_length > 0 && send_content)
url_write(rt->rtsp_hd_out, send_content, send_content_length); url_write(rt->rtsp_hd_out, send_content, send_content_length);
rt->last_cmd_time = av_gettime(); rt->last_cmd_time = av_gettime();
return 0;
} }
void ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method, int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
const char *url, const char *headers) const char *url, const char *headers)
{ {
ff_rtsp_send_cmd_with_content_async(s, method, url, headers, NULL, 0); return ff_rtsp_send_cmd_with_content_async(s, method, url, headers, NULL, 0);
} }
void ff_rtsp_send_cmd(AVFormatContext *s, const char *method, const char *url, int ff_rtsp_send_cmd(AVFormatContext *s, const char *method, const char *url,
const char *headers, RTSPMessageHeader *reply, const char *headers, RTSPMessageHeader *reply,
unsigned char **content_ptr) unsigned char **content_ptr)
{ {
ff_rtsp_send_cmd_with_content(s, method, url, headers, reply, return ff_rtsp_send_cmd_with_content(s, method, url, headers, reply,
content_ptr, NULL, 0); content_ptr, NULL, 0);
} }
void ff_rtsp_send_cmd_with_content(AVFormatContext *s, int ff_rtsp_send_cmd_with_content(AVFormatContext *s,
const char *method, const char *url, const char *method, const char *url,
const char *header, const char *header,
RTSPMessageHeader *reply, RTSPMessageHeader *reply,
...@@ -1062,17 +1064,22 @@ void ff_rtsp_send_cmd_with_content(AVFormatContext *s, ...@@ -1062,17 +1064,22 @@ void ff_rtsp_send_cmd_with_content(AVFormatContext *s,
{ {
RTSPState *rt = s->priv_data; RTSPState *rt = s->priv_data;
HTTPAuthType cur_auth_type; HTTPAuthType cur_auth_type;
int ret;
retry: retry:
cur_auth_type = rt->auth_state.auth_type; cur_auth_type = rt->auth_state.auth_type;
ff_rtsp_send_cmd_with_content_async(s, method, url, header, if ((ret = ff_rtsp_send_cmd_with_content_async(s, method, url, header,
send_content, send_content_length); send_content, send_content_length)))
return ret;
ff_rtsp_read_reply(s, reply, content_ptr, 0); if ((ret = ff_rtsp_read_reply(s, reply, content_ptr, 0) ) < 0)
return ret;
if (reply->status_code == 401 && cur_auth_type == HTTP_AUTH_NONE && if (reply->status_code == 401 && cur_auth_type == HTTP_AUTH_NONE &&
rt->auth_state.auth_type != HTTP_AUTH_NONE) rt->auth_state.auth_type != HTTP_AUTH_NONE)
goto retry; goto retry;
return 0;
} }
/** /**
......
...@@ -345,8 +345,10 @@ extern int rtsp_rtp_port_max; ...@@ -345,8 +345,10 @@ extern int rtsp_rtp_port_max;
* @param send_content if non-null, the data to send as request body content * @param send_content if non-null, the data to send as request body content
* @param send_content_length the length of the send_content data, or 0 if * @param send_content_length the length of the send_content data, or 0 if
* send_content is null * send_content is null
*
* @return zero if success, nonzero otherwise
*/ */
void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, int ff_rtsp_send_cmd_with_content_async(AVFormatContext *s,
const char *method, const char *url, const char *method, const char *url,
const char *headers, const char *headers,
const unsigned char *send_content, const unsigned char *send_content,
...@@ -356,7 +358,7 @@ void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, ...@@ -356,7 +358,7 @@ void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s,
* *
* @see rtsp_send_cmd_with_content_async * @see rtsp_send_cmd_with_content_async
*/ */
void ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method, int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
const char *url, const char *headers); const char *url, const char *headers);
/** /**
...@@ -372,8 +374,10 @@ void ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method, ...@@ -372,8 +374,10 @@ void ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
* @param send_content if non-null, the data to send as request body content * @param send_content if non-null, the data to send as request body content
* @param send_content_length the length of the send_content data, or 0 if * @param send_content_length the length of the send_content data, or 0 if
* send_content is null * send_content is null
*
* @return zero if success, nonzero otherwise
*/ */
void ff_rtsp_send_cmd_with_content(AVFormatContext *s, int ff_rtsp_send_cmd_with_content(AVFormatContext *s,
const char *method, const char *url, const char *method, const char *url,
const char *headers, const char *headers,
RTSPMessageHeader *reply, RTSPMessageHeader *reply,
...@@ -386,7 +390,7 @@ void ff_rtsp_send_cmd_with_content(AVFormatContext *s, ...@@ -386,7 +390,7 @@ void ff_rtsp_send_cmd_with_content(AVFormatContext *s,
* *
* @see rtsp_send_cmd_with_content * @see rtsp_send_cmd_with_content
*/ */
void ff_rtsp_send_cmd(AVFormatContext *s, const char *method, int ff_rtsp_send_cmd(AVFormatContext *s, const char *method,
const char *url, const char *headers, const char *url, const char *headers,
RTSPMessageHeader *reply, unsigned char **content_ptr); RTSPMessageHeader *reply, unsigned char **content_ptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment