2010-03-25 23:46:35 +01:00
|
|
|
/*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2011-05-30 03:11:54 +02:00
|
|
|
#undef _GNU_SOURCE
|
2010-03-25 23:46:35 +01:00
|
|
|
#include "avutil.h"
|
|
|
|
#include "avstring.h"
|
2012-08-06 15:49:32 +02:00
|
|
|
#include "common.h"
|
2010-03-25 23:46:35 +01:00
|
|
|
|
2012-02-06 14:16:33 +01:00
|
|
|
struct error_entry {
|
|
|
|
int num;
|
|
|
|
const char *tag;
|
|
|
|
const char *str;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ERROR_TAG(tag) AVERROR_##tag, #tag
|
2012-09-16 02:53:32 +02:00
|
|
|
static const struct error_entry error_entries[] = {
|
2012-02-06 14:16:33 +01:00
|
|
|
{ ERROR_TAG(BSF_NOT_FOUND), "Bitstream filter not found" },
|
|
|
|
{ ERROR_TAG(BUG), "Internal bug, should not have happened" },
|
|
|
|
{ ERROR_TAG(BUG2), "Internal bug, should not have happened" },
|
2012-07-04 12:42:48 +02:00
|
|
|
{ ERROR_TAG(BUFFER_TOO_SMALL), "Buffer too small" },
|
2012-02-06 14:16:33 +01:00
|
|
|
{ ERROR_TAG(DECODER_NOT_FOUND), "Decoder not found" },
|
|
|
|
{ ERROR_TAG(DEMUXER_NOT_FOUND), "Demuxer not found" },
|
|
|
|
{ ERROR_TAG(ENCODER_NOT_FOUND), "Encoder not found" },
|
|
|
|
{ ERROR_TAG(EOF), "End of file" },
|
|
|
|
{ ERROR_TAG(EXIT), "Immediate exit requested" },
|
2012-07-04 12:50:55 +02:00
|
|
|
{ ERROR_TAG(EXTERNAL), "Generic error in an external library" },
|
2012-02-06 14:16:33 +01:00
|
|
|
{ ERROR_TAG(FILTER_NOT_FOUND), "Filter not found" },
|
|
|
|
{ ERROR_TAG(INVALIDDATA), "Invalid data found when processing input" },
|
|
|
|
{ ERROR_TAG(MUXER_NOT_FOUND), "Muxer not found" },
|
|
|
|
{ ERROR_TAG(OPTION_NOT_FOUND), "Option not found" },
|
|
|
|
{ ERROR_TAG(PATCHWELCOME), "Not yet implemented in FFmpeg, patches welcome" },
|
|
|
|
{ ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
|
|
|
|
{ ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
|
|
|
|
{ ERROR_TAG(UNKNOWN), "Unknown error occurred" },
|
2012-10-22 14:39:12 +02:00
|
|
|
{ ERROR_TAG(EXPERIMENTAL), "Experimental feature" },
|
2012-02-06 14:16:33 +01:00
|
|
|
};
|
|
|
|
|
2010-03-25 23:46:35 +01:00
|
|
|
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
|
|
|
|
{
|
2012-02-06 14:16:33 +01:00
|
|
|
int ret = 0, i;
|
2012-09-16 02:53:32 +02:00
|
|
|
const struct error_entry *entry = NULL;
|
2010-03-25 23:46:35 +01:00
|
|
|
|
2012-02-06 14:16:33 +01:00
|
|
|
for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
|
|
|
|
if (errnum == error_entries[i].num) {
|
|
|
|
entry = &error_entries[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (entry) {
|
|
|
|
av_strlcpy(errbuf, entry->str, errbuf_size);
|
2010-03-25 23:46:35 +01:00
|
|
|
} else {
|
|
|
|
#if HAVE_STRERROR_R
|
2012-06-01 23:30:16 +02:00
|
|
|
ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
|
2010-05-05 23:44:47 +02:00
|
|
|
#else
|
|
|
|
ret = -1;
|
2010-03-25 23:46:35 +01:00
|
|
|
#endif
|
2010-05-05 23:44:47 +02:00
|
|
|
if (ret < 0)
|
2010-05-03 23:56:21 +02:00
|
|
|
snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
|
2010-03-25 23:46:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2012-02-06 14:16:33 +01:00
|
|
|
|
|
|
|
#ifdef TEST
|
|
|
|
|
|
|
|
#undef printf
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
|
2012-09-16 02:53:32 +02:00
|
|
|
const struct error_entry *entry = &error_entries[i];
|
2012-06-10 00:17:45 +02:00
|
|
|
printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
|
2012-02-06 14:16:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
2012-06-10 00:17:45 +02:00
|
|
|
printf("%d: %s\n", -i, av_err2str(-i));
|
2012-02-06 14:16:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* TEST */
|