Commit 0c9f38b8 authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: smooth: merge trackid fix with chunk read

And drop all unused and useless code
parent 0d862d0b
......@@ -135,39 +135,6 @@ static chunk_t * chunk_Get( sms_stream_t *sms, const uint64_t start_time )
return p_chunk;
}
static unsigned set_track_id( chunk_t *chunk, const unsigned tid )
{
uint32_t size, type;
if( !chunk->data || chunk->size < 32 )
return 0;
uint8_t *slice = chunk->data;
if( !slice )
return 0;
SMS_GET4BYTES( size );
SMS_GETFOURCC( type );
assert( type == ATOM_moof );
SMS_GET4BYTES( size );
SMS_GETFOURCC( type );
assert( type == ATOM_mfhd );
slice += size - 8;
SMS_GET4BYTES( size );
SMS_GETFOURCC( type );
assert( type == ATOM_traf );
SMS_GET4BYTES( size );
SMS_GETFOURCC( type );
if( type != ATOM_tfhd )
return 0;
unsigned ret = bswap32( ((uint32_t *)slice)[1] );
((uint32_t *)slice)[1] = bswap32( tid );
return ret;
}
static int sms_Download( stream_t *s, chunk_t *chunk, char *url )
{
stream_t *p_ts = stream_UrlNew( s, url );
......@@ -295,7 +262,7 @@ BandwidthAdaptation( stream_t *s, sms_stream_t *sms,
}
#endif
static int get_new_chunks( stream_t *s, chunk_t *ck, sms_stream_t *sms )
static int parse_chunk( stream_t *s, chunk_t *ck, sms_stream_t *sms )
{
if( ck->size < 24 )
return VLC_EGENERIC;
......@@ -316,6 +283,13 @@ static int get_new_chunks( stream_t *s, chunk_t *ck, sms_stream_t *sms )
MP4_BoxDumpStructure( ck_s, &root_box );
#endif
/* Do track ID fixup */
const MP4_Box_t *tfhd_box = MP4_BoxGet( &root_box, "moof/traf/tfhd" );
if ( tfhd_box )
SetDWBE( &ck->data[tfhd_box->i_pos + 8 + 4], sms->id );
if ( s->p_sys->b_live )
{
const MP4_Box_t *uuid_box = MP4_BoxGet( &root_box, "moof/traf/uuid" );
while( uuid_box && uuid_box->i_type == ATOM_uuid )
{
......@@ -337,6 +311,7 @@ static int get_new_chunks( stream_t *s, chunk_t *ck, sms_stream_t *sms )
chunk_AppendNew( sms, dur, stime );
}
}
}
MP4_Box_t *p_box = root_box.p_first;
while( p_box )
......@@ -506,17 +481,7 @@ static int Download( stream_t *s, sms_stream_t *sms )
}
duration = mdate() - duration;
unsigned real_id = set_track_id( chunk, sms->id );
if( real_id == 0)
{
msg_Err( s, "tfhd box not found or invalid chunk" );
return VLC_EGENERIC;
}
if( p_sys->b_live )
{
get_new_chunks( s, chunk, sms );
}
parse_chunk( s, chunk, sms );
msg_Info( s, "downloaded chunk @%"PRIu64" from stream %s at quality %u",
chunk->start_time, sms->name, sms->current_qlvl->Bitrate );
......
......@@ -761,12 +761,6 @@ static unsigned int sms_Read( stream_t *s, uint8_t *p_read, unsigned int i_read
const char *verb = p_read == NULL ? "skipping" : "reading";
msg_Dbg( s, "%s chunk time %"PRIu64" (%u bytes), type %i",
verb, chunk->start_time, i_read, chunk->type );
/* check integrity */
uint32_t type;
uint8_t *slice = chunk->data;
SMS_GET4BYTES( type );
SMS_GETFOURCC( type );
assert( type == ATOM_moof || type == ATOM_uuid );
}
uint64_t len = 0;
......
......@@ -141,37 +141,6 @@ struct stream_sys_t
bool b_close; /* set by Close() */
};
#define SMS_GET4BYTES( dst ) do { \
dst = U32_AT( slice ); \
slice += 4; \
} while(0)
#define SMS_GET1BYTE( dst ) do { \
dst = *slice; \
slice += 1; \
} while(0)
#define SMS_GET3BYTES( dst ) do { \
dst = Get24bBE( slice ); \
slice += 3; \
} while(0)
#define SMS_GET8BYTES( dst ) do { \
dst = U64_AT( slice ); \
slice += 8; \
} while(0)
#define SMS_GET4or8BYTES( dst ) \
if( (version) == 0 ) \
SMS_GET4BYTES( dst ); \
else \
SMS_GET8BYTES( dst ); \
#define SMS_GETFOURCC( dst ) do { \
memcpy( &dst, slice, 4 ); \
slice += 4; \
} while(0)
#define SMS_GET_SELECTED_ST( cat ) \
sms_get_stream_by_cat( p_sys, cat )
......
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