#include <core/consumer/frame_consumer.h>\r
#include <core/producer/frame_producer.h>\r
\r
-#include <tbb/mutex.h>\r
+#include <tbb/recursive_mutex.h>\r
\r
#if defined(_MSC_VER)\r
#pragma warning (disable : 4244)\r
#include <libavfilter/avfilter.h>\r
}\r
\r
-namespace caspar {\r
+namespace caspar { namespace ffmpeg {\r
\r
int ffmpeg_lock_callback(void **mutex, enum AVLockOp op) \r
{ \r
if(!mutex)\r
return 0;\r
\r
- auto my_mutex = reinterpret_cast<tbb::mutex*>(*mutex);\r
+ auto my_mutex = reinterpret_cast<tbb::recursive_mutex*>(*mutex);\r
\r
switch(op) \r
{ \r
case AV_LOCK_CREATE: \r
{ \r
- *mutex = new tbb::mutex(); \r
+ *mutex = new tbb::recursive_mutex(); \r
break; \r
} \r
case AV_LOCK_OBTAIN: \r
return 0; \r
} \r
\r
-static void sanitize(uint8_t *line)
-{
- while(*line)
- {
- if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
- *line='?';
- line++;
- }
+static void sanitize(uint8_t *line)\r
+{\r
+ while(*line)\r
+ {\r
+ if(*line < 0x08 || (*line > 0x0D && *line < 0x20))\r
+ *line='?';\r
+ line++;\r
+ }\r
}\r
\r
void log_callback(void* ptr, int level, const char* fmt, va_list vl)\r
-{
- static int print_prefix=1;
- static int count;
- static char prev[1024];
- char line[8192];
- static int is_atty;
- AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
- if(level > av_log_get_level())
- return;
- line[0]=0;
-
-#undef fprintf
- if(print_prefix && avc)
- {
- if (avc->parent_log_context_offset)
- {
- AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);
- if(parent && *parent)
- std::sprintf(line, "[%s @ %p] ", (*parent)->item_name(parent), parent);
- }
- std::sprintf(line + strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);
- }
-
- std::vsprintf(line + strlen(line), fmt, vl);
-
- print_prefix = strlen(line) && line[strlen(line)-1] == '\n';
-
- //if(print_prefix && !strcmp(line, prev)){
- // count++;
- // if(is_atty==1)
- // fprintf(stderr, " Last message repeated %d times\r", count);
- // return;
- //}
- //if(count>0){
- // fprintf(stderr, " Last message repeated %d times\n", count);
- // count=0;
- //}
- strcpy(prev, line);
- sanitize((uint8_t*)line);
-
- CASPAR_LOG(trace) << L"[FFMPEG] [" << av_clip(level>>3, 0, 6) << L"] " << line;
-
+{\r
+ static int print_prefix=1;\r
+ static int count;\r
+ static char prev[1024];\r
+ char line[8192];\r
+ static int is_atty;\r
+ AVClass* avc= ptr ? *(AVClass**)ptr : NULL;\r
+ if(level > av_log_get_level())\r
+ return;\r
+ line[0]=0;\r
+ \r
+#undef fprintf\r
+ if(print_prefix && avc) \r
+ {\r
+ if (avc->parent_log_context_offset) \r
+ {\r
+ AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);\r
+ if(parent && *parent)\r
+ std::sprintf(line, "[%s @ %p] ", (*parent)->item_name(parent), parent); \r
+ }\r
+ std::sprintf(line + strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);\r
+ }\r
+\r
+ std::vsprintf(line + strlen(line), fmt, vl);\r
+\r
+ print_prefix = strlen(line) && line[strlen(line)-1] == '\n';\r
+ \r
+ //if(print_prefix && !strcmp(line, prev)){\r
+ // count++;\r
+ // if(is_atty==1)\r
+ // fprintf(stderr, " Last message repeated %d times\r", count);\r
+ // return;\r
+ //}\r
+ //if(count>0){\r
+ // fprintf(stderr, " Last message repeated %d times\n", count);\r
+ // count=0;\r
+ //}\r
+ strcpy(prev, line);\r
+ sanitize((uint8_t*)line);\r
+ \r
+ if(level == AV_LOG_DEBUG)\r
+ CASPAR_LOG(debug) << L"[ffmpeg] " << line;\r
+ else if(level == AV_LOG_INFO)\r
+ CASPAR_LOG(info) << L"[ffmpeg] " << line;\r
+ else if(level == AV_LOG_WARNING)\r
+ CASPAR_LOG(warning) << L"[ffmpeg] " << line;\r
+ else if(level == AV_LOG_ERROR)\r
+ CASPAR_LOG(error) << L"[ffmpeg] " << line;\r
+ else if(level == AV_LOG_FATAL)\r
+ CASPAR_LOG(fatal) << L"[ffmpeg] " << line;\r
+ else\r
+ CASPAR_LOG(trace) << L"[ffmpeg] " << line;\r
+\r
//colored_fputs(av_clip(level>>3, 0, 6), line);\r
}\r
\r
-void init_ffmpeg()\r
+void init()\r
{\r
avfilter_register_all();\r
av_register_all();\r
av_lockmgr_register(ffmpeg_lock_callback);\r
av_log_set_callback(log_callback);\r
\r
- core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_ffmpeg_consumer(params);});\r
- core::register_producer_factory(create_ffmpeg_producer);\r
+ //core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_ffmpeg_consumer(params);});\r
+ core::register_producer_factory(create_producer);\r
}\r
\r
-void uninit_ffmpeg()\r
+void uninit()\r
{\r
avfilter_uninit();\r
av_lockmgr_register(nullptr);\r
return make_version(swscale_version());\r
}\r
\r
-}
\ No newline at end of file
+}}
\ No newline at end of file