Commit e2bbf5ca authored by Laurent Aimar's avatar Laurent Aimar

* ts: better handling on PAT version changes.

parent 65b5865c
...@@ -1807,29 +1807,61 @@ static void PATCallBack( demux_t *p_demux, dvbpsi_pat_t *p_pat ) ...@@ -1807,29 +1807,61 @@ static void PATCallBack( demux_t *p_demux, dvbpsi_pat_t *p_pat )
p_pat->i_ts_id, p_pat->i_version, p_pat->b_current_next ); p_pat->i_ts_id, p_pat->i_version, p_pat->b_current_next );
/* Clean old */ /* Clean old */
for( i = 2; i < 8192; i++ ) if( p_sys->i_pmt > 0 )
{ {
ts_pid_t *pid = &p_sys->pid[i]; int i_pmt_rm = 0;
ts_pid_t **pmt_rm = NULL;
if( pid->b_valid ) /* Search pmt to be deleted */
for( i = 0; i < p_sys->i_pmt; i++ )
{ {
if( pid->psi ) ts_pid_t *pmt = p_sys->pmt[i];
vlc_bool_t b_keep = VLC_FALSE;
for( p_program = p_pat->p_first_program; p_program != NULL; p_program = p_program->p_next )
{ {
if( pid->p_owner == pat->psi ) if( p_program->i_pid == pmt->i_pid && p_program->i_number == pmt->psi->i_number )
{ {
PIDClean( p_demux->out, pid ); b_keep = VLC_TRUE;
TAB_REMOVE( p_sys->i_pmt, p_sys->pmt, pid ); break;
} }
} }
else if( pid->p_owner && pid->p_owner->i_number != 0 && if( !b_keep )
pid->es->id ) {
TAB_APPEND( i_pmt_rm, pmt_rm, pmt );
}
}
/* Delete all ES attached to thoses PMT */
for( i = 2; i < 8192; i++ )
{
ts_pid_t *pid = &p_sys->pid[i];
if( pid->b_valid && !pid->psi )
{
for( i = 0; i < i_pmt_rm; i++ )
{
if( pid->p_owner->i_pid_pcr == pmt_rm[i]->i_pid && pid->es->id )
{ {
/* We only remove es that aren't defined by extra pmt */ /* We only remove es that aren't defined by extra pmt */
PIDClean( p_demux->out, pid ); PIDClean( p_demux->out, pid );
break;
}
} }
} }
} }
/* Delete PMT pid */
for( i = 0; i < i_pmt_rm; i++ )
{
PIDClean( p_demux->out, &p_sys->pid[pmt_rm[i]->i_pid] );
TAB_REMOVE( p_sys->i_pmt, p_sys->pmt, pmt_rm[i] );
}
if( pmt_rm )
{
free( pmt_rm );
}
}
/* now create programs */ /* now create programs */
for( p_program = p_pat->p_first_program; p_program != NULL; for( p_program = p_pat->p_first_program; p_program != NULL;
p_program = p_program->p_next ) p_program = p_program->p_next )
...@@ -1840,6 +1872,8 @@ static void PATCallBack( demux_t *p_demux, dvbpsi_pat_t *p_pat ) ...@@ -1840,6 +1872,8 @@ static void PATCallBack( demux_t *p_demux, dvbpsi_pat_t *p_pat )
{ {
ts_pid_t *pmt = &p_sys->pid[p_program->i_pid]; ts_pid_t *pmt = &p_sys->pid[p_program->i_pid];
if( !pmt->b_valid )
{
PIDInit( pmt, VLC_TRUE, pat->psi ); PIDInit( pmt, VLC_TRUE, pat->psi );
pmt->psi->handle = pmt->psi->handle =
dvbpsi_AttachPMT( p_program->i_number, dvbpsi_AttachPMT( p_program->i_number,
...@@ -1849,6 +1883,7 @@ static void PATCallBack( demux_t *p_demux, dvbpsi_pat_t *p_pat ) ...@@ -1849,6 +1883,7 @@ static void PATCallBack( demux_t *p_demux, dvbpsi_pat_t *p_pat )
TAB_APPEND( p_sys->i_pmt, p_sys->pmt, pmt ); TAB_APPEND( p_sys->i_pmt, p_sys->pmt, pmt );
} }
} }
}
pat->psi->i_version = p_pat->i_version; pat->psi->i_version = p_pat->i_version;
dvbpsi_DeletePAT( p_pat ); dvbpsi_DeletePAT( p_pat );
......
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