Skip to content

Commit

Permalink
epg: API changes
Browse files Browse the repository at this point in the history
EIT structs and Events and should be referenced by their
unique ID.
First step towards in depth changes to epg_t et epg_event_t.
  • Loading branch information
fcartegnie committed Sep 15, 2016
1 parent 3924bed commit aa8683f
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 135 deletions.
51 changes: 37 additions & 14 deletions include/vlc_epg.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@

typedef struct
{
int64_t i_start; /* Interpreted as a value return by time() */
int i_duration; /* Duration of the event in second */
int64_t i_start; /* Interpreted as a value return by time() */
uint32_t i_duration; /* Duration of the event in second */
uint16_t i_id; /* Unique event id withing the event set */

char *psz_name;
char *psz_short_description;
Expand All @@ -44,43 +45,60 @@ typedef struct
typedef struct
{
char *psz_name;
vlc_epg_event_t *p_current; /* Can be null or should be the same than one of pp_event entry */
vlc_epg_event_t *p_current; /* Can be null or should be the same than one of pp_event entry */
uint32_t i_id; /* Unique identifier for this table / events (partial sets) */
uint16_t i_source_id;/* Channel / Program reference id this epg relates to */

int i_event;
size_t i_event;
vlc_epg_event_t **pp_event;
} vlc_epg_t;

/**
* It initializes a vlc_epg_t.
* Creates a new vlc_epg_event_t*
*
* You must call vlc_epg_Clean to release the associated resource.
* You must call vlc_epg_event_Delete to release the associated resources.
*
* \p i_id is the event unique id
* \p i_start start in epoch time
* \p i_duration event duration in seconds
*/
VLC_API void vlc_epg_Init(vlc_epg_t *p_epg, const char *psz_name);
VLC_API vlc_epg_event_t * vlc_epg_event_New(uint16_t i_id,
int64_t i_start, uint32_t i_duration);

/**
* It releases all resources associated to a vlc_epg_t
* Releases a vlc_epg_event_t*.
*/
VLC_API void vlc_epg_Clean(vlc_epg_t *p_epg);
VLC_API void vlc_epg_event_Delete(vlc_epg_event_t *p_event);

/**
* It creates and appends a new vlc_epg_event_t to a vlc_epg_t.
* Returns a vlc_epg_event_t * duplicated from \p p_src.
*
* \see vlc_epg_t for the definitions of the parameters.
*/
VLC_API void vlc_epg_AddEvent(vlc_epg_t *p_epg, int64_t i_start, int i_duration, const char *psz_name, const char *psz_short_description, const char *psz_description, uint8_t i_rating );
VLC_API vlc_epg_event_t * vlc_epg_event_Duplicate(const vlc_epg_event_t *p_src);

/**
* It creates a new vlc_epg_t*
*
* You must call vlc_epg_Delete to release the associated resource.
*
* \p i_id is computed unique id depending on standard (table id, eit number)
* \p i_source_id is the associated program number
*/
VLC_API vlc_epg_t * vlc_epg_New(const char *psz_name) VLC_USED;
VLC_API vlc_epg_t * vlc_epg_New(uint32_t i_id, uint16_t i_source_id);

/**
* It releases a vlc_epg_t*.
*/
VLC_API void vlc_epg_Delete(vlc_epg_t *p_epg);

/**
* It appends a new vlc_epg_event_t to a vlc_epg_t.
* Takes ownership of \p p_evt or returns false
*
* \p p_evt a vlc_epg_event_t * created with vlc_epg_event_New.
*/
VLC_API bool vlc_epg_AddEvent(vlc_epg_t *p_epg, vlc_epg_event_t *p_evt);

/**
* It set the current event of a vlc_epg_t given a start time
*/
Expand All @@ -89,9 +107,14 @@ VLC_API void vlc_epg_SetCurrent(vlc_epg_t *p_epg, int64_t i_start);
/**
* It merges all the event of \p p_src and \p p_dst into \p p_dst.
*
* \p p_src is not modified.
*/
VLC_API void vlc_epg_Merge(vlc_epg_t *p_dst, const vlc_epg_t *p_src);

/**
* Returns a duplicated \p p_src and its associated events.
*
*/
VLC_API vlc_epg_t * vlc_epg_Duplicate(const vlc_epg_t *p_src);

#endif

4 changes: 2 additions & 2 deletions include/vlc_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ enum vlc_module_properties
/**
* Current plugin ABI version
*/
# define MODULE_SYMBOL 3_0_0b
# define MODULE_SUFFIX "__3_0_0b"
# define MODULE_SYMBOL 3_0_0c
# define MODULE_SUFFIX "__3_0_0c"

/*****************************************************************************
* Add a few defines. You do not want to read this section. Really.
Expand Down
28 changes: 24 additions & 4 deletions modules/demux/mpeg/ts_psip.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@

#include <assert.h>

static inline char *grab_notempty( char **ppsz )
{
char *psz_ret = NULL;
if( *ppsz && **ppsz )
{
psz_ret = *ppsz;
*ppsz = NULL;
}
return psz_ret;
}

/*
* Decoders activation order due to dependencies,
* and because callbacks will be fired once per MGT/VCT version
Expand Down Expand Up @@ -368,8 +379,15 @@ static time_t ATSC_AddVLCEPGEvent( demux_t *p_demux, ts_psip_context_t *p_basect
msg_Dbg( p_demux, "EIT Event time %ld +%d %s id 0x%x",
i_start, p_evt->i_length_seconds, psz_title, p_evt->i_event_id );
#endif
vlc_epg_AddEvent( p_epg, i_start, p_evt->i_length_seconds,
psz_title, psz_shortdesc_text, psz_longdesc_text, 0 );
vlc_epg_event_t *p_epgevt = vlc_epg_event_New( p_evt->i_event_id, i_start, p_evt->i_length_seconds );
if( p_epgevt )
{
p_epgevt->psz_name = grab_notempty( &psz_title );
p_epgevt->psz_short_description = grab_notempty( &psz_shortdesc_text );
p_epgevt->psz_description = grab_notempty( &psz_longdesc_text );
if( !vlc_epg_AddEvent( p_epg, p_epgevt ) )
vlc_epg_event_Delete( p_epgevt );
}
}

free( psz_title );
Expand Down Expand Up @@ -417,7 +435,8 @@ static void ATSC_EIT_Callback( void *p_pid, dvbpsi_atsc_eit_t* p_eit )
EIT_DEBUG_TIMESHIFT( i_current_time );


vlc_epg_t *p_epg = vlc_epg_New( NULL );
vlc_epg_t *p_epg = vlc_epg_New( p_basectx->i_tabletype - ATSC_TABLE_TYPE_EIT_0,
i_program_number );
if( !p_epg )
{
dvbpsi_atsc_DeleteEIT( p_eit );
Expand Down Expand Up @@ -510,7 +529,8 @@ static void ATSC_ETT_Callback( void *p_pid, dvbpsi_atsc_ett_t *p_ett )
#ifdef ATSC_DEBUG_EIT
msg_Dbg( p_demux, "Should update EIT %x (matched EIT)", p_event->i_event_id );
#endif
vlc_epg_t *p_epg = vlc_epg_New( NULL );
vlc_epg_t *p_epg = vlc_epg_New( p_basectx->i_tabletype - ATSC_TABLE_TYPE_ETT_0,
i_program_number );
if( likely(p_epg) )
{
(void)
Expand Down
36 changes: 27 additions & 9 deletions modules/demux/mpeg/ts_si.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
} while(0);
#endif

static inline char *grab_notempty( char **ppsz )
{
char *psz_ret = NULL;
if( *ppsz && **ppsz )
{
psz_ret = *ppsz;
*ppsz = NULL;
}
return psz_ret;
}

static void SINewTableCallBack( dvbpsi_t *h, uint8_t i_table_id,
uint16_t i_extension, void *p_pid_cbdata );

Expand Down Expand Up @@ -383,7 +394,7 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit )
p_eit->i_ts_id, p_eit->i_network_id,
p_eit->i_segment_last_section_number, p_eit->i_last_table_id );

p_epg = vlc_epg_New( NULL );
p_epg = vlc_epg_New( p_eit->i_table_id, p_eit->i_extension );
for( p_evt = p_eit->p_first_event; p_evt; p_evt = p_evt->p_next )
{
dvbpsi_descriptor_t *p_dr;
Expand Down Expand Up @@ -548,14 +559,21 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit )
/* */
if( i_start > 0 )
{
vlc_epg_AddEvent( p_epg, i_start, i_duration,
(psz_name && *psz_name) ? psz_name : NULL,
(psz_text && *psz_text) ? psz_text : NULL,
(psz_extra && *psz_extra) ? psz_extra : NULL, i_min_age );

/* Update "now playing" field */
if( b_current_event )
vlc_epg_SetCurrent( p_epg, i_start );
vlc_epg_event_t *p_epgevt = vlc_epg_event_New( p_evt->i_event_id,
i_start, i_duration );
if( p_epgevt )
{
p_epgevt->psz_name = grab_notempty( &psz_name );
p_epgevt->psz_short_description = grab_notempty( &psz_text );
p_epgevt->psz_description = grab_notempty( &psz_extra );
p_epgevt->i_rating = i_min_age;
if( !vlc_epg_AddEvent( p_epg, p_epgevt ) )
vlc_epg_event_Delete( p_epgevt );

/* Update "now playing" field */
if( b_current_event )
vlc_epg_SetCurrent( p_epg, i_start );
}
}

free( psz_name );
Expand Down
35 changes: 23 additions & 12 deletions modules/demux/ty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,6 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 )
{
xds_meta_t *m = &p_sys->xds.meta;
vlc_meta_t *p_meta;
vlc_epg_t *p_epg;

/* Channel meta data */
p_meta = vlc_meta_New();
Expand All @@ -1444,20 +1443,32 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 )
vlc_meta_Delete( p_meta );

