\r
#pragma once\r
\r
-#include <common/exception/exceptions.h>\r
-#include <common/utility/string.h>\r
+#include <common/except.h>\r
\r
#include <string>\r
\r
-#pragma warning(push, 1)\r
-\r
-extern "C" \r
-{\r
-#include <libavutil/error.h>\r
-}\r
-\r
-#pragma warning(pop)\r
-\r
namespace caspar { namespace ffmpeg {\r
\r
struct ffmpeg_error : virtual caspar_exception{};\r
struct averror_protocol_not_found : virtual ffmpeg_error{};\r
struct averror_stream_not_found : virtual ffmpeg_error{};\r
\r
-static std::string av_error_str(int errn)\r
-{\r
- char buf[256];\r
- memset(buf, 0, 256);\r
- if(av_strerror(errn, buf, 256) < 0)\r
- return "";\r
- return std::string(buf);\r
-}\r
-\r
-static void throw_on_ffmpeg_error(int ret, const char* source, const char* func, const char* local_func, const char* file, int line)\r
-{\r
- if(ret >= 0)\r
- return;\r
-\r
- switch(ret)\r
- {\r
- case AVERROR_BSF_NOT_FOUND:\r
- ::boost::exception_detail::throw_exception_(averror_bsf_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line); \r
- case AVERROR_DECODER_NOT_FOUND:\r
- ::boost::exception_detail::throw_exception_(averror_decoder_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_DEMUXER_NOT_FOUND:\r
- ::boost::exception_detail::throw_exception_(averror_demuxer_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_ENCODER_NOT_FOUND:\r
- ::boost::exception_detail::throw_exception_(averror_encoder_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line); \r
- case AVERROR_EOF: \r
- ::boost::exception_detail::throw_exception_(averror_eof()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_EXIT: \r
- ::boost::exception_detail::throw_exception_(averror_exit()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_FILTER_NOT_FOUND: \r
- ::boost::exception_detail::throw_exception_(averror_filter_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_MUXER_NOT_FOUND: \r
- ::boost::exception_detail::throw_exception_(averror_muxer_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_OPTION_NOT_FOUND: \r
- ::boost::exception_detail::throw_exception_(averror_option_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_PATCHWELCOME: \r
- ::boost::exception_detail::throw_exception_(averror_patchwelcome()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_PROTOCOL_NOT_FOUND: \r
- ::boost::exception_detail::throw_exception_(averror_protocol_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- case AVERROR_STREAM_NOT_FOUND:\r
- ::boost::exception_detail::throw_exception_(averror_stream_not_found()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- default:\r
- ::boost::exception_detail::throw_exception_(ffmpeg_error()<< \r
- msg_info(av_error_str(ret)) << \r
- source_info((source)) << \r
- boost::errinfo_api_function(func) << \r
- boost::errinfo_errno(AVUNERROR(ret)), local_func, file, line);\r
- }\r
-}\r
+std::string av_error_str(int errn);\r
\r
-static void throw_on_ffmpeg_error(int ret, const std::string& source, const char* func, const char* local_func, const char* file, int line)\r
-{\r
- throw_on_ffmpeg_error(ret, (source).c_str(), func, local_func, file, line);\r
-}\r
+void throw_on_ffmpeg_error(int ret, const char* source, const char* func, const char* local_func, const char* file, int line);\r
+void throw_on_ffmpeg_error(int ret, const std::wstring& source, const char* func, const char* local_func, const char* file, int line);\r
\r
\r
//#define THROW_ON_ERROR(ret, source, func) throw_on_ffmpeg_error(ret, source, __FUNC__, __FILE__, __LINE__)\r
return ret; \\r
}()\r
\r
-}}
\ No newline at end of file
+}}\r