[vlc-commits] demux: ts: allow to replace generated pat

Francois Cartegnie git at videolan.org
Wed Nov 15 16:57:58 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Nov 15 15:27:22 2017 +0100| [4c7cd5a4ca43223bac9d9f6eb9c3849eb2930e38] | committer: Francois Cartegnie

demux: ts: allow to replace generated pat

refs ts/La_Chevre_PATPMTevery6s.ts

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4c7cd5a4ca43223bac9d9f6eb9c3849eb2930e38
---

 modules/demux/mpeg/ts.c                 | 23 ++++++++++++++++-------
 modules/demux/mpeg/ts.h                 |  7 ++++++-
 modules/demux/mpeg/ts_psi.c             | 24 ++++++++++++++++++------
 modules/demux/mpeg/ts_sl.c              |  2 +-
 modules/demux/mpeg/ts_streams.c         |  1 +
 modules/demux/mpeg/ts_streams_private.h |  1 +
 6 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index 0fa65d7263..431e7b98c7 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -415,7 +415,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_access_control = ( VLC_SUCCESS == SetPIDFilter( p_sys, patpid, true ) );
 
     p_sys->i_pmt_es = 0;
-    p_sys->b_es_all = false;
+    p_sys->seltype = PROGRAM_AUTO_DEFAULT;
 
     /* Read config */
     p_sys->b_es_id_pid = var_CreateGetBool( p_demux, "ts-es-id-pid" );
@@ -609,6 +609,7 @@ static int Demux( demux_t *p_demux )
     {
         MissingPATPMTFixup( p_demux );
         p_sys->patfix.status = PAT_FIXTRIED;
+        GetPID(p_sys, 0)->u.p_pat->b_generated = true;
     }
 
     /* We read at most 100 TS packet or until a frame is completed */
@@ -698,7 +699,7 @@ static int Demux( demux_t *p_demux )
             {
                 msg_Dbg( p_demux, "Creating delayed ES" );
                 AddAndCreateES( p_demux, p_pid, true );
-                UpdatePESFilters( p_demux, p_sys->b_es_all );
+                UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
             }
 
             /* Emulate HW filter */
@@ -1055,28 +1056,33 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
             if( i_int != -1 )
             {
-                p_sys->b_es_all = false;
+                p_sys->seltype = PROGRAM_LIST;
                 ARRAY_APPEND( p_sys->programs, i_int );
                 UpdatePESFilters( p_demux, false );
             }
             else if( likely( p_list != NULL ) )
             {
-                p_sys->b_es_all = false;
+                p_sys->seltype = PROGRAM_LIST;
                 for( int i = 0; i < p_list->i_count; i++ )
                    ARRAY_APPEND( p_sys->programs, p_list->p_values[i].i_int );
                 UpdatePESFilters( p_demux, false );
             }
             else // All ES Mode
             {
-                p_sys->b_es_all = true;
                 p_pat = GetPID(p_sys, 0)->u.p_pat;
                 for( int i = 0; i < p_pat->programs.i_size; i++ )
                    ARRAY_APPEND( p_sys->programs, p_pat->programs.p_elems[i]->i_pid );
+                p_sys->seltype = PROGRAM_ALL;
                 UpdatePESFilters( p_demux, true );
             }
 
             p_sys->b_default_selection = false;
         }
+        else
+        {
+            ARRAY_RESET( p_sys->programs );
+            p_sys->seltype = PROGRAM_AUTO_DEFAULT;
+        }
 
         return VLC_SUCCESS;
     }
@@ -1086,7 +1092,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         i_int = va_arg( args, int );
         msg_Dbg( p_demux, "DEMUX_SET_ES %d", i_int );
 
-        if( !p_sys->b_es_all ) /* Won't change anything */
+        if( p_demux->p_sys->seltype != PROGRAM_ALL ) /* Won't change anything */
             UpdatePESFilters( p_demux, false );
 
         return VLC_SUCCESS;
@@ -2369,7 +2375,7 @@ static void PCRFixHandle( demux_t *p_demux, ts_pmt_t *p_pmt, block_t *p_block )
                 p_pmt->pcr.b_disable = true;
             msg_Warn( p_demux, "No PCR received for program %d, set up workaround using pid %d",
                       p_pmt->i_number, i_cand );
-            UpdatePESFilters( p_demux, p_demux->p_sys->b_es_all );
+            UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
         }
         p_pmt->pcr.b_fix_done = true;
     }
