Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libav: add debug log option and webui
  • Loading branch information
perexg committed Jun 2, 2015
1 parent bd9a4c4 commit e6998d5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 8 deletions.
24 changes: 21 additions & 3 deletions src/libav.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
10 changes: 10 additions & 0 deletions src/libav.h
Expand Up @@ -19,6 +19,9 @@
#ifndef LIBAV_H_
#define LIBAV_H_

#include "build.h"

#if ENABLE_LIBAV

#include <libavformat/avformat.h>
#include "tvheadend.h"
Expand Down Expand Up @@ -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
13 changes: 9 additions & 4 deletions src/main.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -974,9 +981,7 @@ main(int argc, char **argv)

fsmonitor_init();

#if ENABLE_LIBAV
libav_init();
#endif

tvhtime_init();

Expand Down
1 change: 1 addition & 0 deletions src/tvhlog.h
Expand Up @@ -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 */
Expand Down
10 changes: 9 additions & 1 deletion src/webui/extjs.c
Expand Up @@ -47,6 +47,7 @@
#include "timeshift.h"
#include "tvhtime.h"
#include "input.h"
#include "libav.h"
#include "satip/server.h"

#define EXTJSPATH "static/extjs"
Expand Down Expand Up @@ -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");
Expand All @@ -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"));
Expand Down
8 changes: 8 additions & 0 deletions src/webui/static/app/tvhlog.js
Expand Up @@ -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
* ***************************************************************/
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit e6998d5

Please sign in to comment.