yading@11
|
1 /*
|
yading@11
|
2 * This file is part of FFmpeg.
|
yading@11
|
3 *
|
yading@11
|
4 * FFmpeg is free software; you can redistribute it and/or
|
yading@11
|
5 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
6 * License as published by the Free Software Foundation; either
|
yading@11
|
7 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
8 *
|
yading@11
|
9 * FFmpeg is distributed in the hope that it will be useful,
|
yading@11
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
12 * Lesser General Public License for more details.
|
yading@11
|
13 *
|
yading@11
|
14 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
15 * License along with FFmpeg; if not, write to the Free Software
|
yading@11
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
17 */
|
yading@11
|
18
|
yading@11
|
19 #undef _GNU_SOURCE
|
yading@11
|
20 #include "avutil.h"
|
yading@11
|
21 #include "avstring.h"
|
yading@11
|
22 #include "common.h"
|
yading@11
|
23
|
yading@11
|
24 struct error_entry {
|
yading@11
|
25 int num;
|
yading@11
|
26 const char *tag;
|
yading@11
|
27 const char *str;
|
yading@11
|
28 };
|
yading@11
|
29
|
yading@11
|
30 #define ERROR_TAG(tag) AVERROR_##tag, #tag
|
yading@11
|
31 static const struct error_entry error_entries[] = {
|
yading@11
|
32 { ERROR_TAG(BSF_NOT_FOUND), "Bitstream filter not found" },
|
yading@11
|
33 { ERROR_TAG(BUG), "Internal bug, should not have happened" },
|
yading@11
|
34 { ERROR_TAG(BUG2), "Internal bug, should not have happened" },
|
yading@11
|
35 { ERROR_TAG(BUFFER_TOO_SMALL), "Buffer too small" },
|
yading@11
|
36 { ERROR_TAG(DECODER_NOT_FOUND), "Decoder not found" },
|
yading@11
|
37 { ERROR_TAG(DEMUXER_NOT_FOUND), "Demuxer not found" },
|
yading@11
|
38 { ERROR_TAG(ENCODER_NOT_FOUND), "Encoder not found" },
|
yading@11
|
39 { ERROR_TAG(EOF), "End of file" },
|
yading@11
|
40 { ERROR_TAG(EXIT), "Immediate exit requested" },
|
yading@11
|
41 { ERROR_TAG(EXTERNAL), "Generic error in an external library" },
|
yading@11
|
42 { ERROR_TAG(FILTER_NOT_FOUND), "Filter not found" },
|
yading@11
|
43 { ERROR_TAG(INVALIDDATA), "Invalid data found when processing input" },
|
yading@11
|
44 { ERROR_TAG(MUXER_NOT_FOUND), "Muxer not found" },
|
yading@11
|
45 { ERROR_TAG(OPTION_NOT_FOUND), "Option not found" },
|
yading@11
|
46 { ERROR_TAG(PATCHWELCOME), "Not yet implemented in FFmpeg, patches welcome" },
|
yading@11
|
47 { ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
|
yading@11
|
48 { ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
|
yading@11
|
49 { ERROR_TAG(UNKNOWN), "Unknown error occurred" },
|
yading@11
|
50 { ERROR_TAG(EXPERIMENTAL), "Experimental feature" },
|
yading@11
|
51 };
|
yading@11
|
52
|
yading@11
|
53 int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
|
yading@11
|
54 {
|
yading@11
|
55 int ret = 0, i;
|
yading@11
|
56 const struct error_entry *entry = NULL;
|
yading@11
|
57
|
yading@11
|
58 for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
|
yading@11
|
59 if (errnum == error_entries[i].num) {
|
yading@11
|
60 entry = &error_entries[i];
|
yading@11
|
61 break;
|
yading@11
|
62 }
|
yading@11
|
63 }
|
yading@11
|
64 if (entry) {
|
yading@11
|
65 av_strlcpy(errbuf, entry->str, errbuf_size);
|
yading@11
|
66 } else {
|
yading@11
|
67 #if HAVE_STRERROR_R
|
yading@11
|
68 ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
|
yading@11
|
69 #else
|
yading@11
|
70 ret = -1;
|
yading@11
|
71 #endif
|
yading@11
|
72 if (ret < 0)
|
yading@11
|
73 snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
|
yading@11
|
74 }
|
yading@11
|
75
|
yading@11
|
76 return ret;
|
yading@11
|
77 }
|
yading@11
|
78
|
yading@11
|
79 #ifdef TEST
|
yading@11
|
80
|
yading@11
|
81 #undef printf
|
yading@11
|
82
|
yading@11
|
83 int main(void)
|
yading@11
|
84 {
|
yading@11
|
85 int i;
|
yading@11
|
86
|
yading@11
|
87 for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
|
yading@11
|
88 const struct error_entry *entry = &error_entries[i];
|
yading@11
|
89 printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
|
yading@11
|
90 }
|
yading@11
|
91
|
yading@11
|
92 for (i = 0; i < 256; i++) {
|
yading@11
|
93 printf("%d: %s\n", -i, av_err2str(-i));
|
yading@11
|
94 }
|
yading@11
|
95
|
yading@11
|
96 return 0;
|
yading@11
|
97 }
|
yading@11
|
98
|
yading@11
|
99 #endif /* TEST */
|