[vlc-devel] [PATCH 47/48] hls: Trying to work arround streams without bandwidth value.
Hugo Beauzée-Luyssen
beauze.h at gmail.com
Mon Jan 9 16:16:56 CET 2012
A 0 bandwidth forbid us to seek, as the position would always be 0.
This fixes #5370
---
modules/stream_filter/httplive.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 65de170..ce1656b 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -288,6 +288,10 @@ static uint64_t hls_GetStreamSize(hls_stream_t *hls)
* then the deviation from exact byte size will be big and the seek/
* progressbar will not behave entirely as one expects. */
uint64_t size = 0UL;
+ /* If we don't have a valid bandwidth yet, there's no point in
+ * computing the stream size */
+ if ( hls->bandwidth == 0 )
+ return size;
int count = vlc_array_count(hls->segments);
for (int n = 0; n < count; n++)
{
@@ -1465,6 +1469,11 @@ static int hls_DownloadSegmentData(stream_t *s, hls_stream_t *hls, segment_t *se
goto fail;
}
mtime_t duration = mdate() - start;
+ if ( hls->bandwidth == 0 )
+ {
+ /* Try to estimate the bandwidth for this stream */
+ hls->bandwidth = (uint64_t)( (double)segment->size / ( (double)duration / 1000000.0 ) );
+ }
msg_Info(s, "downloaded segment %d from stream %d in %dms",
segment->sequence, *cur_stream, (int)(duration/1000));
@@ -2376,9 +2385,10 @@ static uint64_t GetStreamSize(stream_t *s)
if (hls == NULL) return 0;
vlc_mutex_lock(&hls->lock);
+ if ( hls->size == 0 )
+ hls->size = hls_GetStreamSize( hls );
uint64_t size = hls->size;
vlc_mutex_unlock(&hls->lock);
-
return size;
}
--
1.7.8.3
More information about the vlc-devel
mailing list