From e00f0de4f3e863c993af3137e7f75e364e3f6ac6 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 30 Mar 2015 11:14:09 -0300 Subject: multifilesink: post file message on EOS When multifilesink is operating in any mode other than one file per buffer, the last file created won't have a file message posted as multifilesink doesn't handle the EOS event. This patch fixes it by using the last position to post a file message when EOS is received. This should ensure at least the time related data and the filename are posted to the application or other elements https://bugzilla.gnome.org/show_bug.cgi?id=747000 --- gst/multifile/gstmultifilesink.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'gst') diff --git a/gst/multifile/gstmultifilesink.c b/gst/multifile/gstmultifilesink.c index 85d1cd3a6..c9fc2f55c 100644 --- a/gst/multifile/gstmultifilesink.c +++ b/gst/multifile/gstmultifilesink.c @@ -434,6 +434,30 @@ gst_multi_file_sink_post_message_full (GstMultiFileSink * multifilesink, gst_message_new_element (GST_OBJECT_CAST (multifilesink), s)); } +static void +gst_multi_file_sink_post_message_from_time (GstMultiFileSink * multifilesink, + GstClockTime timestamp, GstClockTime duration, const char *filename) +{ + GstClockTime running_time, stream_time; + guint64 offset, offset_end; + GstSegment *segment; + GstFormat format; + + if (!multifilesink->post_messages) + return; + + segment = &GST_BASE_SINK (multifilesink)->segment; + format = segment->format; + + offset = -1; + offset_end = -1; + + running_time = gst_segment_to_running_time (segment, format, timestamp); + stream_time = gst_segment_to_stream_time (segment, format, timestamp); + + gst_multi_file_sink_post_message_full (multifilesink, timestamp, duration, + offset, offset_end, running_time, stream_time, filename); +} static void gst_multi_file_sink_post_message (GstMultiFileSink * multifilesink, @@ -826,6 +850,19 @@ gst_multi_file_sink_event (GstBaseSink * sink, GstEvent * event) break; } + case GST_EVENT_EOS: + if (multifilesink->file) { + gchar *filename; + + filename = g_strdup_printf (multifilesink->filename, + multifilesink->index); + gst_multi_file_sink_post_message_from_time (multifilesink, + GST_BASE_SINK (multifilesink)->segment.position, -1, filename); + g_free (filename); + + gst_multi_file_sink_close_file (multifilesink, NULL); + } + break; default: break; } -- cgit v1.2.3