]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
libav: add debug log option and webui
authorJaroslav Kysela <perex@perex.cz>
Tue, 2 Jun 2015 10:36:23 +0000 (12:36 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 2 Jun 2015 10:36:23 +0000 (12:36 +0200)
src/libav.c
src/libav.h
src/main.c
src/tvhlog.h
src/webui/extjs.c
src/webui/static/app/tvhlog.js

index 1e12d66affb1d231c48dc7b1e209642fbc450069..916de4ffd6afcfdc6675a80495f2f889f4d39ad4 100644 (file)
@@ -16,11 +16,15 @@ libav_log_callback(void *ptr, int level, const char *fmt, va_list vl)
     l = message;
 
     if(level == AV_LOG_DEBUG)
+#if ENABLE_TRACE
+      level = LOG_TRACE;
+#else
       level = LOG_DEBUG;
+#endif
     else if(level == AV_LOG_VERBOSE)
-      level = LOG_INFO;
+      level = LOG_DEBUG;
     else if(level == AV_LOG_INFO)
-      level = LOG_NOTICE;
+      level = LOG_INFO;
     else if(level == AV_LOG_WARNING)
       level = LOG_WARNING;
     else if(level == AV_LOG_ERROR)
@@ -181,9 +185,23 @@ libav_is_encoder(AVCodec *codec)
  * 
  */ 
 void
+libav_set_loglevel(void)
+{
+  int level = AV_LOG_VERBOSE;
+
+  if (tvhlog_options & TVHLOG_OPT_LIBAV)
+    level = AV_LOG_DEBUG;
+
+  av_log_set_level(level);
+}
+
+/**
+ *
+ */
+void
 libav_init(void)
 {
   av_log_set_callback(libav_log_callback);
-  av_log_set_level(AV_LOG_VERBOSE);
+  libav_set_loglevel();
   av_register_all();
 }
index 61083bf96d692ee6bfd102ea2b61be105f7fa880..6222e55d99d8794ed5faa59653155b7ea6dfc097 100644 (file)
@@ -19,6 +19,9 @@
 #ifndef LIBAV_H_
 #define LIBAV_H_
 
+#include "build.h"
+
+#if ENABLE_LIBAV
 
 #include <libavformat/avformat.h>
 #include "tvheadend.h"
@@ -53,7 +56,14 @@ This list must be updated every time we use a new AV_CODEC_ID
 enum AVCodecID streaming_component_type2codec_id(streaming_component_type_t type);
 streaming_component_type_t codec_id2streaming_component_type(enum AVCodecID id);
 int libav_is_encoder(AVCodec *codec);
+void libav_set_loglevel(void);
 void libav_init(void);
 
+#else
+
+static inline void libav_set_loglevel(void);
+static inline void libav_init(void);
+
 #endif
 
+#endif
index e18fdfe34ee82b6cfb924051ac74a5e777023773..770585ad72f6995cf95f73f81aebc92986f954f2 100644 (file)
@@ -67,9 +67,7 @@
 #include "esfilter.h"
 #include "intlconv.h"
 #include "dbus.h"
-#if ENABLE_LIBAV
 #include "libav.h"
-#endif
 #include "profile.h"
 #include "bouquet.h"
 #include "tvhtime.h"
@@ -159,6 +157,9 @@ const tvh_caps_t tvheadend_capabilities[] = {
 #endif
 #if ENABLE_TRACE
   { "trace",     NULL },
+#endif
+#if ENABLE_LIBAV
+  { "libav",     NULL },
 #endif
   { NULL, NULL }
 };
@@ -610,6 +611,7 @@ main(int argc, char **argv)
               opt_noacl        = 0,
               opt_fileline     = 0,
               opt_threadid     = 0,
+              opt_libav        = 0,
               opt_ipv6         = 0,
               opt_satip_rtsp   = 0,
 #if ENABLE_TSFILE
@@ -700,6 +702,9 @@ main(int argc, char **argv)
 #endif
     {   0, "fileline",  "Add file and line numbers to debug", OPT_BOOL, &opt_fileline },
     {   0, "threadid",  "Add the thread ID to debug", OPT_BOOL, &opt_threadid },
+#if ENABLE_LIBAV
+    {   0, "libav",     "More verbose libav log",  OPT_BOOL, &opt_libav },
+#endif
     {   0, "uidebug",   "Enable webUI debug (non-minified JS)", OPT_BOOL, &opt_uidebug },
     { 'A', "abort",     "Immediately abort",       OPT_BOOL, &opt_abort   },
     { 'D', "dump",      "Enable coredumps for daemon", OPT_BOOL, &opt_dump },
@@ -831,6 +836,8 @@ main(int argc, char **argv)
     log_options |= TVHLOG_OPT_FILELINE;
   if (opt_threadid)
     log_options |= TVHLOG_OPT_THREAD;
+  if (opt_libav)
+    log_options |= TVHLOG_OPT_LIBAV;
   if (opt_log_trace) {
     log_level  = LOG_TRACE;
     log_trace  = opt_log_trace;
@@ -974,9 +981,7 @@ main(int argc, char **argv)
 
   fsmonitor_init();
 
-#if ENABLE_LIBAV
   libav_init();
-#endif
 
   tvhtime_init();
 
index 51de5a3f77189e450707e0385aa558095947a0b0..2b789d82880559e2aa2bf3acf0bba97f7edfded4 100644 (file)
@@ -84,6 +84,7 @@ static inline int tvhlog_limit ( tvhlog_limit_t *limit, uint32_t delay )
 #define TVHLOG_OPT_DECORATE     0x0200
 #define TVHLOG_OPT_FILELINE     0x0400
 #define TVHLOG_OPT_THREAD       0x0800
+#define TVHLOG_OPT_LIBAV        0x1000
 #define TVHLOG_OPT_ALL          0xFFFF
 
 /* Levels */
index 64aab9fe7f858efa4cf77f6b25c05218d20faa83..45206dcd8d19b566ae5e22a070d3f1e2f57816e3 100644 (file)
@@ -47,6 +47,7 @@
 #include "timeshift.h"
 #include "tvhtime.h"
 #include "input.h"
+#include "libav.h"
 #include "satip/server.h"
 
 #define EXTJSPATH "static/extjs"
@@ -582,7 +583,9 @@ extjs_tvhlog(http_connection_t *hc, const char *remain, void *opaque)
     htsmsg_add_str(m, "tvhlog_path",       tvhlog_path ?: "");
     htsmsg_add_u32(m, "tvhlog_options",    tvhlog_options);
     htsmsg_add_u32(m, "tvhlog_dbg_syslog",
-                   tvhlog_options & TVHLOG_OPT_DBG_SYSLOG);
+                   !!(tvhlog_options & TVHLOG_OPT_DBG_SYSLOG));
+    htsmsg_add_u32(m, "tvhlog_libav",
+                   !!(tvhlog_options & TVHLOG_OPT_LIBAV));
     pthread_mutex_unlock(&tvhlog_mutex);
     
     out = json_single_record(m, "config");
@@ -609,6 +612,11 @@ extjs_tvhlog(http_connection_t *hc, const char *remain, void *opaque)
       tvhlog_options |= TVHLOG_OPT_DBG_SYSLOG;
     else
       tvhlog_options &= ~TVHLOG_OPT_DBG_SYSLOG;
+    if ((str = http_arg_get(&hc->hc_req_args, "tvhlog_libav")))
+      tvhlog_options |= TVHLOG_OPT_LIBAV;
+    else
+      tvhlog_options &= ~TVHLOG_OPT_LIBAV;
+    libav_set_loglevel();
     if (tvhlog_path && tvhlog_path[0] != '\0')
       tvhlog_options |= TVHLOG_OPT_DBG_FILE;
     tvhlog_set_trace(http_arg_get(&hc->hc_req_args, "tvhlog_trace"));
index 63336643c98550a3d61a4deeb824c08b4688b871..3a9c45b052539be8b28d745ecb09e6d892b81514 100644 (file)
@@ -42,6 +42,12 @@ tvheadend.tvhlog = function(panel, index) {
         width: 400
     });
 
+    var tvhlogLibav = new Ext.form.Checkbox({
+        name: 'tvhlog_libav',
+        fieldLabel: 'Debug libav log'
+    });
+
+
     /* ****************************************************************
      * Form
      * ***************************************************************/
@@ -69,6 +75,8 @@ tvheadend.tvhlog = function(panel, index) {
     items.push(tvhlogDebugSubsys);
     if (tvheadend.capabilities.indexOf('trace') !== -1)
       items.push(tvhlogTraceSubsys);
+    if (tvheadend.capabilities.indexOf('libav') !== -1)
+      items.push(tvhlogLibav);
 
     var DebuggingPanel = new Ext.form.FieldSet({
         title: 'Debugging Options',