Commit 839d1730 authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: smooth: some streamindex have no fragments (fix #11377)

SteamIndex for Chapters have no stream, then no qlevels
parent c021c39d
......@@ -328,6 +328,8 @@ static int build_smoo_box( stream_t *s, uint8_t *smoo_box )
quality_level_t * qlvl = get_qlevel( sms, sms->download_qlvl );
if ( qlvl )
{
FourCC = qlvl->FourCC ? qlvl->FourCC : sms->default_FourCC;
((uint32_t *)stra_box)[16] = bswap32( FourCC );
((uint32_t *)stra_box)[17] = bswap32( qlvl->Bitrate );
......@@ -348,6 +350,7 @@ static int build_smoo_box( stream_t *s, uint8_t *smoo_box )
memcpy( stra_box + 102, binary_cpd, stra_box[101] );
free( binary_cpd );
}
}
return VLC_SUCCESS;
}
......@@ -598,7 +601,7 @@ void* sms_Thread( void *p_this )
for( int i = 0; i < 3; i++ )
{
sms = SMS_GET_SELECTED_ST( index_to_es_cat( i ) );
if( sms )
if( sms && vlc_array_count( sms->chunks ) )
{
chunk = vlc_array_item_at_index( sms->chunks, 0 );
p_sys->download.lead[i] = chunk->start_time + p_sys->timescale / 1000;
......@@ -676,9 +679,12 @@ void* sms_Thread( void *p_this )
vlc_mutex_unlock( &p_sys->download.lock_wait );
sms = SMS_GET_SELECTED_ST( next_track( s ) );
if ( vlc_array_count( sms->chunks ) )
{
if( Download( s, sms ) != VLC_SUCCESS )
goto cancel;
}
}
cancel:
p_sys->b_error = true;
......
......@@ -172,12 +172,15 @@ static int parse_Manifest( stream_t *s )
p_sys->timescale = TIMESCALE;
}
if( !strcmp( node, "StreamIndex" ) )
{
sms = sms_New();
if( unlikely( !sms ) )
{
xml_ReaderDelete( vlc_reader );
xml_Delete( vlc_xml );
return VLC_ENOMEM;
}
sms->id = next_track_id;
next_track_id++;
......@@ -225,15 +228,21 @@ static int parse_Manifest( stream_t *s )
else if( sms->type == SPU_ES )
sms->name = strdup( "text" );
}
vlc_array_append( p_sys->sms_streams, sms );
}
if( !strcmp( node, "QualityLevel" ) )
{
if ( !sms )
break;
ql = ql_New();
if( !ql )
{
sms_Free( sms );
xml_ReaderDelete( vlc_reader );
xml_Delete( vlc_xml );
return VLC_ENOMEM;
}
ql->id = next_qid;
next_qid++;
while( (name = xml_ReaderNextAttr( vlc_reader, &value )) )
......@@ -275,11 +284,21 @@ static int parse_Manifest( stream_t *s )
if( !strcmp( name, "BitsPerSample" ) )
ql->BitsPerSample = strtoul( value, NULL, 10 );
}
vlc_array_append( sms->qlevels, ql );
}
if ( !strcmp( node, "Content" ) && sms && !sms->url_template )
{
/* empty(@Url) && ./Content == manifest embedded content */
sms_Free( sms );
sms = NULL;
}
if( !strcmp( node, "c" ) )
{
if ( !sms )
break;
loop_count++;
start_time = duration = -1;
while( (name = xml_ReaderNextAttr( vlc_reader, &value )) )
......@@ -327,6 +346,9 @@ static int parse_Manifest( stream_t *s )
if( unlikely( chunk_New( sms, computed_duration,
computed_start_time ) == NULL ) )
{
sms_Free( sms );
xml_ReaderDelete( vlc_reader );
xml_Delete( vlc_xml );
return VLC_ENOMEM;
}
if( b_weird && start_time != -1 )
......@@ -338,17 +360,29 @@ static int parse_Manifest( stream_t *s )
if( strcmp( node, "StreamIndex" ) )
break;
if ( sms )
{
vlc_array_append( p_sys->sms_streams, sms );
computed_start_time = 0;
computed_duration = 0;
loop_count = 0;
if( b_weird && !chunk_New( sms, computed_duration, computed_start_time ) )
{
sms_Free( sms );
xml_ReaderDelete( vlc_reader );
xml_Delete( vlc_xml );
return VLC_ENOMEM;
}
b_weird = false;
next_qid = 1;
if( sms->qlevel_nb == 0 )
sms->qlevel_nb = vlc_array_count( sms->qlevels );
sms = NULL;
}
break;
case XML_READER_NONE:
......@@ -356,6 +390,9 @@ static int parse_Manifest( stream_t *s )
case XML_READER_TEXT:
break;
default:
sms_Free( sms );
xml_ReaderDelete( vlc_reader );
xml_Delete( vlc_xml );
return VLC_EGENERIC;
}
}
......@@ -437,6 +474,8 @@ static int Open( vlc_object_t *p_this )
{
wanted = qlvl = NULL;
sms = vlc_array_item_at_index( p_sys->sms_streams, i );
if ( vlc_array_count( sms->qlevels ) )
{
wanted = vlc_array_item_at_index( sms->qlevels, 0 );
for( unsigned i=1; i < sms->qlevel_nb; i++ )
{
......@@ -446,6 +485,7 @@ static int Open( vlc_object_t *p_this )
}
sms->download_qlvl = wanted->id;
}
}
vlc_mutex_init( &p_sys->download.lock_wait );
vlc_cond_init( &p_sys->download.wait );
......
......@@ -115,6 +115,8 @@ sms_stream_t * sms_New( void )
void sms_Free( sms_stream_t *sms )
{
if ( !sms )
return;
if( sms->qlevels )
{
for( int n = 0; n < vlc_array_count( sms->qlevels ); n++ )
......@@ -138,7 +140,6 @@ void sms_Free( sms_stream_t *sms )
free( sms->name );
free( sms->url_template );
free( sms );
sms = NULL;
}
quality_level_t *get_qlevel( sms_stream_t *sms, const unsigned qid )
......
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