From: Jaroslav Kysela Date: Tue, 2 Jun 2015 10:36:23 +0000 (+0200) Subject: libav: add debug log option and webui X-Git-Tag: v4.2.1~2394 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6998d5d59aabde0e8532b80c31b75d4ea0932a9;p=thirdparty%2Ftvheadend.git libav: add debug log option and webui --- diff --git a/src/libav.c b/src/libav.c index 1e12d66af..916de4ffd 100644 --- a/src/libav.c +++ b/src/libav.c @@ -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(); } diff --git a/src/libav.h b/src/libav.h index 61083bf96..6222e55d9 100644 --- a/src/libav.h +++ b/src/libav.h @@ -19,6 +19,9 @@ #ifndef LIBAV_H_ #define LIBAV_H_ +#include "build.h" + +#if ENABLE_LIBAV #include #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 diff --git a/src/main.c b/src/main.c index e18fdfe34..770585ad7 100644 --- a/src/main.c +++ b/src/main.c @@ -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(); diff --git a/src/tvhlog.h b/src/tvhlog.h index 51de5a3f7..2b789d828 100644 --- a/src/tvhlog.h +++ b/src/tvhlog.h @@ -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 */ diff --git a/src/webui/extjs.c b/src/webui/extjs.c index 64aab9fe7..45206dcd8 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -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")); diff --git a/src/webui/static/app/tvhlog.js b/src/webui/static/app/tvhlog.js index 63336643c..3a9c45b05 100644 --- a/src/webui/static/app/tvhlog.js +++ b/src/webui/static/app/tvhlog.js @@ -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',