gnomevfs: remove GnomeVFS plugin

The gio plugin replaces it.
This commit is contained in:
Tim-Philipp Müller 2011-06-15 00:52:47 +01:00
parent 6b33226281
commit a9e4949238
24 changed files with 10 additions and 2508 deletions

View file

@ -632,22 +632,6 @@ dnl FIXME : add second check somehow if that is necessary
dnl AC_CHECK_LIB(cdda_paranoia, paranoia_init, : , HAVE_CDPARANOIA=no, -lcdda_interface )
dnl AC_CHECK_HEADER(cdda_paranoia.h, :, HAVE_CDPARANOIA=no)
dnl *** GNOME VFS ***
translit(dnm, m, l) AM_CONDITIONAL(USE_GNOME_VFS, true)
AG_GST_CHECK_FEATURE(GNOME_VFS, [GNOME VFS], gnomevfs, [
PKG_CHECK_MODULES(GNOME_VFS, gnome-vfs-2.0, [
HAVE_GNOME_VFS="yes"
AC_SUBST(GNOME_VFS_CFLAGS)
AC_SUBST(GNOME_VFS_LIBS)
GNOME_VFS_MODULES_DIR="`$PKG_CONFIG --variable=modulesdir gnome-vfs-2.0`"
AC_DEFINE_UNQUOTED(GNOME_VFS_MODULES_DIR, "$GNOME_VFS_MODULES_DIR",
[The GnomeVFS modules directory.])
],[
HAVE_GNOME_VFS="no"
]
)
])
dnl *** ivorbis ***
dnl AM_PATH_IVORBIS only takes two options
translit(dnm, m, l) AM_CONDITIONAL(USE_IVORBIS, true)
@ -776,7 +760,6 @@ dnl but we still need to set the conditionals
AM_CONDITIONAL(USE_ALSA, false)
AM_CONDITIONAL(USE_CDPARANOIA, false)
AM_CONDITIONAL(USE_GIO, false)
AM_CONDITIONAL(USE_GNOME_VFS, false)
AM_CONDITIONAL(USE_IVORBIS, false)
AM_CONDITIONAL(USE_LIBVISUAL, false)
AM_CONDITIONAL(USE_OGG, false)
@ -896,7 +879,6 @@ sys/xvimage/Makefile
ext/Makefile
ext/alsa/Makefile
ext/cdparanoia/Makefile
ext/gnomevfs/Makefile
ext/gio/Makefile
ext/libvisual/Makefile
ext/ogg/Makefile

View file

@ -84,8 +84,6 @@ EXTRA_HFILES = \
$(top_srcdir)/ext/gio/gstgiosrc.h \
$(top_srcdir)/ext/gio/gstgiostreamsink.h \
$(top_srcdir)/ext/gio/gstgiostreamsrc.h \
$(top_srcdir)/ext/gnomevfs/gstgnomevfssink.h \
$(top_srcdir)/ext/gnomevfs/gstgnomevfssrc.h \
$(top_srcdir)/ext/ogg/gstoggdemux.h \
$(top_srcdir)/ext/ogg/gstoggmux.h \
$(top_srcdir)/ext/pango/gstclockoverlay.h \

View file

@ -39,8 +39,6 @@
<xi:include href="xml/element-giosrc.xml" />
<xi:include href="xml/element-giostreamsink.xml" />
<xi:include href="xml/element-giostreamsrc.xml" />
<xi:include href="xml/element-gnomevfssink.xml" />
<xi:include href="xml/element-gnomevfssrc.xml" />
<xi:include href="xml/element-multifdsink.xml" />
<xi:include href="xml/element-oggdemux.xml" />
<xi:include href="xml/element-oggmux.xml" />
@ -85,7 +83,6 @@
<xi:include href="xml/plugin-ffmpegcolorspace.xml" />
<xi:include href="xml/plugin-gdp.xml" />
<xi:include href="xml/plugin-gio.xml" />
<xi:include href="xml/plugin-gnomevfs.xml" />
<xi:include href="xml/plugin-libvisual.xml" />
<xi:include href="xml/plugin-ogg.xml" />
<xi:include href="xml/plugin-pango.xml" />

View file

@ -241,9 +241,9 @@ GstDecodeBin
</SECTION>
<SECTION>
<FILE>element-decodebin2</FILE>
<TITLE>decodebin2</TITLE>
GstDecodeBin2
<FILE>element-decodebin</FILE>
<TITLE>decodebin</TITLE>
GstDecodeBin
<SUBSECTION Standard>
</SECTION>
@ -395,34 +395,6 @@ GST_TYPE_TCP_PROTOCOL
gst_tcp_protocol_get_type
</SECTION>
<SECTION>
<FILE>element-gnomevfssink</FILE>
<TITLE>gnomevfssink</TITLE>
GstGnomeVFSSink
<SUBSECTION Standard>
GstGnomeVFSSinkClass
GST_GNOME_VFS_SINK_CLASS
GST_TYPE_GNOME_VFS_SINK
GST_IS_GNOME_VFS_SINK
gst_gnome_vfs_sink_get_type
GST_IS_GNOME_VFS_SINK_CLASS
GST_GNOME_VFS_SINK
</SECTION>
<SECTION>
<FILE>element-gnomevfssrc</FILE>
<TITLE>gnomevfssrc</TITLE>
GstGnomeVFSSrc
<SUBSECTION Standard>
GST_GNOME_VFS_SRC
GST_GNOME_VFS_SRC_CLASS
GST_IS_GNOME_VFS_SRC
GST_IS_GNOME_VFS_SRC_CLASS
GST_TYPE_GNOME_VFS_SRC
GstGnomeVFSSrcClass
gst_gnome_vfs_src_get_type
</SECTION>
<SECTION>
<FILE>element-oggdemux</FILE>
<TITLE>oggdemux</TITLE>
@ -460,13 +432,6 @@ GST_TYPE_OGG_MUX
GstOggMuxClass
</SECTION>
<SECTION>
<FILE>gstplaybasebin</FILE>
<TITLE>GstPlayBaseBin</TITLE>
GstPlayBaseBin
<SUBSECTION Standard>
</SECTION>
<SECTION>
<FILE>element-playbin</FILE>
<TITLE>playbin</TITLE>
@ -475,9 +440,9 @@ GstPlayBin
</SECTION>
<SECTION>
<FILE>element-playbin2</FILE>
<TITLE>playbin2</TITLE>
GstPlayBin2
<FILE>element-playbin</FILE>
<TITLE>playbin</TITLE>
GstPlayBin
GstPlayFlags
<SUBSECTION Standard>
gst_play_flags_get_type

View file

@ -1,43 +0,0 @@
<plugin>
<name>gnomevfs</name>
<description>elements to read from and write to Gnome-VFS uri&apos;s</description>
<filename>../../ext/gnomevfs/.libs/libgstgnomevfs.so</filename>
<basename>libgstgnomevfs.so</basename>
<version>0.10.34.1</version>
<license>LGPL</license>
<source>gst-plugins-base</source>
<package>GStreamer Base Plug-ins git</package>
<origin>Unknown package origin</origin>
<elements>
<element>
<name>gnomevfssink</name>
<longname>GnomeVFS Sink</longname>
<class>Sink/File</class>
<description>Write a stream to a GnomeVFS URI</description>
<author>Bastien Nocera &lt;hadess@hadess.net&gt;</author>
<pads>
<caps>
<name>sink</name>
<direction>sink</direction>
<presence>always</presence>
<details>ANY</details>
</caps>
</pads>
</element>
<element>
<name>gnomevfssrc</name>
<longname>GnomeVFS Source</longname>
<class>Source/File</class>
<description>Read from any GnomeVFS-supported file</description>
<author>Bastien Nocera &lt;hadess@hadess.net&gt;, GStreamer maintainers &lt;gstreamer-devel@lists.sourceforge.net&gt;</author>
<pads>
<caps>
<name>src</name>
<direction>source</direction>
<presence>always</presence>
<details>ANY</details>
</caps>
</pads>
</element>
</elements>
</plugin>

View file

@ -16,12 +16,6 @@ else
GIO_DIR=
endif
if USE_GNOME_VFS
GNOMEVFS_DIR=gnomevfs
else
GNOMEVFS_DIR=
endif
if USE_LIBVISUAL
LIBVISUAL_DIR=libvisual
else
@ -64,7 +58,6 @@ SUBDIRS = \
$(ALSA_DIR) \
$(CDPARANOIA_DIR) \
$(GIO_DIR) \
$(GNOMEVFS_DIR) \
$(LIBVISUAL_DIR) \
$(OGG_DIR) \
$(PANGO_DIR) \
@ -75,7 +68,6 @@ DIST_SUBDIRS = \
alsa \
cdparanoia \
gio \
gnomevfs \
libvisual \
ogg \
pango \

View file

