mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-16 17:10:35 +00:00
splitfilesrc: Implement splitfile:// URI scheme
https://bugzilla.gnome.org/show_bug.cgi?id=609049 Conflicts: gst/multifile/gstsplitfilesrc.c
This commit is contained in:
parent
540245894f
commit
9b13a29f91
1 changed files with 89 additions and 10 deletions
|
@ -65,6 +65,8 @@ enum
|
||||||
|
|
||||||
#define DEFAULT_LOCATION NULL
|
#define DEFAULT_LOCATION NULL
|
||||||
|
|
||||||
|
static void gst_split_file_src_uri_handler_init (gpointer g_iface,
|
||||||
|
gpointer iface_data);
|
||||||
static void gst_split_file_src_set_property (GObject * object, guint prop_id,
|
static void gst_split_file_src_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_split_file_src_get_property (GObject * object, guint prop_id,
|
static void gst_split_file_src_get_property (GObject * object, guint prop_id,
|
||||||
|
@ -88,8 +90,24 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_DEBUG_CATEGORY_STATIC (splitfilesrc_debug);
|
GST_DEBUG_CATEGORY_STATIC (splitfilesrc_debug);
|
||||||
#define GST_CAT_DEFAULT splitfilesrc_debug
|
#define GST_CAT_DEFAULT splitfilesrc_debug
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GstSplitFileSrc, gst_split_file_src, GST_TYPE_BASE_SRC);
|
G_DEFINE_TYPE (GstSplitFileSrc, gst_split_file_src, GST_TYPE_BASE_SRC);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_do_init (GType type)
|
||||||
|
{
|
||||||
|
static const GInterfaceInfo urihandler_info = {
|
||||||
|
gst_split_file_src_uri_handler_init,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (splitfilesrc_debug, "splitfilesrc", 0,
|
||||||
|
"Split File src");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#define WIN32_BLURB " Location string must be in UTF-8 encoding (on Windows)."
|
#define WIN32_BLURB " Location string must be in UTF-8 encoding (on Windows)."
|
||||||
#else
|
#else
|
||||||
|
@ -183,16 +201,15 @@ gst_split_file_src_get_size (GstBaseSrc * basesrc, guint64 * size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_split_file_src_set_property (GObject * object, guint prop_id,
|
gst_split_file_src_set_location (GstSplitFileSrc * src, const char *location)
|
||||||
const GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
{
|
||||||
GstSplitFileSrc *src = GST_SPLIT_FILE_SRC (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_LOCATION:
|
|
||||||
GST_OBJECT_LOCK (src);
|
GST_OBJECT_LOCK (src);
|
||||||
g_free (src->location);
|
g_free (src->location);
|
||||||
src->location = g_value_dup_string (value);
|
|
||||||
|
if (location != NULL && g_str_has_prefix (location, "splitfile://"))
|
||||||
|
src->location = g_strdup (location + strlen ("splitfile://"));
|
||||||
|
else
|
||||||
|
src->location = g_strdup (location);
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
if (!g_utf8_validate (src->location, -1, NULL)) {
|
if (!g_utf8_validate (src->location, -1, NULL)) {
|
||||||
g_warning ("splitfilesrc 'location' property must be in UTF-8 "
|
g_warning ("splitfilesrc 'location' property must be in UTF-8 "
|
||||||
|
@ -200,6 +217,17 @@ gst_split_file_src_set_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
GST_OBJECT_UNLOCK (src);
|
GST_OBJECT_UNLOCK (src);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_split_file_src_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstSplitFileSrc *src = GST_SPLIT_FILE_SRC (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_LOCATION:
|
||||||
|
gst_split_file_src_set_location (src, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -603,3 +631,54 @@ cancelled:
|
||||||
return GST_FLOW_FLUSHING;
|
return GST_FLOW_FLUSHING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static guint
|
||||||
|
gst_split_file_src_uri_get_type (void)
|
||||||
|
{
|
||||||
|
return GST_URI_SRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar **
|
||||||
|
gst_split_file_src_uri_get_protocols (void)
|
||||||
|
{
|
||||||
|
static const gchar *protocols[] = { "splitfile", NULL };
|
||||||
|
|
||||||
|
return (gchar **) protocols;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
gst_split_file_src_uri_get_uri (GstURIHandler * handler)
|
||||||
|
{
|
||||||
|
GstSplitFileSrc *src = GST_SPLIT_FILE_SRC (handler);
|
||||||
|
gchar *ret;
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (src);
|
||||||
|
if (src->location != NULL)
|
||||||
|
ret = g_strdup_printf ("splitfile://%s", src->location);
|
||||||
|
else
|
||||||
|
ret = NULL;
|
||||||
|
GST_OBJECT_UNLOCK (src);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_split_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
|
||||||
|
{
|
||||||
|
GstSplitFileSrc *src = GST_SPLIT_FILE_SRC (handler);
|
||||||
|
|
||||||
|
gst_split_file_src_set_location (src, uri);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_split_file_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
||||||
|
{
|
||||||
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
|
||||||
|
|
||||||
|
iface->get_type = gst_split_file_src_uri_get_type;
|
||||||
|
iface->get_protocols = gst_split_file_src_uri_get_protocols;
|
||||||
|
iface->get_uri = gst_split_file_src_uri_get_uri;
|
||||||
|
iface->set_uri = gst_split_file_src_uri_set_uri;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue