comparison rtsp.c @ 6095:c5337969b43b libavformat

RTSP: Propagate errors up from ff_rtsp_send_cmd* Patch by Josh Allmann, joshua dot allmann at gmail
author mstorsjo
date Sat, 05 Jun 2010 19:45:46 +0000
parents e6d6b3826eb2
children 7c2221a89902
comparison
equal deleted inserted replaced
6094:e6d6b3826eb2 6095:c5337969b43b
999 return AVERROR(EPERM); 999 return AVERROR(EPERM);
1000 1000
1001 return 0; 1001 return 0;
1002 } 1002 }
1003 1003
1004 void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, 1004 int ff_rtsp_send_cmd_with_content_async(AVFormatContext *s,
1005 const char *method, const char *url, 1005 const char *method, const char *url,
1006 const char *headers, 1006 const char *headers,
1007 const unsigned char *send_content, 1007 const unsigned char *send_content,
1008 int send_content_length) 1008 int send_content_length)
1009 { 1009 {
1034 1034
1035 url_write(rt->rtsp_hd_out, buf, strlen(buf)); 1035 url_write(rt->rtsp_hd_out, buf, strlen(buf));
1036 if (send_content_length > 0 && send_content) 1036 if (send_content_length > 0 && send_content)
1037 url_write(rt->rtsp_hd_out, send_content, send_content_length); 1037 url_write(rt->rtsp_hd_out, send_content, send_content_length);
1038 rt->last_cmd_time = av_gettime(); 1038 rt->last_cmd_time = av_gettime();
1039 } 1039
1040 1040 return 0;
1041 void ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method, 1041 }
1042
1043 int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
1042 const char *url, const char *headers) 1044 const char *url, const char *headers)
1043 { 1045 {
1044 ff_rtsp_send_cmd_with_content_async(s, method, url, headers, NULL, 0); 1046 return ff_rtsp_send_cmd_with_content_async(s, method, url, headers, NULL, 0);
1045 } 1047 }
1046 1048
1047 void ff_rtsp_send_cmd(AVFormatContext *s, const char *method, const char *url, 1049 int ff_rtsp_send_cmd(AVFormatContext *s, const char *method, const char *url,
1048 const char *headers, RTSPMessageHeader *reply, 1050 const char *headers, RTSPMessageHeader *reply,
1049 unsigned char **content_ptr) 1051 unsigned char **content_ptr)
1050 { 1052 {
1051 ff_rtsp_send_cmd_with_content(s, method, url, headers, reply, 1053 return ff_rtsp_send_cmd_with_content(s, method, url, headers, reply,
1052 content_ptr, NULL, 0); 1054 content_ptr, NULL, 0);
1053 } 1055 }
1054 1056
1055 void ff_rtsp_send_cmd_with_content(AVFormatContext *s, 1057 int ff_rtsp_send_cmd_with_content(AVFormatContext *s,
1056 const char *method, const char *url, 1058 const char *method, const char *url,
1057 const char *header, 1059 const char *header,
1058 RTSPMessageHeader *reply, 1060 RTSPMessageHeader *reply,
1059 unsigned char **content_ptr, 1061 unsigned char **content_ptr,
1060 const unsigned char *send_content, 1062 const unsigned char *send_content,
1061 int send_content_length) 1063 int send_content_length)
1062 { 1064 {
1063 RTSPState *rt = s->priv_data; 1065 RTSPState *rt = s->priv_data;
1064 HTTPAuthType cur_auth_type; 1066 HTTPAuthType cur_auth_type;
1067 int ret;
1065 1068
1066 retry: 1069 retry:
1067 cur_auth_type = rt->auth_state.auth_type; 1070 cur_auth_type = rt->auth_state.auth_type;
1068 ff_rtsp_send_cmd_with_content_async(s, method, url, header, 1071 if ((ret = ff_rtsp_send_cmd_with_content_async(s, method, url, header,
1069 send_content, send_content_length); 1072 send_content, send_content_length)))
1070 1073 return ret;
1071 ff_rtsp_read_reply(s, reply, content_ptr, 0); 1074
1075 if ((ret = ff_rtsp_read_reply(s, reply, content_ptr, 0) ) < 0)
1076 return ret;
1072 1077
1073 if (reply->status_code == 401 && cur_auth_type == HTTP_AUTH_NONE && 1078 if (reply->status_code == 401 && cur_auth_type == HTTP_AUTH_NONE &&
1074 rt->auth_state.auth_type != HTTP_AUTH_NONE) 1079 rt->auth_state.auth_type != HTTP_AUTH_NONE)
1075 goto retry; 1080 goto retry;
1081
1082 return 0;
1076 } 1083 }
1077 1084
1078 /** 1085 /**
1079 * @return 0 on success, <0 on error, 1 if protocol is unavailable. 1086 * @return 0 on success, <0 on error, 1 if protocol is unavailable.
1080 */ 1087 */