From: Jaroslav Kysela Date: Sat, 2 Sep 2017 15:39:51 +0000 (+0200) Subject: libav: log - rework filters and print the class_name X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9ab44723384852458825fa7c4b3743b3bb53125;p=thirdparty%2Ftvheadend.git libav: log - rework filters and print the class_name --- diff --git a/src/libav.c b/src/libav.c index 7bf408fb9..24a08690a 100644 --- a/src/libav.c +++ b/src/libav.c @@ -7,22 +7,42 @@ static void libav_log_callback(void *ptr, int level, const char *fmt, va_list vl) { - int severity = LOG_TVH_NOTIFY, l; - char *fmt1 = (char *)fmt; + int severity = LOG_TVH_NOTIFY, l1, l2; + const char *class_name; + char *fmt1; if (level != AV_LOG_QUIET && ((level <= AV_LOG_INFO) || (tvhlog_options & TVHLOG_OPT_LIBAV))) { + class_name = av_default_item_name(ptr); + + l1 = strlen(fmt); + l2 = strlen(class_name); + fmt1 = alloca(l1 + l2 + 3); + if (fmt == NULL) + return; + + strcpy(fmt1, class_name); + strcat(fmt1, ": "); + strcat(fmt1, fmt); + /* remove trailing newline */ - l = strlen(fmt); - if (fmt[l-1] == '\n') { - fmt1 = tvh_strdupa(fmt); - fmt1[l-1] = '\0'; + if (fmt[l1-1] == '\n') + fmt1[l1 + l2 + 1] = '\0'; + + if (strcmp(class_name, "AVFormatContext") == 0) { + if (strcmp(fmt, "Negative cts, previous timestamps might be wrong.\n") == 0) { + level = AV_LOG_TRACE; + } else if (strcmp(fmt, "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n") == 0 && + strstr(fmt, ", pts=-") == 0) { + level = AV_LOG_TRACE; + } + } else if (strcmp(class_name, "AVCodecContext") == 0) { + if (strcmp(fmt, "forced frame type (%d) at %d was changed to frame type (%d)\n") == 0) { + level = AV_LOG_TRACE; + } } - if (strcmp(fmt1, "forced frame type (%d) at %d was changed to frame type (%d)") == 0) - level = AV_LOG_TRACE; - switch(level) { case AV_LOG_TRACE: #if ENABLE_TRACE