Commit 95b15a98 authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: smooth: handle live max lookahead

parent a95ac7be
...@@ -760,7 +760,13 @@ void* sms_Thread( void *p_this ) ...@@ -760,7 +760,13 @@ void* sms_Thread( void *p_this )
vlc_mutex_unlock( &p_sys->download.lock_wait ); vlc_mutex_unlock( &p_sys->download.lock_wait );
sms = SMS_GET_SELECTED_ST( next_track( s ) ); sms = SMS_GET_SELECTED_ST( next_track( s ) );
if ( vlc_array_count( sms->chunks ) )
vlc_mutex_lock( &p_sys->download.lock_wait );
unsigned i_ahead = ahead_chunks_count( p_sys, sms );
vlc_mutex_unlock( &p_sys->download.lock_wait );
if ( vlc_array_count( sms->chunks ) &&
( !p_sys->b_live || i_ahead < p_sys->lookahead_count ) )
{ {
if( Download( s, sms ) != VLC_SUCCESS ) if( Download( s, sms ) != VLC_SUCCESS )
goto cancel; goto cancel;
......
...@@ -168,6 +168,8 @@ static int parse_Manifest( stream_t *s ) ...@@ -168,6 +168,8 @@ static int parse_Manifest( stream_t *s )
p_sys->vod_duration = strtoull( value, NULL, 10 ); p_sys->vod_duration = strtoull( value, NULL, 10 );
else if( !strcmp( name, "TimeScale" ) ) else if( !strcmp( name, "TimeScale" ) )
p_sys->timescale = strtoull( value, NULL, 10 ); p_sys->timescale = strtoull( value, NULL, 10 );
else if ( !strcmp( name, "LookAheadFragmentCount" ) )
p_sys->lookahead_count = strtoul( value, NULL, 10 );
} }
if( !p_sys->timescale ) if( !p_sys->timescale )
p_sys->timescale = TIMESCALE; p_sys->timescale = TIMESCALE;
......
...@@ -103,6 +103,7 @@ struct stream_sys_t ...@@ -103,6 +103,7 @@ struct stream_sys_t
unsigned i_tracks; /* Total number of tracks in the Manifest */ unsigned i_tracks; /* Total number of tracks in the Manifest */
sms_queue_t *bws; /* Measured bandwidths of the N last chunks */ sms_queue_t *bws; /* Measured bandwidths of the N last chunks */
uint64_t vod_duration; /* total duration of the VOD media */ uint64_t vod_duration; /* total duration of the VOD media */
unsigned lookahead_count;/* max number of fragments ahead on server on live streaming */
uint64_t time_pos; uint64_t time_pos;
unsigned timescale; unsigned timescale;
...@@ -188,6 +189,7 @@ void sms_Free( sms_stream_t *); ...@@ -188,6 +189,7 @@ void sms_Free( sms_stream_t *);
uint8_t *decode_string_hex_to_binary( const char * ); uint8_t *decode_string_hex_to_binary( const char * );
sms_stream_t * sms_get_stream_by_cat( vlc_array_t *, int ); sms_stream_t * sms_get_stream_by_cat( vlc_array_t *, int );
bool no_more_chunks( unsigned[], vlc_array_t *); bool no_more_chunks( unsigned[], vlc_array_t *);
unsigned int ahead_chunks_count( stream_sys_t *, sms_stream_t * );
int index_to_es_cat( int ); int index_to_es_cat( int );
int es_cat_to_index( int ); int es_cat_to_index( int );
......
...@@ -293,3 +293,12 @@ bool no_more_chunks( unsigned *indexes, vlc_array_t *streams ) ...@@ -293,3 +293,12 @@ bool no_more_chunks( unsigned *indexes, vlc_array_t *streams )
} }
return true; return true;
} }
unsigned int ahead_chunks_count( stream_sys_t *p_sys, sms_stream_t *sms )
{
int ind = es_cat_to_index( sms->type );
if ( p_sys->download.ck_index[ind] > vlc_array_count( p_sys->download.chunks ) )
return p_sys->download.ck_index[ind] - vlc_array_count( p_sys->download.chunks );
else
return 0;
}
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