Commit 64354fcd authored by Christophe Massiot's avatar Christophe Massiot

* utils.c: Add a new level of verboseness so that error output can be...

* utils.c: Add a new level of verboseness so that error output can be disabled. * dvblast.c, demux.c: Reflect the change in biTStream API for printing. New -x switch to enable event output on stdout.
parent ca663870
This diff is collapsed.
......@@ -49,6 +49,8 @@
#include "en50221.h"
#include "comm.h"
#include <bitstream/common.h>
/*****************************************************************************
* Local declarations
*****************************************************************************/
......@@ -361,6 +363,13 @@ static void FrontendPoll( void )
{
int32_t i_value = 0;
msg_Dbg( NULL, "frontend has acquired lock" );
switch (i_print_type) {
case PRINT_XML:
printf("<STATUS type=\"lock\" status=\"1\"/>\n");
break;
default:
printf("frontend has acquired lock" );
}
i_frontend_timeout = 0;
i_last_packet = i_wallclock;
......@@ -378,6 +387,13 @@ static void FrontendPoll( void )
else
{
msg_Dbg( NULL, "frontend has lost lock" );
switch (i_print_type) {
case PRINT_XML:
printf("<STATUS type=\"lock\" status=\"0\"/>\n");
break;
default:
printf("frontend has lost lock" );
}
i_frontend_timeout = i_wallclock + i_frontend_timeout_duration;
}
......
......@@ -86,6 +86,7 @@ char *psz_udp_src = NULL;
int i_asi_adapter = 0;
const char *psz_native_charset = "UTF-8";
const char *psz_dvb_charset = "ISO_8859-1";
print_type_t i_print_type = -1;
volatile sig_atomic_t b_hup_received = 0;
int i_verbose = DEFAULT_VERBOSITY;
......@@ -376,7 +377,8 @@ static void DisplayVersion()
*****************************************************************************/
void usage()
{
msg_Raw( NULL, "Usage: dvblast [-q] [-c <config file>] [-r <remote socket>] [-t <ttl>] [-o <SSRC IP>] [-i <RT priority>] [-a <adapter>] [-n <frontend number>] [-S <diseqc>] [-f <frequency>|-D [<src host>[:<src port>]@]<src mcast>[:<port>][/<opts>]*|-A <ASI adapter>] [-s <symbol rate>] [-v <0|13|18>] [-p] [-b <bandwidth>] [-I <inversion>] [-F <fec inner>] [-m <modulation] [-R <rolloff>] [-P <pilot>] [-K <fec lp>] [-G <guard interval>] [-H <hierarchy>] [-X <transmission>] [-O <lock timeout>] [-u] [-U] [-L <latency>] [-E <retention>] [-d <dest IP>[<:port>][/<opts>]*] [-C [-e] [-M <network name] [-N <network ID>]] [-T] [-j <system charset>] [-J <DVB charset>] [-Q <quit timeout>]" );
DisplayVersion();
msg_Raw( NULL, "Usage: dvblast [-q] [-c <config file>] [-r <remote socket>] [-t <ttl>] [-o <SSRC IP>] [-i <RT priority>] [-a <adapter>] [-n <frontend number>] [-S <diseqc>] [-f <frequency>|-D [<src host>[:<src port>]@]<src mcast>[:<port>][/<opts>]*|-A <ASI adapter>] [-s <symbol rate>] [-v <0|13|18>] [-p] [-b <bandwidth>] [-I <inversion>] [-F <fec inner>] [-m <modulation] [-R <rolloff>] [-P <pilot>] [-K <fec lp>] [-G <guard interval>] [-H <hierarchy>] [-X <transmission>] [-O <lock timeout>] [-u] [-U] [-L <latency>] [-E <retention>] [-d <dest IP>[<:port>][/<opts>]*] [-C [-e] [-M <network name] [-N <network ID>]] [-T] [-j <system charset>] [-J <DVB charset>] [-Q <quit timeout>] [-x <text|xml>" );
msg_Raw( NULL, "Input:" );
msg_Raw( NULL, " -a --adapter read packets from a Linux-DVB adapter (typically 0-n)" );
......@@ -427,6 +429,7 @@ void usage()
msg_Raw( NULL, " -j --system-charset character set used for printing messages (default UTF-8)" );
msg_Raw( NULL, " -J --dvb-charset character set used in output DVB tables (default ISO_8859-1)" );
msg_Raw( NULL, " -l --logger use syslog for logging messages instead of stderr" );
msg_Raw( NULL, " -x --print print interesting events on stdout in a given format" );
msg_Raw( NULL, " -q --quiet be quiet (less verbosity, repeat or use number for even quieter)" );
msg_Raw( NULL, " -Q --quit-timeout when locked, quit after this delay (in ms), or after the first lock timeout" );
msg_Raw( NULL, " -r --remote-socket <remote socket>" );
......@@ -447,8 +450,6 @@ int main( int i_argc, char **pp_argv )
int b_enable_syslog = 0;
DisplayVersion();
if ( i_argc == 1 )
usage();
......@@ -492,6 +493,7 @@ int main( int i_argc, char **pp_argv )
{ "system-charset", required_argument, NULL, 'j' },
{ "dvb-charset", required_argument, NULL, 'J' },
{ "logger", no_argument, NULL, 'l' },
{ "print", required_argument, NULL, 'x' },
{ "quit-timeout", required_argument, NULL, 'Q' },
{ "quiet", no_argument, NULL, 'q' },
{ "help", no_argument, NULL, 'h' },
......@@ -499,7 +501,7 @@ int main( int i_argc, char **pp_argv )
{ 0, 0, 0, 0 }
};
while ( (c = getopt_long(i_argc, pp_argv, "q::c:r:t:o:i:a:n:f:F:R:s:S:v:pb:I:m:P:K:G:H:X:O:uUTL:E:d:D:A:lCeM:N:j:J:Q:hV", long_options, NULL)) != -1 )
while ( (c = getopt_long(i_argc, pp_argv, "q::c:r:t:o:i:a:n:f:F:R:s:S:v:pb:I:m:P:K:G:H:X:O:uUTL:E:d:D:A:lCeM:N:j:J:x:Q:hV", long_options, NULL)) != -1 )
{
switch ( c )
{
......@@ -700,6 +702,10 @@ int main( int i_argc, char **pp_argv )
i_network_id = strtoul( optarg, NULL, 0 );
break;
case 'T':
b_random_tsid = 1;
break;
case 'j':
psz_native_charset = optarg;
break;
......@@ -712,8 +718,13 @@ int main( int i_argc, char **pp_argv )
b_enable_syslog = 1;
break;
case 'T':
b_random_tsid = 1;
case 'x':
if ( !strcmp(optarg, "text") )
i_print_type = PRINT_TEXT;
else if ( !strcmp(optarg, "xml") )
i_print_type = PRINT_XML;
else
msg_Warn( NULL, "unrecognized print type %s", optarg );
break;
case 'Q':
......@@ -735,7 +746,18 @@ int main( int i_argc, char **pp_argv )
if ( b_enable_syslog )
msg_Connect( pp_argv[0] );
if ( i_verbose )
DisplayVersion();
msg_Warn( NULL, "restarting" );
switch (i_print_type) {
case PRINT_XML:
printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
printf("<TS>\n");
break;
default:
break;
}
if ( b_udp_global )
{
......
......@@ -35,7 +35,7 @@
#define PADDING_PID 8191
#define WATCHDOG_WAIT 10000000LL
#define MAX_ERRORS 1000
#define DEFAULT_VERBOSITY 3
#define DEFAULT_VERBOSITY 4
#define MAX_POLL_TIMEOUT 100000 /* 100 ms */
#define DEFAULT_OUTPUT_LATENCY 200000 /* 200 ms */
#define DEFAULT_MAX_RETENTION 40000 /* 40 ms */
......@@ -165,6 +165,7 @@ extern char *psz_udp_src;
extern int i_asi_adapter;
extern const char *psz_native_charset;
extern const char *psz_dvb_charset;
extern enum print_type_t i_print_type;
extern void (*pf_Open)( void );
extern block_t * (*pf_Read)( mtime_t i_poll_timeout );
......
......@@ -114,7 +114,7 @@ signal_catch() {
exec_dvblast() {
tmp_file=`mktemp`
$DVBLAST $diseqc $adapter -O $LOCK_TIMEOUT -Q $QUIT_TIMEOUT $opts 2>| $tmp_file &
$DVBLAST $diseqc $adapter -O $LOCK_TIMEOUT -Q $QUIT_TIMEOUT -q4 -x xml $opts 2>| $tmp_file &
childpid=$!
wait $childpid
if test $? -eq 0; then
......
......@@ -43,9 +43,10 @@
* Local declarations
*****************************************************************************/
#define MAX_MSG 1024
#define VERB_DBG 3
#define VERB_INFO 2
#define VERB_WARN 1
#define VERB_DBG 4
#define VERB_INFO 3
#define VERB_WARN 2
#define VERB_ERR 1
/*****************************************************************************
* msg_Connect
......@@ -89,15 +90,18 @@ void msg_Info( void *_unused, const char *psz_format, ... )
*****************************************************************************/
void msg_Err( void *_unused, const char *psz_format, ... )
{
va_list args;
char psz_fmt[MAX_MSG];
va_start( args, psz_format );
if ( i_verbose >= VERB_ERR )
{
va_list args;
char psz_fmt[MAX_MSG];
va_start( args, psz_format );
snprintf( psz_fmt, MAX_MSG, "error: %s\n", psz_format );
if ( i_syslog )
vsyslog( LOG_ERR, psz_fmt, args );
else
vfprintf( stderr, psz_fmt, args );
snprintf( psz_fmt, MAX_MSG, "error: %s\n", psz_format );
if ( i_syslog )
vsyslog( LOG_ERR, psz_fmt, args );
else
vfprintf( stderr, psz_fmt, args );
}
}
/*****************************************************************************
......
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