Commit 0d02e6fb authored by Jean-Paul Saman's avatar Jean-Paul Saman
Browse files

stream_filter/httplive.c: split up parse_SegmentationInformation() function.

Split up parse_SegmentInformation() into two functions:
parse_SegmentInformation() - parse #EXTINF to get duration
  parse_AddSegment() - adds new segment

The parse_SegmentInformation() did both functions before and this
made some HTTP Live URL not work as expected. The splitting up of
these functionalities solves this issue.
parent 255acda2
...@@ -499,8 +499,10 @@ static char *ConstructUrl(vlc_url_t *url) ...@@ -499,8 +499,10 @@ static char *ConstructUrl(vlc_url_t *url)
return psz_url; return psz_url;
} }
static int parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_read, const char *uri) static int parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_read, int *duration)
{ {
VLC_UNUSED(s);
assert(hls); assert(hls);
assert(p_read); assert(p_read);
...@@ -514,10 +516,19 @@ static int parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_read ...@@ -514,10 +516,19 @@ static int parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_read
token = strtok_r(NULL, ",", &p_next); token = strtok_r(NULL, ",", &p_next);
if (token == NULL) if (token == NULL)
return VLC_EGENERIC; return VLC_EGENERIC;
int duration = atoi(token);
*duration = atoi(token);
/* Ignore the rest of the line */ /* Ignore the rest of the line */
return VLC_SUCCESS;
}
static int parse_AddSegment(stream_t *s, hls_stream_t *hls, const int duration, const char *uri)
{
assert(hls);
assert(uri);
/* Store segment information */ /* Store segment information */
char *psz_path = NULL; char *psz_path = NULL;
if (hls->url.psz_path != NULL) if (hls->url.psz_path != NULL)
...@@ -878,6 +889,7 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const ...@@ -878,6 +889,7 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const
assert(hls); assert(hls);
/* */ /* */
int segment_duration = -1;
do do
{ {
/* Next line */ /* Next line */
...@@ -887,17 +899,7 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const ...@@ -887,17 +899,7 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const
p_begin = p_read; p_begin = p_read;
if (strncmp(line, "#EXTINF", 7) == 0) if (strncmp(line, "#EXTINF", 7) == 0)
{ err = parse_SegmentInformation(s, hls, line, &segment_duration);
char *uri = ReadLine(p_begin, &p_read, p_end - p_begin);
if (uri == NULL)
err = VLC_EGENERIC;
else
{
err = parse_SegmentInformation(s, hls, line, uri);
free(uri);
}
p_begin = p_read;
}
else if (strncmp(line, "#EXT-X-TARGETDURATION", 21) == 0) else if (strncmp(line, "#EXT-X-TARGETDURATION", 21) == 0)
err = parse_TargetDuration(s, hls, line); err = parse_TargetDuration(s, hls, line);
else if (strncmp(line, "#EXT-X-MEDIA-SEQUENCE", 21) == 0) else if (strncmp(line, "#EXT-X-MEDIA-SEQUENCE", 21) == 0)
...@@ -914,6 +916,11 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const ...@@ -914,6 +916,11 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const
err = parse_Version(s, hls, line); err = parse_Version(s, hls, line);
else if (strncmp(line, "#EXT-X-ENDLIST", 14) == 0) else if (strncmp(line, "#EXT-X-ENDLIST", 14) == 0)
err = parse_EndList(s, hls); err = parse_EndList(s, hls);
else if (strncmp(line, "#", 1) != 0)
{
err = parse_AddSegment(s, hls, segment_duration, line);
segment_duration = -1; /* reset duration */
}
free(line); free(line);
line = NULL; line = NULL;
......
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