From 1e98e41381a6ca3ff662236b861bd39602b44dc7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 20 Dec 2014 18:46:29 +0100 Subject: decoder/ffmpeg: move code to lib/ffmpeg/LogCallback.cxx --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 36 ++--------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'src/decoder/plugins') diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 0c11c6349..fcd33a790 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -26,6 +26,7 @@ #include "lib/ffmpeg/Domain.hxx" #include "lib/ffmpeg/Error.hxx" #include "lib/ffmpeg/LogError.hxx" +#include "lib/ffmpeg/LogCallback.hxx" #include "lib/ffmpeg/Buffer.hxx" #include "../DecoderAPI.hxx" #include "FfmpegMetaData.hxx" @@ -56,39 +57,6 @@ extern "C" { #include #include -static LogLevel -import_ffmpeg_level(int level) -{ - if (level <= AV_LOG_FATAL) - return LogLevel::ERROR; - - if (level <= AV_LOG_WARNING) - return LogLevel::WARNING; - - if (level <= AV_LOG_INFO) - return LogLevel::INFO; - - return LogLevel::DEBUG; -} - -static void -mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level, - const char *fmt, va_list vl) -{ - const AVClass * cls = nullptr; - - if (ptr != nullptr) - cls = *(const AVClass *const*)ptr; - - if (cls != nullptr) { - char domain[64]; - snprintf(domain, sizeof(domain), "%s/%s", - ffmpeg_domain.GetName(), cls->item_name(ptr)); - const Domain d(domain); - LogFormatV(d, import_ffmpeg_level(level), fmt, vl); - } -} - /** * API compatibility wrapper for av_open_input_stream() and * avformat_open_input(). @@ -111,7 +79,7 @@ mpd_ffmpeg_open_input(AVFormatContext **ic_ptr, static bool ffmpeg_init(gcc_unused const config_param ¶m) { - av_log_set_callback(mpd_ffmpeg_log_callback); + av_log_set_callback(FfmpegLogCallback); av_register_all(); return true; -- cgit v1.2.3