Commit f55287c1 authored by Georgi Chorbadzhiyski's avatar Georgi Chorbadzhiyski

demux: Add per pid information and counters.

parent 8d659bd0
......@@ -67,6 +67,11 @@ typedef struct ts_pid_t
and should be outputed in all services */
bool b_emm;
/* PID info and stats */
mtime_t i_bytes_ts;
unsigned long i_packets_passed;
ts_pid_info_t info;
/* biTStream PSI section gathering */
uint8_t *p_psi_buffer;
uint16_t i_psi_buffer_used;
......@@ -266,6 +271,24 @@ static void demux_Handle( block_t *p_ts )
return;
}
if ( i_pid != PADDING_PID )
p_pids[i_pid].info.i_scrambling = ts_get_scrambling( p_ts->p_ts );
p_pids[i_pid].info.i_last_packet_ts = i_wallclock;
p_pids[i_pid].info.i_packets++;
p_pids[i_pid].i_packets_passed++;
/* Calculate bytes_per_sec */
if ( i_wallclock > p_pids[i_pid].i_bytes_ts + 1000000 ) {
p_pids[i_pid].info.i_bytes_per_sec = p_pids[i_pid].i_packets_passed * TS_SIZE;
p_pids[i_pid].i_packets_passed = 0;
p_pids[i_pid].i_bytes_ts = i_wallclock;
}
if ( p_pids[i_pid].info.i_first_packet_ts == 0 )
p_pids[i_pid].info.i_first_packet_ts = i_wallclock;
if ( i_pid != PADDING_PID && p_pids[i_pid].i_last_cc != -1
&& !ts_check_duplicate( i_cc, p_pids[i_pid].i_last_cc )
&& ts_check_discontinuity( i_cc, p_pids[i_pid].i_last_cc ) )
......@@ -274,6 +297,8 @@ static void demux_Handle( block_t *p_ts )
uint16_t i_sid = 0;
const char *pid_desc = get_pid_desc(i_pid, &i_sid);
p_pids[i_pid].info.i_cc_errors++;
msg_Warn( NULL, "TS discontinuity on pid %4hu expected_cc %2u got %2u (%s, sid %d)",
i_pid, expected_cc, i_cc, pid_desc, i_sid );
......@@ -297,6 +322,8 @@ static void demux_Handle( block_t *p_ts )
uint16_t i_sid = 0;
const char *pid_desc = get_pid_desc(i_pid, &i_sid);
p_pids[i_pid].info.i_transport_errors++;
msg_Warn( NULL, "transport_error_indicator on pid %hu (%s, sid %u)",
i_pid, pid_desc, i_sid );
switch ( i_print_type )
......@@ -2801,3 +2828,14 @@ uint8_t *demux_get_packed_PMT( uint16_t i_sid, unsigned int *pi_pack_size ) {
}
return NULL;
}
inline void demux_get_PID_info( uint16_t i_pid, uint8_t *p_data ) {
ts_pid_info_t *p_info = (ts_pid_info_t *)p_data;
*p_info = p_pids[i_pid].info;
}
inline void demux_get_PIDS_info( uint8_t *p_data ) {
int i_pid;
for (i_pid = 0; i_pid < MAX_PIDS; i_pid++ )
demux_get_PID_info( i_pid, p_data + ( i_pid * sizeof(ts_pid_info_t) ) );
}
......@@ -132,6 +132,20 @@ typedef struct output_t
uint16_t i_tsid;
} output_t;
typedef struct ts_pid_info {
mtime_t i_first_packet_ts; /* Time of the first seen packet */
mtime_t i_last_packet_ts; /* Time of the last seen packet */
unsigned long i_packets; /* How much packets have been seen */
unsigned long i_cc_errors; /* Countinuity counter errors */
unsigned long i_transport_errors; /* Transport errors */
unsigned long i_bytes_per_sec; /* How much bytes were process last second */
uint8_t i_scrambling; /* Scrambling bits from the last ts packet */
/* 0 = Not scrambled
1 = Reserved for future use
2 = Scrambled with even key
3 = Scrambled with odd key */
} ts_pid_info_t;
extern int i_syslog;
extern int i_verbose;
extern output_t **pp_outputs;
......@@ -244,6 +258,8 @@ uint8_t *demux_get_current_packed_CAT( unsigned int *pi_pack_size );
uint8_t *demux_get_current_packed_NIT( unsigned int *pi_pack_size );
uint8_t *demux_get_current_packed_SDT( unsigned int *pi_pack_size );
uint8_t *demux_get_packed_PMT( uint16_t service_id, unsigned int *pi_pack_size );
void demux_get_PID_info( uint16_t i_pid, uint8_t *p_data );
void demux_get_PIDS_info( uint8_t *p_data );
output_t *output_Create( const output_config_t *p_config );
int output_Init( output_t *p_output, const output_config_t *p_config );
......
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