Commit e3e4ade7 authored by Christophe Massiot's avatar Christophe Massiot

* dvblast.c, output.c: New /ttl= output option. * demux.c: Miscellaneous cosmetics.

parent ca44fe14
...@@ -119,6 +119,7 @@ Available options include : ...@@ -119,6 +119,7 @@ Available options include :
/tsid=XXX (sets the transport stream ID) /tsid=XXX (sets the transport stream ID)
/retention=XXX (see -E) /retention=XXX (see -E)
/latency=XXX (see -L) /latency=XXX (see -L)
/ttl=XX (see -t)
Several options can be appended, for instance: Several options can be appended, for instance:
239.255.0.1:1234/udp/epg/tsid=42 239.255.0.1:1234/udp/epg/tsid=42
......
...@@ -1445,14 +1445,13 @@ static void HandlePAT( mtime_t i_dts ) ...@@ -1445,14 +1445,13 @@ static void HandlePAT( mtime_t i_dts )
const uint8_t *p_old_program = NULL; const uint8_t *p_old_program = NULL;
uint16_t i_sid = patn_get_program( p_program ); uint16_t i_sid = patn_get_program( p_program );
uint16_t i_pid = patn_get_pid( p_program ); uint16_t i_pid = patn_get_pid( p_program );
int i_pmt;
j++; j++;
if ( i_sid == 0 ) if ( i_sid == 0 )
{ {
if ( i_pid != NIT_PID ) if ( i_pid != NIT_PID )
msg_Warn( NULL, msg_Warn( NULL,
"NIT is carried on PID %u which isn't DVB compliant", "NIT is carried on PID %hu which isn't DVB compliant",
i_pid ); i_pid );
continue; /* NIT */ continue; /* NIT */
} }
...@@ -1463,6 +1462,7 @@ static void HandlePAT( mtime_t i_dts ) ...@@ -1463,6 +1462,7 @@ static void HandlePAT( mtime_t i_dts )
|| patn_get_pid( p_old_program ) != i_pid || patn_get_pid( p_old_program ) != i_pid
|| b_change ) || b_change )
{ {
int i_pmt;
b_display = true; b_display = true;
if ( p_old_program != NULL ) if ( p_old_program != NULL )
...@@ -1538,7 +1538,7 @@ static void HandlePATSection( uint16_t i_pid, uint8_t *p_section, ...@@ -1538,7 +1538,7 @@ static void HandlePATSection( uint16_t i_pid, uint8_t *p_section,
{ {
if ( i_pid != PAT_PID || !pat_validate( p_section ) ) if ( i_pid != PAT_PID || !pat_validate( p_section ) )
{ {
msg_Warn( NULL, "invalid PAT section received on PID %u", i_pid ); msg_Warn( NULL, "invalid PAT section received on PID %hu", i_pid );
free( p_section ); free( p_section );
return; return;
} }
...@@ -1578,7 +1578,7 @@ static void HandlePMT( uint16_t i_pid, uint8_t *p_pmt, mtime_t i_dts ) ...@@ -1578,7 +1578,7 @@ static void HandlePMT( uint16_t i_pid, uint8_t *p_pmt, mtime_t i_dts )
if ( i_pid != p_sid->i_pmt_pid ) if ( i_pid != p_sid->i_pmt_pid )
{ {
msg_Warn( NULL, "invalid PMT section received on PID %u", i_pid ); msg_Warn( NULL, "invalid PMT section received on PID %hu", i_pid );
free( p_pmt ); free( p_pmt );
return; return;
} }
...@@ -1593,7 +1593,7 @@ static void HandlePMT( uint16_t i_pid, uint8_t *p_pmt, mtime_t i_dts ) ...@@ -1593,7 +1593,7 @@ static void HandlePMT( uint16_t i_pid, uint8_t *p_pmt, mtime_t i_dts )
if ( !pmt_validate( p_pmt ) ) if ( !pmt_validate( p_pmt ) )
{ {
msg_Warn( NULL, "invalid PMT section received on PID %u", i_pid ); msg_Warn( NULL, "invalid PMT section received on PID %hu", i_pid );
free( p_pmt ); free( p_pmt );
goto out_pmt; goto out_pmt;
} }
...@@ -1733,12 +1733,15 @@ out_nit: ...@@ -1733,12 +1733,15 @@ out_nit:
; ;
} }
/*****************************************************************************
* HandleNITSection
*****************************************************************************/
static void HandleNITSection( uint16_t i_pid, uint8_t *p_section, static void HandleNITSection( uint16_t i_pid, uint8_t *p_section,
mtime_t i_dts ) mtime_t i_dts )
{ {
if ( i_pid != NIT_PID || !nit_validate( p_section ) ) if ( i_pid != NIT_PID || !nit_validate( p_section ) )
{ {
msg_Warn( NULL, "invalid NIT section received on PID %u", i_pid ); msg_Warn( NULL, "invalid NIT section received on PID %hu", i_pid );
free( p_section ); free( p_section );
return; return;
} }
...@@ -1767,7 +1770,7 @@ static void HandleSDT( mtime_t i_dts ) ...@@ -1767,7 +1770,7 @@ static void HandleSDT( mtime_t i_dts )
if ( psi_table_validate( pp_current_sdt_sections ) && if ( psi_table_validate( pp_current_sdt_sections ) &&
psi_table_compare( pp_current_sdt_sections, pp_next_sdt_sections ) ) psi_table_compare( pp_current_sdt_sections, pp_next_sdt_sections ) )
{ {
/* Identical sdt. Shortcut. */ /* Identical SDT. Shortcut. */
psi_table_free( pp_next_sdt_sections ); psi_table_free( pp_next_sdt_sections );
psi_table_init( pp_next_sdt_sections ); psi_table_init( pp_next_sdt_sections );
goto out_sdt; goto out_sdt;
...@@ -1853,7 +1856,7 @@ static void HandleSDTSection( uint16_t i_pid, uint8_t *p_section, ...@@ -1853,7 +1856,7 @@ static void HandleSDTSection( uint16_t i_pid, uint8_t *p_section,
{ {
if ( i_pid != SDT_PID || !sdt_validate( p_section ) ) if ( i_pid != SDT_PID || !sdt_validate( p_section ) )
{ {
msg_Warn( NULL, "invalid SDT section received on PID %u", i_pid ); msg_Warn( NULL, "invalid SDT section received on PID %hu", i_pid );
free( p_section ); free( p_section );
return; return;
} }
...@@ -1887,7 +1890,7 @@ static void HandleEIT( uint16_t i_pid, uint8_t *p_eit, mtime_t i_dts ) ...@@ -1887,7 +1890,7 @@ static void HandleEIT( uint16_t i_pid, uint8_t *p_eit, mtime_t i_dts )
if ( i_pid != EIT_PID || !eit_validate( p_eit ) ) if ( i_pid != EIT_PID || !eit_validate( p_eit ) )
{ {
msg_Warn( NULL, "invalid EIT section received on PID %u", i_pid ); msg_Warn( NULL, "invalid EIT section received on PID %hu", i_pid );
free( p_eit ); free( p_eit );
return; return;
} }
...@@ -1905,7 +1908,7 @@ static void HandleSection( uint16_t i_pid, uint8_t *p_section, mtime_t i_dts ) ...@@ -1905,7 +1908,7 @@ static void HandleSection( uint16_t i_pid, uint8_t *p_section, mtime_t i_dts )
if ( !psi_validate( p_section ) ) if ( !psi_validate( p_section ) )
{ {
msg_Warn( NULL, "invalid section on PID %u", i_pid ); msg_Warn( NULL, "invalid section on PID %hu", i_pid );
free( p_section ); free( p_section );
return; return;
} }
......
...@@ -48,7 +48,6 @@ int i_nb_outputs = 0; ...@@ -48,7 +48,6 @@ int i_nb_outputs = 0;
output_t output_dup = { 0 }; output_t output_dup = { 0 };
static char *psz_conf_file = NULL; static char *psz_conf_file = NULL;
char *psz_srv_socket = NULL; char *psz_srv_socket = NULL;
int i_ttl = 64;
in_addr_t i_ssrc = 0; in_addr_t i_ssrc = 0;
static int i_priority = -1; static int i_priority = -1;
int i_adapter = 0; int i_adapter = 0;
...@@ -79,6 +78,7 @@ static int b_dvb_global = 0; ...@@ -79,6 +78,7 @@ static int b_dvb_global = 0;
static int b_epg_global = 0; static int b_epg_global = 0;
static mtime_t i_latency_global = DEFAULT_OUTPUT_LATENCY; static mtime_t i_latency_global = DEFAULT_OUTPUT_LATENCY;
static mtime_t i_retention_global = DEFAULT_MAX_RETENTION; static mtime_t i_retention_global = DEFAULT_MAX_RETENTION;
static int i_ttl_global = 64;
void (*pf_Open)( void ) = NULL; void (*pf_Open)( void ) = NULL;
block_t * (*pf_Read)( mtime_t i_poll_timeout ) = NULL; block_t * (*pf_Read)( mtime_t i_poll_timeout ) = NULL;
...@@ -123,6 +123,7 @@ static void ReadConfiguration( char *psz_file ) ...@@ -123,6 +123,7 @@ static void ReadConfiguration( char *psz_file )
mtime_t i_retention = i_retention_global; mtime_t i_retention = i_retention_global;
mtime_t i_latency = i_latency_global; mtime_t i_latency = i_latency_global;
int i_tsid = -1; int i_tsid = -1;
int i_ttl = i_ttl_global;
snprintf( sz_port, sizeof( sz_port ), "%d", DEFAULT_PORT ); snprintf( sz_port, sizeof( sz_port ), "%d", DEFAULT_PORT );
...@@ -149,6 +150,8 @@ static void ReadConfiguration( char *psz_file ) ...@@ -149,6 +150,8 @@ static void ReadConfiguration( char *psz_file )
i_retention = strtoll( psz_token2 + 10, NULL, 0 ) * 1000; i_retention = strtoll( psz_token2 + 10, NULL, 0 ) * 1000;
else if ( !strncasecmp( psz_token2, "latency=", 8 ) ) else if ( !strncasecmp( psz_token2, "latency=", 8 ) )
i_latency = strtoll( psz_token2 + 8, NULL, 0 ) * 1000; i_latency = strtoll( psz_token2 + 8, NULL, 0 ) * 1000;
else if ( !strncasecmp( psz_token2, "ttl=", 4 ) )
i_ttl = strtol( psz_token2 + 4, NULL, 0 );
else else
msg_Warn( NULL, "unrecognized option %s", psz_token2 ); msg_Warn( NULL, "unrecognized option %s", psz_token2 );
} }
...@@ -246,8 +249,9 @@ static void ReadConfiguration( char *psz_file ) ...@@ -246,8 +249,9 @@ static void ReadConfiguration( char *psz_file )
} }
} }
msg_Dbg( NULL, "conf: %s config=0x%x sid=%d pids[%d]=%d,%d,%d,%d,%d...", msg_Dbg( NULL,
psz_displayname, i_config, i_sid, i_nb_pids, "conf: %s config=0x%x ttl=%d sid=%d pids[%d]=%d,%d,%d,%d,%d...",
psz_displayname, i_config, i_ttl, i_sid, i_nb_pids,
i_nb_pids < 1 ? -1 : pi_pids[0], i_nb_pids < 1 ? -1 : pi_pids[0],
i_nb_pids < 2 ? -1 : pi_pids[1], i_nb_pids < 2 ? -1 : pi_pids[1],
i_nb_pids < 3 ? -1 : pi_pids[2], i_nb_pids < 3 ? -1 : pi_pids[2],
...@@ -294,6 +298,8 @@ static void ReadConfiguration( char *psz_file ) ...@@ -294,6 +298,8 @@ static void ReadConfiguration( char *psz_file )
p_output->i_output_latency = i_latency; p_output->i_output_latency = i_latency;
p_output->i_max_retention = i_retention; p_output->i_max_retention = i_retention;
demux_Change( p_output, i_tsid, i_sid, pi_pids, i_nb_pids ); demux_Change( p_output, i_tsid, i_sid, pi_pids, i_nb_pids );
if ( p_output->i_ttl != i_ttl )
output_SetTTL( p_output, i_ttl );
} }
free( psz_displayname ); free( psz_displayname );
...@@ -479,7 +485,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -479,7 +485,7 @@ int main( int i_argc, char **pp_argv )
break; break;
case 't': case 't':
i_ttl = strtol( optarg, NULL, 0 ); i_ttl_global = strtol( optarg, NULL, 0 );
break; break;
case 'o': case 'o':
......
...@@ -119,7 +119,6 @@ extern output_t **pp_outputs; ...@@ -119,7 +119,6 @@ extern output_t **pp_outputs;
extern int i_nb_outputs; extern int i_nb_outputs;
extern output_t output_dup; extern output_t output_dup;
extern char *psz_srv_socket; extern char *psz_srv_socket;
extern int i_ttl;
extern in_addr_t i_ssrc; extern in_addr_t i_ssrc;
extern int i_adapter; extern int i_adapter;
extern int i_fenum; extern int i_fenum;
...@@ -199,6 +198,7 @@ int output_Init( output_t *p_output, const char *psz_displayname, ...@@ -199,6 +198,7 @@ int output_Init( output_t *p_output, const char *psz_displayname,
void output_Close( output_t *p_output ); void output_Close( output_t *p_output );
void output_Put( output_t *p_output, block_t *p_block ); void output_Put( output_t *p_output, block_t *p_block );
mtime_t output_Send( void ); mtime_t output_Send( void );
void output_SetTTL( output_t *p_output, int i_ttl );
void comm_Open( void ); void comm_Open( void );
void comm_Read( void ); void comm_Read( void );
......
...@@ -148,6 +148,7 @@ int output_Init( output_t *p_output, const char *psz_displayname, ...@@ -148,6 +148,7 @@ int output_Init( output_t *p_output, const char *psz_displayname,
p_output->i_ref_wallclock = 0; p_output->i_ref_wallclock = 0;
p_output->i_config = 0; p_output->i_config = 0;
p_output->i_ttl = 0;
p_output->psz_displayname = strdup( psz_displayname ); p_output->psz_displayname = strdup( psz_displayname );
p_output->i_addrlen = p_ai->ai_addrlen; p_output->i_addrlen = p_ai->ai_addrlen;
...@@ -336,38 +337,39 @@ mtime_t output_Send( void ) ...@@ -336,38 +337,39 @@ mtime_t output_Send( void )
} }
/***************************************************************************** /*****************************************************************************
* net_Open * output_SetTTL : set the TTL of an output socket
*****************************************************************************/ *****************************************************************************/
static int net_Open( output_t *p_output ) void output_SetTTL( output_t *p_output, int i_ttl )
{ {
int i_handle = socket( p_output->p_addr->ss_family, SOCK_DGRAM, IPPROTO_UDP );
if ( i_handle < 0 )
{
msg_Err( NULL, "couldn't create socket for %s (%s)",
p_output->psz_displayname, strerror(errno) );
return -errno;
}
if ( p_output->p_addr->ss_family == AF_INET6 ) if ( p_output->p_addr->ss_family == AF_INET6 )
{ {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)p_output->p_addr; struct sockaddr_in6 *addr = (struct sockaddr_in6 *)p_output->p_addr;
if ( IN6_IS_ADDR_MULTICAST( addr->sin6_addr.s6_addr ) ) if ( IN6_IS_ADDR_MULTICAST( addr->sin6_addr.s6_addr ) )
{ setsockopt( p_output->i_handle, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
int i = i_ttl; (void *)&i_ttl, sizeof(i_ttl) );
setsockopt( i_handle, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(void *)&i, sizeof(i) );
}
} }
else if ( p_output->p_addr->ss_family == AF_INET ) else if ( p_output->p_addr->ss_family == AF_INET )
{ {
struct sockaddr_in *addr = (struct sockaddr_in *)p_output->p_addr; struct sockaddr_in *addr = (struct sockaddr_in *)p_output->p_addr;
if ( IN_MULTICAST( ntohl( addr->sin_addr.s_addr ) ) ) if ( IN_MULTICAST( ntohl( addr->sin_addr.s_addr ) ) )
{ setsockopt( p_output->i_handle, IPPROTO_IP, IP_MULTICAST_TTL,
int i = i_ttl; (void *)&i_ttl, sizeof(i_ttl) );
setsockopt( i_handle, IPPROTO_IP, IP_MULTICAST_TTL,
(void *)&i, sizeof(i) );
} }
p_output->i_ttl = i_ttl;
}
/*****************************************************************************
* net_Open
*****************************************************************************/
static int net_Open( output_t *p_output )
{
int i_handle = socket( p_output->p_addr->ss_family, SOCK_DGRAM, IPPROTO_UDP );
if ( i_handle < 0 )
{
msg_Err( NULL, "couldn't create socket for %s (%s)",
p_output->psz_displayname, strerror(errno) );
return -errno;
} }
if ( connect( i_handle, (struct sockaddr *)p_output->p_addr, if ( connect( i_handle, (struct sockaddr *)p_output->p_addr,
......
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