Commit 66b32e89 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: ts: set fmt id on all es and add collision avoidance for extra es

parent 4ae70e16
...@@ -436,6 +436,8 @@ struct demux_sys_t ...@@ -436,6 +436,8 @@ struct demux_sys_t
/* */ /* */
bool b_es_id_pid; bool b_es_id_pid;
uint16_t i_next_extraid;
csa_t *csa; csa_t *csa;
int i_csa_pkt_size; int i_csa_pkt_size;
bool b_split_es; bool b_split_es;
...@@ -1098,6 +1100,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -1098,6 +1100,7 @@ static int Open( vlc_object_t *p_this )
/* Read config */ /* Read config */
p_sys->b_es_id_pid = var_CreateGetBool( p_demux, "ts-es-id-pid" ); p_sys->b_es_id_pid = var_CreateGetBool( p_demux, "ts-es-id-pid" );
p_sys->i_next_extraid = 1;
p_sys->b_trust_pcr = var_CreateGetBool( p_demux, "ts-trust-pcr" ); p_sys->b_trust_pcr = var_CreateGetBool( p_demux, "ts-trust-pcr" );
...@@ -5018,6 +5021,14 @@ static void PMTParseEsIso639( demux_t *p_demux, ts_pes_es_t *p_es, ...@@ -5018,6 +5021,14 @@ static void PMTParseEsIso639( demux_t *p_demux, ts_pes_es_t *p_es,
#endif #endif
} }
static inline void SetExtraESGroupAndID( demux_sys_t *p_sys, es_format_t *p_fmt,
const es_format_t *p_parent_fmt )
{
if ( p_sys->b_es_id_pid ) /* pid is 13 bits */
p_fmt->i_id = (p_sys->i_next_extraid++ << 13) | p_parent_fmt->i_id;
p_fmt->i_group = p_parent_fmt->i_group;
}
static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool b_create_delayed ) static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool b_create_delayed )
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
...@@ -5031,8 +5042,9 @@ static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool b_create_delay ...@@ -5031,8 +5042,9 @@ static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool b_create_delay
pid->u.p_pes->es.id = es_out_Add( p_demux->out, &pid->u.p_pes->es.fmt ); pid->u.p_pes->es.id = es_out_Add( p_demux->out, &pid->u.p_pes->es.fmt );
for( int i = 0; i < pid->u.p_pes->extra_es.i_size; i++ ) for( int i = 0; i < pid->u.p_pes->extra_es.i_size; i++ )
{ {
pid->u.p_pes->extra_es.p_elems[i]->id = es_format_t *p_fmt = &pid->u.p_pes->extra_es.p_elems[i]->fmt;
es_out_Add( p_demux->out, &pid->u.p_pes->extra_es.p_elems[i]->fmt ); SetExtraESGroupAndID( p_sys, p_fmt, &pid->u.p_pes->es.fmt );
pid->u.p_pes->extra_es.p_elems[i]->id = es_out_Add( p_demux->out, p_fmt );
} }
p_sys->i_pmt_es += 1 + pid->u.p_pes->extra_es.i_size; p_sys->i_pmt_es += 1 + pid->u.p_pes->extra_es.i_size;
...@@ -5062,8 +5074,9 @@ static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool b_create_delay ...@@ -5062,8 +5074,9 @@ static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool b_create_delay
pid->u.p_pes->es.id = es_out_Add( p_demux->out, &pid->u.p_pes->es.fmt ); pid->u.p_pes->es.id = es_out_Add( p_demux->out, &pid->u.p_pes->es.fmt );
for( int k = 0; k < pid->u.p_pes->extra_es.i_size; k++ ) for( int k = 0; k < pid->u.p_pes->extra_es.i_size; k++ )
{ {
pid->u.p_pes->extra_es.p_elems[k]->id = es_format_t *p_fmt = &pid->u.p_pes->extra_es.p_elems[k]->fmt;
es_out_Add( p_demux->out, &pid->u.p_pes->extra_es.p_elems[k]->fmt ); SetExtraESGroupAndID( p_sys, p_fmt, &pid->u.p_pes->es.fmt );
pid->u.p_pes->extra_es.p_elems[k]->id = es_out_Add( p_demux->out, p_fmt );
} }
p_sys->i_pmt_es += 1 + pid->u.p_pes->extra_es.i_size; p_sys->i_pmt_es += 1 + pid->u.p_pes->extra_es.i_size;
} }
...@@ -5403,9 +5416,10 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt ) ...@@ -5403,9 +5416,10 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
break; break;
} }
/* Set Groups / ID */
p_pes->es.fmt.i_group = p_dvbpsipmt->i_program_number; p_pes->es.fmt.i_group = p_dvbpsipmt->i_program_number;
for( int i = 0; i < p_pes->extra_es.i_size; i++ ) if( p_sys->b_es_id_pid )
p_pes->extra_es.p_elems[i]->fmt.i_group = p_dvbpsipmt->i_program_number; p_pes->es.fmt.i_id = p_dvbpsies->i_pid;
if( p_pes->es.fmt.i_cat == UNKNOWN_ES ) if( p_pes->es.fmt.i_cat == UNKNOWN_ES )
{ {
...@@ -5418,8 +5432,6 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt ) ...@@ -5418,8 +5432,6 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
msg_Dbg( p_demux, " => pid %d has now es fcc=%4.4s", msg_Dbg( p_demux, " => pid %d has now es fcc=%4.4s",
p_dvbpsies->i_pid, (char*)&p_pes->es.fmt.i_codec ); p_dvbpsies->i_pid, (char*)&p_pes->es.fmt.i_codec );
if( p_sys->b_es_id_pid ) p_pes->es.fmt.i_id = p_dvbpsies->i_pid;
/* Check if we can avoid restarting the ES */ /* Check if we can avoid restarting the ES */
if( b_reusing_pid ) if( b_reusing_pid )
{ {
......
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