]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
libav: log - rework filters and print the class_name
authorJaroslav Kysela <perex@perex.cz>
Sat, 2 Sep 2017 15:39:51 +0000 (17:39 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sat, 2 Sep 2017 15:39:51 +0000 (17:39 +0200)
src/libav.c

index 7bf408fb97f3ebd24d3a38d58f17310b3e254868..24a08690a6ab8efa7fabb8a3853fd9948794e5b1 100644 (file)
@@ -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