Commit a2bc23f8 authored by Rémi Duraffort's avatar Rémi Duraffort

demux_ts: use var_CreateGet instead of var_Create+var_Get.

parent 925079c4
...@@ -436,8 +436,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -436,8 +436,6 @@ static int Open( vlc_object_t *p_this )
bool b_append; bool b_append;
bool b_topfield = false; bool b_topfield = false;
vlc_value_t val;
if( stream_Peek( p_demux->s, &p_peek, TS_PACKET_SIZE_MAX ) < if( stream_Peek( p_demux->s, &p_peek, TS_PACKET_SIZE_MAX ) <
TS_PACKET_SIZE_MAX ) return VLC_EGENERIC; TS_PACKET_SIZE_MAX ) return VLC_EGENERIC;
...@@ -587,9 +585,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -587,9 +585,7 @@ static int Open( vlc_object_t *p_this )
{ {
p_sys->b_file_out = true; p_sys->b_file_out = true;
var_Create( p_demux, "ts-dump-append", VLC_VAR_BOOL|VLC_VAR_DOINHERIT ); b_append = var_CreateGetBool( p_demux, "ts-dump-append" );
var_Get( p_demux, "ts-dump-append", &val );
b_append = val.b_bool;
if ( b_append ) if ( b_append )
psz_mode = "ab"; psz_mode = "ab";
else else
...@@ -608,13 +604,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -608,13 +604,9 @@ static int Open( vlc_object_t *p_this )
if( p_sys->b_file_out ) if( p_sys->b_file_out )
{ {
vlc_value_t bufsize;
/* Determine how many packets to read. */ /* Determine how many packets to read. */
var_Create( p_demux, "ts-dump-size", int bufsize = var_CreateGetInteger( p_demux, "ts-dump-size" );
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); p_sys->i_ts_read = (int) (bufsize / p_sys->i_packet_size);
var_Get( p_demux, "ts-dump-size", &bufsize );
p_sys->i_ts_read = (int) (bufsize.i_int / p_sys->i_packet_size);
if( p_sys->i_ts_read <= 0 ) if( p_sys->i_ts_read <= 0 )
{ {
p_sys->i_ts_read = 1500 / p_sys->i_packet_size; p_sys->i_ts_read = 1500 / p_sys->i_packet_size;
...@@ -691,16 +683,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -691,16 +683,12 @@ static int Open( vlc_object_t *p_this )
TAB_INIT( p_sys->i_pmt, p_sys->pmt ); TAB_INIT( p_sys->i_pmt, p_sys->pmt );
/* Read config */ /* Read config */
var_Create( p_demux, "ts-es-id-pid", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); p_sys->b_es_id_pid = var_CreateGetBool( p_demux, "ts-es-id-pid" );
var_Get( p_demux, "ts-es-id-pid", &val );
p_sys->b_es_id_pid = val.b_bool;
var_Create( p_demux, "ts-out", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); char* psz_string = var_CreateGetString( p_demux, "ts-out" );
var_Get( p_demux, "ts-out", &val ); if( psz_string && *psz_string && !p_sys->b_file_out )
if( val.psz_string && *val.psz_string && !p_sys->b_file_out )
{ {
vlc_value_t mtu; char *psz = strchr( psz_string, ':' );
char *psz = strchr( val.psz_string, ':' );
int i_port = 0; int i_port = 0;
p_sys->b_udp_out = true; p_sys->b_udp_out = true;
...@@ -711,9 +699,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -711,9 +699,9 @@ static int Open( vlc_object_t *p_this )
i_port = atoi( psz ); i_port = atoi( psz );
} }
if( i_port <= 0 ) i_port = 1234; if( i_port <= 0 ) i_port = 1234;
msg_Dbg( p_demux, "resend ts to '%s:%d'", val.psz_string, i_port ); msg_Dbg( p_demux, "resend ts to '%s:%d'", psz_string, i_port );
p_sys->fd = net_ConnectUDP( VLC_OBJECT(p_demux), val.psz_string, i_port, -1 ); p_sys->fd = net_ConnectUDP( VLC_OBJECT(p_demux), psz_string, i_port, -1 );
if( p_sys->fd < 0 ) if( p_sys->fd < 0 )
{ {
msg_Err( p_demux, "failed to open udp socket, send disabled" ); msg_Err( p_demux, "failed to open udp socket, send disabled" );
...@@ -721,10 +709,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -721,10 +709,8 @@ static int Open( vlc_object_t *p_this )
} }
else else
{ {
var_Create( p_demux, "ts-out-mtu", int i_mtu = var_CreateGetInteger( p_demux, "ts-out-mtu" );
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); p_sys->i_ts_read = i_mtu / p_sys->i_packet_size;
var_Get( p_demux, "ts-out-mtu", &mtu );
p_sys->i_ts_read = mtu.i_int / p_sys->i_packet_size;
if( p_sys->i_ts_read <= 0 ) if( p_sys->i_ts_read <= 0 )
{ {
p_sys->i_ts_read = 1500 / p_sys->i_packet_size; p_sys->i_ts_read = 1500 / p_sys->i_packet_size;
...@@ -732,38 +718,35 @@ static int Open( vlc_object_t *p_this ) ...@@ -732,38 +718,35 @@ static int Open( vlc_object_t *p_this )
p_sys->buffer = malloc( p_sys->i_packet_size * p_sys->i_ts_read ); p_sys->buffer = malloc( p_sys->i_packet_size * p_sys->i_ts_read );
} }
} }
free( val.psz_string ); free( psz_string );
/* We handle description of an extra PMT */ /* We handle description of an extra PMT */
var_Create( p_demux, "ts-extra-pmt", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); psz_string = var_CreateGetString( p_demux, "ts-extra-pmt" );
var_Get( p_demux, "ts-extra-pmt", &val );
p_sys->b_user_pmt = false; p_sys->b_user_pmt = false;
if( val.psz_string && *val.psz_string ) if( psz_string && *psz_string )
UserPmt( p_demux, val.psz_string ); UserPmt( p_demux, psz_string );
free( val.psz_string ); free( psz_string );
var_Create( p_demux, "ts-csa-ck", VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); psz_string = var_CreateGetStringCommand( p_demux, "ts-csa-ck" );
var_Get( p_demux, "ts-csa-ck", &val ); if( psz_string && *psz_string )
if( val.psz_string && *val.psz_string )
{ {
int i_res; int i_res;
vlc_value_t csa2; char* psz_csa2;
p_sys->csa = csa_New(); p_sys->csa = csa_New();
var_Create( p_demux, "ts-csa2-ck", VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND); psz_csa2 = var_CreateGetStringCommand( p_demux, "ts-csa2-ck" );
var_Get( p_demux, "ts-csa2-ck", &csa2 ); i_res = csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, psz_string, true );
i_res = csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, val.psz_string, true ); if( i_res == VLC_SUCCESS && psz_csa2 && *psz_csa2 )
if( i_res == VLC_SUCCESS && csa2.psz_string && *csa2.psz_string )
{ {
if( csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, csa2.psz_string, false ) != VLC_SUCCESS ) if( csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, psz_csa2, false ) != VLC_SUCCESS )
{ {
csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, val.psz_string, false ); csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, psz_string, false );
} }
} }
else if ( i_res == VLC_SUCCESS ) else if ( i_res == VLC_SUCCESS )
{ {
csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, val.psz_string, false ); csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, psz_string, false );
} }
else else
{ {
...@@ -773,29 +756,25 @@ static int Open( vlc_object_t *p_this ) ...@@ -773,29 +756,25 @@ static int Open( vlc_object_t *p_this )
if( p_sys->csa ) if( p_sys->csa )
{ {
vlc_value_t pkt_val;
var_AddCallback( p_demux, "ts-csa-ck", ChangeKeyCallback, (void *)1 ); var_AddCallback( p_demux, "ts-csa-ck", ChangeKeyCallback, (void *)1 );
var_AddCallback( p_demux, "ts-csa2-ck", ChangeKeyCallback, NULL ); var_AddCallback( p_demux, "ts-csa2-ck", ChangeKeyCallback, NULL );
var_Create( p_demux, "ts-csa-pkt", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); int i_pkt = var_CreateGetInteger( p_demux, "ts-csa-pkt" );
var_Get( p_demux, "ts-csa-pkt", &pkt_val ); if( i_pkt < 4 || i_pkt > 188 )
if( pkt_val.i_int < 4 || pkt_val.i_int > 188 )
{ {
msg_Err( p_demux, "wrong packet size %d specified.", pkt_val.i_int ); msg_Err( p_demux, "wrong packet size %d specified.", i_pkt );
msg_Warn( p_demux, "using default packet size of 188 bytes" ); msg_Warn( p_demux, "using default packet size of 188 bytes" );
p_sys->i_csa_pkt_size = 188; p_sys->i_csa_pkt_size = 188;
} }
else p_sys->i_csa_pkt_size = pkt_val.i_int; else
p_sys->i_csa_pkt_size = i_pkt;
msg_Dbg( p_demux, "decrypting %d bytes of packet", p_sys->i_csa_pkt_size ); msg_Dbg( p_demux, "decrypting %d bytes of packet", p_sys->i_csa_pkt_size );
} }
free( csa2.psz_string ); free( psz_csa2 );
} }
free( val.psz_string ); free( psz_string );
var_Create( p_demux, "ts-silent", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); p_sys->b_silent = var_CreateGetBool( p_demux, "ts-silent" );
var_Get( p_demux, "ts-silent", &val );
p_sys->b_silent = val.b_bool;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
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