@ -1,21 +0,0 @@
plugin_LTLIBRARIES = libgstgnomevfs.la
libgstgnomevfs_la_SOURCES = \
gstgnomevfs.c \
gstgnomevfssink.c \
gstgnomevfssrc.c \
gstgnomevfsuri.c
libgstgnomevfs_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GNOME_VFS_CFLAGS)
libgstgnomevfs_la_LIBADD = \
$(top_builddir)/gst-libs/gst/tag/libgsttag-$(GST_MAJORMINOR).la \
$(GST_BASE_LIBS) $(GNOME_VFS_LIBS)
libgstgnomevfs_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstgnomevfs_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = \
gstgnomevfs.h \
gstgnomevfssink.h \
gstgnomevfssrc.h \
gstgnomevfsuri.h

View file

@ -1,143 +0,0 @@
/* GStreamer
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* gnomevfs.c: register gnomevfs elements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gst/gst-i18n-plugin.h"
#include "gstgnomevfs.h"
#include "gstgnomevfssrc.h"
#include "gstgnomevfssink.h"
#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)
{
static GType type; /* 0 */
if (type == 0) {
type = g_boxed_type_register_static ("GnomeVFSURI",
(GBoxedCopyFunc) gnome_vfs_uri_ref,
(GBoxedFreeFunc) gnome_vfs_uri_unref);
}
return type;
}
static gpointer
gst_gnome_vfs_handle_copy (gpointer handle)
{
return handle;
}
static void
gst_gnome_vfs_handle_free (gpointer handle)
{
return;
}
GType
gst_gnome_vfs_handle_get_type (void)
{
static GType type; /* 0 */
if (type == 0) {
/* hackish, but makes it show up nicely in gst-inspect */
type = g_boxed_type_register_static ("GnomeVFSHandle",
(GBoxedCopyFunc) gst_gnome_vfs_handle_copy,
(GBoxedFreeFunc) gst_gnome_vfs_handle_free);
}
return type;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
/* gnome vfs engine init */
if (!gnome_vfs_initialized ()) {
if (!gnome_vfs_init ()) {
GST_WARNING ("Failed to initialize GnomeVFS - not registering plugin!");
return FALSE;
}
}
gst_plugin_add_dependency_simple (plugin, NULL, GNOME_VFS_MODULES_DIR, NULL,
GST_PLUGIN_DEPENDENCY_FLAG_NONE);
if (!gst_element_register (plugin, "gnomevfssrc", GST_RANK_MARGINAL,
gst_gnome_vfs_src_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "gnomevfssink", GST_RANK_MARGINAL,
gst_gnome_vfs_sink_get_type ()))
return FALSE;
#ifdef ENABLE_NLS
/* FIXME: add category
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, LOCALEDIR);
*/
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gnomevfs",
"elements to read from and write to Gnome-VFS uri's",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

View file

@ -1,38 +0,0 @@
/* GStreamer
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_GNOME_VFS_H__
#define __GST_GNOME_VFS_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define GST_TYPE_GNOME_VFS_URI (gst_gnome_vfs_uri_get_type ())
#define GST_TYPE_GNOME_VFS_HANDLE (gst_gnome_vfs_handle_get_type ())
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__ */

View file

@ -1,627 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2001 Bastien Nocera <hadess@hadess.net>
* 2003 Colin Walters <walters@verbum.org>
* 2005 Tim-Philipp Müller <tim centricular net>
*
* gstgnomevfssink.c:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-gnomevfssink
* @see_also: #GstFileSink, #GstGnomeVFSSrc
*
* This plugin writes incoming data to a local or remote location specified
* by an URI. This location can be specified using any protocol supported by
* the GnomeVFS library. Common protocols are 'file', 'ftp', or 'smb'.
*
* Applications can connect to the #GstGnomeVFSSink::allow-overwrite signal to
* receive a callback when an existing file will be overwritten. The return
* value of the signal will determine if gnomevfssink will overwrite the
* resource or abort with an error.
*
* <refsect2>
* <title>Example launch lines</title>
* |[
* gst-launch -v filesrc location=input.xyz ! gnomevfssink location=file:///home/joe/out.xyz
* ]| The above pipeline will simply copy a local file. Instead of gnomevfssink,
* we could just as well have used the filesink element here.
* |[
* gst-launch -v filesrc location=foo.mp3 ! mad ! flacenc ! gnomevfssink location=smb://othercomputer/foo.flac
* ]| The above pipeline will re-encode an mp3 file into FLAC format and store
* it on a remote host using the Samba protocol.
* </refsect2>
*
* Last reviewed on 2006-02-28 (0.10.4)
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstgnomevfssink.h"
#include "gst/gst-i18n-plugin.h"
#include <gst/gst.h>
#include <libgnomevfs/gnome-vfs.h>
#include <string.h>
#include <errno.h>
enum
{
SIGNAL_ERASE_ASK,
LAST_SIGNAL
};
enum
{
ARG_0,
ARG_LOCATION,
ARG_URI,
ARG_HANDLE
};
static void gst_gnome_vfs_sink_finalize (GObject * obj);
static void gst_gnome_vfs_sink_uri_handler_init (gpointer g_iface,
gpointer iface_data);
static void gst_gnome_vfs_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gnome_vfs_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_gnome_vfs_sink_open_file (GstGnomeVFSSink * sink);
static void gst_gnome_vfs_sink_close_file (GstGnomeVFSSink * sink);
static gboolean gst_gnome_vfs_sink_start (GstBaseSink * basesink);
static gboolean gst_gnome_vfs_sink_stop (GstBaseSink * basesink);
static GstFlowReturn gst_gnome_vfs_sink_render (GstBaseSink * basesink,
GstBuffer * buffer);
static gboolean gst_gnome_vfs_sink_handle_event (GstBaseSink * basesink,
GstEvent * event);
static gboolean gst_gnome_vfs_sink_query (GstPad * pad, GstQuery * query);
static guint gst_gnome_vfs_sink_signals[LAST_SIGNAL]; /* all 0 */
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GST_DEBUG_CATEGORY_STATIC (gst_gnome_vfs_sink_debug);
#define GST_CAT_DEFAULT gst_gnome_vfs_sink_debug
static void
gst_gnome_vfs_sink_do_init (GType type)
{
static const GInterfaceInfo urihandler_info = {
gst_gnome_vfs_sink_uri_handler_init,
NULL,
NULL
};
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
GST_DEBUG_CATEGORY_INIT (gst_gnome_vfs_sink_debug, "gnomevfssink", 0,
"Gnome VFS sink element");
}
#define gst_gnome_vfs_sink_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGnomeVFSSink, gst_gnome_vfs_sink,
GST_TYPE_BASE_SINK, gst_gnome_vfs_sink_do_init (g_define_type_id));
static gboolean
_gst_boolean_allow_overwrite_accumulator (GSignalInvocationHint * ihint,
GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
gboolean allow_overwrite;
allow_overwrite = g_value_get_boolean (handler_return);
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
g_value_set_boolean (return_accu, allow_overwrite);
/* stop emission if signal doesn't allow overwriting */
return allow_overwrite;
}
static void
gst_gnome_vfs_sink_class_init (GstGnomeVFSSinkClass * klass)
{
GstBaseSinkClass *basesink_class;
GstElementClass *gstelement_class;
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
basesink_class = (GstBaseSinkClass *) klass;
gobject_class->set_property = gst_gnome_vfs_sink_set_property;
gobject_class->get_property = gst_gnome_vfs_sink_get_property;
gobject_class->finalize = gst_gnome_vfs_sink_finalize;
g_object_class_install_property (gobject_class, ARG_LOCATION,
g_param_spec_string ("location", "File Location",
"Location of the file to write", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, ARG_URI,
g_param_spec_boxed ("uri", "GnomeVFSURI", "URI for GnomeVFS",
GST_TYPE_GNOME_VFS_URI, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, ARG_HANDLE,
g_param_spec_boxed ("handle", "GnomeVFSHandle", "Handle for GnomeVFS",
GST_TYPE_GNOME_VFS_HANDLE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstGnomeVFSSink::allow-overwrite
* @sink: the object which received the signal
* @uri: the URI to be overwritten
*
* This signal is fired when gnomevfssink is about to overwrite an
* existing resource. The application can connect to this signal and ask
* the user if the resource may be overwritten.
*
* Returns: A boolean indicating that the resource may be overwritten.
*/
gst_gnome_vfs_sink_signals[SIGNAL_ERASE_ASK] =
g_signal_new ("allow-overwrite", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstGnomeVFSSinkClass, erase_ask),
_gst_boolean_allow_overwrite_accumulator, NULL,
gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_GNOME_VFS_URI);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sinktemplate));
gst_element_class_set_details_simple (gstelement_class,
"GnomeVFS Sink", "Sink/File",
"Write a stream to a GnomeVFS URI", "Bastien Nocera <hadess@hadess.net>");
basesink_class->stop = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_stop);
basesink_class->start = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_start);
basesink_class->event = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_handle_event);
basesink_class->render = GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_render);
basesink_class->get_times = NULL;
}
static void
gst_gnome_vfs_sink_finalize (GObject * obj)
{
GstGnomeVFSSink *sink = GST_GNOME_VFS_SINK (obj);
if (sink->uri) {
gnome_vfs_uri_unref (sink->uri);
sink->uri = NULL;
}
if (sink->uri_name) {
g_free (sink->uri_name);
sink->uri_name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static void
gst_gnome_vfs_sink_init (GstGnomeVFSSink * sink)
{
gst_pad_set_query_function (GST_BASE_SINK_PAD (sink),
GST_DEBUG_FUNCPTR (gst_gnome_vfs_sink_query));
sink->uri = NULL;
sink->uri_name = NULL;
sink->handle = NULL;
sink->own_handle = FALSE;
sink->current_pos = 0;
GST_BASE_SINK (sink)->sync = FALSE;
}
static void
gst_gnome_vfs_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGnomeVFSSink *sink;
GstState cur_state;
sink = GST_GNOME_VFS_SINK (object);
gst_element_get_state (GST_ELEMENT (sink), &cur_state, NULL, 0);
if (cur_state == GST_STATE_PLAYING || cur_state == GST_STATE_PAUSED) {
GST_WARNING_OBJECT (sink, "cannot set property when PAUSED or PLAYING");
return;
}
GST_OBJECT_LOCK (sink);
switch (prop_id) {
case ARG_LOCATION:{
const gchar *new_location;
if (sink->uri) {
gnome_vfs_uri_unref (sink->uri);
sink->uri = NULL;
}
if (sink->uri_name) {
g_free (sink->uri_name);
sink->uri_name = NULL;
}
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;
}
case ARG_URI:{
if (sink->uri) {
gnome_vfs_uri_unref (sink->uri);
sink->uri = NULL;
}
if (sink->uri_name) {
g_free (sink->uri_name);
sink->uri_name = NULL;
}
if (g_value_get_boxed (value)) {
sink->uri = (GnomeVFSURI *) g_value_dup_boxed (value);
sink->uri_name = gnome_vfs_uri_to_string (sink->uri, 0);
}
break;
}
case ARG_HANDLE:{
if (sink->uri) {
gnome_vfs_uri_unref (sink->uri);
sink->uri = NULL;
}
if (sink->uri_name) {
g_free (sink->uri_name);
sink->uri_name = NULL;
}
sink->handle = g_value_get_boxed (value);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
GST_OBJECT_UNLOCK (sink);
}
static void
gst_gnome_vfs_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstGnomeVFSSink *sink;
sink = GST_GNOME_VFS_SINK (object);
GST_OBJECT_LOCK (sink);
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, sink->uri_name);
break;
case ARG_URI:
g_value_set_boxed (value, sink->uri);
break;
case ARG_HANDLE:
g_value_set_boxed (value, sink->handle);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
GST_OBJECT_UNLOCK (sink);
}
static gboolean
gst_gnome_vfs_sink_open_file (GstGnomeVFSSink * sink)
{
GnomeVFSResult result;
if (sink->uri) {
/* open the file, all permissions, umask will apply */
result = gnome_vfs_create_uri (&(sink->handle), sink->uri,
GNOME_VFS_OPEN_WRITE, TRUE,
GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE |
GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE |
GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE);
/* if the file existed and the property says to ask, then ask! */
if (result == GNOME_VFS_ERROR_FILE_EXISTS) {
gboolean erase_anyway = FALSE;
g_signal_emit (G_OBJECT (sink),
gst_gnome_vfs_sink_signals[SIGNAL_ERASE_ASK], 0, sink->uri,
&erase_anyway);
if (erase_anyway) {
result = gnome_vfs_create_uri (&(sink->handle), sink->uri,
GNOME_VFS_OPEN_WRITE, FALSE,
GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE |
GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE |
GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE);
}
}
GST_DEBUG_OBJECT (sink, "open: %s", gnome_vfs_result_to_string (result));
if (result != GNOME_VFS_OK) {
gchar *filename = gnome_vfs_uri_to_string (sink->uri,
GNOME_VFS_URI_HIDE_PASSWORD);
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
(_("Could not open vfs file \"%s\" for writing: %s."),
filename, gnome_vfs_result_to_string (result)), GST_ERROR_SYSTEM);
g_free (filename);
return FALSE;
}
sink->own_handle = TRUE;
} else if (!sink->handle) {
GST_ELEMENT_ERROR (sink, RESOURCE, FAILED, (_("No filename given")),
(NULL));
return FALSE;
} else {
sink->own_handle = FALSE;
}
sink->current_pos = 0;
return TRUE;
}
static void
gst_gnome_vfs_sink_close_file (GstGnomeVFSSink * sink)
{
GnomeVFSResult result;
if (sink->own_handle) {
/* close the file */
result = gnome_vfs_close (sink->handle);
if (result != GNOME_VFS_OK) {
gchar *filename = gnome_vfs_uri_to_string (sink->uri,
GNOME_VFS_URI_HIDE_PASSWORD);
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
(_("Could not close vfs file \"%s\"."), filename), GST_ERROR_SYSTEM);
g_free (filename);
}
sink->own_handle = FALSE;
sink->handle = NULL;
}
}
static gboolean
gst_gnome_vfs_sink_start (GstBaseSink * basesink)
{
gboolean ret;
ret = gst_gnome_vfs_sink_open_file (GST_GNOME_VFS_SINK (basesink));
return ret;
}
static gboolean
gst_gnome_vfs_sink_stop (GstBaseSink * basesink)
{
GST_DEBUG_OBJECT (basesink, "closing ...");
gst_gnome_vfs_sink_close_file (GST_GNOME_VFS_SINK (basesink));
return TRUE;
}
static gboolean
gst_gnome_vfs_sink_handle_event (GstBaseSink * basesink, GstEvent * event)
{
GstGnomeVFSSink *sink;
gboolean ret = TRUE;
sink = GST_GNOME_VFS_SINK (basesink);
GST_DEBUG_OBJECT (sink, "processing %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEGMENT:{
GnomeVFSResult res;
const GstSegment *segment;
gst_event_parse_segment (event, &segment);
if (segment->format != GST_FORMAT_BYTES) {
GST_WARNING_OBJECT (sink, "ignored NEWSEGMENT event in %s format",
gst_format_get_name (segment->format));
break;
}
GST_LOG_OBJECT (sink, "seeking to offset %" G_GINT64_FORMAT,
segment->start);
res = gnome_vfs_seek (sink->handle, GNOME_VFS_SEEK_START, segment->start);
if (res != GNOME_VFS_OK) {
GST_ERROR_OBJECT (sink, "Failed to seek to offset %"
G_GINT64_FORMAT ": %s", segment->start,
gnome_vfs_result_to_string (res));
ret = FALSE;
} else {
sink->current_pos = segment->start;
}
break;
}
case GST_EVENT_FLUSH_START:
case GST_EVENT_EOS:{
/* No need to flush with GnomeVfs */
break;
}
default:
break;
}
return ret;
}
static gboolean
gst_gnome_vfs_sink_query (GstPad * pad, GstQuery * query)
{
GstGnomeVFSSink *sink;
GstFormat format;
sink = GST_GNOME_VFS_SINK (GST_PAD_PARENT (pad));
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
gst_query_parse_position (query, &format, NULL);
switch (format) {
case GST_FORMAT_DEFAULT:
case GST_FORMAT_BYTES:
gst_query_set_position (query, GST_FORMAT_BYTES, sink->current_pos);
return TRUE;
default:
return FALSE;
}
case GST_QUERY_FORMATS:
gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
return TRUE;
case GST_QUERY_URI:
gst_query_set_uri (query, sink->uri_name);
return TRUE;
default:
return gst_pad_query_default (pad, query);
}
}
static GstFlowReturn
gst_gnome_vfs_sink_render (GstBaseSink * basesink, GstBuffer * buf)
{
GnomeVFSFileSize written, cur_pos;
GstGnomeVFSSink *sink;
GnomeVFSResult result;
GstFlowReturn ret;
guint8 *data;
gsize size;
sink = GST_GNOME_VFS_SINK (basesink);
if (gnome_vfs_tell (sink->handle, &cur_pos) == GNOME_VFS_OK) {
/* bring up to date with current position for proper reporting */
sink->current_pos = cur_pos;
}
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
result = gnome_vfs_write (sink->handle, data, size, &written);
gst_buffer_unmap (buf, data, size);
switch (result) {
case GNOME_VFS_OK:{
GST_DEBUG_OBJECT (sink, "wrote %" G_GINT64_FORMAT " bytes at %"
G_GINT64_FORMAT, (gint64) written, (gint64) cur_pos);
if (written < size) {
/* FIXME: what to do here? (tpm) */
g_warning ("%s: %" G_GSIZE_FORMAT " bytes should be written, only %"
G_GUINT64_FORMAT " bytes written", G_STRLOC, size, written);
}
sink->current_pos += size;
ret = GST_FLOW_OK;
break;
}
case GNOME_VFS_ERROR_NO_SPACE:{
/* TODO: emit signal/send msg on out-of-diskspace and
* handle this gracefully (see open bug) (tpm) */
GST_ELEMENT_ERROR (sink, RESOURCE, NO_SPACE_LEFT, (NULL),
("bufsize=%u, written=%u", size, (guint) written));
ret = GST_FLOW_ERROR;
break;
}
default:{
gchar *filename = gnome_vfs_uri_to_string (sink->uri,
GNOME_VFS_URI_HIDE_PASSWORD);
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filename),
("%s, bufsize=%u, written=%u", gnome_vfs_result_to_string (result),
size, (guint) written));
g_free (filename);
ret = GST_FLOW_ERROR;
break;
}
}
return ret;
}
/*** GSTURIHANDLER INTERFACE *************************************************/
static GstURIType
gst_gnome_vfs_sink_uri_get_type (void)
{
return GST_URI_SINK;
}
static gchar **
gst_gnome_vfs_sink_uri_get_protocols (void)
{
return gst_gnomevfs_get_supported_uris ();
}
static const gchar *
gst_gnome_vfs_sink_uri_get_uri (GstURIHandler * handler)
{
GstGnomeVFSSink *sink = GST_GNOME_VFS_SINK (handler);
return sink->uri_name;
}
static gboolean
gst_gnome_vfs_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
{
GstGnomeVFSSink *sink = GST_GNOME_VFS_SINK (handler);
GstState cur_state;
gst_element_get_state (GST_ELEMENT (sink), &cur_state, NULL, 0);
if (cur_state == GST_STATE_PLAYING || cur_state == GST_STATE_PAUSED) {
GST_WARNING_OBJECT (sink, "cannot set uri when PAUSED or PLAYING");
return FALSE;
}
g_object_set (sink, "location", uri, NULL);
return TRUE;
}
static void
gst_gnome_vfs_sink_uri_handler_init (gpointer g_iface, gpointer iface_data)
{
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
iface->get_type = gst_gnome_vfs_sink_uri_get_type;
iface->get_protocols = gst_gnome_vfs_sink_uri_get_protocols;
iface->get_uri = gst_gnome_vfs_sink_uri_get_uri;
iface->set_uri = gst_gnome_vfs_sink_uri_set_uri;
}

