[vlc-devel] [PATCH 1/2] vlc_epg: add parental rating from ts streams.
Francois Cartegnie
fcvlcdev at free.fr
Tue Mar 12 00:31:37 CET 2013
---
include/vlc_epg.h | 3 ++-
modules/demux/ts.c | 21 ++++++++++++++++++++-
modules/demux/ty.c | 2 +-
src/input/es_out_timeshift.c | 3 ++-
src/misc/epg.c | 5 ++++-
5 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/include/vlc_epg.h b/include/vlc_epg.h
index 25d8ed2..c0fd0f5 100644
--- a/include/vlc_epg.h
+++ b/include/vlc_epg.h
@@ -38,6 +38,7 @@ typedef struct
char *psz_short_description;
char *psz_description;
+ uint8_t i_rating; /* Parental control, set to 0 when undefined */
} vlc_epg_event_t;
typedef struct
@@ -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.
*/
-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*
diff --git a/modules/demux/ts.c b/modules/demux/ts.c
index 1374791..5ba2f04 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -2837,6 +2837,7 @@ static void EITCallBack( demux_t *p_demux,
char *psz_extra = strdup("");
int64_t i_start;
int i_duration;
+ int i_min_age = 0;
i_start = EITConvertStartTime( p_evt->i_start_time );
i_duration = EITConvertDuration( p_evt->i_duration );
@@ -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
{
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,
/* */
if( i_start > 0 )
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 */
if( p_evt->i_running_status == 0x04 && i_start > 0 )
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index 9ff31ec..f2f30c8 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -1443,7 +1443,7 @@ static void DemuxDecodeXds( demux_t *p_demux, uint8_t d1, uint8_t d2 )
p_epg = vlc_epg_New( NULL );
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 )
// TODO but VLC cannot yet handle rating per epg event
vlc_epg_SetCurrent( p_epg, 0 );
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index 4f5db4f..520f735 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -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,
p_evt->i_start, p_evt->i_duration,
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,
p_epg->p_current ? p_epg->p_current->i_start : -1 );
diff --git a/src/misc/epg.c b/src/misc/epg.c
index 82a7600..c0148b5 100644
--- a/src/misc/epg.c
+++ b/src/misc/epg.c
@@ -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,
- 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) );
if( !p_evt )
@@ -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_short_description = psz_short_description ? strdup( psz_short_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 );
}
@@ -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_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->i_rating = p_evt->i_rating;
TAB_INSERT( p_dst->i_event, p_dst->pp_event, p_copy, j );
}
}
--
1.7.9
More information about the vlc-devel
mailing list