mirror of
https://github.com/Rafostar/clapper.git
synced 2025-12-24 05:56:41 +01:00
clapper: Modify URI of media item from GFile in-place
When creating item from GFile, modify URI in-place if needed (avoid a copy)
This commit is contained in:
@@ -142,12 +142,19 @@ clapper_media_item_new_from_file (GFile *file)
|
||||
{
|
||||
ClapperMediaItem *item;
|
||||
gchar *uri;
|
||||
gsize length;
|
||||
|
||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||
|
||||
uri = clapper_utils_uri_from_file (file);
|
||||
item = clapper_media_item_new (uri);
|
||||
uri = g_file_get_uri (file);
|
||||
length = strlen (uri);
|
||||
|
||||
/* GFile might incorrectly append "/" at the end of an URI,
|
||||
* remove it to make it work with GStreamer URI handling */
|
||||
if (uri[length - 1] == '/')
|
||||
uri[length - 1] = '\0';
|
||||
|
||||
item = clapper_media_item_new (uri);
|
||||
g_free (uri);
|
||||
|
||||
return item;
|
||||
|
||||
@@ -55,9 +55,6 @@ void clapper_utils_timeline_remove_on_main_sync (ClapperTimeline *timeline, Clap
|
||||
G_GNUC_INTERNAL
|
||||
void clapper_utils_prop_notify_on_main_sync (GObject *object, GParamSpec *pspec);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gchar * clapper_utils_uri_from_file (GFile *file);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gchar * clapper_utils_title_from_uri (const gchar *uri);
|
||||
|
||||
|
||||
@@ -248,28 +248,6 @@ clapper_utils_prop_notify_on_main_sync (GObject *object, GParamSpec *pspec)
|
||||
GST_DEBUG ("Prop notify invoke finished");
|
||||
}
|
||||
|
||||
gchar *
|
||||
clapper_utils_uri_from_file (GFile *file)
|
||||
{
|
||||
gchar *uri = g_file_get_uri (file);
|
||||
gsize length = strlen (uri);
|
||||
|
||||
/* GFile might incorrectly append "/" at the end of an URI,
|
||||
* remove it to make it work with GStreamer URI handling */
|
||||
if (uri[length - 1] == '/') {
|
||||
gchar *fixed_uri;
|
||||
|
||||
/* NULL terminated copy without last character */
|
||||
fixed_uri = g_new0 (gchar, length);
|
||||
memcpy (fixed_uri, uri, length - 1);
|
||||
|
||||
g_free (uri);
|
||||
uri = fixed_uri;
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
gchar *
|
||||
clapper_utils_title_from_uri (const gchar *uri)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user