Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Utkin <andrey.utkin@corp.bluecherry.net>2014-10-18 00:24:00 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-10-20 06:31:46 +0400
commit9d86ce783bf468e83c7d84240739baffd800d114 (patch)
tree2d384608bede225e725a246be537632ac38dc273 /libavformat/http.c
parentd4e62ebae7f47d7ad5479ec5f71f903f988dd19c (diff)
avformat/http: Introduce ff_http_averror()
int ff_http_averror(int status_code, int default_averror) This helper function returns AVERROR_ value from 3-digit HTTP status code. Second argument, default_averror, is used if no specific AVERROR_ is available. It is introduced because in different places of code different return codes are used - -1, AVERROR(EIO), AVERROR_INVALIDDATA. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/http.c')
-rw-r--r--libavformat/http.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index 018d25c9d7..1958a1b4d5 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -272,6 +272,23 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
return ret;
}
+int ff_http_averror(int status_code, int default_averror)
+{
+ switch (status_code) {
+ case 400: return AVERROR_HTTP_BAD_REQUEST;
+ case 401: return AVERROR_HTTP_UNAUTHORIZED;
+ case 403: return AVERROR_HTTP_FORBIDDEN;
+ case 404: return AVERROR_HTTP_NOT_FOUND;
+ default: break;
+ }
+ if (status_code >= 400 && status_code <= 499)
+ return AVERROR_HTTP_OTHER_4XX;
+ else if (status_code >= 500)
+ return AVERROR_HTTP_SERVER_ERROR;
+ else
+ return default_averror;
+}
+
static int http_open(URLContext *h, const char *uri, int flags,
AVDictionary **options)
{