|
1 /* GStreamer |
|
2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de> |
|
3 * |
|
4 * gnomevfs.c: register gnomevfs elements |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Library General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 2 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Library General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Library General Public |
|
17 * License along with this library; if not, write to the |
|
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 * Boston, MA 02111-1307, USA. |
|
20 */ |
|
21 |
|
22 #ifdef HAVE_CONFIG_H |
|
23 # include "config.h" |
|
24 #endif |
|
25 |
|
26 #include "gst/gst-i18n-plugin.h" |
|
27 |
|
28 #include "gstgnomevfs.h" |
|
29 #include "gstgnomevfssrc.h" |
|
30 #include "gstgnomevfssink.h" |
|
31 |
|
32 #include <libgnomevfs/gnome-vfs.h> |
|
33 #include <gst/gst.h> |
|
34 |
|
35 #include <string.h> |
|
36 |
|
37 gchar * |
|
38 gst_gnome_vfs_location_to_uri_string (const gchar * location) |
|
39 { |
|
40 gchar *newloc, *ret; |
|
41 |
|
42 if (location == NULL) |
|
43 return NULL; |
|
44 |
|
45 /* already an URI string? */ |
|
46 if (strstr (location, "://")) |
|
47 return g_strdup (location); |
|
48 |
|
49 newloc = gnome_vfs_escape_path_string (location); |
|
50 |
|
51 if (newloc && *newloc == '/') { |
|
52 ret = g_strdup_printf ("file://%s", newloc); |
|
53 } else { |
|
54 gchar *curdir; |
|
55 |
|
56 curdir = g_get_current_dir (); |
|
57 ret = g_strdup_printf ("file://%s/%s", curdir, newloc); |
|
58 g_free (curdir); |
|
59 } |
|
60 |
|
61 g_free (newloc); |
|
62 return ret; |
|
63 } |
|
64 |
|
65 GType |
|
66 gst_gnome_vfs_uri_get_type (void) |
|
67 { |
|
68 static GType type; /* 0 */ |
|
69 |
|
70 if (type == 0) { |
|
71 type = g_boxed_type_register_static ("GnomeVFSURI", |
|
72 (GBoxedCopyFunc) gnome_vfs_uri_ref, |
|
73 (GBoxedFreeFunc) gnome_vfs_uri_unref); |
|
74 } |
|
75 |
|
76 return type; |
|
77 } |
|
78 |
|
79 static gpointer |
|
80 gst_gnome_vfs_handle_copy (gpointer handle) |
|
81 { |
|
82 return handle; |
|
83 } |
|
84 |
|
85 static void |
|
86 gst_gnome_vfs_handle_free (gpointer handle) |
|
87 { |
|
88 return; |
|
89 } |
|
90 |
|
91 GType |
|
92 gst_gnome_vfs_handle_get_type (void) |
|
93 { |
|
94 static GType type; /* 0 */ |
|
95 |
|
96 if (type == 0) { |
|
97 /* hackish, but makes it show up nicely in gst-inspect */ |
|
98 type = g_boxed_type_register_static ("GnomeVFSHandle", |
|
99 (GBoxedCopyFunc) gst_gnome_vfs_handle_copy, |
|
100 (GBoxedFreeFunc) gst_gnome_vfs_handle_free); |
|
101 } |
|
102 |
|
103 return type; |
|
104 } |
|
105 |
|
106 static gboolean |
|
107 plugin_init (GstPlugin * plugin) |
|
108 { |
|
109 /* gnome vfs engine init */ |
|
110 if (!gnome_vfs_initialized ()) { |
|
111 if (!gnome_vfs_init ()) { |
|
112 GST_WARNING ("Failed to initialize GnomeVFS - not registering plugin!"); |
|
113 return FALSE; |
|
114 } |
|
115 } |
|
116 |
|
117 if (!gst_element_register (plugin, "gnomevfssrc", GST_RANK_SECONDARY, |
|
118 gst_gnome_vfs_src_get_type ())) |
|
119 return FALSE; |
|
120 |
|
121 if (!gst_element_register (plugin, "gnomevfssink", GST_RANK_SECONDARY, |
|
122 gst_gnome_vfs_sink_get_type ())) |
|
123 return FALSE; |
|
124 |
|
125 #ifdef ENABLE_NLS |
|
126 /* FIXME: add category |
|
127 GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, LOCALEDIR); |
|
128 */ |
|
129 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); |
|
130 #endif /* ENABLE_NLS */ |
|
131 |
|
132 return TRUE; |
|
133 } |
|
134 |
|
135 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, |
|
136 GST_VERSION_MINOR, |
|
137 "gnomevfs", |
|
138 "elements to read from and write to Gnome-VFS uri's", |
|
139 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) |