mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 21:18:52 +00:00
hls: m3u8playlist: simplify gst_m3u8_playlist_render()
Remove playlist_str GString variable from GstM3U8Playlist struct, since it's only used temporarily in playlist_render(). Might just as well keep it local then.
This commit is contained in:
parent
019cdea1bd
commit
54e1753da4
2 changed files with 20 additions and 25 deletions
|
@ -161,50 +161,46 @@ gst_m3u8_playlist_target_duration (GstM3U8Playlist * playlist)
|
||||||
return (guint) ((target_duration + 500 * GST_MSECOND) / GST_SECOND);
|
return (guint) ((target_duration + 500 * GST_MSECOND) / GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
render_entry (GstM3U8Entry * entry, GstM3U8Playlist * playlist)
|
|
||||||
{
|
|
||||||
gchar *entry_str;
|
|
||||||
|
|
||||||
entry_str = gst_m3u8_entry_render (entry, playlist->version);
|
|
||||||
g_string_append_printf (playlist->playlist_str, "%s", entry_str);
|
|
||||||
g_free (entry_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
gst_m3u8_playlist_render (GstM3U8Playlist * playlist)
|
gst_m3u8_playlist_render (GstM3U8Playlist * playlist)
|
||||||
{
|
{
|
||||||
gchar *pl;
|
GString *playlist_str;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
g_return_val_if_fail (playlist != NULL, NULL);
|
g_return_val_if_fail (playlist != NULL, NULL);
|
||||||
|
|
||||||
playlist->playlist_str = g_string_new ("");
|
playlist_str = g_string_new ("");
|
||||||
|
|
||||||
/* #EXTM3U */
|
/* #EXTM3U */
|
||||||
g_string_append_printf (playlist->playlist_str, M3U8_HEADER_TAG);
|
g_string_append_printf (playlist_str, M3U8_HEADER_TAG);
|
||||||
/* #EXT-X-VERSION */
|
/* #EXT-X-VERSION */
|
||||||
g_string_append_printf (playlist->playlist_str, M3U8_VERSION_TAG,
|
g_string_append_printf (playlist_str, M3U8_VERSION_TAG, playlist->version);
|
||||||
playlist->version);
|
|
||||||
/* #EXT-X-ALLOW_CACHE */
|
/* #EXT-X-ALLOW_CACHE */
|
||||||
g_string_append_printf (playlist->playlist_str, M3U8_ALLOW_CACHE_TAG,
|
g_string_append_printf (playlist_str, M3U8_ALLOW_CACHE_TAG,
|
||||||
playlist->allow_cache ? "YES" : "NO");
|
playlist->allow_cache ? "YES" : "NO");
|
||||||
/* #EXT-X-MEDIA-SEQUENCE */
|
/* #EXT-X-MEDIA-SEQUENCE */
|
||||||
g_string_append_printf (playlist->playlist_str, M3U8_MEDIA_SEQUENCE_TAG,
|
g_string_append_printf (playlist_str, M3U8_MEDIA_SEQUENCE_TAG,
|
||||||
playlist->sequence_number - playlist->entries->length);
|
playlist->sequence_number - playlist->entries->length);
|
||||||
/* #EXT-X-TARGETDURATION */
|
/* #EXT-X-TARGETDURATION */
|
||||||
g_string_append_printf (playlist->playlist_str, M3U8_TARGETDURATION_TAG,
|
g_string_append_printf (playlist_str, M3U8_TARGETDURATION_TAG,
|
||||||
gst_m3u8_playlist_target_duration (playlist));
|
gst_m3u8_playlist_target_duration (playlist));
|
||||||
g_string_append_printf (playlist->playlist_str, "\n");
|
g_string_append (playlist_str, "\n");
|
||||||
|
|
||||||
/* Entries */
|
/* Entries */
|
||||||
g_queue_foreach (playlist->entries, (GFunc) render_entry, playlist);
|
for (l = playlist->entries->head; l != NULL; l = l->next) {
|
||||||
|
GstM3U8Entry *entry = l->data;
|
||||||
|
gchar *entry_str;
|
||||||
|
|
||||||
|
/* FIXME: just make gst_m3u8_entry_render() append to GString directly */
|
||||||
|
entry_str = gst_m3u8_entry_render (entry, playlist->version);
|
||||||
|
g_string_append (playlist_str, entry_str);
|
||||||
|
g_free (entry_str);
|
||||||
|
}
|
||||||
|
|
||||||
if (playlist->end_list)
|
if (playlist->end_list)
|
||||||
g_string_append_printf (playlist->playlist_str, M3U8_ENDLIST_TAG);
|
g_string_append (playlist_str, M3U8_ENDLIST_TAG);
|
||||||
|
|
||||||
pl = playlist->playlist_str->str;
|
return g_string_free (playlist_str, FALSE);
|
||||||
g_string_free (playlist->playlist_str, FALSE);
|
|
||||||
return pl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -49,7 +49,6 @@ struct _GstM3U8Playlist
|
||||||
|
|
||||||
/*< Private >*/
|
/*< Private >*/
|
||||||
GQueue *entries;
|
GQueue *entries;
|
||||||
GString *playlist_str;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue