GNOME Bugzilla – Bug 469402
File uri handling on windows broken
Last modified: 2007-09-12 12:44:16 UTC
When you use gst-app (from cvs repository) or when you use gst-launch like this : gst-launch playbin uri=file:///c:/film.avi you obtained this messages (on msdos and msys): FAILED to play file:///g:/film.avi: Could not open file "/g:/film.avi" for reading. E:\devel-release\src_releases\gstreamer\plugins\elements\gstfilesrc.c(981): (function) (): /playbin/source: system error: Invalid argument Effectively, /c:/path doesn't exist on windows. To correct this bug, I propose following patch in gst/gsturi.c. Function uses g_filename_from_uri from glib and the result will be fine on all platforms. Perhaps, else case does not necessary. Samuel gchar * gst_uri_get_location (const gchar * uri) { gchar *colon; gchar *location, *unescaped; GError *err = NULL; g_return_val_if_fail (uri != NULL, NULL); g_return_val_if_fail (gst_uri_is_valid (uri), NULL); if (gst_uri_has_protocol(uri, "file") == TRUE) { unescaped = g_filename_from_uri(uri, NULL, &err); if (err != NULL) { GST_WARNING ("Failed to convert URI to a local filename: %s", err->message); g_error_free(err); } } else { colon = strstr (uri, "://"); location = g_strdup (colon + 3); unescaped = unescape_string (location, "/"); g_free (location); } return unescaped; }
Shouldn't this be gst-launch playbin uri=file://c:/film.avi i.e. with only two / before c:/?
Should be fixed now: 2007-09-12 Tim-Philipp Müller <tim at centricular dot net> * gst/gsturi.c: (gst_uri_get_location): If there's no hostname, we want to return 'c:/foo/bar.txt' and not '/c:/foo/bar.txt' on Windows. Fixes #469402. * tests/check/gst/gsturi.c: Unit test for the above and a few more things. g_filename_from_uri() is not really an option because it only handles the 'file://' protocol, and other protocols may include file paths too. Besides, it's a bit awkward since you'd also need to prepend the hostname to the return value of _from_uri(). (In reply to comment #1) > Shouldn't this be > gst-launch playbin uri=file://c:/film.avi > > i.e. with only two / before c:/? Don't think so. Do you have links that suggest otherwise?