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()
typedef struct segment_s
{
int sequence; /* unique sequence number */
int length; /* segment duration (ms) */
int length; /* segment duration (seconds) */
uint64_t size; /* segment size in bytes */
vlc_url_t url;
......@@ -1475,6 +1475,8 @@ static int segment_Seek(stream_t *s, uint64_t pos)
return VLC_EGENERIC;
vlc_mutex_lock(&segment->lock);
if (segment->data)
{
length += segment->size;
uint64_t size = segment->size -segment->data->i_buffer;
if (size > 0)
......@@ -1493,6 +1495,20 @@ static int segment_Seek(stream_t *s, uint64_t pos)
p_sys->segment = n;
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);
}
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