Commit e9adc2be authored by François Cartegnie's avatar François Cartegnie 🤞

vlc_epg: add parental rating from ts streams.

parent f1a9cf16
...@@ -38,6 +38,7 @@ typedef struct ...@@ -38,6 +38,7 @@ typedef struct
char *psz_short_description; char *psz_short_description;
char *psz_description; char *psz_description;
uint8_t i_rating; /* Parental control, set to 0 when undefined */
} vlc_epg_event_t; } vlc_epg_event_t;
typedef struct typedef struct
...@@ -66,7 +67,7 @@ VLC_API void vlc_epg_Clean(vlc_epg_t *p_epg); ...@@ -66,7 +67,7 @@ VLC_API void vlc_epg_Clean(vlc_epg_t *p_epg);
* *
* \see vlc_epg_t for the definitions of the parameters. * \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); 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 );
/** /**
* It creates a new vlc_epg_t* * It creates a new vlc_epg_t*
......
...@@ -2837,6 +2837,7 @@ static void EITCallBack( demux_t *p_demux, ...@@ -2837,6 +2837,7 @@ static void EITCallBack( demux_t *p_demux,
char *psz_extra = strdup(""); char *psz_extra = strdup("");
int64_t i_start; int64_t i_start;
int i_duration; int i_duration;
int i_min_age = 0;
i_start = EITConvertStartTime( p_evt->i_start_time ); i_start = EITConvertStartTime( p_evt->i_start_time );
i_duration = EITConvertDuration( p_evt->i_duration ); i_duration = EITConvertDuration( p_evt->i_duration );
...@@ -2915,6 +2916,24 @@ static void EITCallBack( demux_t *p_demux, ...@@ -2915,6 +2916,24 @@ static void EITCallBack( demux_t *p_demux,
} }
} }
} }
else if( p_dr->i_tag == 0x55 )
{
dvbpsi_parental_rating_dr_t *pR = dvbpsi_DecodeParentalRatingDr( p_dr );
if ( pR )
{
for ( int i = 0; i < pR->i_ratings_number; i++ )
{
const dvbpsi_parental_rating_t *p_rating = & pR->p_parental_rating[ i ];
if ( p_rating->i_rating > 0x00 && p_rating->i_rating <= 0x0F )
{
if ( p_rating->i_rating + 3 > i_min_age )
i_min_age = p_rating->i_rating + 3;
msg_Dbg( p_demux, "..* event parental control set to %d years",
i_min_age );
}
}
}
}
else else
{ {
msg_Dbg( p_demux, " - tag=0x%x(%d)", p_dr->i_tag, p_dr->i_tag ); msg_Dbg( p_demux, " - tag=0x%x(%d)", p_dr->i_tag, p_dr->i_tag );
...@@ -2924,7 +2943,7 @@ static void EITCallBack( demux_t *p_demux, ...@@ -2924,7 +2943,7 @@ static void EITCallBack( demux_t *p_demux,
/* */ /* */
if( i_start > 0 ) if( i_start > 0 )
vlc_epg_AddEvent( p_epg, i_start, i_duration, psz_name, psz_text, vlc_epg_AddEvent( p_epg, i_start, i_duration, psz_name, psz_text,
*psz_extra ? psz_extra : NULL ); *psz_extra ? psz_extra : NULL, i_min_age );
/* Update "now playing" field */ /* Update "now playing" field */
if( p_evt->i_running_status == 0x04 && i_start > 0 ) if( p_evt->i_running_status == 0x04 && i_start > 0 )
......
...@@ -1443,7 +1443,7 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 ) ...@@ -1443,7 +1443,7 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 )
p_epg = vlc_epg_New( NULL ); p_epg = vlc_epg_New( NULL );
if( m->current.psz_name ) if( m->current.psz_name )
{ {
vlc_epg_AddEvent( p_epg, 0, 0, m->current.psz_name, NULL, NULL ); vlc_epg_AddEvent( p_epg, 0, 0, m->current.psz_name, NULL, NULL, 0 );
//if( m->current.psz_rating ) //if( m->current.psz_rating )
// TODO but VLC cannot yet handle rating per epg event // TODO but VLC cannot yet handle rating per epg event
vlc_epg_SetCurrent( p_epg, 0 ); vlc_epg_SetCurrent( p_epg, 0 );
......
...@@ -1371,7 +1371,8 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co ...@@ -1371,7 +1371,8 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
vlc_epg_AddEvent( p_cmd->u.control.u.int_epg.p_epg, vlc_epg_AddEvent( p_cmd->u.control.u.int_epg.p_epg,
p_evt->i_start, p_evt->i_duration, p_evt->i_start, p_evt->i_duration,
p_evt->psz_name, p_evt->psz_name,
p_evt->psz_short_description, p_evt->psz_description ); p_evt->psz_short_description,
p_evt->psz_description, 0 );
} }
vlc_epg_SetCurrent( p_cmd->u.control.u.int_epg.p_epg, vlc_epg_SetCurrent( p_cmd->u.control.u.int_epg.p_epg,
p_epg->p_current ? p_epg->p_current->i_start : -1 ); p_epg->p_current ? p_epg->p_current->i_start : -1 );
......
...@@ -55,7 +55,8 @@ void vlc_epg_Clean( vlc_epg_t *p_epg ) ...@@ -55,7 +55,8 @@ void vlc_epg_Clean( vlc_epg_t *p_epg )
} }
void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration, 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 ) const char *psz_name, const char *psz_short_description,
const char *psz_description, uint8_t i_rating )
{ {
vlc_epg_event_t *p_evt = malloc( sizeof(*p_evt) ); vlc_epg_event_t *p_evt = malloc( sizeof(*p_evt) );
if( !p_evt ) if( !p_evt )
...@@ -65,6 +66,7 @@ void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration, ...@@ -65,6 +66,7 @@ void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration,
p_evt->psz_name = psz_name ? strdup( psz_name ) : NULL; p_evt->psz_name = psz_name ? strdup( psz_name ) : NULL;
p_evt->psz_short_description = psz_short_description ? strdup( psz_short_description ) : NULL; p_evt->psz_short_description = psz_short_description ? strdup( psz_short_description ) : NULL;
p_evt->psz_description = psz_description ? strdup( psz_description ) : NULL; p_evt->psz_description = psz_description ? strdup( psz_description ) : NULL;
p_evt->i_rating = i_rating;
TAB_APPEND( p_epg->i_event, p_epg->pp_event, p_evt ); TAB_APPEND( p_epg->i_event, p_epg->pp_event, p_evt );
} }
...@@ -130,6 +132,7 @@ void vlc_epg_Merge( vlc_epg_t *p_dst, const vlc_epg_t *p_src ) ...@@ -130,6 +132,7 @@ void vlc_epg_Merge( vlc_epg_t *p_dst, const vlc_epg_t *p_src )
p_copy->psz_name = p_evt->psz_name ? strdup( p_evt->psz_name ) : NULL; p_copy->psz_name = p_evt->psz_name ? strdup( p_evt->psz_name ) : NULL;
p_copy->psz_short_description = p_evt->psz_short_description ? strdup( p_evt->psz_short_description ) : NULL; p_copy->psz_short_description = p_evt->psz_short_description ? strdup( p_evt->psz_short_description ) : NULL;
p_copy->psz_description = p_evt->psz_description ? strdup( p_evt->psz_description ) : NULL; p_copy->psz_description = p_evt->psz_description ? strdup( p_evt->psz_description ) : NULL;
p_copy->i_rating = p_evt->i_rating;
TAB_INSERT( p_dst->i_event, p_dst->pp_event, p_copy, j ); TAB_INSERT( p_dst->i_event, p_dst->pp_event, p_copy, j );
} }
} }
......
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