3 #include <common/exception/exceptions.h>
\r
4 #include <common/utility/string.h>
\r
8 #pragma warning(push, 1)
\r
12 #include <libavutil/error.h>
\r
15 #pragma warning(pop)
\r
17 namespace caspar { namespace ffmpeg {
\r
19 struct ffmpeg_error : virtual caspar_exception{};
\r
20 struct ffmpeg_stream_not_found : virtual ffmpeg_error{};
\r
22 static std::string av_error_str(int errn)
\r
25 memset(buf, 0, 256);
\r
26 if(av_strerror(errn, buf, 256) < 0)
\r
28 return std::string(buf);
\r
31 #define THROW_ON_ERROR(ret, source, func) \
\r
34 BOOST_THROW_EXCEPTION( \
\r
36 msg_info(av_error_str(ret)) << \
\r
37 source_info(narrow(source)) << \
\r
38 boost::errinfo_api_function(func) << \
\r
39 boost::errinfo_errno(AVUNERROR(ret))); \
\r
42 #define THROW_ON_ERROR_STR_(call) #call
\r
43 #define THROW_ON_ERROR_STR(call) THROW_ON_ERROR_STR_(call)
\r
45 #define THROW_ON_ERROR3(call, source, exception) \
\r
51 BOOST_THROW_EXCEPTION( \
\r
53 msg_info(av_error_str(ret)) << \
\r
54 source_info(narrow(source)) << \
\r
55 boost::errinfo_api_function(THROW_ON_ERROR_STR(call)) << \
\r
56 boost::errinfo_errno(AVUNERROR(ret))); \
\r
60 #define THROW_ON_ERROR2(call, source) THROW_ON_ERROR3(call, source, ffmpeg_error)
\r