[vlc-devel] [PATCH] Use sid/nid as epg data source.

Francois Cartegnie fcvlcdev at free.fr
Sun Mar 17 17:11:17 CET 2013


Current EPG's psz_name is set by ES to which is appended
the ES program ID: "Channel.[Program xxx]". (*)
The input item matching epg is also accessed by name
from its epg list (likely the reason of the previous point).

I'd like to identify epg by NID+SID, as issued from EIT.
This would allow sharing that data with an external source.

Do we have cases where EPG won't come from TS streams
(then not related to EIT) ?

Francois

(*) for convenience, last part is stripped by UI.

---
 include/vlc_epg.h  |    2 ++
 modules/demux/ts.c |    2 ++
 src/input/es_out.c |   23 +++++++++++++++++++++--
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/vlc_epg.h b/include/vlc_epg.h
index 25d8ed2..7969ec9 100644
--- a/include/vlc_epg.h
+++ b/include/vlc_epg.h
@@ -43,6 +43,8 @@ typedef struct
 typedef struct
 {
     char            *psz_name;
+    uint16_t        i_network_id;
+    uint16_t        i_service_id;
     vlc_epg_event_t *p_current; /* Can be null or should be the same than one of pp_event entry */
 
     int             i_event;
diff --git a/modules/demux/ts.c b/modules/demux/ts.c
index 1374791..f68675e 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -2937,6 +2937,8 @@ static void EITCallBack( demux_t *p_demux,
     }
     if( p_epg->i_event > 0 )
     {
+        p_epg->i_service_id = p_eit->i_service_id;
+        p_epg->i_network_id = p_eit->i_network_id;
         if( b_current_following &&
             (  p_sys->i_current_program == -1 ||
                p_sys->i_current_program == p_eit->i_service_id ) )
diff --git a/src/input/es_out.c b/src/input/es_out.c
index c566287..982bd20 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1141,6 +1141,23 @@ static char *EsOutProgramGetMetaName( es_out_pgrm_t *p_pgrm )
     return psz;
 }
 
+/* EsOutProgramEPGMeta:
+ */
+static char *EsOutProgramGetEPGMetaName( es_out_pgrm_t *p_pgrm, vlc_epg_t *p_epg )
+{
+    char *psz = NULL;
+    if( p_pgrm->psz_name )
+    {
+        return strdup( p_pgrm->psz_name );
+    }
+    else
+    {
+        if( asprintf( &psz, "%s SID %d", _("Program"), p_epg->i_service_id ) == -1 )
+            return NULL;
+    }
+    return psz;
+}
+
 static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_meta )
 {
     es_out_sys_t      *p_sys = out->p_sys;
@@ -1261,7 +1278,7 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg
         return;
 
     /* Update info */
-    psz_cat = EsOutProgramGetMetaName( p_pgrm );
+    psz_cat = EsOutProgramGetEPGMetaName( p_pgrm, p_epg );
     msg_Dbg( p_input, "EsOutProgramEpg: number=%d name=%s", i_group, psz_cat );
 
     /* Merge EPG */
@@ -1282,7 +1299,9 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg
     {
         const vlc_epg_t *p_tmp = p_item->pp_epg[i];
 
-        if( p_tmp->psz_name && !strcmp(p_tmp->psz_name, psz_cat) )
+        if( p_tmp->psz_name
+            && p_tmp->i_network_id == p_epg->i_network_id
+            && p_tmp->i_service_id == p_epg->i_service_id )
         {
             if( p_tmp->p_current && p_tmp->p_current->psz_name && *p_tmp->p_current->psz_name )
                 p_pgrm->psz_now_playing = strdup( p_tmp->p_current->psz_name );
-- 
1.7.9




More information about the vlc-devel mailing list