View file

@ -1,84 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2001 Bastien Nocera <hadess@hadess.net>
* 2003 Colin Walters <walters@verbum.org>
* 2005 Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_GNOME_VFS_SINK_H__
#define __GST_GNOME_VFS_SINK_H__
#include "gstgnomevfs.h"
#include "gstgnomevfsuri.h"
#include <gst/base/gstbasesink.h>
G_BEGIN_DECLS
#define GST_TYPE_GNOME_VFS_SINK \
(gst_gnome_vfs_sink_get_type())
#define GST_GNOME_VFS_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GNOME_VFS_SINK,GstGnomeVFSSink))
#define GST_GNOME_VFS_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GNOME_VFS_SINK,GstGnomeVFSSinkClass))
#define GST_IS_GNOME_VFS_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GNOME_VFS_SINK))
#define GST_IS_GNOME_VFS_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GNOME_VFS_SINK))
typedef struct _GstGnomeVFSSink GstGnomeVFSSink;
typedef struct _GstGnomeVFSSinkClass GstGnomeVFSSinkClass;
/**
* GstGnomeVFSSink:
*
* Opaque data structure.
*/
struct _GstGnomeVFSSink
{
GstBaseSink basesink;
/*< private >*/
/* uri */
GnomeVFSURI *uri;
gchar *uri_name;
/* handle */
GnomeVFSHandle *handle;
/* whether we opened the handle ourselves */
gboolean own_handle;
guint64 current_pos;
};
struct _GstGnomeVFSSinkClass
{
GstBaseSinkClass basesink_class;
/* signals */
gboolean (*erase_ask) (GstElement * element, GnomeVFSURI * uri);
};
GType gst_gnome_vfs_sink_get_type (void);
G_END_DECLS
#endif /* __GST_GNOME_VFS_SINK_H__ */