/* Event meta data (current/future) */
p_epg = vlc_epg_New( NULL );
if( m->current.psz_name )
{
vlc_epg_AddEvent( p_epg, 0, 0, m->current.psz_name, NULL, NULL, 0 );
//if( m->current.psz_rating )
// TODO but VLC cannot yet handle rating per epg event
vlc_epg_SetCurrent( p_epg, 0 );
}
if( m->future.psz_name )
{
vlc_epg_t *p_epg = vlc_epg_New( TY_ES_GROUP, TY_ES_GROUP );
if ( p_epg )
{
vlc_epg_event_t *p_evt = vlc_epg_event_New( 0, 0, 0 );
if ( p_evt )
{
if( m->current.psz_name )
p_evt->psz_name = strdup( m->current.psz_name );
if( !vlc_epg_AddEvent( p_epg, p_evt ) )
vlc_epg_event_Delete( p_evt );
}
//if( m->current.psz_rating )
// TODO but VLC cannot yet handle rating per epg event
vlc_epg_SetCurrent( p_epg, 0 );

if( m->future.psz_name )
{
}
if( p_epg->i_event > 0 )
es_out_Control( p_demux->out, ES_OUT_SET_GROUP_EPG,
TY_ES_GROUP, p_epg );
vlc_epg_Delete( p_epg );
}
}
if( p_epg->i_event > 0 )
es_out_Control( p_demux->out, ES_OUT_SET_GROUP_EPG, TY_ES_GROUP, p_epg );
vlc_epg_Delete( p_epg );
}
p_demux->p_sys->xds.b_meta_changed = false;
}
Expand Down
14 changes: 1 addition & 13 deletions src/input/es_out_timeshift.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,21 +1426,9 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co

