[vlc-commits] demux: adaptative: fix tfhd track ID on segment read

Francois Cartegnie git at videolan.org
Mon Nov 2 12:37:02 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov  2 12:23:36 2015 +0100| [6d9aba2f8b96ca5877a331b5b655cc1d79ccaa9c] | committer: Francois Cartegnie

demux: adaptative: fix tfhd track ID on segment read

Better than late in-demuxer fix.
reverts 8b269f94fa95a1d374140fef3a8f3fd33422bddd

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

 modules/demux/mp4/mp4.c                            |   22 --------------------
 modules/demux/smooth/mp4/IndexReader.cpp           |    5 +++++
 .../demux/smooth/playlist/ForgedInitSegment.cpp    |    2 +-
 3 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index ff9fb3b..0161464 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -84,7 +84,6 @@ struct demux_sys_t
     bool         b_fastseekable;
     bool         b_seekmode;
     bool         b_smooth;       /* Is it Smooth Streaming? (streamfilter) */
-    bool         b_ismv;
 
     bool            b_index_probed;
     bool            b_fragments_probed;
@@ -653,7 +652,6 @@ static int Open( vlc_object_t * p_this )
             else if (BOXDATA(p_ftyp)->i_compatible_brands[i] == VLC_FOURCC('s', 'm', 'o', 'o') )
             {
                 msg_Dbg( p_demux, "Handling VLC Smooth Stream" );
-                p_sys->b_ismv = true;
             }
         }
     }
@@ -4258,18 +4256,6 @@ static bool AddFragment( demux_t *p_demux, MP4_Box_t *p_moox )
             i_track_defaultsamplesize = 1;
             i_track_defaultsampleduration = 1;
         }
-        else if( p_sys->b_ismv && p_sys->i_tracks == 1 )
-        {
-            const MP4_Box_t *p_trex = MP4_BoxGet( p_moovfragment->p_moox, "mvex/trex" );
-            if ( p_trex )
-            {
-               i_track_defaultsamplesize = BOXDATA(p_trex)->i_default_sample_size;
-               i_track_defaultsampleduration = BOXDATA(p_trex)->i_default_sample_duration;
-            }
-            const MP4_Box_t *p_mdhd = MP4_BoxGet( p_moovfragment->p_moox, "trak/mdia/mdhd" );
-            if ( p_mdhd )
-                i_track_timescale = BOXDATA(p_mdhd)->i_timescale;
-        }
         else
         {
             /* set trex for defaults */
@@ -5166,14 +5152,6 @@ static int DemuxAsLeaf( demux_t *p_demux )
                     return 1;
                 }
 
-                /* Hotfix for adaptive/smooth streaming as we don't know track # when creating moov */
-                if( p_fragbox->i_type == ATOM_moof && p_sys->b_ismv && p_sys->i_tracks == 1 )
-                {
-                    MP4_Box_t *p_tfhd = MP4_BoxGet( p_fragbox, "traf/tfhd" );
-                    if(p_tfhd && BOXDATA(p_tfhd))
-                        p_sys->track[0].i_track_ID = BOXDATA(p_tfhd)->i_track_ID;
-                }
-
                 MP4_Box_t *p_mfhd = MP4_BoxGet( p_fragbox, "mfhd" );
                 if( p_mfhd && BOXDATA(p_mfhd) )
                 {
diff --git a/modules/demux/smooth/mp4/IndexReader.cpp b/modules/demux/smooth/mp4/IndexReader.cpp
index 84add9b..0869f33 100644
--- a/modules/demux/smooth/mp4/IndexReader.cpp
+++ b/modules/demux/smooth/mp4/IndexReader.cpp
@@ -37,6 +37,11 @@ bool IndexReader::parseIndex(block_t *p_block, BaseRepresentation *rep)
     if(!rep || !parseBlock(p_block))
         return false;
 
+    /* Do track ID fixup */
+    const MP4_Box_t *tfhd_box = MP4_BoxGet( rootbox, "moof/traf/tfhd" );
+    if ( tfhd_box )
+        SetDWBE( &p_block->p_buffer[tfhd_box->i_pos + 8 + 4], 0x01 );
+
     const MP4_Box_t *uuid_box = MP4_BoxGet( rootbox, "moof/traf/uuid" );
     while( uuid_box && uuid_box->i_type == ATOM_uuid )
     {
diff --git a/modules/demux/smooth/playlist/ForgedInitSegment.cpp b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
index 97f3347..1411f79 100644
--- a/modules/demux/smooth/playlist/ForgedInitSegment.cpp
+++ b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
@@ -204,7 +204,7 @@ block_t * ForgedInitSegment::buildMoovBox()
     mp4mux_trackinfo_t trackinfo;
     mp4mux_trackinfo_Init(&trackinfo);
 
-    trackinfo.i_track_id = track_id;
+    trackinfo.i_track_id = 0x01; /* Will always be 1st and unique track; tfhd patched on block read */
     trackinfo.i_timescale = timescale.Get();
     trackinfo.i_read_duration = duration.Get();
     trackinfo.i_trex_default_length = 1;



More information about the vlc-commits mailing list