View file

@ -1,926 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2001 Bastien Nocera <hadess@hadess.net>
* 2002 Kristian Rietveld <kris@gtk.org>
* 2002,2003 Colin Walters <walters@gnu.org>
*
* gnomevfssrc.c:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-gnomevfssrc
* @see_also: #GstFileSrc, #GstGnomeVFSSink
*
* This plugin reads data from a local or remote location specified
* by an URI. This location can be specified using any protocol supported by
* the GnomeVFS library. Common protocols are 'file', 'http', 'ftp', or 'smb'.
*
* In case the #GstGnomeVFSSrc:iradio-mode property is set and the
* location is a http resource, gnomevfssrc will send special icecast http
* headers to the server to request additional icecast metainformation. If
* the server is not an icecast server, it will display the same behaviour
* as if the #GstGnomeVFSSrc:iradio-mode property was not set. However,
* if the server is in fact an icecast server, gnomevfssrc will output
* data with a media type of application/x-icy, in which case you will
* need to use the #GstICYDemux element as follow-up element to extract
* the icecast meta data and to determine the underlying media type.
*
* <refsect2>
* <title>Example launch lines</title>
* |[
* gst-launch -v gnomevfssrc location=file:///home/joe/foo.xyz ! fakesink
* ]| The above pipeline will simply read a local file and do nothing with the
* data read. Instead of gnomevfssrc, we could just as well have used the
* filesrc element here.
* |[
* gst-launch -v gnomevfssrc location=smb://othercomputer/foo.xyz ! filesink location=/home/joe/foo.xyz
* ]| The above pipeline will copy a file from a remote host to the local file
* system using the Samba protocol.
* |[
* gst-launch -v gnomevfssrc location=http://music.foobar.com/demo.mp3 ! mad ! audioconvert ! audioresample ! alsasink
* ]| The above pipeline will read and decode and play an mp3 file from a
* web server using the http protocol.
* </refsect2>
*/
#define BROKEN_SIG 1
/*#undef BROKEN_SIG */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gst/gst-i18n-plugin.h"
#include "gstgnomevfssrc.h"
#include <gnome-vfs-module-2.0/libgnomevfs/gnome-vfs-cancellable-ops.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>
#include <string.h>
#include <gst/gst.h>
#include <gst/tag/tag.h>
/* gnome-vfs.h doesn't include the following header, which we need: */
#include <libgnomevfs/gnome-vfs-standard-callbacks.h>
GST_DEBUG_CATEGORY_STATIC (gnomevfssrc_debug);
#define GST_CAT_DEFAULT gnomevfssrc_debug
static GStaticMutex count_lock = G_STATIC_MUTEX_INIT;
static gint ref_count = 0;
static gboolean vfs_owner = FALSE;
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
enum
{
ARG_0,
ARG_HANDLE,
ARG_LOCATION,
ARG_IRADIO_MODE,
ARG_IRADIO_NAME,
ARG_IRADIO_GENRE,
ARG_IRADIO_URL,
ARG_IRADIO_TITLE
};
static void gst_gnome_vfs_src_finalize (GObject * object);
static void gst_gnome_vfs_src_uri_handler_init (gpointer g_iface,
gpointer iface_data);
static void gst_gnome_vfs_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gnome_vfs_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_gnome_vfs_src_stop (GstBaseSrc * src);
static gboolean gst_gnome_vfs_src_start (GstBaseSrc * src);
static gboolean gst_gnome_vfs_src_is_seekable (GstBaseSrc * src);
static gboolean gst_gnome_vfs_src_unlock (GstBaseSrc * basesrc);
static gboolean gst_gnome_vfs_src_unlock_stop (GstBaseSrc * basesrc);
static gboolean gst_gnome_vfs_src_get_size (GstBaseSrc * src, guint64 * size);
static GstFlowReturn gst_gnome_vfs_src_create (GstBaseSrc * basesrc,
guint64 offset, guint size, GstBuffer ** buffer);
static gboolean gst_gnome_vfs_src_query (GstBaseSrc * src, GstQuery * query);
#define gst_gnome_vfs_src_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGnomeVFSSrc, gst_gnome_vfs_src, GST_TYPE_BASE_SRC,
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
gst_gnome_vfs_src_uri_handler_init));
static void
gst_gnome_vfs_src_class_init (GstGnomeVFSSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
gobject_class = G_OBJECT_CLASS (klass);
gstelement_class = GST_ELEMENT_CLASS (klass);
gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
GST_DEBUG_CATEGORY_INIT (gnomevfssrc_debug, "gnomevfssrc", 0,
"Gnome-VFS Source");
gobject_class->finalize = gst_gnome_vfs_src_finalize;
gobject_class->set_property = gst_gnome_vfs_src_set_property;
gobject_class->get_property = gst_gnome_vfs_src_get_property;
/* properties */
gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
"location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
g_object_class_install_property (gobject_class,
ARG_HANDLE,
g_param_spec_boxed ("handle",
"GnomeVFSHandle", "Handle for GnomeVFS",
GST_TYPE_GNOME_VFS_HANDLE,
GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/* icecast stuff */
g_object_class_install_property (gobject_class,
ARG_IRADIO_MODE,
g_param_spec_boolean ("iradio-mode",
"iradio-mode",
"Enable internet radio mode (extraction of shoutcast/icecast metadata)",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
ARG_IRADIO_NAME,
g_param_spec_string ("iradio-name",
"iradio-name", "Name of the stream", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, ARG_IRADIO_GENRE,
g_param_spec_string ("iradio-genre", "iradio-genre",
"Genre of the stream", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, ARG_IRADIO_URL,
g_param_spec_string ("iradio-url", "iradio-url",
"Homepage URL for radio stream", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, ARG_IRADIO_TITLE,
g_param_spec_string ("iradio-title", "iradio-title",
"Name of currently playing song", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&srctemplate));
gst_element_class_set_details_simple (gstelement_class,
"GnomeVFS Source", "Source/File",
"Read from any GnomeVFS-supported file",
"Bastien Nocera <hadess@hadess.net>, "
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_start);
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_stop);
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_unlock);
gstbasesrc_class->unlock_stop =
GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_unlock_stop);
gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_get_size);
gstbasesrc_class->is_seekable =
GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_is_seekable);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_create);
gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_query);
}
static void
gst_gnome_vfs_src_init (GstGnomeVFSSrc * gnomevfssrc)
{
gnomevfssrc->uri = NULL;
gnomevfssrc->uri_name = NULL;
gnomevfssrc->context = NULL;
gnomevfssrc->handle = NULL;
gnomevfssrc->interrupted = FALSE;
gnomevfssrc->curoffset = 0;
gnomevfssrc->seekable = FALSE;
gnomevfssrc->iradio_mode = FALSE;
gnomevfssrc->http_callbacks_pushed = FALSE;
gnomevfssrc->iradio_name = NULL;
gnomevfssrc->iradio_genre = NULL;
gnomevfssrc->iradio_url = NULL;
gnomevfssrc->iradio_title = NULL;
g_static_mutex_lock (&count_lock);
if (ref_count == 0) {
/* gnome vfs engine init */
if (gnome_vfs_initialized () == FALSE) {
gnome_vfs_init ();
vfs_owner = TRUE;
}
}
ref_count++;
g_static_mutex_unlock (&count_lock);
}
static void
gst_gnome_vfs_src_finalize (GObject * object)
{
GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (object);
g_static_mutex_lock (&count_lock);
ref_count--;
if (ref_count == 0 && vfs_owner) {
if (gnome_vfs_initialized () == TRUE) {
gnome_vfs_shutdown ();
}
}
g_static_mutex_unlock (&count_lock);
if (src->uri) {
gnome_vfs_uri_unref (src->uri);
src->uri = NULL;
}
g_free (src->uri_name);
src->uri_name = NULL;
g_free (src->iradio_name);
src->iradio_name = NULL;
g_free (src->iradio_genre);
src->iradio_genre = NULL;
g_free (src->iradio_url);
src->iradio_url = NULL;
g_free (src->iradio_title);
src->iradio_title = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/*
* URI interface support.
*/
static GstURIType
gst_gnome_vfs_src_uri_get_type (void)
{
return GST_URI_SRC;
}
static gchar **
gst_gnome_vfs_src_uri_get_protocols (void)
{
return gst_gnomevfs_get_supported_uris ();
}
static const gchar *
gst_gnome_vfs_src_uri_get_uri (GstURIHandler * handler)
{
GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (handler);
return src->uri_name;
}
static gboolean
gst_gnome_vfs_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
{
GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (handler);
if (GST_STATE (src) == GST_STATE_PLAYING ||
GST_STATE (src) == GST_STATE_PAUSED)
return FALSE;
g_object_set (G_OBJECT (src), "location", uri, NULL);
return TRUE;
}
static void
gst_gnome_vfs_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
{
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
iface->get_type = gst_gnome_vfs_src_uri_get_type;
iface->get_protocols = gst_gnome_vfs_src_uri_get_protocols;
iface->get_uri = gst_gnome_vfs_src_uri_get_uri;
iface->set_uri = gst_gnome_vfs_src_uri_set_uri;
}
static void
gst_gnome_vfs_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (object);
switch (prop_id) {
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)
break;
if (src->uri) {
gnome_vfs_uri_unref (src->uri);
src->uri = NULL;
}
if (src->uri_name) {
g_free (src->uri_name);
src->uri_name = NULL;
}
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) {
if (src->uri) {
gnome_vfs_uri_unref (src->uri);
src->uri = NULL;
}
if (src->uri_name) {
g_free (src->uri_name);
src->uri_name = NULL;
}
src->handle = g_value_get_boxed (value);
}
break;
case ARG_IRADIO_MODE:
src->iradio_mode = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_gnome_vfs_src_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (object);
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, src->uri_name);
break;
case ARG_HANDLE:
g_value_set_boxed (value, src->handle);
break;
case ARG_IRADIO_MODE:
g_value_set_boolean (value, src->iradio_mode);
break;
case ARG_IRADIO_NAME:
g_value_set_string (value, src->iradio_name);
break;
case ARG_IRADIO_GENRE:
g_value_set_string (value, src->iradio_genre);
break;
case ARG_IRADIO_URL:
g_value_set_string (value, src->iradio_url);
break;
case ARG_IRADIO_TITLE:
g_value_set_string (value, src->iradio_title);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static char *
gst_gnome_vfs_src_unicodify (const char *str)
{
const gchar *env_vars[] = { "GST_ICY_TAG_ENCODING",
"GST_TAG_ENCODING", NULL
};
return gst_tag_freeform_string_to_utf8 (str, -1, env_vars);
}
static void
gst_gnome_vfs_src_send_additional_headers_callback (gconstpointer in,
gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
{
GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (callback_data);
GnomeVFSModuleCallbackAdditionalHeadersOut *out_args =
(GnomeVFSModuleCallbackAdditionalHeadersOut *) out;
if (!src->iradio_mode)
return;
GST_DEBUG_OBJECT (src, "sending headers\n");
out_args->headers = g_list_append (out_args->headers,
g_strdup ("icy-metadata:1\r\n"));
}
static void
gst_gnome_vfs_src_received_headers_callback (gconstpointer in,
gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
{
GList *i;
gint icy_metaint;
GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (callback_data);
GnomeVFSModuleCallbackReceivedHeadersIn *in_args =
(GnomeVFSModuleCallbackReceivedHeadersIn *) in;
/* This is only used for internet radio stuff right now */
if (!src->iradio_mode)
return;
GST_DEBUG_OBJECT (src, "receiving internet radio metadata\n");
/* FIXME: Could we use "Accept-Ranges: bytes"
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5
* to enable pull-mode?
*/
for (i = in_args->headers; i; i = i->next) {
char *data = (char *) i->data;
char *value = strchr (data, ':');
char *key;
if (!value)
continue;
value++;
g_strstrip (value);
if (!strlen (value))
continue;
GST_LOG_OBJECT (src, "data %s", data);
/* Icecast stuff */
if (strncmp (data, "icy-metaint:", 12) == 0) { /* ugh */
if (sscanf (data + 12, "%d", &icy_metaint) == 1) {
if (icy_metaint > 0) {
GstCaps *icy_caps;
icy_caps = gst_caps_new_simple ("application/x-icy",
"metadata-interval", G_TYPE_INT, icy_metaint, NULL);
gst_pad_set_caps (GST_BASE_SRC_PAD (src), icy_caps);
gst_caps_unref (icy_caps);
}
}
continue;
}
if (!strncmp (data, "icy-", 4))
key = data + 4;
else
continue;
GST_DEBUG_OBJECT (src, "key: %s", key);
if (!strncmp (key, "name", 4)) {
g_free (src->iradio_name);
src->iradio_name = gst_gnome_vfs_src_unicodify (value);
if (src->iradio_name)
g_object_notify (G_OBJECT (src), "iradio-name");
} else if (!strncmp (key, "genre", 5)) {
g_free (src->iradio_genre);
src->iradio_genre = gst_gnome_vfs_src_unicodify (value);
if (src->iradio_genre)
g_object_notify (G_OBJECT (src), "iradio-genre");
} else if (!strncmp (key, "url", 3)) {
g_free (src->iradio_url);
src->iradio_url = gst_gnome_vfs_src_unicodify (value);
if (src->iradio_url)
g_object_notify (G_OBJECT (src), "iradio-url");
}
}
}
static void
gst_gnome_vfs_src_push_callbacks (GstGnomeVFSSrc * src)
{
if (src->http_callbacks_pushed)
return;
GST_DEBUG_OBJECT (src, "pushing callbacks");
gnome_vfs_module_callback_push
(GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS,
gst_gnome_vfs_src_send_additional_headers_callback, src, NULL);
gnome_vfs_module_callback_push
(GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS,
gst_gnome_vfs_src_received_headers_callback, src, NULL);
src->http_callbacks_pushed = TRUE;
}
static void
gst_gnome_vfs_src_pop_callbacks (GstGnomeVFSSrc * src)
{
if (!src->http_callbacks_pushed)
return;
GST_DEBUG_OBJECT (src, "popping callbacks");
gnome_vfs_module_callback_pop
(GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS);
gnome_vfs_module_callback_pop
(GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS);
src->http_callbacks_pushed = FALSE;
}
/*
* Read a new buffer from src->reqoffset, takes care of events
* and seeking and such.
*/
static GstFlowReturn
gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
GstBuffer ** buffer)
{
GnomeVFSResult res;
GstBuffer *buf;
GnomeVFSFileSize readbytes;
guint8 *data, *ptr;
gsize todo;
GstGnomeVFSSrc *src;
gboolean interrupted = FALSE;
src = GST_GNOME_VFS_SRC (basesrc);
GST_DEBUG ("now at %" G_GINT64_FORMAT ", reading from %" G_GUINT64_FORMAT
", size %u", src->curoffset, offset, size);
/* seek if required */
if (G_UNLIKELY (src->curoffset != offset)) {
GST_DEBUG ("need to seek");
if (src->seekable) {
GST_DEBUG ("seeking to %" G_GUINT64_FORMAT, offset);
res = gnome_vfs_seek (src->handle, GNOME_VFS_SEEK_START, offset);
if (res != GNOME_VFS_OK)
goto seek_failed;
src->curoffset = offset;
} else {
goto cannot_seek;
}
}
buf = gst_buffer_new_and_alloc (size);
if (G_UNLIKELY (buf == NULL)) {
GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", size);
return GST_FLOW_ERROR;
}
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
ptr = data;
todo = size;
while (!src->interrupted && todo > 0) {
/* this can return less that we ask for */
res =
gnome_vfs_read_cancellable (src->handle, data, todo, &readbytes,
src->context);
if (G_UNLIKELY (res == GNOME_VFS_ERROR_CANCELLED)) {
GST_DEBUG_OBJECT (src, "interrupted");
/* Just take what we've so far gotten and return */
size = size - todo;
todo = 0;
interrupted = TRUE;
break;
}
if (G_UNLIKELY (res == GNOME_VFS_ERROR_EOF || (res == GNOME_VFS_OK
&& readbytes == 0)))
goto eos;
if (G_UNLIKELY (res != GNOME_VFS_OK))
goto read_failed;
if (readbytes < todo) {
ptr += readbytes;
todo -= readbytes;
} else {
todo = 0;
}
GST_LOG (" got size %" G_GUINT64_FORMAT, readbytes);
}
gst_buffer_unmap (buf, data, size);
if (interrupted)
goto interrupted;
GST_BUFFER_OFFSET (buf) = src->curoffset;
src->curoffset += size;
/* we're done, return the buffer */
*buffer = buf;
return GST_FLOW_OK;
seek_failed:
{
GST_ELEMENT_ERROR (src, RESOURCE, SEEK, (NULL),
("Failed to seek to requested position %" G_GINT64_FORMAT ": %s",
offset, gnome_vfs_result_to_string (res)));
return GST_FLOW_ERROR;
}
cannot_seek:
{
GST_ELEMENT_ERROR (src, RESOURCE, SEEK, (NULL),
("Requested seek from %" G_GINT64_FORMAT " to %" G_GINT64_FORMAT
" on non-seekable stream", src->curoffset, offset));
return GST_FLOW_ERROR;
}
read_failed:
{
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Failed to read data: %s", gnome_vfs_result_to_string (res)));
return GST_FLOW_ERROR;
}
interrupted:
{
gst_buffer_unref (buf);
return GST_FLOW_WRONG_STATE;
}
eos:
{
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
GST_DEBUG_OBJECT (src, "Reading data gave EOS");
return GST_FLOW_UNEXPECTED;
}
}
static gboolean
gst_gnome_vfs_src_is_seekable (GstBaseSrc * basesrc)
{
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (basesrc);
return src->seekable;
}
static gboolean
gst_gnome_vfs_src_scheduling (GstBaseSrc * basesrc, GstQuery * query)
{
GstGnomeVFSSrc *src;
const gchar *protocol;
gboolean pull_mode;
src = GST_GNOME_VFS_SRC (basesrc);
pull_mode = FALSE;
if (src->uri == NULL) {
GST_WARNING_OBJECT (src, "no URI set yet");
goto undecided;
}
if (gnome_vfs_uri_is_local (src->uri)) {
GST_LOG_OBJECT (src, "local URI (%s), assuming random access is possible",
GST_STR_NULL (src->uri_name));
pull_mode = TRUE;
} else {
/* blacklist certain protocols we know won't work getrange-based */
protocol = gnome_vfs_uri_get_scheme (src->uri);
if (protocol == NULL)
goto undecided;
if (strcmp (protocol, "http") == 0 || strcmp (protocol, "https") == 0) {
GST_LOG_OBJECT (src,
"blacklisted protocol '%s', no random access possible" " (URI=%s)",
protocol, GST_STR_NULL (src->uri_name));
} else {
GST_LOG_OBJECT (src, "undecided about URI '%s', let base class handle it",
GST_STR_NULL (src->uri_name));
}
goto undecided;
}
gst_query_set_scheduling (query, pull_mode, pull_mode, FALSE, 1, -1, 1);
return TRUE;
/* fall through to undecided */
undecided:
{
/* don't know what to do, let the basesrc class decide for us */
return GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
}
}
static gboolean
gst_gnome_vfs_src_query (GstBaseSrc * basesrc, GstQuery * query)
{
gboolean ret = FALSE;
GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (basesrc);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_URI:
gst_query_set_uri (query, src->uri_name);
ret = TRUE;
break;
case GST_QUERY_SCHEDULING:
ret = gst_gnome_vfs_src_scheduling (basesrc, query);
break;
default:
ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
break;
}
return ret;
}
/* Interrupt a blocking request. */
static gboolean
gst_gnome_vfs_src_unlock (GstBaseSrc * basesrc)
{
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (basesrc);
GST_DEBUG_OBJECT (src, "unlock()");
src->interrupted = TRUE;
if (src->context) {
GnomeVFSCancellation *cancel =
gnome_vfs_context_get_cancellation (src->context);
if (cancel)
gnome_vfs_cancellation_cancel (cancel);
}
return TRUE;
}
/* Interrupt interrupt. */
static gboolean
gst_gnome_vfs_src_unlock_stop (GstBaseSrc * basesrc)
{
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (basesrc);
GST_DEBUG_OBJECT (src, "unlock_stop()");
src->interrupted = FALSE;
return TRUE;
}
static gboolean
gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size)
{
GstGnomeVFSSrc *src;
GnomeVFSFileInfo *info;
GnomeVFSFileInfoOptions options;
GnomeVFSResult res;
src = GST_GNOME_VFS_SRC (basesrc);
*size = -1;
info = gnome_vfs_file_info_new ();
options = GNOME_VFS_FILE_INFO_DEFAULT | GNOME_VFS_FILE_INFO_FOLLOW_LINKS;
res = gnome_vfs_get_file_info_from_handle (src->handle, info, options);
if (res == GNOME_VFS_OK) {
if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
*size = info->size;
GST_DEBUG_OBJECT (src, "from handle: %" G_GUINT64_FORMAT " bytes", *size);
} else if (src->own_handle && gnome_vfs_uri_is_local (src->uri)) {
GST_DEBUG_OBJECT (src,
"file size not known, file local, trying fallback");
res = gnome_vfs_get_file_info_uri (src->uri, info, options);
if (res == GNOME_VFS_OK &&
(info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
*size = info->size;
GST_DEBUG_OBJECT (src, "from uri: %" G_GUINT64_FORMAT " bytes", *size);
}
}
} else {
GST_WARNING_OBJECT (src, "getting info failed: %s",
gnome_vfs_result_to_string (res));
}
gnome_vfs_file_info_unref (info);
if (*size == (GnomeVFSFileSize) - 1)
return FALSE;
GST_DEBUG_OBJECT (src, "return size %" G_GUINT64_FORMAT, *size);
return TRUE;
}
/* open the file, do stuff necessary to go to PAUSED state */
static gboolean
gst_gnome_vfs_src_start (GstBaseSrc * basesrc)
{
GnomeVFSResult res;
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (basesrc);
gst_gnome_vfs_src_push_callbacks (src);
src->context = gnome_vfs_context_new ();
if (src->uri != NULL) {
GnomeVFSOpenMode mode = GNOME_VFS_OPEN_READ;
/* this can block... */
res = gnome_vfs_open_uri (&src->handle, src->uri, mode);
if (res != GNOME_VFS_OK)
goto open_failed;
src->own_handle = TRUE;
} else if (!src->handle) {
goto no_filename;
} else {
src->own_handle = FALSE;
}
if (gnome_vfs_seek (src->handle, GNOME_VFS_SEEK_CURRENT, 0) == GNOME_VFS_OK) {
src->seekable = TRUE;
} else {
src->seekable = FALSE;
}
return TRUE;
/* ERRORS */
open_failed:
{
gchar *filename = gnome_vfs_uri_to_string (src->uri,
GNOME_VFS_URI_HIDE_PASSWORD);
gst_gnome_vfs_src_pop_callbacks (src);
if (res == GNOME_VFS_ERROR_NOT_FOUND ||
res == GNOME_VFS_ERROR_HOST_NOT_FOUND ||
res == GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE) {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
("Could not open vfs file \"%s\" for reading: %s (%d)",
filename, gnome_vfs_result_to_string (res), res));
} else {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Could not open vfs file \"%s\" for reading: %s (%d)",
filename, gnome_vfs_result_to_string (res), res));
}
g_free (filename);
return FALSE;
}
no_filename:
{
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No filename given"));
return FALSE;
}
}
static gboolean
gst_gnome_vfs_src_stop (GstBaseSrc * basesrc)
{
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (basesrc);
gst_gnome_vfs_src_pop_callbacks (src);
if (src->own_handle) {
GnomeVFSResult res;
res = gnome_vfs_close (src->handle);
if (res != GNOME_VFS_OK) {
GST_ELEMENT_ERROR (src, RESOURCE, CLOSE, (NULL),
("Could not close vfs handle: %s", gnome_vfs_result_to_string (res)));
}
src->handle = NULL;
}
src->curoffset = 0;
src->interrupted = FALSE;
gnome_vfs_context_free (src->context);
src->context = NULL;
return TRUE;
}

