Commit 744985a0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

mpeg: prepare for void *p_sys

parent 9abc61b8
......@@ -391,8 +391,9 @@ static inline void demux_UpdateTitleFromStream( demux_t *demux,
}
}
# define demux_UpdateTitleFromStream(demux) \
demux_UpdateTitleFromStream(demux, &(demux)->p_sys->current_title, \
&(demux)->p_sys->current_seekpoint)
demux_UpdateTitleFromStream(demux, \
&((demux_sys_t *)((demux)->p_sys))->current_title, \
&((demux_sys_t *)((demux)->p_sys))->current_seekpoint)
#endif
VLC_USED
......
......@@ -700,7 +700,7 @@ static int Demux( demux_t *p_demux )
{
msg_Dbg( p_demux, "Creating delayed ES" );
AddAndCreateES( p_demux, p_pid, true );
UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
UpdatePESFilters( p_demux, p_sys->seltype == PROGRAM_ALL );
}
/* Emulate HW filter */
......@@ -1101,7 +1101,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
i_int = va_arg( args, int );
msg_Dbg( p_demux, "DEMUX_SET_ES %d", i_int );
if( p_demux->p_sys->seltype != PROGRAM_ALL ) /* Won't change anything */
if( p_sys->seltype != PROGRAM_ALL ) /* Won't change anything */
UpdatePESFilters( p_demux, false );
return VLC_SUCCESS;
......@@ -2366,6 +2366,8 @@ int FindPCRCandidate( ts_pmt_t *p_pmt )
/* Tries to reselect a new PCR when none has been received */
static void PCRFixHandle( demux_t *p_demux, ts_pmt_t *p_pmt, block_t *p_block )
{
demux_sys_t *p_sys = p_demux->p_sys;
if ( p_pmt->pcr.b_disable || p_pmt->pcr.b_fix_done )
{
return;
......@@ -2378,15 +2380,15 @@ static void PCRFixHandle( demux_t *p_demux, ts_pmt_t *p_pmt, block_t *p_block )
else if( p_block->i_dts - p_pmt->pcr.i_first_dts > CLOCK_FREQ / 2 ) /* "PCR repeat rate shall not exceed 100ms" */
{
if( p_pmt->pcr.i_current < 0 &&
GetPID( p_demux->p_sys, p_pmt->i_pid_pcr )->probed.i_pcr_count == 0 )
GetPID( p_sys, p_pmt->i_pid_pcr )->probed.i_pcr_count == 0 )
{
int i_cand = FindPCRCandidate( p_pmt );
p_pmt->i_pid_pcr = i_cand;
if ( GetPID( p_demux->p_sys, p_pmt->i_pid_pcr )->probed.i_pcr_count == 0 )
if ( GetPID( p_sys, p_pmt->i_pid_pcr )->probed.i_pcr_count == 0 )
p_pmt->pcr.b_disable = true;
msg_Warn( p_demux, "No PCR received for program %d, set up workaround using pid %d",
p_pmt->i_number, i_cand );
UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
UpdatePESFilters( p_demux, p_sys->seltype == PROGRAM_ALL );
}
p_pmt->pcr.b_fix_done = true;
}
......@@ -2394,6 +2396,7 @@ static void PCRFixHandle( demux_t *p_demux, ts_pmt_t *p_pmt, block_t *p_block )
static block_t * ProcessTSPacket( demux_t *p_demux, ts_pid_t *pid, block_t *p_pkt, int *pi_skip )
{
demux_sys_t *p_sys = p_demux->p_sys;
const uint8_t *p = p_pkt->p_buffer;
const bool b_adaptation = p[3]&0x20;
const bool b_payload = p[3]&0x10;
......@@ -2423,11 +2426,11 @@ static block_t * ProcessTSPacket( demux_t *p_demux, ts_pid_t *pid, block_t *p_pk
if( b_scrambled )
{
if( p_demux->p_sys->csa )
if( p_sys->csa )
{
vlc_mutex_lock( &p_demux->p_sys->csa_lock );
csa_Decrypt( p_demux->p_sys->csa, p_pkt->p_buffer, p_demux->p_sys->i_csa_pkt_size );
vlc_mutex_unlock( &p_demux->p_sys->csa_lock );
vlc_mutex_lock( &p_sys->csa_lock );
csa_Decrypt( p_sys->csa, p_pkt->p_buffer, p_sys->i_csa_pkt_size );
vlc_mutex_unlock( &p_sys->csa_lock );
}
else
p_pkt->i_flags |= BLOCK_FLAG_SCRAMBLED;
......@@ -2588,6 +2591,7 @@ static bool MayHaveStartCodeOnEnd( const uint8_t *p_buf, size_t i_buf )
static bool GatherPESData( demux_t *p_demux, ts_pid_t *pid, block_t *p_pkt, size_t i_skip )
{
demux_sys_t *p_sys = p_demux->p_sys;
const bool b_unit_start = p_pkt->p_buffer[1]&0x40;
bool b_ret = false;
ts_stream_t *p_pes = pid->u.p_stream;
......@@ -2609,7 +2613,7 @@ static bool GatherPESData( demux_t *p_demux, ts_pid_t *pid, block_t *p_pkt, size
}
/* We'll cannot parse any pes data */
if( (p_pkt->i_flags & BLOCK_FLAG_SCRAMBLED) && p_demux->p_sys->b_valid_scrambling )
if( (p_pkt->i_flags & BLOCK_FLAG_SCRAMBLED) && p_sys->b_valid_scrambling )
{
block_Release( p_pkt );
return PushPESBlock( p_demux, pid, NULL, true );
......
......@@ -411,8 +411,10 @@ static ts_standards_e ProbePMTStandard( const dvbpsi_pmt_t *p_dvbpsipmt )
static void SetupAudioExtendedDescriptors( demux_t *p_demux, ts_es_t *p_es,
const dvbpsi_pmt_es_t *p_dvbpsies )
{
if( p_demux->p_sys->standard == TS_STANDARD_AUTO ||
p_demux->p_sys->standard == TS_STANDARD_DVB )
demux_sys_t *p_sys = p_demux->p_sys;
if( p_sys->standard == TS_STANDARD_AUTO ||
p_sys->standard == TS_STANDARD_DVB )
{
const dvbpsi_descriptor_t *p_dr = PMTEsFindDescriptor( p_dvbpsies, 0x7F );
if( p_dr && p_dr->i_length > 1 && p_dr->p_data[0] == 0x06 /* Tag extension */ )
......@@ -613,6 +615,7 @@ static const char *const ppsz_teletext_type[] = {
static void PMTSetupEsTeletext( demux_t *p_demux, ts_stream_t *p_pes,
const dvbpsi_pmt_es_t *p_dvbpsies )
{
demux_sys_t *p_sys = p_demux->p_sys;
es_format_t *p_fmt = &p_pes->p_es->fmt;
ts_teletext_page_t p_page[2 * 64 + 20];
......@@ -684,7 +687,7 @@ static void PMTSetupEsTeletext( demux_t *p_demux, ts_stream_t *p_pes,
/* */
es_format_Change(p_fmt, SPU_ES, VLC_CODEC_TELETEXT );
if( !p_demux->p_sys->b_split_es || i_page <= 0 )
if( !p_sys->b_split_es || i_page <= 0 )
{
p_fmt->subs.teletext.i_magazine = -1;
p_fmt->subs.teletext.i_page = 0;
......@@ -694,7 +697,7 @@ static void PMTSetupEsTeletext( demux_t *p_demux, ts_stream_t *p_pes,
if( !p_dr )
p_dr = PMTEsFindDescriptor( p_dvbpsies, 0x56 );
if( !p_demux->p_sys->b_split_es && p_dr && p_dr->i_length > 0 )
if( !p_sys->b_split_es && p_dr && p_dr->i_length > 0 )
{
/* Descriptor pass-through */
p_fmt->p_extra = malloc( p_dr->i_length );
......@@ -750,6 +753,7 @@ static void PMTSetupEsTeletext( demux_t *p_demux, ts_stream_t *p_pes,
static void PMTSetupEsDvbSubtitle( demux_t *p_demux, ts_stream_t *p_pes,
const dvbpsi_pmt_es_t *p_dvbpsies )
{
demux_sys_t *p_sys = p_demux->p_sys;
es_format_t *p_fmt = &p_pes->p_es->fmt;
es_format_Change( p_fmt, SPU_ES, VLC_CODEC_DVBS );
......@@ -765,12 +769,12 @@ static void PMTSetupEsDvbSubtitle( demux_t *p_demux, ts_stream_t *p_pes,
i_page++;
}
if( !p_demux->p_sys->b_split_es || i_page <= 0 )
if( !p_sys->b_split_es || i_page <= 0 )
{
p_fmt->subs.dvb.i_id = -1;
p_fmt->psz_description = strdup( _("DVB subtitles") );
if( !p_demux->p_sys->b_split_es && p_dr && p_dr->i_length > 0 )
if( !p_sys->b_split_es && p_dr && p_dr->i_length > 0 )
{
/* Descriptor pass-through */
p_fmt->p_extra = malloc( p_dr->i_length );
......@@ -1006,9 +1010,11 @@ static void PMTSetupEs0x02( ts_es_t *p_es,
static void PMTSetupEs0x05PrivateData( demux_t *p_demux, ts_es_t *p_es,
const dvbpsi_pmt_es_t *p_dvbpsies )
{
demux_sys_t *p_sys = p_demux->p_sys;
VLC_UNUSED(p_es);
if( p_demux->p_sys->standard == TS_STANDARD_DVB ||
p_demux->p_sys->standard == TS_STANDARD_AUTO )
if( p_sys->standard == TS_STANDARD_DVB ||
p_sys->standard == TS_STANDARD_AUTO )
{
dvbpsi_descriptor_t *p_ait_dr = PMTEsFindDescriptor( p_dvbpsies, 0x6F );
if( p_ait_dr )
......@@ -1027,6 +1033,7 @@ static void PMTSetupEs0x05PrivateData( demux_t *p_demux, ts_es_t *p_es,
static void PMTSetupEs0x06( demux_t *p_demux, ts_stream_t *p_pes,
const dvbpsi_pmt_es_t *p_dvbpsies )
{
demux_sys_t *p_sys = p_demux->p_sys;
es_format_t *p_fmt = &p_pes->p_es->fmt;
dvbpsi_descriptor_t *p_subs_dr = PMTEsFindDescriptor( p_dvbpsies, 0x59 );
dvbpsi_descriptor_t *desc;
......@@ -1067,7 +1074,7 @@ static void PMTSetupEs0x06( demux_t *p_demux, ts_stream_t *p_pes,
{
es_format_Change( p_fmt, VIDEO_ES, VLC_CODEC_HEVC );
}
else if ( p_demux->p_sys->standard == TS_STANDARD_ARIB )
else if( p_sys->standard == TS_STANDARD_ARIB )
{
/* Lookup our data component descriptor first ARIB STD B10 6.4 */
dvbpsi_descriptor_t *p_dr = PMTEsFindDescriptor( p_dvbpsies, 0xFD );
......@@ -1480,6 +1487,7 @@ static void FillPESFromDvbpsiES( demux_t *p_demux,
const ts_pmt_t *p_pmt,
ts_stream_t *p_pes )
{
demux_sys_t *p_sys = p_demux->p_sys;
ts_transport_type_t type_change = TS_TRANSPORT_PES;
PIDFillFormat( p_demux, p_pes, p_dvbpsies->i_type, &type_change );
......@@ -1579,7 +1587,7 @@ static void FillPESFromDvbpsiES( demux_t *p_demux,
/* Set Groups / ID */
p_pes->p_es->fmt.i_group = p_dvbpsipmt->i_program_number;
if( p_demux->p_sys->b_es_id_pid )
if( p_sys->b_es_id_pid )
p_pes->p_es->fmt.i_id = p_dvbpsies->i_pid;
}
......@@ -1980,7 +1988,7 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
p_pmt->i_number, i_cand );
}
UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
UpdatePESFilters( p_demux, p_sys->seltype == PROGRAM_ALL );
/* Probe Boundaries */
if( p_sys->b_canfastseek && p_pmt->i_last_dts == -1 )
......
......@@ -422,7 +422,8 @@ static void ATSC_EIT_Callback( void *p_pid, dvbpsi_atsc_eit_t* p_eit )
}
demux_t *p_demux = (demux_t *) p_eit_pid->u.p_psip->handle->p_sys;
ts_pid_t *p_base_pid = GetPID(p_demux->p_sys, ATSC_BASE_PID);
demux_sys_t *p_sys = p_demux->p_sys;
ts_pid_t *p_base_pid = GetPID(p_sys, ATSC_BASE_PID);
ts_psip_t *p_basepsip = p_base_pid->u.p_psip;
ts_psip_context_t *p_basectx = p_basepsip->p_ctx;
......@@ -441,7 +442,7 @@ static void ATSC_EIT_Callback( void *p_pid, dvbpsi_atsc_eit_t* p_eit )
return;
}
const ts_pid_t *pid_sibling_ett = ATSC_GetSiblingxTTPID( &p_demux->p_sys->pids, p_basectx->p_mgt,
const ts_pid_t *pid_sibling_ett = ATSC_GetSiblingxTTPID( &p_sys->pids, p_basectx->p_mgt,
p_eit_pid->u.p_psip );
/* Get System Time for finding and setting current event */
......@@ -492,7 +493,7 @@ static void ATSC_EIT_Callback( void *p_pid, dvbpsi_atsc_eit_t* p_eit )
if( p_epg->b_present && i_current_event_start_time )
{
vlc_epg_SetCurrent( p_epg, i_current_event_start_time );
ts_pat_t *p_pat = ts_pid_Get(&p_demux->p_sys->pids, 0)->u.p_pat;
ts_pat_t *p_pat = ts_pid_Get(&p_sys->pids, 0)->u.p_pat;
ts_pmt_t *p_pmt = ts_pat_Get_pmt(p_pat, i_program_number);
if(p_pmt)
{
......@@ -520,7 +521,8 @@ static void ATSC_ETT_Callback( void *p_pid, dvbpsi_atsc_ett_t *p_ett )
}
demux_t *p_demux = (demux_t *) p_ett_pid->u.p_psip->handle->p_sys;
ts_pid_t *p_base_pid = GetPID(p_demux->p_sys, ATSC_BASE_PID);
demux_sys_t *p_sys = p_demux->p_sys;
ts_pid_t *p_base_pid = GetPID(p_sys, ATSC_BASE_PID);
ts_psip_t *p_basepsip = p_base_pid->u.p_psip;
ts_psip_context_t *p_basectx = p_basepsip->p_ctx;
......@@ -541,8 +543,8 @@ static void ATSC_ETT_Callback( void *p_pid, dvbpsi_atsc_ett_t *p_ett )
/* If ETT with that version isn't already in list (inserted when matched eit is present) */
if( ATSC_ETTFindByETMId( p_ctx, p_ett->i_etm_id, p_ett->i_version ) == NULL )
{
const dvbpsi_atsc_mgt_t *p_mgt = ts_pid_Get( &p_demux->p_sys->pids, ATSC_BASE_PID )->u.p_psip->p_ctx->p_mgt;
ts_pid_t *p_sibling_eit = ATSC_GetSiblingxTTPID( &p_demux->p_sys->pids, p_mgt, p_ett_pid->u.p_psip );
const dvbpsi_atsc_mgt_t *p_mgt = ts_pid_Get( &p_sys->pids, ATSC_BASE_PID )->u.p_psip->p_ctx->p_mgt;
ts_pid_t *p_sibling_eit = ATSC_GetSiblingxTTPID( &p_sys->pids, p_mgt, p_ett_pid->u.p_psip );
if( p_sibling_eit )
{
const dvbpsi_atsc_eit_event_t *p_event =
......@@ -672,6 +674,7 @@ static void ATSC_MGT_Callback( void *p_cb_basepid, dvbpsi_atsc_mgt_t* p_mgt )
}
ts_psip_t *p_mgtpsip = p_base_pid->u.p_psip;
demux_t *p_demux = (demux_t *) p_mgtpsip->handle->p_sys;
demux_sys_t *p_sys = p_demux->p_sys;
if( ( p_mgtpsip->i_version != -1 && p_mgtpsip->i_version == p_mgt->i_version ) ||
p_mgt->b_current_next == 0 )
......@@ -723,7 +726,7 @@ static void ATSC_MGT_Callback( void *p_cb_basepid, dvbpsi_atsc_mgt_t* p_mgt )
? ATSC_CVCT_TABLE_ID
: ATSC_TVCT_TABLE_ID;
if( !ATSC_ATTACH( p_mgtpsip->handle, VCT, i_table_id,
GetPID(p_demux->p_sys, 0)->u.p_pat->i_ts_id, p_base_pid ) )
GetPID(p_sys, 0)->u.p_pat->i_ts_id, p_base_pid ) )
msg_Dbg( p_demux, " * pid=%d listening for ATSC VCT", p_base_pid->i_pid );
}
else if( p_tab->i_table_type >= ATSC_TABLE_TYPE_EIT_0 &&
......@@ -731,7 +734,7 @@ static void ATSC_MGT_Callback( void *p_cb_basepid, dvbpsi_atsc_mgt_t* p_mgt )
p_tab->i_table_type <= ATSC_TABLE_TYPE_EIT_127 &&
p_tab->i_table_type_pid != p_base_pid->i_pid )
{
ts_pid_t *pid = GetPID(p_demux->p_sys, p_tab->i_table_type_pid);
ts_pid_t *pid = GetPID(p_sys, p_tab->i_table_type_pid);
if( PIDSetup( p_demux, TYPE_PSIP, pid, NULL ) )
{
SetPIDFilter( p_demux->p_sys, pid, true );
......@@ -746,10 +749,10 @@ static void ATSC_MGT_Callback( void *p_cb_basepid, dvbpsi_atsc_mgt_t* p_mgt )
p_tab->i_table_type <= ATSC_TABLE_TYPE_ETT_127 &&
p_tab->i_table_type_pid != p_base_pid->i_pid )
{
ts_pid_t *pid = GetPID(p_demux->p_sys, p_tab->i_table_type_pid);
ts_pid_t *pid = GetPID(p_sys, p_tab->i_table_type_pid);
if( PIDSetup( p_demux, TYPE_PSIP, pid, NULL ) )
{
SetPIDFilter( p_demux->p_sys, pid, true );
SetPIDFilter( p_sys, pid, true );
pid->u.p_psip->p_ctx->i_tabletype = p_tab->i_table_type;
ATSC_Ready_SubDecoders( pid->u.p_psip->handle, pid );
msg_Dbg( p_demux, " * pid=%d reserved for ATSC ETT", pid->i_pid );
......@@ -779,6 +782,7 @@ static void ATSC_STT_Callback( void *p_cb_basepid, dvbpsi_atsc_stt_t* p_stt )
return;
}
demux_t *p_demux = (demux_t *) p_base_pid->u.p_psip->handle->p_sys;
demux_sys_t *p_sys = p_demux->p_sys;
ts_psip_context_t *p_ctx = p_base_pid->u.p_psip->p_ctx;
dvbpsi_t *p_handle = p_base_pid->u.p_psip->handle;
......@@ -802,10 +806,10 @@ static void ATSC_STT_Callback( void *p_cb_basepid, dvbpsi_atsc_stt_t* p_stt )
time_t i_current_time = atsc_a65_GPSTimeToEpoch( p_stt->i_system_time,
p_stt->i_gps_utc_offset );
EIT_DEBUG_TIMESHIFT( i_current_time );
p_demux->p_sys->i_network_time = i_current_time;
p_demux->p_sys->i_network_time_update = time(NULL);
p_sys->i_network_time = i_current_time;
p_sys->i_network_time_update = time(NULL);
es_out_Control( p_demux->out, ES_OUT_SET_EPG_TIME, p_demux->p_sys->i_network_time );
es_out_Control( p_demux->out, ES_OUT_SET_EPG_TIME, p_sys->i_network_time );
}
p_ctx->p_stt = p_stt;
......@@ -837,8 +841,9 @@ static void ATSC_NewTable_Callback( dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, void *p_cb_pid )
{
demux_t *p_demux = (demux_t *) p_dvbpsi->p_sys;
demux_sys_t *p_sys = p_demux->p_sys;
assert( ((ts_pid_t *) p_cb_pid)->type == TYPE_PSIP );
const ts_pid_t *p_base_pid = ts_pid_Get( &p_demux->p_sys->pids, ATSC_BASE_PID );
const ts_pid_t *p_base_pid = ts_pid_Get( &p_sys->pids, ATSC_BASE_PID );
if( !p_base_pid->u.p_psip->p_ctx->p_vct )
return;
......
......@@ -696,7 +696,7 @@ static void ARIB_CDT_RawCallback( dvbpsi_t *p_handle, const dvbpsi_psi_section_t
VLC_UNUSED(p_cdtpid);
demux_t *p_demux = (demux_t *) p_handle->p_sys;
demux_sys_t *p_sys = p_demux->p_sys;
const ts_pat_t *p_pat = GetPID(p_demux->p_sys, 0)->u.p_pat;
const ts_pat_t *p_pat = GetPID(p_sys, 0)->u.p_pat;
while( p_section )
{
......@@ -766,6 +766,7 @@ static void SINewTableCallBack( dvbpsi_t *h, uint8_t i_table_id,
assert( h );
ts_pid_t *p_pid = (ts_pid_t *) p_pid_cbdata;
demux_t *p_demux = (demux_t *) h->p_sys;
demux_sys_t *p_sys = p_demux->p_sys;
#if 0
msg_Dbg( p_demux, "SINewTableCallback: table 0x%"PRIx8"(%"PRIu16") ext=0x%"PRIx16"(%"PRIu16")",
i_table_id, i_table_id, i_extension, i_extension );
......@@ -780,7 +781,7 @@ static void SINewTableCallBack( dvbpsi_t *h, uint8_t i_table_id,
(i_table_id >= 0x50 && i_table_id <= 0x5f) ) ) /* Schedule */
{
/* Do not attach decoders if we can't decode timestamps */
if( p_demux->p_sys->i_network_time > 0 )
if( p_sys->i_network_time > 0 )
{
if( !dvbpsi_eit_attach( h, i_table_id, i_extension,
(dvbpsi_eit_callback)EITCallBack, p_demux ) )
......
......@@ -140,6 +140,7 @@ void SLPackets_Section_Handler( demux_t *p_demux,
void *p_pes_cbdata )
{
VLC_UNUSED(p_sectiondata); VLC_UNUSED(i_sectiondata);
demux_sys_t *p_sys = p_demux->p_sys;
ts_stream_t *p_pes = (ts_stream_t *) p_pes_cbdata;
ts_pmt_t *p_pmt = p_pes->p_es->p_program;
......@@ -187,7 +188,7 @@ void SLPackets_Section_Handler( demux_t *p_demux,
}
if( b_changed )
UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
UpdatePESFilters( p_demux, p_sys->seltype == PROGRAM_ALL );
}
}
......
......@@ -190,12 +190,14 @@ ts_es_t * ts_es_New( ts_pmt_t *p_program )
static void ts_pes_es_Clean( demux_t *p_demux, ts_es_t *p_es )
{
demux_sys_t *p_sys = p_demux->p_sys;
if( p_es->id )
{
/* Ensure we don't wait for overlap hacks #14257 */
es_out_Control( p_demux->out, ES_OUT_SET_ES_STATE, p_es->id, false );
es_out_Del( p_demux->out, p_es->id );
p_demux->p_sys->i_pmt_es--;
p_sys->i_pmt_es--;
}
es_format_Clean( &p_es->fmt );
}
......
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