mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +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);
|
||||
}
|
||||
|
||||
} 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;
|
||||
} 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))
|
||||
self->version = val;
|
||||
} else if (g_str_has_prefix (data, "#EXT-X-STREAM-INF:") ||
|
||||
g_str_has_prefix (data, "#EXT-X-I-FRAME-STREAM-INF:")) {
|
||||
} else if (g_str_has_prefix (data_ext_x, "STREAM-INF:") ||
|
||||
g_str_has_prefix (data_ext_x, "I-FRAME-STREAM-INF:")) {
|
||||
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;
|
||||
|
||||
new_list = gst_m3u8_new ();
|
||||
|
@ -584,20 +604,20 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
|
|||
} else {
|
||||
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))
|
||||
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))
|
||||
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;
|
||||
} 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> */
|
||||
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;
|
||||
} else if (g_str_has_prefix (data, "#EXT-X-KEY:")) {
|
||||
} else if (g_str_has_prefix (data_ext_x, "KEY:")) {
|
||||
gchar *v, *a;
|
||||
|
||||
data = data + 11;
|
||||
|
@ -657,23 +677,7 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
|
|||
}
|
||||
}
|
||||
}
|
||||
} 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-BYTERANGE:")) {
|
||||
} else if (g_str_has_prefix (data_ext_x, "BYTERANGE:")) {
|
||||
gchar *v = data + 17;
|
||||
|
||||
if (int64_from_string (v, &v, &size)) {
|
||||
|
@ -685,6 +689,9 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data,
|
|||
} else {
|
||||
GST_LOG ("Ignored line: %s", data);
|
||||
}
|
||||
} else {
|
||||
GST_LOG ("Ignored line: %s", data);
|
||||
}
|
||||
|
||||
next_line:
|
||||
if (!end)
|
||||
|
|
Loading…
Reference in a new issue