4 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
\r
6 * This file is part of CasparCG (www.casparcg.com).
\r
8 * CasparCG is free software: you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation, either version 3 of the License, or
\r
11 * (at your option) any later version.
\r
13 * CasparCG is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License
\r
19 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
21 * Author: Robert Nagy, ronag89@gmail.com
\r
23 #include "ffmpeg_error.h"
\r
25 #include <common/utf.h>
\r
27 #pragma warning(disable: 4146)
\r
31 #include <libavutil/error.h>
\r
34 namespace caspar { namespace ffmpeg {
\r
36 std::string av_error_str(int errn)
\r
39 memset(buf, 0, 256);
\r
40 if(av_strerror(errn, buf, 256) < 0)
\r
42 return std::string(buf);
\r
45 void throw_on_ffmpeg_error(int ret, const char* source, const char* func, const char* local_func, const char* file, int line)
\r
52 case AVERROR_BSF_NOT_FOUND:
\r
53 ::boost::exception_detail::throw_exception_(averror_bsf_not_found()<<
\r
54 msg_info(av_error_str(ret)) <<
\r
55 source_info(source) <<
\r
56 boost::errinfo_api_function(func) <<
\r
57 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
58 case AVERROR_DECODER_NOT_FOUND:
\r
59 ::boost::exception_detail::throw_exception_(averror_decoder_not_found()<<
\r
60 msg_info(av_error_str(ret)) <<
\r
61 source_info(source) <<
\r
62 boost::errinfo_api_function(func) <<
\r
63 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
64 case AVERROR_DEMUXER_NOT_FOUND:
\r
65 ::boost::exception_detail::throw_exception_(averror_demuxer_not_found()<<
\r
66 msg_info(av_error_str(ret)) <<
\r
67 source_info(source) <<
\r
68 boost::errinfo_api_function(func) <<
\r
69 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
70 case AVERROR_ENCODER_NOT_FOUND:
\r
71 ::boost::exception_detail::throw_exception_(averror_encoder_not_found()<<
\r
72 msg_info(av_error_str(ret)) <<
\r
73 source_info(source) <<
\r
74 boost::errinfo_api_function(func) <<
\r
75 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
77 ::boost::exception_detail::throw_exception_(averror_eof()<<
\r
78 msg_info(av_error_str(ret)) <<
\r
79 source_info(source) <<
\r
80 boost::errinfo_api_function(func) <<
\r
81 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
83 ::boost::exception_detail::throw_exception_(averror_exit()<<
\r
84 msg_info(av_error_str(ret)) <<
\r
85 source_info(source) <<
\r
86 boost::errinfo_api_function(func) <<
\r
87 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
88 case AVERROR_FILTER_NOT_FOUND:
\r
89 ::boost::exception_detail::throw_exception_(averror_filter_not_found()<<
\r
90 msg_info(av_error_str(ret)) <<
\r
91 source_info(source) <<
\r
92 boost::errinfo_api_function(func) <<
\r
93 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
94 case AVERROR_MUXER_NOT_FOUND:
\r
95 ::boost::exception_detail::throw_exception_(averror_muxer_not_found()<<
\r
96 msg_info(av_error_str(ret)) <<
\r
97 source_info(source) <<
\r
98 boost::errinfo_api_function(func) <<
\r
99 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
100 case AVERROR_OPTION_NOT_FOUND:
\r
101 ::boost::exception_detail::throw_exception_(averror_option_not_found()<<
\r
102 msg_info(av_error_str(ret)) <<
\r
103 source_info(source) <<
\r
104 boost::errinfo_api_function(func) <<
\r
105 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
106 case AVERROR_PATCHWELCOME:
\r
107 ::boost::exception_detail::throw_exception_(averror_patchwelcome()<<
\r
108 msg_info(av_error_str(ret)) <<
\r
109 source_info(source) <<
\r
110 boost::errinfo_api_function(func) <<
\r
111 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
112 case AVERROR_PROTOCOL_NOT_FOUND:
\r
113 ::boost::exception_detail::throw_exception_(averror_protocol_not_found()<<
\r
114 msg_info(av_error_str(ret)) <<
\r
115 source_info(source) <<
\r
116 boost::errinfo_api_function(func) <<
\r
117 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
118 case AVERROR_STREAM_NOT_FOUND:
\r
119 ::boost::exception_detail::throw_exception_(averror_stream_not_found()<<
\r
120 msg_info(av_error_str(ret)) <<
\r
121 source_info(source) <<
\r
122 boost::errinfo_api_function(func) <<
\r
123 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
125 ::boost::exception_detail::throw_exception_(ffmpeg_error()<<
\r
126 msg_info(av_error_str(ret)) <<
\r
127 source_info(source) <<
\r
128 boost::errinfo_api_function(func) <<
\r
129 boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);
\r
133 void throw_on_ffmpeg_error(int ret, const std::wstring& source, const char* func, const char* local_func, const char* file, int line)
\r
135 throw_on_ffmpeg_error(ret, u8(source).c_str(), func, local_func, file, line);
\r