View file

@ -1,89 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2001 Bastien Nocera <hadess@hadess.net>
* 2002 Kristian Rietveld <kris@gtk.org>
* 2002,2003 Colin Walters <walters@gnu.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_GNOME_VFS_SRC_H__
#define __GST_GNOME_VFS_SRC_H__
#include <gst/base/gstbasesrc.h>
#include "gstgnomevfs.h"
#include "gstgnomevfsuri.h"
#include <libgnomevfs/gnome-vfs.h>
G_BEGIN_DECLS
#define GST_TYPE_GNOME_VFS_SRC \
(gst_gnome_vfs_src_get_type())
#define GST_GNOME_VFS_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GNOME_VFS_SRC,GstGnomeVFSSrc))
#define GST_GNOME_VFS_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GNOME_VFS_SRC,GstGnomeVFSSrcClass))
#define GST_IS_GNOME_VFS_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GNOME_VFS_SRC))
#define GST_IS_GNOME_VFS_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GNOME_VFS_SRC))
typedef struct _GstGnomeVFSSrc GstGnomeVFSSrc;
typedef struct _GstGnomeVFSSrcClass GstGnomeVFSSrcClass;
/**
* GstGnomeVFSSrc:
*
* Opaque data structure.
*/
struct _GstGnomeVFSSrc
{
GstBaseSrc basesrc;
/* uri, file, ... */
GnomeVFSURI *uri;
gchar *uri_name;
GnomeVFSContext *context;
GnomeVFSHandle *handle;
gboolean own_handle;
gboolean interrupted;
GnomeVFSFileOffset curoffset; /* current offset in file */
gboolean seekable;
/* shoutcast/icecast metadata extraction handling */
gboolean iradio_mode;
gboolean http_callbacks_pushed;
gchar *iradio_name;
gchar *iradio_genre;
gchar *iradio_url;
gchar *iradio_title;
};
struct _GstGnomeVFSSrcClass
{
GstBaseSrcClass basesrc_class;
};
GType gst_gnome_vfs_src_get_type (void);
G_END_DECLS
#endif /* __GST_GNOME_VFS_SRC_H__ */

