Commit f7009eb5 authored by Jan Schmidt's avatar Jan Schmidt

splitmuxsink: Add format-location-full signal

Add a new signal for formatting the filename, which receives
a GstSample containing the first buffer from the reference
stream that will be muxed into that file.

Useful for creating filenames that are based on the
running time or other attributes of the buffer.

To make it work, opening of files and setting filenames is
now deferred until there is some data to write to it,
which also requires some changes to how async state changes
and gap events are handled.
parent 107902ec
This diff is collapsed.
......@@ -82,6 +82,9 @@ typedef struct _MqStreamCtx
GstPad *srcpad;
gboolean out_blocked;
GstBuffer *cur_buffer;
GstEvent *pending_gap;
} MqStreamCtx;
struct _GstSplitMuxSink {
......@@ -131,6 +134,9 @@ struct _GstSplitMuxSink {
gboolean switching_fragment;
gboolean have_video;
gboolean need_async_start;
gboolean async_pending;
};
struct _GstSplitMuxSinkClass {
......
......@@ -192,6 +192,20 @@ GST_START_TEST (test_splitmuxsrc_format_location)
GST_END_TEST;
static gchar *
check_format_location (GstElement * object,
guint fragment_id, GstSample * first_sample)
{
GstBuffer *buf = gst_sample_get_buffer (first_sample);
/* Must have a buffer */
fail_if (buf == NULL);
GST_LOG ("New file - first buffer %" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
return NULL;
}
GST_START_TEST (test_splitmuxsink)
{
GstMessage *msg;
......@@ -213,6 +227,8 @@ GST_START_TEST (test_splitmuxsink)
fail_if (pipeline == NULL);
sink = gst_bin_get_by_name (GST_BIN (pipeline), "splitsink");
fail_if (sink == NULL);
g_signal_connect (sink, "format-location-full",
(GCallback) check_format_location, NULL);
dest_pattern = g_build_filename (tmpdir, "out%05d.ogg", NULL);
g_object_set (G_OBJECT (sink), "location", dest_pattern, NULL);
g_free (dest_pattern);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment