msmith gstreamer: gstreamer/ gstreamer/plugins/elements/

[email protected]
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gstreamer
Changes by:     msmith
Date:           Thu Nov 20 2008  21:05:29 UTC

Log message:
    * plugins/elements/gstfilesrc.c:
      Use g_filename_from_uri() for URI parsing in filesrc rather than rolling
      out own slightly incorrect version. Fixes use of some paths on
      win32.

Modified files:
    .               : ChangeLog
    plugins/elements: gstfilesrc.c

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.4166&r2=1.4167
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/plugins/elements/gstfilesrc.c.diff?r1=1.165&r2=1.166

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v
retrieving revision 1.4166
retrieving revision 1.4167
diff -u -d -r1.4166 -r1.4167
--- ChangeLog	20 Nov 2008 20:44:54 -0000	1.4166
+++ ChangeLog	20 Nov 2008 21:05:13 -0000	1.4167
@@ -1,5 +1,12 @@
 2008-11-20  Michael Smith <[email protected]>
 
+	* plugins/elements/gstfilesrc.c:
+	  Use g_filename_from_uri() for URI parsing in filesrc rather than rolling
+	  out own slightly incorrect version. Fixes use of some paths on
+	  win32.
+
+2008-11-20  Michael Smith <[email protected]>
 	* gst/gstregistrybinary.c:
 	  In win32 codepath, if we fail to write the registry, create the
 	  directory for it and try again, matching the behaviour in non-win32
Index: gstfilesrc.c
RCS file: /cvs/gstreamer/gstreamer/plugins/elements/gstfilesrc.c,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- gstfilesrc.c	23 Oct 2008 12:52:58 -0000	1.165
+++ gstfilesrc.c	20 Nov 2008 21:05:14 -0000	1.166
@@ -1100,46 +1100,44 @@
 static gboolean
 gst_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
 {
-  gchar *protocol, *location;
+  gchar *location, *hostname = NULL;
   gboolean ret;
   GstFileSrc *src = GST_FILE_SRC (handler);
-  protocol = gst_uri_get_protocol (uri);
-  if (strcmp (protocol, "file") != 0) {
-    g_free (protocol);
-    return FALSE;
-  }
-  g_free (protocol);
-
-  /* allow file://localhost/foo/bar by stripping localhost but fail
-   * for every other hostname */
-  if (g_str_has_prefix (uri, "file://localhost/")) {
-    char *tmp;
-    /* 16 == strlen ("file://localhost") */
-    tmp = g_strconcat ("file://", uri + 16, NULL);
-    /* we use gst_uri_get_location() although we already have the
-     * "location" with uri + 16 because it provides unescaping */
-    location = gst_uri_get_location (tmp);
-    g_free (tmp);
-  } else if (strcmp (uri, "file://") == 0) {
+  if (strcmp (uri, "file://") == 0) {
     /* Special case for "file://" as this is used by some applications
      *  to test with gst_element_make_from_uri if there's an element
      *  that supports the URI protocol. */
     gst_file_src_set_location (src, NULL);
     return TRUE;
-  } else {
-    location = gst_uri_get_location (uri);
-    GST_LOG_OBJECT (src, "Location '%s' found from uri '%s'", location, uri);
   }
-  if (!location)
-  if (!g_path_is_absolute (location)) {
-    g_free (location);
+  location = g_filename_from_uri (uri, &hostname, NULL);
+  if (!location) {
+    GST_WARNING_OBJECT (src, "Invalid URI '%s' for filesrc", uri);
     return FALSE;
+  if (hostname) {
+    if (!strcmp (hostname, "localhost")) {
+      /* Only 'localhost' is permitted */
+      GST_WARNING_OBJECT (src, "Invalid hostname '%s' for filesrc", hostname);
+      g_free (hostname);
+      return FALSE;
+    }
+    g_free (hostname);
+  }
+#ifdef G_OS_WIN32
+  /* Unfortunately, g_filename_from_uri() doesn't handle some UNC paths
+   * correctly on windows, it leaves them with an extra backslash
+   * at the start if they're of the mozilla-style file://///host/path/file 
+   * form. Correct this.
+   */
+  if (location[0] == '\\' && location[1] == '\\' && location[2] == '\\')
+    g_memmove (location, location + 1, strlen (location + 1) + 1);
+#endif
   ret = gst_file_src_set_location (src, location);
   g_free (location);

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.