From bd2a1487cc464910d19bfb8f5f5e3a255d844c2d Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 9 Nov 2015 17:51:12 +0100 Subject: [PATCH] splitmuxsrc: add a format-location signal that allows bypassing the location property This signal allows a user to directly return a sorted list of files to be joined, so that they don't have to follow the filename pattern that the "location" property expects. https://bugzilla.gnome.org/show_bug.cgi?id=753625 --- gst/multifile/gstsplitmuxsrc.c | 47 ++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/gst/multifile/gstsplitmuxsrc.c b/gst/multifile/gstsplitmuxsrc.c index fee29e00a4..c55db9fc7b 100644 --- a/gst/multifile/gstsplitmuxsrc.c +++ b/gst/multifile/gstsplitmuxsrc.c @@ -61,6 +61,14 @@ enum PROP_LOCATION }; +enum +{ + SIGNAL_FORMAT_LOCATION, + SIGNAL_LAST +}; + +static guint signals[SIGNAL_LAST]; + static GstStaticPadTemplate video_src_template = GST_STATIC_PAD_TEMPLATE ("video", GST_PAD_SRC, @@ -212,6 +220,20 @@ gst_splitmux_src_class_init (GstSplitMuxSrcClass * klass) g_param_spec_string ("location", "File Input Pattern", "Glob pattern for the location of the files to read", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** + * GstSplitMuxSrc::format-location: + * @splitmux: the #GstSplitMuxSrc + * + * Returns: A NULL-terminated sorted array of strings containing the + * filenames of the input files. The array will be freed internally + * using g_strfreev() + * + * Since: 1.8 + */ + signals[SIGNAL_FORMAT_LOCATION] = + g_signal_new ("format-location", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_STRV, 0); } static void @@ -601,17 +623,22 @@ gst_splitmux_src_start (GstSplitMuxSrc * splitmux) GST_DEBUG_OBJECT (splitmux, "Starting"); - GST_OBJECT_LOCK (splitmux); - if (splitmux->location != NULL && splitmux->location[0] != '\0') { - basename = g_path_get_basename (splitmux->location); - dirname = g_path_get_dirname (splitmux->location); + g_signal_emit (splitmux, signals[SIGNAL_FORMAT_LOCATION], 0, &files); + + if (files == NULL || *files == NULL) { + GST_OBJECT_LOCK (splitmux); + if (splitmux->location != NULL && splitmux->location[0] != '\0') { + basename = g_path_get_basename (splitmux->location); + dirname = g_path_get_dirname (splitmux->location); + } + GST_OBJECT_UNLOCK (splitmux); + + g_strfreev (files); + files = gst_split_util_find_files (dirname, basename, &err); + + if (files == NULL || *files == NULL) + goto no_files; } - GST_OBJECT_UNLOCK (splitmux); - - files = gst_split_util_find_files (dirname, basename, &err); - - if (files == NULL || *files == NULL) - goto no_files; SPLITMUX_SRC_LOCK (splitmux); splitmux->pads_complete = FALSE;