2001-12-23 16:42:33 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
* 2001 Bastien Nocera <hadess@hadess.net>
|
2003-12-23 21:28:35 +00:00
|
|
|
* 2003 Colin Walters <walters@verbum.org>
|
2001-12-23 16:42:33 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-10-31 20:03:29 +00:00
|
|
|
|
2004-01-19 13:50:39 +00:00
|
|
|
#include "gst/gst-i18n-plugin.h"
|
2004-01-18 21:46:58 +00:00
|
|
|
|
2003-10-31 20:03:29 +00:00
|
|
|
#include "gstgnomevfs.h"
|
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <libgnomevfs/gnome-vfs.h>
|
2001-12-26 23:56:00 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define GST_TYPE_GNOMEVFSSINK \
|
|
|
|
(gst_gnomevfssink_get_type())
|
|
|
|
#define GST_GNOMEVFSSINK(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GNOMEVFSSINK,GstGnomeVFSSink))
|
|
|
|
#define GST_GNOMEVFSSINK_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GNOMEVFSSINK,GstGnomeVFSSinkClass))
|
|
|
|
#define GST_IS_GNOMEVFSSINK(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GNOMEVFSSINK))
|
|
|
|
#define GST_IS_GNOMEVFSSINK_CLASS(obj) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GNOMEVFSSINK))
|
|
|
|
|
|
|
|
typedef struct _GstGnomeVFSSink GstGnomeVFSSink;
|
|
|
|
typedef struct _GstGnomeVFSSinkClass GstGnomeVFSSinkClass;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_GNOMEVFSSINK_OPEN = GST_ELEMENT_FLAG_LAST,
|
2001-12-23 16:42:33 +00:00
|
|
|
|
2004-05-21 23:28:57 +00:00
|
|
|
GST_GNOMEVFSSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
|
2004-03-15 19:32:28 +00:00
|
|
|
}
|
|
|
|
GstGnomeVFSSinkFlags;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
struct _GstGnomeVFSSink
|
|
|
|
{
|
2001-12-23 16:42:33 +00:00
|
|
|
GstElement element;
|
|
|
|
|
|
|
|
/* uri */
|
|
|
|
GnomeVFSURI *uri;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
/* handle */
|
|
|
|
GnomeVFSHandle *handle;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
|
|
|
|
/* whether we opened the handle ourselves */
|
|
|
|
gboolean own_handle;
|
2001-12-23 16:42:33 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
struct _GstGnomeVFSSinkClass
|
|
|
|
{
|
2001-12-23 16:42:33 +00:00
|
|
|
GstElementClass parent_class;
|
|
|
|
|
|
|
|
/* signals */
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
gboolean (*erase_ask) (GstElement * element, GnomeVFSURI * uri);
|
2001-12-23 16:42:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* GnomeVFSSink signals and args */
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 16:42:33 +00:00
|
|
|
/* FILL ME */
|
|
|
|
SIGNAL_ERASE_ASK,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 16:42:33 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_LOCATION,
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
ARG_URI,
|
|
|
|
ARG_HANDLE
|
2001-12-23 16:42:33 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_gnomevfssink_base_init (gpointer g_class);
|
|
|
|
static void gst_gnomevfssink_class_init (GstGnomeVFSSinkClass * klass);
|
|
|
|
static void gst_gnomevfssink_init (GstGnomeVFSSink * gnomevfssink);
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
static void gst_gnomevfssink_dispose (GObject * obj);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_gnomevfssink_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_gnomevfssink_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static gboolean gst_gnomevfssink_open_file (GstGnomeVFSSink * sink);
|
|
|
|
static void gst_gnomevfssink_close_file (GstGnomeVFSSink * sink);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_gnomevfssink_chain (GstPad * pad, GstData * _data);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstElementStateReturn gst_gnomevfssink_change_state (GstElement *
|
|
|
|
element);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
static guint gst_gnomevfssink_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_gnomevfssink_get_type (void)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
static GType gnomevfssink_type = 0;
|
|
|
|
|
|
|
|
if (!gnomevfssink_type) {
|
|
|
|
static const GTypeInfo gnomevfssink_info = {
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstGnomeVFSSinkClass),
|
2003-10-31 20:03:29 +00:00
|
|
|
gst_gnomevfssink_base_init,
|
2001-12-23 16:42:33 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GClassInitFunc) gst_gnomevfssink_class_init,
|
2001-12-23 16:42:33 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstGnomeVFSSink),
|
2001-12-23 16:42:33 +00:00
|
|
|
0,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GInstanceInitFunc) gst_gnomevfssink_init,
|
2001-12-23 16:42:33 +00:00
|
|
|
};
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gnomevfssink_type =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstGnomeVFSSink",
|
|
|
|
&gnomevfssink_info, 0);
|
2001-12-23 16:42:33 +00:00
|
|
|
}
|
|
|
|
return gnomevfssink_type;
|
|
|
|
}
|
|
|
|
|
2003-10-31 20:03:29 +00:00
|
|
|
static void
|
|
|
|
gst_gnomevfssink_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
static GstElementDetails gst_gnomevfssink_details =
|
|
|
|
GST_ELEMENT_DETAILS ("GnomeVFS Sink",
|
|
|
|
"Sink/File",
|
|
|
|
"Write stream to a GnomeVFS URI",
|
|
|
|
"Bastien Nocera <hadess@hadess.net>");
|
2003-10-31 20:03:29 +00:00
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &gst_gnomevfssink_details);
|
|
|
|
}
|
|
|
|
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
static gboolean
|
2004-04-09 18:55:10 +00:00
|
|
|
_gst_boolean_allow_overwrite_accumulator (GSignalInvocationHint * ihint,
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
GValue * return_accu, const GValue * handler_return, gpointer dummy)
|
|
|
|
{
|
2004-04-09 18:55:10 +00:00
|
|
|
gboolean allow_overwrite;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
|
2004-04-09 18:55:10 +00:00
|
|
|
allow_overwrite = g_value_get_boolean (handler_return);
|
2004-05-09 16:48:42 +00:00
|
|
|
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
|
|
|
|
g_value_set_boolean (return_accu, allow_overwrite);
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
|
2004-04-09 18:55:10 +00:00
|
|
|
/* stop emission if signal doesn't allow overwriting */
|
|
|
|
return allow_overwrite;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_gnomevfssink_class_init (GstGnomeVFSSinkClass * klass)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
|
|
|
|
"location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_URI,
|
|
|
|
g_param_spec_pointer ("uri", "GnomeVFSURI", "URI for GnomeVFS",
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (gobject_class, ARG_HANDLE,
|
2004-03-14 22:34:34 +00:00
|
|
|
g_param_spec_pointer ("handle",
|
2004-03-15 19:32:28 +00:00
|
|
|
"GnomeVFSHandle", "Handle for GnomeVFS", G_PARAM_READWRITE));
|
2003-12-23 21:28:35 +00:00
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
gst_gnomevfssink_signals[SIGNAL_ERASE_ASK] =
|
2004-04-09 18:55:10 +00:00
|
|
|
g_signal_new ("allow-overwrite", G_TYPE_FROM_CLASS (klass),
|
2004-05-09 16:48:42 +00:00
|
|
|
G_SIGNAL_RUN_CLEANUP, G_STRUCT_OFFSET (GstGnomeVFSSinkClass, erase_ask),
|
2004-04-09 18:55:10 +00:00
|
|
|
_gst_boolean_allow_overwrite_accumulator, NULL,
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_gnomevfssink_set_property;
|
|
|
|
gobject_class->get_property = gst_gnomevfssink_get_property;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
gobject_class->dispose = gst_gnomevfssink_dispose;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = gst_gnomevfssink_change_state;
|
|
|
|
|
|
|
|
/* gnome vfs engine init */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (gnome_vfs_initialized () == FALSE)
|
|
|
|
gnome_vfs_init ();
|
2001-12-23 16:42:33 +00:00
|
|
|
}
|
|
|
|
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
static void
|
|
|
|
gst_gnomevfssink_dispose (GObject * obj)
|
|
|
|
{
|
|
|
|
GstGnomeVFSSink *sink = GST_GNOMEVFSSINK (obj);
|
|
|
|
|
|
|
|
if (sink->uri) {
|
|
|
|
gnome_vfs_uri_unref (sink->uri);
|
|
|
|
sink->uri = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void
|
|
|
|
gst_gnomevfssink_init (GstGnomeVFSSink * gnomevfssink)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
GstPad *pad;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
pad = gst_pad_new ("sink", GST_PAD_SINK);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (gnomevfssink), pad);
|
|
|
|
gst_pad_set_chain_function (pad, gst_gnomevfssink_chain);
|
|
|
|
|
|
|
|
gnomevfssink->uri = NULL;
|
|
|
|
gnomevfssink->handle = NULL;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
gnomevfssink->own_handle = FALSE;
|
2001-12-23 16:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_gnomevfssink_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
GstGnomeVFSSink *sink;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
|
|
|
sink = GST_GNOMEVFSSINK (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_LOCATION:
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
if (sink->uri) {
|
|
|
|
gnome_vfs_uri_unref (sink->uri);
|
|
|
|
sink->uri = NULL;
|
|
|
|
}
|
|
|
|
if (g_value_get_string (value)) {
|
|
|
|
sink->uri = gnome_vfs_uri_new (g_value_get_string (value));
|
|
|
|
}
|
2003-12-23 21:28:35 +00:00
|
|
|
break;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
case ARG_URI:
|
|
|
|
if (sink->uri) {
|
|
|
|
gnome_vfs_uri_unref (sink->uri);
|
|
|
|
sink->uri = NULL;
|
|
|
|
}
|
|
|
|
if (g_value_get_pointer (value)) {
|
|
|
|
sink->uri = gnome_vfs_uri_ref (g_value_get_pointer (value));
|
|
|
|
}
|
2001-12-23 16:42:33 +00:00
|
|
|
break;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
case ARG_HANDLE:
|
|
|
|
if (GST_STATE (sink) == GST_STATE_NULL ||
|
|
|
|
GST_STATE (sink) == GST_STATE_READY) {
|
|
|
|
sink->handle = g_value_get_pointer (value);
|
|
|
|
}
|
2001-12-23 16:42:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void
|
|
|
|
gst_gnomevfssink_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
GstGnomeVFSSink *sink;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
/* it's not null if we got it, but it might not be ours */
|
|
|
|
g_return_if_fail (GST_IS_GNOMEVFSSINK (object));
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
sink = GST_GNOMEVFSSINK (object);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_LOCATION:
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
if (sink->uri) {
|
|
|
|
gchar *filename = gnome_vfs_uri_to_string (sink->uri,
|
|
|
|
GNOME_VFS_URI_HIDE_PASSWORD);
|
|
|
|
|
|
|
|
g_value_set_string (value, filename);
|
|
|
|
g_free (filename);
|
|
|
|
} else {
|
|
|
|
g_value_set_string (value, NULL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ARG_URI:
|
|
|
|
g_value_set_pointer (value, sink->uri);
|
2001-12-23 16:42:33 +00:00
|
|
|
break;
|
2003-12-23 21:28:35 +00:00
|
|
|
case ARG_HANDLE:
|
|
|
|
g_value_set_pointer (value, sink->handle);
|
|
|
|
break;
|
2001-12-23 16:42:33 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_gnomevfssink_open_file (GstGnomeVFSSink * sink)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
GnomeVFSResult result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (!GST_FLAG_IS_SET (sink, GST_GNOMEVFSSINK_OPEN), FALSE);
|
|
|
|
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
if (sink->uri) {
|
2003-12-23 21:28:35 +00:00
|
|
|
/* open the file */
|
2004-03-14 22:34:34 +00:00
|
|
|
result = gnome_vfs_create_uri (&(sink->handle), sink->uri,
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
GNOME_VFS_OPEN_WRITE, TRUE,
|
2004-03-15 19:32:28 +00:00
|
|
|
GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE
|
|
|
|
| GNOME_VFS_PERM_GROUP_READ);
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
/* 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_gnomevfssink_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);
|
|
|
|
}
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG ("open: %s", gnome_vfs_result_to_string (result));
|
2003-12-23 21:28:35 +00:00
|
|
|
if (result != GNOME_VFS_OK) {
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
gchar *filename = gnome_vfs_uri_to_string (sink->uri,
|
|
|
|
GNOME_VFS_URI_HIDE_PASSWORD);
|
|
|
|
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
|
2004-05-09 16:48:42 +00:00
|
|
|
(_("Could not open vfs file \"%s\" for writing: %s."),
|
|
|
|
filename, gnome_vfs_result_to_string (result)), GST_ERROR_SYSTEM);
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
g_free (filename);
|
2003-12-23 21:28:35 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:34 +00:00
|
|
|
}
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
sink->own_handle = TRUE;
|
|
|
|
} else if (!sink->handle) {
|
2004-04-16 17:01:15 +00:00
|
|
|
GST_ELEMENT_ERROR (sink, RESOURCE, FAILED, (_("No filename given")),
|
|
|
|
(NULL));
|
2004-04-10 13:07:31 +00:00
|
|
|
return FALSE;
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
}
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
GST_FLAG_SET (sink, GST_GNOMEVFSSINK_OPEN);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_gnomevfssink_close_file (GstGnomeVFSSink * sink)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
GnomeVFSResult result;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_FLAG_IS_SET (sink, GST_GNOMEVFSSINK_OPEN));
|
|
|
|
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
if (sink->own_handle) {
|
2003-12-23 21:28:35 +00:00
|
|
|
/* close the file */
|
2004-03-14 22:34:34 +00:00
|
|
|
result = gnome_vfs_close (sink->handle);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
if (result != GNOME_VFS_OK) {
|
|
|
|
gchar *filename = gnome_vfs_uri_to_string (sink->uri,
|
|
|
|
GNOME_VFS_URI_HIDE_PASSWORD);
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
(_("Could not close vfs file \"%s\"."), filename), GST_ERROR_SYSTEM);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
sink->own_handle = FALSE;
|
2001-12-23 16:42:33 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2003-12-23 21:28:35 +00:00
|
|
|
GST_FLAG_UNSET (sink, GST_GNOMEVFSSINK_OPEN);
|
2001-12-23 16:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_gnomevfssink_chain:
|
|
|
|
* @pad: the pad this gnomevfssink is connected to
|
|
|
|
* @buf: the buffer that has to be absorbed
|
|
|
|
*
|
|
|
|
* take the buffer from the pad and write to file if it's open
|
|
|
|
*/
|
2004-03-14 22:34:34 +00:00
|
|
|
static void
|
|
|
|
gst_gnomevfssink_chain (GstPad * pad, GstData * _data)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
2003-10-08 16:08:22 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2001-12-23 16:42:33 +00:00
|
|
|
GstGnomeVFSSink *sink;
|
|
|
|
GnomeVFSResult result;
|
|
|
|
GnomeVFSFileSize bytes_written;
|
|
|
|
|
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
|
|
|
|
|
|
|
sink = GST_GNOMEVFSSINK (gst_pad_get_parent (pad));
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (GST_FLAG_IS_SET (sink, GST_GNOMEVFSSINK_OPEN)) {
|
|
|
|
result =
|
2004-03-15 19:32:28 +00:00
|
|
|
gnome_vfs_write (sink->handle, GST_BUFFER_DATA (buf),
|
|
|
|
GST_BUFFER_SIZE (buf), &bytes_written);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG ("write: %s, written_bytes: %" G_GUINT64_FORMAT,
|
2004-03-15 19:32:28 +00:00
|
|
|
gnome_vfs_result_to_string (result), bytes_written);
|
2004-03-14 22:34:34 +00:00
|
|
|
if (bytes_written < GST_BUFFER_SIZE (buf)) {
|
|
|
|
printf ("gnomevfssink : Warning : %d bytes should be written, only %"
|
2004-03-15 19:32:28 +00:00
|
|
|
G_GUINT64_FORMAT " bytes written\n", GST_BUFFER_SIZE (buf),
|
|
|
|
bytes_written);
|
2001-12-23 16:42:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_gnomevfssink_change_state (GstElement * element)
|
2001-12-23 16:42:33 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_GNOMEVFSSINK (element), GST_STATE_FAILURE);
|
|
|
|
|
ext/gnomevfs/gstgnomevfssink.c: Fix erase signal. Don't erase by default. Remove handoff signal.
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_base_init),
(_gst_boolean_did_something_accumulator),
(gst_gnomevfssink_class_init), (gst_gnomevfssink_dispose),
(gst_gnomevfssink_init), (gst_gnomevfssink_set_property),
(gst_gnomevfssink_get_property), (gst_gnomevfssink_open_file),
(gst_gnomevfssink_close_file), (gst_gnomevfssink_chain),
(gst_gnomevfssink_change_state):
Fix erase signal. Don't erase by default. Remove handoff signal.
Remove erase property. Don't segfault. General cleanup.
2004-04-07 01:41:58 +00:00
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
|
|
|
if (!GST_FLAG_IS_SET (element, GST_GNOMEVFSSINK_OPEN)) {
|
|
|
|
if (!gst_gnomevfssink_open_file (GST_GNOMEVFSSINK (element)))
|
|
|
|
return GST_STATE_FAILURE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
if (GST_FLAG_IS_SET (element, GST_GNOMEVFSSINK_OPEN))
|
|
|
|
gst_gnomevfssink_close_file (GST_GNOMEVFSSINK (element));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-12-23 16:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|