Commit 6a1d414e authored by François Cartegnie's avatar François Cartegnie 🤞

demux: ts: move eit event start/length to programs

current event is relative to programs, not to first eit callback
parent 13199723
......@@ -388,8 +388,6 @@ static int Open( vlc_object_t *p_this )
ARRAY_INIT( p_sys->programs );
p_sys->b_default_selection = false;
p_sys->i_tdt_delta = 0;
p_sys->i_dvb_start = 0;
p_sys->i_dvb_length = 0;
p_sys->vdr = vdr;
......@@ -746,24 +744,23 @@ static int Demux( demux_t *p_demux )
/*****************************************************************************
* Control:
*****************************************************************************/
static int DVBEventInformation( demux_t *p_demux, int64_t *pi_time, int64_t *pi_length )
static int EITCurrentEventTime( const ts_pmt_t *p_pmt, mtime_t i_tdt_offset,
time_t *pi_time, time_t *pi_length )
{
demux_sys_t *p_sys = p_demux->p_sys;
if( pi_length )
*pi_length = 0;
if( pi_time )
*pi_time = 0;
if( p_sys->i_dvb_length > 0 )
if( p_pmt && p_pmt->eit.i_event_length > 0 )
{
const int64_t t = mdate() + p_sys->i_tdt_delta;
if( p_sys->i_dvb_start <= t && t < p_sys->i_dvb_start + p_sys->i_dvb_length )
const time_t t = time(NULL) + i_tdt_offset / CLOCK_FREQ;
if( p_pmt->eit.i_event_start <= t && t < p_pmt->eit.i_event_start + p_pmt->eit.i_event_length )
{
if( pi_length )
*pi_length = p_sys->i_dvb_length;
*pi_length = p_pmt->eit.i_event_length;
if( pi_time )
*pi_time = t - p_sys->i_dvb_start;
*pi_time = t - p_pmt->eit.i_event_start;
return VLC_SUCCESS;
}
}
......@@ -893,7 +890,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( p_sys->b_dvb_meta && p_sys->b_access_control )
{
int64_t i_time, i_length;
if( !DVBEventInformation( p_demux, &i_time, &i_length ) && i_length > 0 )
if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, &i_time, &i_length ) && i_length > 0 )
{
*pf = (double)i_time/(double)i_length;
return VLC_SUCCESS;
......@@ -934,7 +931,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
!p_sys->b_force_seek_per_percent && p_pmt )
{
int64_t i_time, i_length;
if( !DVBEventInformation( p_demux, &i_time, &i_length ) &&
if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, &i_time, &i_length ) &&
i_length > 0 && !SeekToTime( p_demux, p_pmt, (int64_t)(TO_SCALE(i_length) * f) ) )
{
ReadyQueuesPostSeek( p_demux );
......@@ -989,7 +986,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( p_sys->b_dvb_meta && p_sys->b_access_control )
{
if( !DVBEventInformation( p_demux, pi64, NULL ) )
if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, pi64, NULL ) )
return VLC_SUCCESS;
}
......@@ -1006,7 +1003,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( p_sys->b_dvb_meta && p_sys->b_access_control )
{
if( !DVBEventInformation( p_demux, NULL, pi64 ) )
if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, NULL, pi64 ) )
return VLC_SUCCESS;
}
......
......@@ -99,8 +99,6 @@ struct demux_sys_t
/* */
bool b_dvb_meta;
int64_t i_tdt_delta;
int64_t i_dvb_start;
int64_t i_dvb_length;
bool b_broken_charset; /* True if broken encoding is used in EPG/SDT */
/* Selected programs */
......
......@@ -480,13 +480,18 @@ static void EITCallBack( demux_t *p_demux,
p_eit->i_extension
) )
{
p_sys->i_dvb_length = 0;
p_sys->i_dvb_start = 0;
if( p_epg->p_current )
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, p_eit->i_extension);
if(p_pmt)
{
p_sys->i_dvb_start = CLOCK_FREQ * p_epg->p_current->i_start;
p_sys->i_dvb_length = CLOCK_FREQ * p_epg->p_current->i_duration;
p_pmt->eit.i_event_length = 0;
p_pmt->eit.i_event_start = 0;
if( p_epg->p_current )
{
p_pmt->eit.i_event_start = p_epg->p_current->i_start;
p_pmt->eit.i_event_length = p_epg->p_current->i_duration;
}
}
}
es_out_Control( p_demux->out, ES_OUT_SET_GROUP_EPG,
......
......@@ -132,6 +132,9 @@ ts_pmt_t *ts_pmt_New( demux_t *p_demux )
pmt->pcr.b_fix_done = false;
pmt->eit.i_event_length = 0;
pmt->eit.i_event_start = 0;
return pmt;
}
......
......@@ -62,6 +62,12 @@ struct ts_pmt_t
bool b_fix_done;
} pcr;
struct
{
time_t i_event_start;
time_t i_event_length;
} eit;
mtime_t i_last_dts;
};
......
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