Add a logger callback for FFmpeg log messages

This commit is contained in:
Julien BLACHE 2010-03-07 10:45:15 +01:00
parent 092eb59fe0
commit 119525e612
3 changed files with 27 additions and 0 deletions

View File

@ -29,6 +29,8 @@
#include <event.h>
#include <libavutil/log.h>
#include "logger.h"
@ -130,6 +132,26 @@ DPRINTF(int severity, int domain, const char *fmt, ...)
va_end(ap);
}
void
logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap)
{
int severity;
/* Can't use a switch() because some definitions have the same value */
if ((level == AV_LOG_FATAL) || (level == AV_LOG_ERROR))
severity = E_LOG;
else if ((level == AV_LOG_WARNING) || (level == AV_LOG_INFO) || (level == AV_LOG_VERBOSE))
severity = E_WARN;
else if (level == AV_LOG_DEBUG)
severity = E_DBG;
else if (level == AV_LOG_QUIET)
severity = E_SPAM;
else
severity = E_LOG;
vlogger(severity, L_FFMPEG, fmt, ap);
}
void
logger_libevent(int severity, const char *msg)
{

View File

@ -38,6 +38,9 @@ vlogger(int severity, int domain, const char *fmt, va_list args);
void
DPRINTF(int severity, int domain, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
void
logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap);
void
logger_libevent(int severity, const char *msg);

View File

@ -49,6 +49,7 @@
#include <getopt.h>
#include <event.h>
#include <libavutil/log.h>
#include <libavformat/avformat.h>
#include <gcrypt.h>
@ -555,6 +556,7 @@ main(int argc, char **argv)
/* Initialize ffmpeg */
av_register_all();
av_log_set_callback(logger_ffmpeg);
/* Initialize libgcrypt */
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);