[vlc-commits] demux: ts: fix delayed es creation after filtering

Francois Cartegnie git at videolan.org
Sun Mar 15 22:03:52 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar 13 16:24:52 2015 +0100| [92141e412795d4e7b86b5bb73beb82b43106f9a9] | committer: Francois Cartegnie

demux: ts: fix delayed es creation after filtering

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

 modules/demux/ts.c |   49 ++++++++++++++++++++++---------------------------
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/modules/demux/ts.c b/modules/demux/ts.c
index 6ef23da..8b251c9 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -507,7 +507,7 @@ static inline int PIDGet( block_t *p )
 }
 
 static bool GatherData( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk );
-static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid );
+static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool );
 static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_prg, mtime_t i_pcr );
 
 static block_t* ReadTSPacket( demux_t *p_demux );
@@ -1331,7 +1331,7 @@ static int Demux( demux_t *p_demux )
             p_sys->b_end_preparse = true;
             if( p_sys->es_creation == DELAY_ES ) /* No longer delay ES since that pid's program sends data */
             {
-                AddAndCreateES( p_demux, NULL );
+                AddAndCreateES( p_demux, p_pid, true );
             }
             b_frame = GatherData( p_demux, p_pid, p_pkt );
 
@@ -5053,36 +5053,33 @@ static void PMTParseEsIso639( demux_t *p_demux, ts_pes_es_t *p_es,
 #endif
 }
 
-static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid )
+static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid, bool b_create_delayed )
 {
     demux_sys_t  *p_sys = p_demux->p_sys;
-    bool b_create_delayed = false;
 
-    if( pid )
+    if( b_create_delayed )
+        p_sys->es_creation = CREATE_ES;
+
+    if( pid && p_sys->es_creation == CREATE_ES )
     {
-        if( SEEN(*pid) && p_sys->es_creation == DELAY_ES )
+        pid->u.p_pes->es.id = es_out_Add( p_demux->out, &pid->u.p_pes->es.fmt );
+        for( int i = 0; i < pid->u.p_pes->extra_es.i_size; i++ )
         {
-            p_sys->es_creation = CREATE_ES;
-            b_create_delayed = true;
+            pid->u.p_pes->extra_es.p_elems[i]->id =
+                    es_out_Add( p_demux->out, &pid->u.p_pes->extra_es.p_elems[i]->fmt );
         }
+        p_sys->i_pmt_es += 1 + pid->u.p_pes->extra_es.i_size;
 
-        if( p_sys->es_creation == CREATE_ES )
+        /* Update the default program == first created ES group */
+        if( p_sys->b_default_selection )
         {
-            pid->u.p_pes->es.id = es_out_Add( p_demux->out, &pid->u.p_pes->es.fmt );
-            for( int i = 0; i < pid->u.p_pes->extra_es.i_size; i++ )
-            {
-                pid->u.p_pes->extra_es.p_elems[i]->id =
-                    es_out_Add( p_demux->out, &pid->u.p_pes->extra_es.p_elems[i]->fmt );
-            }
-            p_sys->i_pmt_es += 1 + pid->u.p_pes->extra_es.i_size;
-            UpdatePESFilters( p_demux, p_sys->b_es_all );
+            p_sys->b_default_selection = false;
+            assert(p_sys->programs.i_size == 1);
+            if( p_sys->programs.p_elems[0] != pid->p_parent->u.p_pmt->i_number )
+                p_sys->programs.p_elems[0] = pid->p_parent->u.p_pmt->i_number;
+            msg_Dbg( p_demux, "Default program is %d", pid->p_parent->u.p_pmt->i_number );
         }
     }
-    else if( p_sys->es_creation == DELAY_ES )
-    {
-        p_sys->es_creation = CREATE_ES;
-        b_create_delayed = true;
-    }
 
     if( b_create_delayed )
     {
@@ -5103,13 +5100,11 @@ static void AddAndCreateES( demux_t *p_demux, ts_pid_t *pid )
                         es_out_Add( p_demux->out, &pid->u.p_pes->extra_es.p_elems[k]->fmt );
                 }
                 p_sys->i_pmt_es += 1 + pid->u.p_pes->extra_es.i_size;
-
-                if( pid->u.p_pes->es.id != NULL && ProgramIsSelected( p_sys, pid->p_parent->u.p_pmt->i_number ) )
-                    SetPIDFilter( p_sys, pid, true );
             }
         }
-        UpdatePESFilters( p_demux, p_sys->b_es_all );
     }
+
+    UpdatePESFilters( p_demux, p_sys->b_es_all );
 }
 
 static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
@@ -5501,7 +5496,7 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
             }
             else
             {
-                AddAndCreateES( p_demux, pespid );
+                AddAndCreateES( p_demux, pespid, false );
             }
         }
 



More information about the vlc-commits mailing list