@@ -2746,6 +2752,9 @@ void TsChangeStandard( demux_sys_t *p_sys, ts_standards_e v )
 
 bool ProgramIsSelected( demux_sys_t *p_sys, uint16_t i_pgrm )
 {
+    if( p_sys->seltype == PROGRAM_ALL )
+        return true;
+
     for(int i=0; i<p_sys->programs.i_size; i++)
         if( p_sys->programs.p_elems[i] == i_pgrm )
             return true;
diff --git a/modules/demux/mpeg/ts.h b/modules/demux/mpeg/ts.h
index d2a06d3a48..cb50e36ba0 100644
--- a/modules/demux/mpeg/ts.h
+++ b/modules/demux/mpeg/ts.h
@@ -77,7 +77,6 @@ struct demux_sys_t
 
     bool        b_user_pmt;
     int         i_pmt_es;
-    bool        b_es_all; /* If we need to return all es/programs */
 
     enum
     {
@@ -108,6 +107,12 @@ struct demux_sys_t
     bool        b_broken_charset; /* True if broken encoding is used in EPG/SDT */
 
     /* Selected programs */
+    enum
+    {
+        PROGRAM_AUTO_DEFAULT, /* Always select first program sending data */
+        PROGRAM_LIST, /* explicit list of programs, see list below */
+        PROGRAM_ALL, /* everything */
+    } seltype; /* reflects the DEMUX_SET_GROUP */
     DECL_ARRAY( int ) programs; /* List of selected/access-filtered programs */
     bool        b_default_selection; /* True if set by default to first pmt seen (to get data from filtered access) */
 
diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index e947f774a3..2938013230 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -98,11 +98,22 @@ static void PATCallBack( void *data, dvbpsi_pat_t *p_dvbpsipat )
         return;
     }
 
-    if( ( p_pat->i_version != -1 &&
-            ( !p_dvbpsipat->b_current_next ||
-              p_dvbpsipat->i_version == p_pat->i_version ) ) ||
-        ( p_pat->i_ts_id != -1 && p_dvbpsipat->i_ts_id != p_pat->i_ts_id ) ||
-        p_sys->b_user_pmt || PATCheck( p_demux, p_dvbpsipat ) )
+    /* check versioning changes */
+    if( !p_pat->b_generated )
+    {
+        /* override hotfixes */
+        if( ( p_pat->i_version != -1 && p_dvbpsipat->i_version == p_pat->i_version ) ||
+            ( p_pat->i_ts_id != -1 && p_dvbpsipat->i_ts_id != p_pat->i_ts_id ) )
+        {
+            dvbpsi_pat_delete( p_dvbpsipat );
+            return;
+        }
+    }
+    else msg_Warn( p_demux, "Replacing generated PAT with one received from stream" );
+
+    /* check content */
+    if( !p_dvbpsipat->b_current_next || p_sys->b_user_pmt ||
+        PATCheck( p_demux, p_dvbpsipat ) )
     {
         dvbpsi_pat_delete( p_dvbpsipat );
         return;
@@ -171,6 +182,7 @@ static void PATCallBack( void *data, dvbpsi_pat_t *p_dvbpsipat )
     }
     p_pat->i_version = p_dvbpsipat->i_version;
     p_pat->i_ts_id = p_dvbpsipat->i_ts_id;
+    p_pat->b_generated = false;
 
     for(int i=0; i<old_pmt_rm.i_size; i++)
     {
@@ -1945,7 +1957,7 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
                   p_pmt->i_number, i_cand );
     }
 
-    UpdatePESFilters( p_demux, p_sys->b_es_all );
+    UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
 
     /* Probe Boundaries */
     if( p_sys->b_canfastseek && p_pmt->i_last_dts == -1 )
diff --git a/modules/demux/mpeg/ts_sl.c b/modules/demux/mpeg/ts_sl.c
index 986db8b78e..bcf22c1fe9 100644
--- a/modules/demux/mpeg/ts_sl.c
+++ b/modules/demux/mpeg/ts_sl.c
@@ -187,7 +187,7 @@ void SLPackets_Section_Handler( demux_t *p_demux,
         }
 
         if( b_changed )
-            UpdatePESFilters( p_demux, p_demux->p_sys->b_es_all );
+            UpdatePESFilters( p_demux, p_demux->p_sys->seltype == PROGRAM_ALL );
     }
 }
 
diff --git a/modules/demux/mpeg/ts_streams.c b/modules/demux/mpeg/ts_streams.c
index 9b5ec2d8d9..68de1e0eca 100644
--- a/modules/demux/mpeg/ts_streams.c
+++ b/modules/demux/mpeg/ts_streams.c
@@ -71,6 +71,7 @@ ts_pat_t *ts_pat_New( demux_t *p_demux )
 
     pat->i_version  = -1;
     pat->i_ts_id    = -1;
+    pat->b_generated = false;
     ARRAY_INIT( pat->programs );
 
     return pat;
diff --git a/modules/demux/mpeg/ts_streams_private.h b/modules/demux/mpeg/ts_streams_private.h
index d1bfe3e8f8..478ffb4057 100644
--- a/modules/demux/mpeg/ts_streams_private.h
+++ b/modules/demux/mpeg/ts_streams_private.h
@@ -31,6 +31,7 @@ struct ts_pat_t
 {
     int             i_version;
     int             i_ts_id;
+    bool            b_generated;
     dvbpsi_t       *handle;
     DECL_ARRAY(ts_pid_t *) programs;
 



More information about the vlc-commits mailing list