Commit 6d9aba2f authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptative: fix tfhd track ID on segment read

Better than late in-demuxer fix.
reverts 8b269f94
parent 33ea1f23
......@@ -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) )
{
......
......@@ -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 )
{
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment