summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitrios Katsaros <patcherwork@gmail.com>2017-06-15 13:37:28 +0200
committerTim-Philipp Müller <tim@centricular.com>2018-01-23 18:05:49 +0000
commitdccfaf2e91a4a7b227d9193623344eb634aada5b (patch)
tree575f1b8ce12d5b46660e2cf49f7ff435811d26f9
parent379059b1c7baede5f8206dc2b132109831abcd93 (diff)
multifilesrc: implement uri handler
With this patch we can now provide a set of files created by multifilesink as a source for uri elements. e.g. gst-launch-1.0 playbin uri=multifile://img%25d.ppm Note that for the %d pattern you need to replace % with %25. This is to be compliant with URL naming standards. https://bugzilla.gnome.org/show_bug.cgi?id=783581
-rw-r--r--gst/multifile/gstmultifilesrc.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/gst/multifile/gstmultifilesrc.c b/gst/multifile/gstmultifilesrc.c
index fd2464246..18ea59468 100644
--- a/gst/multifile/gstmultifilesrc.c
+++ b/gst/multifile/gstmultifilesrc.c
@@ -59,6 +59,8 @@ static void gst_multi_file_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstCaps *gst_multi_file_src_getcaps (GstBaseSrc * src, GstCaps * filter);
static gboolean gst_multi_file_src_query (GstBaseSrc * src, GstQuery * query);
+static void gst_multi_file_src_uri_handler_init (gpointer g_iface,
+ gpointer iface_data);
static GstStaticPadTemplate gst_multi_file_src_pad_template =
@@ -85,7 +87,9 @@ enum
#define DEFAULT_INDEX 0
#define gst_multi_file_src_parent_class parent_class
-G_DEFINE_TYPE (GstMultiFileSrc, gst_multi_file_src, GST_TYPE_PUSH_SRC);
+G_DEFINE_TYPE_WITH_CODE (GstMultiFileSrc, gst_multi_file_src, GST_TYPE_PUSH_SRC,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
+ gst_multi_file_src_uri_handler_init));
static gboolean
@@ -482,3 +486,65 @@ handle_error:
return GST_FLOW_ERROR;
}
}
+
+static GstURIType
+gst_multi_file_src_uri_get_type (GType type)
+{
+ return GST_URI_SRC;
+}
+
+static const gchar *const *
+gst_multi_file_src_uri_get_protocols (GType type)
+{
+ static const gchar *protocols[] = { "multifile", NULL };
+
+ return (const gchar * const *) protocols;
+}
+
+static gchar *
+gst_multi_file_src_uri_get_uri (GstURIHandler * handler)
+{
+ GstMultiFileSrc *src = GST_MULTI_FILE_SRC (handler);
+ gchar *ret;
+
+ GST_OBJECT_LOCK (src);
+ if (src->filename != NULL)
+ ret = g_strdup_printf ("multifile://%s", src->filename);
+ else
+ ret = NULL;
+ GST_OBJECT_UNLOCK (src);
+
+ return ret;
+}
+
+static gboolean
+gst_multi_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
+{
+ GstMultiFileSrc *src = GST_MULTI_FILE_SRC (handler);
+
+ GstUri *gsturi;
+
+ gsturi = gst_uri_from_string (uri);
+ g_free (src->filename);
+ src->filename = NULL;
+ if (gsturi) {
+ gchar *turi = gst_uri_get_path (gsturi);
+ gst_multi_file_src_set_location (src, turi);
+ g_free (turi);
+ gst_uri_unref (gsturi);
+ }
+
+ return TRUE;
+}
+
+static void
+gst_multi_file_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
+{
+ GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
+
+ iface->get_type = gst_multi_file_src_uri_get_type;
+ iface->get_protocols = gst_multi_file_src_uri_get_protocols;
+ iface->get_uri = gst_multi_file_src_uri_get_uri;
+ iface->set_uri = gst_multi_file_src_uri_set_uri;
+}