splitmuxsrc: add a format-location signal that allows bypassing the location property
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Mon, 9 Nov 2015 16:51:12 +0000 (17:51 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 5 May 2016 09:49:07 +0000 (10:49 +0100)
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

index fee29e00a44be8e605b5ee2bd9752df2d9568cf1..c55db9fc7b1afab48dde0ad5dcc72e1a83820cfc 100644 (file)
@@ -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);
-  }
-  GST_OBJECT_UNLOCK (splitmux);
+  g_signal_emit (splitmux, signals[SIGNAL_FORMAT_LOCATION], 0, &files);
 
-  files = gst_split_util_find_files (dirname, basename, &err);
+  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;
+    if (files == NULL || *files == NULL)
+      goto no_files;
+  }
 
   SPLITMUX_SRC_LOCK (splitmux);
   splitmux->pads_complete = FALSE;