[vlc-commits] stream_filter: smooth: handle live max lookahead
Francois Cartegnie
git at videolan.org
Wed Oct 29 11:48:46 CET 2014
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Oct 29 11:33:07 2014 +0100| [95b15a98ed05c953e5b8c4274fb681fcb877e457] | committer: Francois Cartegnie
stream_filter: smooth: handle live max lookahead
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=95b15a98ed05c953e5b8c4274fb681fcb877e457
---
modules/stream_filter/smooth/downloader.c | 8 +++++++-
modules/stream_filter/smooth/smooth.c | 2 ++
modules/stream_filter/smooth/smooth.h | 2 ++
modules/stream_filter/smooth/utils.c | 9 +++++++++
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/modules/stream_filter/smooth/downloader.c b/modules/stream_filter/smooth/downloader.c
index ded6f38..12b1150 100644
--- a/modules/stream_filter/smooth/downloader.c
+++ b/modules/stream_filter/smooth/downloader.c
@@ -760,7 +760,13 @@ 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 ) )
+
+ 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 )
goto cancel;
diff --git a/modules/stream_filter/smooth/smooth.c b/modules/stream_filter/smooth/smooth.c
index 62fe468..876bb86 100644
--- a/modules/stream_filter/smooth/smooth.c
+++ b/modules/stream_filter/smooth/smooth.c
@@ -168,6 +168,8 @@ static int parse_Manifest( stream_t *s )
p_sys->vod_duration = strtoull( value, NULL, 10 );
else if( !strcmp( name, "TimeScale" ) )
p_sys->timescale = strtoull( value, NULL, 10 );
+ else if ( !strcmp( name, "LookAheadFragmentCount" ) )
+ p_sys->lookahead_count = strtoul( value, NULL, 10 );
}
if( !p_sys->timescale )
p_sys->timescale = TIMESCALE;
diff --git a/modules/stream_filter/smooth/smooth.h b/modules/stream_filter/smooth/smooth.h
index c4121b1..568bda1 100644
--- a/modules/stream_filter/smooth/smooth.h
+++ b/modules/stream_filter/smooth/smooth.h
@@ -103,6 +103,7 @@ struct stream_sys_t
unsigned i_tracks; /* Total number of tracks in the Manifest */
sms_queue_t *bws; /* Measured bandwidths of the N last chunks */
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;
unsigned timescale;
@@ -188,6 +189,7 @@ void sms_Free( sms_stream_t *);
uint8_t *decode_string_hex_to_binary( const char * );
sms_stream_t * sms_get_stream_by_cat( vlc_array_t *, int );
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 es_cat_to_index( int );
diff --git a/modules/stream_filter/smooth/utils.c b/modules/stream_filter/smooth/utils.c
index e51bc22..89095c7 100644
--- a/modules/stream_filter/smooth/utils.c
+++ b/modules/stream_filter/smooth/utils.c
@@ -293,3 +293,12 @@ bool no_more_chunks( unsigned *indexes, vlc_array_t *streams )
}
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;
+}
More information about the vlc-commits
mailing list