uint8_t *d = APDUGetLength( p_apdu, &l );
if ( l < 4 ) break;
- p_apdu[l + 3] = '\0';
+ p_apdu[l + 4] = '\0';
i_type = *d++;
i_manufacturer = ((int)d[0] << 8) | d[1];
SPDUSend( p_access, i_session_id, p_sys->pp_capmts[i],
i_size + (p - p_sys->pp_capmts[i]) );
}
-
- p_sys->i_ca_timeout = 100000;
+ p_sys->i_ca_next_pmt = 0;
}
break;
}
}
if ( p_sys->pb_active_slot[i_slot] )
{
- p_sys->i_ca_timeout = 1000;
+ p_sys->i_ca_timeout = 100000;
return VLC_SUCCESS;
}
}
}
+ if ( p_sys->i_ca_next_pmt && p_sys->i_ca_next_pmt <= mdate() )
+ {
+ for ( i_session_id = 1; i_session_id <= MAX_SESSIONS; i_session_id++ )
+ {
+ int i;
+
+ if ( p_sys->p_sessions[i_session_id - 1].i_resource_id
+ != RI_CONDITIONAL_ACCESS_SUPPORT )
+ continue;
+
+ msg_Dbg( p_access, "sending CAPMT on session %d", i_session_id );
+ for ( i = 0; i < p_sys->i_nb_capmts; i++ )
+ {
+ int i_size;
+ uint8_t *p;
+ p = GetLength( &p_sys->pp_capmts[i][3], &i_size );
+ SPDUSend( p_access, i_session_id, p_sys->pp_capmts[i],
+ i_size + (p - p_sys->pp_capmts[i]) );
+ }
+ }
+
+ p_sys->i_ca_next_pmt = 0;
+ }
+
return VLC_SUCCESS;
}
int i_nb_capmts )
{
access_sys_t *p_sys = p_access->p_sys;
- int i_session_id;
-
- for ( i_session_id = 1; i_session_id <= MAX_SESSIONS; i_session_id++ )
- {
- int i;
-
- if ( p_sys->p_sessions[i_session_id - 1].i_resource_id
- != RI_CONDITIONAL_ACCESS_SUPPORT )
- continue;
-
- msg_Dbg( p_access, "sending CAPMT on session %d", i_session_id );
- for ( i = 0; i < i_nb_capmts; i++ )
- {
- int i_size;
- uint8_t *p;
- p = GetLength( &pp_capmts[i][3], &i_size );
- SPDUSend( p_access, i_session_id, pp_capmts[i],
- i_size + (p - pp_capmts[i]) );
- }
-
- p_sys->i_ca_timeout = 100000;
- }
if ( p_sys->i_nb_capmts )
{
}
p_sys->pp_capmts = pp_capmts;
p_sys->i_nb_capmts = i_nb_capmts;
+ p_sys->i_ca_next_pmt = mdate() + 1000000;
return VLC_SUCCESS;
}
#define SILENT_TEXT N_("Silent mode")
#define SILENT_LONGTEXT N_("do not complain on encrypted PES")
+#define CAPMT_SYSID_TEXT N_("CAPMT System ID")
+#define CAPMT_SYSID_LONGTEXT N_("only forward descriptors from this SysID to the CAM")
+
vlc_module_begin();
set_description( _("ISO 13818-1 MPEG Transport Stream input - new" ) );
set_shortname ( _("MPEG-TS") );
MTUOUT_LONGTEXT, VLC_TRUE );
add_string( "ts-csa-ck", NULL, NULL, CSA_TEXT, CSA_LONGTEXT, VLC_TRUE );
add_bool( "ts-silent", 0, NULL, SILENT_TEXT, SILENT_LONGTEXT, VLC_TRUE );
+ add_integer( "ts-capmt-sysid", 0, NULL, CAPMT_SYSID_TEXT,
+ CAPMT_SYSID_LONGTEXT, VLC_TRUE );
set_capability( "demux2", 10 );
set_callbacks( Open, Close );
vlc_bool_t b_es_id_pid;
csa_t *csa;
vlc_bool_t b_silent;
+ uint16_t i_capmt_sysid;
vlc_bool_t b_udp_out;
int fd; /* udp socket */
var_Get( p_demux, "ts-silent", &val );
p_sys->b_silent = val.b_bool;
+ var_Create( p_demux, "ts-capmt-sysid", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+ var_Get( p_demux, "ts-capmt-sysid", &val );
+ p_sys->i_capmt_sysid = val.i_int;
+
return VLC_SUCCESS;
}
}
else if( p_dr->i_tag == 0x9 )
{
- msg_Dbg( p_demux, " * descriptor : CA (0x9)" );
- i_cad_length += p_dr->i_length + 2;
+ uint16_t i_sysid = ((uint16_t)p_dr->p_data[0] << 8)
+ | p_dr->p_data[1];
+ msg_Dbg( p_demux, " * descriptor : CA (0x9) SysID 0x%x", i_sysid );
+ if ( !p_sys->i_capmt_sysid || p_sys->i_capmt_sysid == i_sysid )
+ i_cad_length += p_dr->i_length + 2;
}
else
{
prg->p_capmt[0] = p_pmt->i_program_number >> 8;
prg->p_capmt[1] = p_pmt->i_program_number & 0xff;
- prg->p_capmt[2] = (p_pmt->i_version << 1) | 0x1;
+ prg->p_capmt[2] = ((p_pmt->i_version & 0x1f) << 1) | 0x1;
prg->p_capmt[3] = (i_cad_length + 1) >> 8;
prg->p_capmt[4] = (i_cad_length + 1) & 0xff;
prg->p_capmt[5] = 0x1; /* ok_descrambling */
{
if( p_dr->i_tag == 0x9 )
{
- prg->p_capmt[i] = 0x9;
- prg->p_capmt[i+1] = p_dr->i_length;
- memcpy( &prg->p_capmt[i+2], p_dr->p_data, p_dr->i_length );
- i += p_dr->i_length + 2;
+ uint16_t i_sysid = ((uint16_t)p_dr->p_data[0] << 8)
+ | p_dr->p_data[1];
+ if ( !p_sys->i_capmt_sysid || p_sys->i_capmt_sysid == i_sysid )
+ {
+ prg->p_capmt[i] = 0x9;
+ prg->p_capmt[i+1] = p_dr->i_length;
+ memcpy( &prg->p_capmt[i+2], p_dr->p_data, p_dr->i_length );
+ i += p_dr->i_length + 2;
+ }
}
}
}
{
if( p_dr->i_tag == 0x9 )
{
- msg_Dbg( p_demux, " * descriptor : CA (0x9)" );
- i_cad_length += p_dr->i_length + 2;
+ uint16_t i_sysid = ((uint16_t)p_dr->p_data[0] << 8)
+ | p_dr->p_data[1];
+ msg_Dbg( p_demux, " * descriptor : CA (0x9) SysID 0x%x",
+ i_sysid );
+ if ( !p_sys->i_capmt_sysid || p_sys->i_capmt_sysid == i_sysid )
+ i_cad_length += p_dr->i_length + 2;
}
else
{
prg->p_capmt[0] = p_pmt->i_program_number >> 8;
prg->p_capmt[1] = p_pmt->i_program_number & 0xff;
- prg->p_capmt[2] = (p_pmt->i_version << 1) | 0x1;
+ prg->p_capmt[2] = ((p_pmt->i_version & 0x1f) << 1) | 0x1;
prg->p_capmt[3] = 0; /* cad length */
prg->p_capmt[4] = 0;
{
if( p_dr->i_tag == 0x9 )
{
- prg->p_capmt[i] = 0x9;
- prg->p_capmt[i+1] = p_dr->i_length;
- memcpy( &prg->p_capmt[i+2], p_dr->p_data, p_dr->i_length );
- i += p_dr->i_length + 2;
+ uint16_t i_sysid = ((uint16_t)p_dr->p_data[0] << 8)
+ | p_dr->p_data[1];
+ if ( !p_sys->i_capmt_sysid
+ || p_sys->i_capmt_sysid == i_sysid )
+ {
+ prg->p_capmt[i] = 0x9;
+ prg->p_capmt[i+1] = p_dr->i_length;
+ memcpy( &prg->p_capmt[i+2], p_dr->p_data, p_dr->i_length );
+ i += p_dr->i_length + 2;
+ }
}
}
}
/* Now select PID at access level */
if( p_sys->b_dvb_control )
{
- if( p_sys->i_dvb_program <= 0 || p_sys->i_dvb_program == p_program->i_number )
+ if( DVBProgramIsSelected( p_demux, p_program->i_number ) )
{
if( p_sys->i_dvb_program == 0 )
p_sys->i_dvb_program = p_program->i_number;