ext/gnomevfs/: Make gnomevfssink accept filenames as well as URIs for the "location...
authorTim-Philipp Müller <tim@centricular.net>
Mon, 27 Mar 2006 16:15:00 +0000 (16:15 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 27 Mar 2006 16:15:00 +0000 (16:15 +0000)
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).

ChangeLog
common
ext/gnomevfs/gstgnomevfs.c
ext/gnomevfs/gstgnomevfs.h
ext/gnomevfs/gstgnomevfssink.c
ext/gnomevfs/gstgnomevfssrc.c

index 47051d8..a4cb493 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-03-27  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * 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 <thomas at apestaart dot org>
 
        * tests/check/generic/clock-selection.c: (GST_START_TEST):
diff --git a/common b/common
index 5685efc..45cc64e 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 5685efc3f9976d6abe3fec557353fc2053b0e3fb
+Subproject commit 45cc64e522d61410eb8d1a3e7ef67569851cd77a
index b6b1259..a9792c7 100644 (file)
 #include <libgnomevfs/gnome-vfs.h>
 #include <gst/gst.h>
 
+#include <string.h>
+
+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)
 {
index 8069a6f..f2228be 100644 (file)
@@ -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__ */
index f6dbb3d..c1a1961 100644 (file)
@@ -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;
index bae262d..8da0311 100644 (file)
@@ -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) {