Permalink
Browse files

Construct a proper URL.

  • Loading branch information...
1 parent d78a623 commit 568a67ec342fc20dbc41cade9c4e317f0c1d00ba @felipec committed May 22, 2008
Showing with 30 additions and 11 deletions.
  1. +24 −2 gst-backend.c
  2. +1 −1 gst-backend.h
  3. +5 −8 ui.c
View
@@ -72,7 +72,7 @@ backend_set_window (gpointer window_)
}
void
-backend_play (const char *uri)
+backend_play (const gchar *filename)
{
backend_stop ();
@@ -92,7 +92,29 @@ backend_play (const char *uri)
gst_object_unref (bus);
}
- g_object_set (G_OBJECT (bin), "uri", uri, NULL);
+ {
+ gchar *uri;
+
+ if (gst_uri_is_valid (filename))
+ {
+ uri = g_strdup (filename);
+ }
+ else if (g_path_is_absolute (filename))
+ {
+ uri = g_filename_to_uri (filename, NULL, NULL);
+ }
+ else
+ {
+ gchar *tmp;
+ tmp = g_build_filename (g_get_current_dir (), filename, NULL);
+ uri = g_filename_to_uri (tmp, NULL, NULL);
+ g_free (tmp);
+ }
+
+ g_debug ("%s", uri);
+ g_object_set (G_OBJECT (bin), "uri", uri, NULL);
+ g_free (uri);
+ }
g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL);
View
@@ -22,7 +22,7 @@
void backend_init (int *argc, char **argv[]);
void backend_deinit (void);
void backend_set_window (gpointer window);
-void backend_play (const char *uri);
+void backend_play (const gchar *filename);
void backend_stop (void);
void backend_seek (gint value);
void backend_seek_absolute (guint64 value);
View
@@ -24,7 +24,7 @@
#include "gst-backend.h"
-static char *uri_to_play;
+static gchar *filename;
static GtkWidget *video_output;
static GtkWidget *pause_button;
static GtkWidget *scale;
@@ -244,8 +244,8 @@ init (gpointer data)
{
backend_set_window (GINT_TO_POINTER (GDK_WINDOW_XWINDOW (video_output->window)));
- if (uri_to_play)
- backend_play (uri_to_play);
+ if (filename)
+ backend_play (filename);
return FALSE;
}
@@ -289,10 +289,7 @@ main (int argc,
if (argc > 1)
{
- if (strchr (argv[1], ':'))
- uri_to_play = g_strdup (argv[1]);
- else
- uri_to_play = g_strdup_printf ("file://%s", argv[1]);
+ filename = g_strdup (argv[1]);
}
toggle_fullscreen ();
@@ -301,7 +298,7 @@ main (int argc,
gtk_main ();
- g_free (uri_to_play);
+ g_free (filename);
backend_deinit ();

0 comments on commit 568a67e

Please sign in to comment.