View file

@ -1,90 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2001 Bastien Nocera <hadess@hadess.net>
* 2003 Colin Walters <walters@verbum.org>
*
* gstgnomevfssink.c:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <libgnomevfs/gnome-vfs.h>
#include "gstgnomevfsuri.h"
#include <gst/gst.h>
/* FIXME: move this to source and sink and remove this file:
* e.g. sinks cannot save to http:// and src cannot read from burn://
*/
static gpointer
_internal_get_supported_uris (gpointer data)
{
/* no dav/davs in the list, because they don't appear to be reliable enough */
const gchar *uris[] = {
"http://localhost/bla",
"https://localhost/bla",
"file:///bla",
"smb://localhost/bla",
"ftp://localhost/bla",
"sftp://localhost/bla",
"nfs://localhost/bla",
"ssh://localhost/bla",
"burn://"
};
GnomeVFSURI *uri;
gchar **result;
gint n, r = 0;
result = g_new0 (gchar *, G_N_ELEMENTS (uris) + 1);
for (n = 0; n < G_N_ELEMENTS (uris); n++) {
uri = gnome_vfs_uri_new (uris[n]);
if (uri != NULL) {
gchar *protocol = g_strdup (uris[n]);
gint n;
gnome_vfs_uri_unref (uri);
for (n = 0; protocol[n] != '\0'; n++) {
if (protocol[n] == ':') {
protocol[n] = '\0';
break;
}
}
GST_DEBUG ("adding protocol '%s'", protocol);
result[r++] = protocol;
} else {
GST_DEBUG ("could not create GnomeVfsUri from '%s'", uris[n]);
}
}
result[r] = NULL;
return result;
}
gchar **
gst_gnomevfs_get_supported_uris (void)
{
static GOnce once = G_ONCE_INIT;
g_once (&once, _internal_get_supported_uris, NULL);
return (gchar **) once.retval;
}

