mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
hlsdemux: skip checking '#EXT-X-' token for all entries
Put this common check before to avoid repeating it for all possible entries to save some cycles
This commit is contained in:
parent
c79e8a78ac
commit
3e9b89111a
1 changed files with 159 additions and 152 deletions
|
@ -510,15 +510,35 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
|
||||||
self->files = g_list_prepend (self->files, file);
|
self->files = g_list_prepend (self->files, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-ENDLIST")) {
|
} else if (g_str_has_prefix (data, "#EXTINF:")) {
|
||||||
|
gdouble fval;
|
||||||
|
if (!double_from_string (data + 8, &data, &fval)) {
|
||||||
|
GST_WARNING ("Can't read EXTINF duration");
|
||||||
|
goto next_line;
|
||||||
|
}
|
||||||
|
duration = fval * (gdouble) GST_SECOND;
|
||||||
|
if (duration > self->targetduration)
|
||||||
|
GST_WARNING ("EXTINF duration > TARGETDURATION");
|
||||||
|
if (!data || *data != ',')
|
||||||
|
goto next_line;
|
||||||
|
data = g_utf8_next_char (data);
|
||||||
|
if (data != end) {
|
||||||
|
g_free (title);
|
||||||
|
title = g_strdup (data);
|
||||||
|
}
|
||||||
|
} else if (g_str_has_prefix (data, "#EXT-X-")) {
|
||||||
|
gchar *data_ext_x = data + 7;
|
||||||
|
|
||||||
|
/* All these entries start with #EXT-X- */
|
||||||
|
if (g_str_has_prefix (data_ext_x, "ENDLIST")) {
|
||||||
self->endlist = TRUE;
|
self->endlist = TRUE;
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-VERSION:")) {
|
} else if (g_str_has_prefix (data_ext_x, "VERSION:")) {
|
||||||
if (int_from_string (data + 15, &data, &val))
|
if (int_from_string (data + 15, &data, &val))
|
||||||
self->version = val;
|
self->version = val;
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-STREAM-INF:") ||
|
} else if (g_str_has_prefix (data_ext_x, "STREAM-INF:") ||
|
||||||
g_str_has_prefix (data, "#EXT-X-I-FRAME-STREAM-INF:")) {
|
g_str_has_prefix (data_ext_x, "I-FRAME-STREAM-INF:")) {
|
||||||
gchar *v, *a;
|
gchar *v, *a;
|
||||||
gboolean iframe = g_str_has_prefix (data, "#EXT-X-I-FRAME-STREAM-INF:");
|
gboolean iframe = g_str_has_prefix (data_ext_x, "I-FRAME-STREAM-INF:");
|
||||||
GstM3U8 *new_list;
|
GstM3U8 *new_list;
|
||||||
|
|
||||||
new_list = gst_m3u8_new ();
|
new_list = gst_m3u8_new ();
|
||||||
|
@ -584,20 +604,20 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
|
||||||
} else {
|
} else {
|
||||||
list = new_list;
|
list = new_list;
|
||||||
}
|
}
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-TARGETDURATION:")) {
|
} else if (g_str_has_prefix (data_ext_x, "TARGETDURATION:")) {
|
||||||
if (int_from_string (data + 22, &data, &val))
|
if (int_from_string (data + 22, &data, &val))
|
||||||
self->targetduration = val * GST_SECOND;
|
self->targetduration = val * GST_SECOND;
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-MEDIA-SEQUENCE:")) {
|
} else if (g_str_has_prefix (data_ext_x, "MEDIA-SEQUENCE:")) {
|
||||||
if (int_from_string (data + 22, &data, &val))
|
if (int_from_string (data + 22, &data, &val))
|
||||||
self->mediasequence = val;
|
self->mediasequence = val;
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-DISCONTINUITY")) {
|
} else if (g_str_has_prefix (data_ext_x, "DISCONTINUITY")) {
|
||||||
discontinuity = TRUE;
|
discontinuity = TRUE;
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-PROGRAM-DATE-TIME:")) {
|
} else if (g_str_has_prefix (data_ext_x, "PROGRAM-DATE-TIME:")) {
|
||||||
/* <YYYY-MM-DDThh:mm:ssZ> */
|
/* <YYYY-MM-DDThh:mm:ssZ> */
|
||||||
GST_DEBUG ("FIXME parse date");
|
GST_DEBUG ("FIXME parse date");
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-ALLOW-CACHE:")) {
|
} else if (g_str_has_prefix (data_ext_x, "ALLOW-CACHE:")) {
|
||||||
self->allowcache = g_ascii_strcasecmp (data + 19, "YES") == 0;
|
self->allowcache = g_ascii_strcasecmp (data + 19, "YES") == 0;
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-KEY:")) {
|
} else if (g_str_has_prefix (data_ext_x, "KEY:")) {
|
||||||
gchar *v, *a;
|
gchar *v, *a;
|
||||||
|
|
||||||
data = data + 11;
|
data = data + 11;
|
||||||
|
@ -657,23 +677,7 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (g_str_has_prefix (data, "#EXTINF:")) {
|
} else if (g_str_has_prefix (data_ext_x, "BYTERANGE:")) {
|
||||||
gdouble fval;
|
|
||||||
if (!double_from_string (data + 8, &data, &fval)) {
|
|
||||||
GST_WARNING ("Can't read EXTINF duration");
|
|
||||||
goto next_line;
|
|
||||||
}
|
|
||||||
duration = fval * (gdouble) GST_SECOND;
|
|
||||||
if (duration > self->targetduration)
|
|
||||||
GST_WARNING ("EXTINF duration > TARGETDURATION");
|
|
||||||
if (!data || *data != ',')
|
|
||||||
goto next_line;
|
|
||||||
data = g_utf8_next_char (data);
|
|
||||||
if (data != end) {
|
|
||||||
g_free (title);
|
|
||||||
title = g_strdup (data);
|
|
||||||
}
|
|
||||||
} else if (g_str_has_prefix (data, "#EXT-X-BYTERANGE:")) {
|
|
||||||
gchar *v = data + 17;
|
gchar *v = data + 17;
|
||||||
|
|
||||||
if (int64_from_string (v, &v, &size)) {
|
if (int64_from_string (v, &v, &size)) {
|
||||||
|
@ -685,6 +689,9 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
|
||||||
} else {
|
} else {
|
||||||
GST_LOG ("Ignored line: %s", data);
|
GST_LOG ("Ignored line: %s", data);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
GST_LOG ("Ignored line: %s", data);
|
||||||
|
}
|
||||||
|
|
||||||
next_line:
|
next_line:
|
||||||
if (!end)
|
if (!end)
|
||||||
|
|
Loading…
Reference in a new issue