Commit a24fd472 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dvbinfo: implement monitor mode

In monitor mode dvbinfo runs as Unix daemon and the logging goes to syslog instead of stderr.
- added -m (--monitor) commandline switch to run in the background
- added -s (--summary) commandline switch to produce bitrate summary files
- added --summary-file commandline switch to give a summary-file name (default: stdout)
- added --summary-period commandline switch to write every <n> ms a new summary file
- implemented a logging callback function for routing the dvbpsi log messages to dvbinfo application
parent c576e208
This diff is collapsed.
......@@ -23,6 +23,15 @@
#ifndef DVBINFO_H_
#define DVBINFO_H_
/* defined loglevels for use within dvbinfo are as follows,
* they match to this order of syslog priority levels.
* { LOG_ERR, LOG_WARNING, LOG_INFO, LOG_DEBUG };
*/
#define DVBINFO_LOG_ERROR 0
#define DVBINFO_LOG_WARN 1
#define DVBINFO_LOG_INFO 2
#define DVBINFO_LOG_DEBUG 3
typedef struct params_s
{
/* parameters */
......@@ -39,10 +48,21 @@ typedef struct params_s
int debug;
bool b_verbose;
/* statistics */
bool b_summary; /* write summary */
struct summary_s {
int mode; /* one of: i_summary_mode */
int64_t period; /* summary period in ms */
char *file; /* summary file name */
FILE *fd; /* summary file descriptor */
} summary;
/* read data from file of socket */
ssize_t (*pf_read)(int fd, void *buf, size_t count);
ssize_t (*pf_write)(int fd, const void *buf, size_t count);
/* logging function */
void (*pf_log)(const int level, const char *format, ...);
} params_t;
#endif
This diff is collapsed.
......@@ -23,16 +23,24 @@
#ifndef DVBINFO_DVBPSI_H_
#define DVBINFO_DVBPSI_H_
/* Date and time */
typedef int64_t mtime_t;
mtime_t mdate(void);
/* Summary */
#define SUM_BANDWIDTH 0
#define SUM_TABLE 1
#define SUM_PACKET 2
#define SUM_WIRE 3
/* MPEG-TS PSI decoders */
typedef struct ts_stream_t ts_stream_t;
typedef void (* ts_stream_log_cb)(void *data, const int level, const char *msg, ...);
/* */
ts_stream_t *libdvbpsi_init(int debug);
ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data);
bool libdvbpsi_process(ts_stream_t *stream, uint8_t *buf, ssize_t length, mtime_t date);
void libdvbpsi_summary(ts_stream_t *stream);
void libdvbpsi_summary(FILE *fd, ts_stream_t *stream, const int summary_mode);
void libdvbpsi_exit(ts_stream_t *stream);
#endif
......@@ -97,6 +97,12 @@ struct dvbpsi_s
/* Messages callback */
dvbpsi_message_cb pf_message; /*!< Log message callback */
enum dvbpsi_msg_level i_msg_level; /*!< Log level */
/* private data pointer for use by caller, not by libdvbpsi itself ! */
void *p_sys; /*!< pointer to private data
from caller. Do not use
from inside libdvbpsi. It
will crash any application. */
};
/*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment