From: Tim-Philipp Müller Date: Mon, 27 Mar 2006 16:15:00 +0000 (+0000) Subject: ext/gnomevfs/: Make gnomevfssink accept filenames as well as URIs for the "location... X-Git-Tag: 1.19.3~511^2~12047 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5e5e53f0722aec70fa9dfa373851e1504e7fc6c;p=platform%2Fupstream%2Fgstreamer.git ext/gnomevfs/: Make gnomevfssink accept filenames as well as URIs for the "location" property, just like gnomevfssrc ... Original commit message from CVS: * ext/gnomevfs/gstgnomevfs.c: (gst_gnome_vfs_location_to_uri_string): * ext/gnomevfs/gstgnomevfs.h: * ext/gnomevfs/gstgnomevfssink.c: (gst_gnome_vfs_sink_set_property): * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_set_property): Make gnomevfssink accept filenames as well as URIs for the "location" property, just like gnomevfssrc does (and filesrc/filesink do) (#336190). --- diff --git a/ChangeLog b/ChangeLog index 47051d8..a4cb493 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-03-27 Tim-Philipp Müller + + * ext/gnomevfs/gstgnomevfs.c: + (gst_gnome_vfs_location_to_uri_string): + * ext/gnomevfs/gstgnomevfs.h: + * ext/gnomevfs/gstgnomevfssink.c: + (gst_gnome_vfs_sink_set_property): + * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_set_property): + Make gnomevfssink accept filenames as well as URIs for the + "location" property, just like gnomevfssrc does (and + filesrc/filesink do) (#336190). + 2006-03-24 Thomas Vander Stichele * tests/check/generic/clock-selection.c: (GST_START_TEST): diff --git a/common b/common index 5685efc..45cc64e 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 5685efc3f9976d6abe3fec557353fc2053b0e3fb +Subproject commit 45cc64e522d61410eb8d1a3e7ef67569851cd77a diff --git a/ext/gnomevfs/gstgnomevfs.c b/ext/gnomevfs/gstgnomevfs.c index b6b1259..a9792c7 100644 --- a/ext/gnomevfs/gstgnomevfs.c +++ b/ext/gnomevfs/gstgnomevfs.c @@ -32,6 +32,36 @@ #include #include +#include + +gchar * +gst_gnome_vfs_location_to_uri_string (const gchar * location) +{ + gchar *newloc, *ret; + + if (location == NULL) + return NULL; + + /* already an URI string? */ + if (strstr (location, "://")) + return g_strdup (location); + + newloc = gnome_vfs_escape_path_string (location); + + if (newloc && *newloc == '/') { + ret = g_strdup_printf ("file://%s", newloc); + } else { + gchar *curdir; + + curdir = g_get_current_dir (); + ret = g_strdup_printf ("file://%s/%s", curdir, newloc); + g_free (curdir); + } + + g_free (newloc); + return ret; +} + GType gst_gnome_vfs_uri_get_type (void) { diff --git a/ext/gnomevfs/gstgnomevfs.h b/ext/gnomevfs/gstgnomevfs.h index 8069a6f..f2228be 100644 --- a/ext/gnomevfs/gstgnomevfs.h +++ b/ext/gnomevfs/gstgnomevfs.h @@ -31,6 +31,8 @@ G_BEGIN_DECLS GType gst_gnome_vfs_uri_get_type (void); GType gst_gnome_vfs_handle_get_type (void); +gchar * gst_gnome_vfs_location_to_uri_string (const gchar * location); + G_END_DECLS #endif /* __GST_GNOME_VFS_H__ */ diff --git a/ext/gnomevfs/gstgnomevfssink.c b/ext/gnomevfs/gstgnomevfssink.c index f6dbb3d..c1a1961 100644 --- a/ext/gnomevfs/gstgnomevfssink.c +++ b/ext/gnomevfs/gstgnomevfssink.c @@ -267,6 +267,8 @@ gst_gnome_vfs_sink_set_property (GObject * object, guint prop_id, switch (prop_id) { case ARG_LOCATION:{ + const gchar *new_location; + if (sink->uri) { gnome_vfs_uri_unref (sink->uri); sink->uri = NULL; @@ -275,8 +277,10 @@ gst_gnome_vfs_sink_set_property (GObject * object, guint prop_id, g_free (sink->uri_name); sink->uri_name = NULL; } - if (g_value_get_string (value)) { - sink->uri_name = g_value_dup_string (value); + + new_location = g_value_get_string (value); + if (new_location) { + sink->uri_name = gst_gnome_vfs_location_to_uri_string (new_location); sink->uri = gnome_vfs_uri_new (sink->uri_name); } break; diff --git a/ext/gnomevfs/gstgnomevfssrc.c b/ext/gnomevfs/gstgnomevfssrc.c index bae262d..8da0311 100644 --- a/ext/gnomevfs/gstgnomevfssrc.c +++ b/ext/gnomevfs/gstgnomevfssrc.c @@ -384,12 +384,13 @@ gst_gnome_vfs_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstGnomeVFSSrc *src; - gchar cwd[PATH_MAX]; src = GST_GNOME_VFS_SRC (object); switch (prop_id) { - case ARG_LOCATION: + case ARG_LOCATION:{ + const gchar *new_location; + /* the element must be stopped or paused in order to do this */ if (GST_STATE (src) == GST_STATE_PLAYING || GST_STATE (src) == GST_STATE_PAUSED) @@ -404,25 +405,13 @@ gst_gnome_vfs_src_set_property (GObject * object, guint prop_id, src->uri_name = NULL; } - if (g_value_get_string (value)) { - const gchar *location = g_value_get_string (value); - - if (!strchr (location, ':')) { - gchar *newloc = gnome_vfs_escape_path_string (location); - - if (*newloc == '/') - src->uri_name = g_strdup_printf ("file://%s", newloc); - else - src->uri_name = - g_strdup_printf ("file://%s/%s", getcwd (cwd, PATH_MAX), - newloc); - g_free (newloc); - } else - src->uri_name = g_strdup (location); - + new_location = g_value_get_string (value); + if (new_location) { + src->uri_name = gst_gnome_vfs_location_to_uri_string (new_location); src->uri = gnome_vfs_uri_new (src->uri_name); } break; + } case ARG_HANDLE: if (GST_STATE (src) == GST_STATE_NULL || GST_STATE (src) == GST_STATE_READY) {