Commit 5a7f4600 authored by Jean-Paul Saman's avatar Jean-Paul Saman

stream_filter/httplive.c: Also check for empty lines.

Do not treat an empty line as a HLS segment.
parent 1ce738d1
......@@ -138,6 +138,7 @@ static int Control(stream_t *, int i_query, va_list);
static ssize_t read_M3U8(stream_t *s, vlc_url_t *url, uint8_t **buffer);
static ssize_t ReadM3U8(stream_t *s, uint8_t **buffer);
static char *ReadLine(uint8_t *buffer, uint8_t **pos, size_t len);
static char *SkipWhiteSpace(char *buffer, const size_t len);
static int hls_Download(stream_t *s, segment_t *segment);
......@@ -940,8 +941,15 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const
err = parse_EndList(s, hls);
else if (strncmp(line, "#", 1) != 0)
{
err = parse_AddSegment(s, hls, segment_duration, line);
segment_duration = -1; /* reset duration */
char *tmp = SkipWhiteSpace(line, strlen(line));
if (tmp)
{
free(line);
line = tmp;
err = parse_AddSegment(s, hls, segment_duration, line);
segment_duration = -1; /* reset duration */
}
else err = VLC_SUCCESS;
}
free(line);
......@@ -1519,6 +1527,34 @@ static char *ReadLine(uint8_t *buffer, uint8_t **pos, const size_t len)
return line;
}
static char *SkipWhiteSpace(char *buffer, const size_t len)
{
assert(buffer);
char *line = NULL;
uint8_t *begin = buffer;
uint8_t *p = begin;
uint8_t *end = p + len;
while (p < end)
{
if ((*p != '\t') || (*p != ' ') || (*p != '\0'))
break;
p++;
}
/* copy line excluding '\t', ' ' or '\0' */
line = strndup((char *)begin, p - begin);
if (*p != '\0')
{
/* next pass start after '\t' or ' ' */
p++;
}
return line;
}
/****************************************************************************
* Open
****************************************************************************/
......
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