Commit 0c7c4caa authored by Jean-Paul Saman's avatar Jean-Paul Saman

stream_filter/httplive.c: do not crash on seeking

After the adaptive bandwidth changes seeking could end up in a segment
that is not available. Each segment is downloaded once and after switching
to higher or lower bandwidth segments downloaded for previous bandwidths
will not be deleted or downloaded. The later is to be fixed.
parent d20cd478
...@@ -61,7 +61,7 @@ vlc_module_end() ...@@ -61,7 +61,7 @@ vlc_module_end()
typedef struct segment_s typedef struct segment_s
{ {
int sequence; /* unique sequence number */ int sequence; /* unique sequence number */
int length; /* segment duration (ms) */ int length; /* segment duration (seconds) */
uint64_t size; /* segment size in bytes */ uint64_t size; /* segment size in bytes */
vlc_url_t url; vlc_url_t url;
...@@ -1475,6 +1475,8 @@ static int segment_Seek(stream_t *s, uint64_t pos) ...@@ -1475,6 +1475,8 @@ static int segment_Seek(stream_t *s, uint64_t pos)
return VLC_EGENERIC; return VLC_EGENERIC;
vlc_mutex_lock(&segment->lock); vlc_mutex_lock(&segment->lock);
if (segment->data)
{
length += segment->size; length += segment->size;
uint64_t size = segment->size -segment->data->i_buffer; uint64_t size = segment->size -segment->data->i_buffer;
if (size > 0) if (size > 0)
...@@ -1493,6 +1495,20 @@ static int segment_Seek(stream_t *s, uint64_t pos) ...@@ -1493,6 +1495,20 @@ static int segment_Seek(stream_t *s, uint64_t pos)
p_sys->segment = n; p_sys->segment = n;
b_found = true; b_found = true;
} }
}
else
{
/* FIXME: seeking is weird when seeking in segments
that have not been downloaded yet */
length += segment->length * hls->bandwidth;
if (!b_found && (pos <= length))
{
count = p_sys->segment;
p_sys->segment = n;
b_found = true;
}
}
vlc_mutex_unlock(&segment->lock); vlc_mutex_unlock(&segment->lock);
} }
return VLC_SUCCESS; return VLC_SUCCESS;
......
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