From 75c9a5f129b76458a24e188f39b201dcd3de0159 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Sat, 4 Apr 2015 10:56:56 -0300 Subject: [PATCH] hlssink: write the playlist end marker on EOS Catch EOS from the multifilesink and add the endlist marker to the playlist when it happens https://bugzilla.gnome.org/show_bug.cgi?id=747319 --- ext/hls/gsthlssink.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/ext/hls/gsthlssink.c b/ext/hls/gsthlssink.c index 445caf50a8..de5e84cefd 100644 --- a/ext/hls/gsthlssink.c +++ b/ext/hls/gsthlssink.c @@ -252,6 +252,25 @@ missing_element: return FALSE; } +static void +gst_hls_sink_write_playlist (GstHlsSink * sink) +{ + char *playlist_content; + GError *error = NULL; + + playlist_content = gst_m3u8_playlist_render (sink->playlist); + if (!g_file_set_contents (sink->playlist_location, + playlist_content, -1, &error)) { + GST_ERROR ("Failed to write playlist: %s", error->message); + GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, + (("Failed to write playlist '%s'."), error->message), (NULL)); + g_error_free (error); + error = NULL; + } + g_free (playlist_content); + +} + static void gst_hls_sink_handle_message (GstBin * bin, GstMessage * message) { @@ -261,10 +280,8 @@ gst_hls_sink_handle_message (GstBin * bin, GstMessage * message) case GST_MESSAGE_ELEMENT: { const char *filename; - char *playlist_content; GstClockTime running_time, duration; gboolean discont = FALSE; - GError *error = NULL; gchar *entry_location; const GstStructure *structure; @@ -289,16 +306,8 @@ gst_hls_sink_handle_message (GstBin * bin, GstMessage * message) gst_m3u8_playlist_add_entry (sink->playlist, entry_location, NULL, duration, sink->index, discont); g_free (entry_location); - playlist_content = gst_m3u8_playlist_render (sink->playlist); - if (!g_file_set_contents (sink->playlist_location, - playlist_content, -1, &error)) { - GST_ERROR ("Failed to write playlist: %s", error->message); - GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, - (("Failed to write playlist '%s'."), error->message), (NULL)); - g_error_free (error); - error = NULL; - } - g_free (playlist_content); + + gst_hls_sink_write_playlist (sink); /* multifilesink is starting a new file. It means that upstream sent a key * unit and we can schedule the next key unit now. @@ -313,6 +322,11 @@ gst_hls_sink_handle_message (GstBin * bin, GstMessage * message) message = NULL; break; } + case GST_MESSAGE_EOS:{ + sink->playlist->end_list = TRUE; + gst_hls_sink_write_playlist (sink); + break; + } default: break; }