View file

@ -1,32 +0,0 @@
/* GStreamer
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_GNOME_VFS_URI_H__
#define __GST_GNOME_VFS_URI_H__
#include <libgnomevfs/gnome-vfs.h>
G_BEGIN_DECLS
gchar **gst_gnomevfs_get_supported_uris (void);
G_END_DECLS
#endif /* __GST_GNOME_VFS_URI_H__ */

View file

@ -880,7 +880,7 @@ gst_pb_utils_get_encoder_description (const GstCaps * caps)
/**
* gst_pb_utils_get_element_description:
* @factory_name: the name of the element, e.g. "gnomevfssrc"
* @factory_name: the name of the element, e.g. "giosrc"
*
* Returns a localised string describing the given element, for use in
* error dialogs or other messages to be seen by the user. Should never

View file

@ -23,8 +23,6 @@ BuildRequires: gtk-doc >= 1.3
BuildRequires: orc-devel
Requires: orc
@USE_GNOME_VFS_TRUE@Requires: gnome-vfs2 > 1.9.4.00
@USE_GNOME_VFS_TRUE@BuildRequires: gnome-vfs2-devel > 1.9.4.00
@USE_VORBIS_TRUE@Requires: libogg >= 1.0
@USE_VORBIS_TRUE@Requires: libvorbis >= 1.0
@USE_VORBIS_TRUE@BuildRequires: libogg-devel >= 1.0
@ -128,7 +126,6 @@ rm -rf $RPM_BUILD_ROOT
# base plugins with dependencies
@USE_ALSA_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstalsa.so
@USE_THEORA_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgsttheora.so
@USE_GNOME_VFS_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstgnomevfs.so
@USE_VORBIS_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstvorbis.so
@USE_VORBIS_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstogg.so
@USE_XVIDEO_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstximage*.so

View file

@ -2,8 +2,6 @@ ext/alsa/gstalsamixertrack.c
ext/alsa/gstalsasink.c
ext/alsa/gstalsasrc.c
ext/cdparanoia/gstcdparanoiasrc.c
ext/gnomevfs/gstgnomevfssrc.c
ext/gnomevfs/gstgnomevfssink.c
ext/ogg/gstoggdemux.c
gst/playback/gstdecodebin.c
gst/playback/gstdecodebin2.c

View file

@ -34,12 +34,6 @@ else
check_alsa =
endif
if USE_GNOME_VFS
check_gnomevfs = elements/gnomevfssink
else
check_gnomevfs =
endif
if USE_GIO
check_gio = pipelines/gio
else
@ -107,7 +101,6 @@ endif
check_PROGRAMS = \
$(check_alsa) \
$(check_gnomevfs) \
$(check_gio) \
$(check_ogg) \
$(check_pango) \

View file

@ -11,7 +11,6 @@ decodebin
encodebin
gdpdepay
gdppay
gnomevfssink
libvisual
multifdsink
videorate

View file

@ -1,323 +0,0 @@
/* GStreamer unit test for the gnomevfssink element
*
* Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
* Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <glib.h>
#include <glib/gstdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for close() */
#endif
#include <gst/check/gstcheck.h>
static GstPad *mysrcpad;
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static GstElement *
setup_gnomevfssink (void)
{
GstElement *gnomevfssink;
GST_DEBUG ("setup_gnomevfssink");
gnomevfssink = gst_check_setup_element ("gnomevfssink");
mysrcpad = gst_check_setup_src_pad (gnomevfssink, &srctemplate, NULL);
gst_pad_set_active (mysrcpad, TRUE);
return gnomevfssink;
}
static void
cleanup_gnomevfssink (GstElement * gnomevfssink)
{
gst_pad_set_active (mysrcpad, FALSE);
gst_check_teardown_src_pad (gnomevfssink);
gst_check_teardown_element (gnomevfssink);
}
#if 0
/* this queries via the element vfunc, which is currently not implemented */
#define CHECK_QUERY_POSITION(gnomevfssink,format,position) \
G_STMT_START { \
GstFormat fmt = format; \
gint64 pos; \
fail_unless (gst_element_query_position (gnomevfssink, &fmt, &pos)); \
fail_unless_equals_int (pos, position); \
} G_STMT_END
#else
#define CHECK_QUERY_POSITION(gnomevfssink,format,position) \
G_STMT_START { \
GstFormat fmt = format; \
GstPad *pad; \
gint64 pos; \
pad = gst_element_get_static_pad (gnomevfssink, "sink"); \
fail_unless (gst_pad_query_position (pad, &fmt, &pos)); \
fail_unless_equals_int (pos, position); \
gst_object_unref (pad); \
} G_STMT_END
#endif
#define PUSH_BYTES(num_bytes) \
G_STMT_START { \
GstBuffer *buf = gst_buffer_new_and_alloc(num_bytes); \
GRand *rand = g_rand_new_with_seed (num_bytes); \
gsize i; \
guint8 *data; \
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); \
for (i = 0; i < num_bytes; ++i) \
data[i] = (g_rand_int (rand) >> 24) & 0xff; \
gst_buffer_unmap (buf, data, num_bytes); \
fail_unless_equals_int (gst_pad_push (mysrcpad, buf), GST_FLOW_OK); \
g_rand_free (rand); \
} G_STMT_END
/* TODO: we don't check that the data is actually written to the right
* position after a seek */
GST_START_TEST (test_seeking)
{
const gchar *tmpdir;
GstElement *gnomevfssink;
GstSegment segment;
gchar *tmp_fn;
gint fd;
tmpdir = g_get_tmp_dir ();
if (tmpdir == NULL)
return;
/* this is just silly, but gcc warns if we try to use tpmnam() */
tmp_fn =
g_build_filename (tmpdir, "gstreamer-gnomevfssink-test-XXXXXX", NULL);
fd = g_mkstemp (tmp_fn);
if (fd < 0) {
GST_ERROR ("can't create temp file %s: %s", tmp_fn, g_strerror (errno));
g_free (tmp_fn);
return;
}
/* don't want the file, just a filename (hence silly, see above) */
close (fd);
g_remove (tmp_fn);
gnomevfssink = setup_gnomevfssink ();
GST_LOG ("using temp file '%s'", tmp_fn);
g_object_set (gnomevfssink, "location", tmp_fn, NULL);
fail_unless_equals_int (gst_element_set_state (gnomevfssink,
GST_STATE_PLAYING), GST_STATE_CHANGE_ASYNC);
#if 0
/* Test that gnomevfssink is seekable with a file fd */
/* gnomevfssink doesn't implement seekable query at the moment */
GstQuery *seeking_query;
gboolean seekable;
fail_unless ((seeking_query = gst_query_new_seeking (GST_FORMAT_BYTES))
!= NULL);
fail_unless (gst_element_query (gnomevfssink, seeking_query) == TRUE);
gst_query_parse_seeking (seeking_query, NULL, &seekable, NULL, NULL);
fail_unless (seekable == TRUE);
gst_query_unref (seeking_query);
#endif
gst_segment_init (&segment, GST_FORMAT_BYTES);
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 0);
/* push buffer with size 0 and NULL data */
PUSH_BYTES (0);
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 0);
PUSH_BYTES (1);
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 1);
PUSH_BYTES (99);
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 100);
PUSH_BYTES (8800);
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 8900);
gst_segment_init (&segment, GST_FORMAT_BYTES);
segment.start = 8800;
if (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment))) {
GST_LOG ("seek ok");
/* make sure that that new position is reported immediately */
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 8800);
PUSH_BYTES (1);
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 8801);
PUSH_BYTES (9256);
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 18057);
} else {
GST_WARNING ("seeking not supported for tempfile?!");
}
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
fail_unless_equals_int (gst_element_set_state (gnomevfssink, GST_STATE_NULL),
GST_STATE_CHANGE_SUCCESS);
/* cleanup */
cleanup_gnomevfssink (gnomevfssink);
/* check that we wrote data to the right position after the seek */
{
gchar *data = NULL;
gsize len;
fail_unless (g_file_get_contents (tmp_fn, &data, &len, NULL),
"Failed to read in newly-created file '%s'", tmp_fn);
fail_unless_equals_int (len, 18057);
{
/* we wrote 9256 bytes at position 8801 */
GRand *rand = g_rand_new_with_seed (9256);
guint i;
for (i = 0; i < 9256; ++i) {
guint8 byte_written = *(((guint8 *) data) + 8801 + i);
fail_unless_equals_int (byte_written, g_rand_int (rand) >> 24);
}
g_rand_free (rand);
}
g_free (data);
}
/* remove file */
g_remove (tmp_fn);
g_free (tmp_fn);
}
GST_END_TEST;
GST_START_TEST (test_coverage)
{
GstElement *gnomevfssink;
gchar *location;
GstBus *bus;
GstMessage *message;
gnomevfssink = setup_gnomevfssink ();
bus = gst_bus_new ();
gst_element_set_bus (gnomevfssink, bus);
g_object_set (gnomevfssink, "location", "/i/do/not/exist", NULL);
g_object_get (gnomevfssink, "location", &location, NULL);
fail_unless_equals_string (location, "/i/do/not/exist");
g_free (location);
fail_unless_equals_int (gst_element_set_state (gnomevfssink,
GST_STATE_PLAYING), GST_STATE_CHANGE_FAILURE);
/* a state change and an error */
fail_if ((message = gst_bus_pop (bus)) == NULL);
fail_unless_message_error (message, RESOURCE, OPEN_WRITE);
gst_message_unref (message);
g_object_set (gnomevfssink, "location", NULL, NULL);
g_object_get (gnomevfssink, "location", &location, NULL);
fail_if (location);
/* cleanup */
gst_element_set_bus (gnomevfssink, NULL);
gst_object_unref (GST_OBJECT (bus));
cleanup_gnomevfssink (gnomevfssink);
}
GST_END_TEST;
GST_START_TEST (test_uri_interface)
{
GstElement *gnomevfssink;
gchar *location;
GstBus *bus;
gnomevfssink = setup_gnomevfssink ();
bus = gst_bus_new ();
gst_element_set_bus (gnomevfssink, bus);
g_object_set (G_OBJECT (gnomevfssink), "location", "/i/do/not/exist", NULL);
g_object_get (G_OBJECT (gnomevfssink), "location", &location, NULL);
fail_unless_equals_string (location, "/i/do/not/exist");
g_free (location);
location = (gchar *) gst_uri_handler_get_uri (GST_URI_HANDLER (gnomevfssink));
fail_unless_equals_string (location, "file://%2Fi%2Fdo%2Fnot%2Fexist");
/* should accept file:///foo/bar URIs */
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (gnomevfssink),
"file:///foo/bar"));
location = (gchar *) gst_uri_handler_get_uri (GST_URI_HANDLER (gnomevfssink));
fail_unless_equals_string (location, "file://%2Ffoo%2Fbar");
g_object_get (G_OBJECT (gnomevfssink), "location", &location, NULL);
fail_unless_equals_string (location, "/foo/bar");
g_free (location);
/* should accept file://localhost/foo/bar URIs */
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (gnomevfssink),
"file://localhost/foo/baz"));
location = (gchar *) gst_uri_handler_get_uri (GST_URI_HANDLER (gnomevfssink));
fail_unless_equals_string (location, "file://%2Ffoo%2Fbaz");
g_object_get (G_OBJECT (gnomevfssink), "location", &location, NULL);
fail_unless_equals_string (location, "/foo/baz");
g_free (location);
/* should fail with other hostnames */
fail_if (gst_uri_handler_set_uri (GST_URI_HANDLER (gnomevfssink),
"file://hostname/foo/foo"));
/* cleanup */
gst_element_set_bus (gnomevfssink, NULL);
gst_object_unref (GST_OBJECT (bus));
cleanup_gnomevfssink (gnomevfssink);
}
GST_END_TEST;
static Suite *
gnomevfssink_suite (void)
{
Suite *s = suite_create ("gnomevfssink");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
/* FIXME: these two tests fail right now because of uri/location stuff */
if (0) {
tcase_add_test (tc_chain, test_coverage);
tcase_add_test (tc_chain, test_uri_interface);
}
tcase_add_test (tc_chain, test_seeking);
return s;
}
GST_CHECK_MAIN (gnomevfssink);

View file

@ -66,9 +66,7 @@ gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
#endif
/* configuration */
//#define SOURCE "filesrc"
#define SOURCE "gnomevfssrc"
#define SOURCE "filesrc"
#define ASINK "alsasink"
//#define ASINK "osssink"

View file

@ -21,8 +21,7 @@ static guint update_id = 0;
static guint changed_id = 0;
static guint schanged_id = 0;
//#define SOURCE "filesrc"
#define SOURCE "gnomevfssrc"
#define SOURCE "filesrc"
#define ASINK "alsasink"
//#define ASINK "osssink"
#define VSINK "xvimagesink"

View file

@ -129,7 +129,7 @@ main (gint argc, gchar * argv[])
g_signal_connect (bus, "message::state-changed", G_CALLBACK (state_cb),
pipeline);
source = gst_element_factory_make ("gnomevfssrc", "source");
source = gst_element_factory_make ("giosrc", "source");
g_assert (source);
if (argv[1] && strstr (argv[1], "://") != NULL) {