if( b_copy )
{
p_cmd->u.control.u.int_epg.p_epg = vlc_epg_New( p_epg->psz_name );
p_cmd->u.control.u.int_epg.p_epg = vlc_epg_Duplicate( p_epg );
if( !p_cmd->u.control.u.int_epg.p_epg )
return VLC_EGENERIC;
for( int i = 0; i < p_epg->i_event; i++ )
{
vlc_epg_event_t *p_evt = p_epg->pp_event[i];

vlc_epg_AddEvent( p_cmd->u.control.u.int_epg.p_epg,
p_evt->i_start, p_evt->i_duration,
p_evt->psz_name,
p_evt->psz_short_description,
p_evt->psz_description, 0 );
}
vlc_epg_SetCurrent( p_cmd->u.control.u.int_epg.p_epg,
p_epg->p_current ? p_epg->p_current->i_start : -1 );
}
else
{
Expand Down
22 changes: 10 additions & 12 deletions src/input/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,26 +906,24 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )
vlc_epg_t *p_epg = NULL;
for( int i = 0; i < p_item->i_epg; i++ )
{
vlc_epg_t *p_tmp = p_item->pp_epg[i];

if( (p_tmp->psz_name == NULL) != (p_update->psz_name == NULL) )
continue;
if( p_tmp->psz_name && p_update->psz_name && strcmp(p_tmp->psz_name, p_update->psz_name) )
continue;

p_epg = p_tmp;
break;
if( p_item->pp_epg[i]->i_source_id == p_update->i_source_id )
{
p_epg = p_item->pp_epg[i];
break;
}
}

/* */
if( !p_epg )
{
p_epg = vlc_epg_New( p_update->psz_name );
p_epg = vlc_epg_Duplicate( p_update );
if( p_epg )
TAB_APPEND( p_item->i_epg, p_item->pp_epg, p_epg );
}
if( p_epg )
else
{
vlc_epg_Merge( p_epg, p_update );
}

vlc_mutex_unlock( &p_item->lock );

Expand All @@ -940,7 +938,7 @@ void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )
input_item_DelInfo( p_item, psz_epg, NULL );

vlc_mutex_lock( &p_item->lock );
for( int i = 0; i < p_epg->i_event; i++ )
for( size_t i = 0; i < p_epg->i_event; i++ )
{
const vlc_epg_event_t *p_evt = p_epg->pp_event[i];
time_t t_start = (time_t)p_evt->i_start;
Expand Down
6 changes: 4 additions & 2 deletions src/libvlccore.sym
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,12 @@ vlc_timer_getoverrun
vlc_timer_schedule
vlc_towc
vlc_ureduce
vlc_epg_Init
vlc_epg_Clean
vlc_epg_event_Delete
vlc_epg_event_Duplicate
vlc_epg_event_New
vlc_epg_New
vlc_epg_Delete
vlc_epg_Duplicate
vlc_epg_AddEvent
vlc_epg_SetCurrent
vlc_epg_Merge
Expand Down
Loading

0 comments on commit aa8683f

Please sign in to comment.