summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Glayal <spglegle@yahoo.fr>2009-08-18 08:45:08 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-08-18 08:45:08 +0200
commitabafed991ed1aa33796a451ae26e64751c098c1e (patch)
tree2b6cea40af7cd49f5a8dd6a7024bd374016dd67a
parent95f555379a3676ca212e6f511a6525614e8729dc (diff)
filesink: Add property to allow to append to an already existing file
Fixes bug #591441.
-rw-r--r--plugins/elements/gstfilesink.c26
-rw-r--r--plugins/elements/gstfilesink.h2
2 files changed, 27 insertions, 1 deletions
diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c
index d1a376023b..26fa1ea910 100644
--- a/plugins/elements/gstfilesink.c
+++ b/plugins/elements/gstfilesink.c
@@ -90,6 +90,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_file_sink_debug);
#define DEFAULT_LOCATION NULL
#define DEFAULT_BUFFER_MODE -1
#define DEFAULT_BUFFER_SIZE 64 * 1024
+#define DEFAULT_APPEND FALSE
enum
{
@@ -97,6 +98,7 @@ enum
PROP_LOCATION,
PROP_BUFFER_MODE,
PROP_BUFFER_SIZE,
+ PROP_APPEND,
PROP_LAST
};
@@ -185,6 +187,18 @@ gst_file_sink_class_init (GstFileSinkClass * klass)
G_MAXUINT, DEFAULT_BUFFER_SIZE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ * GstFileSink:append
+ *
+ * Append to an already existing file.
+ *
+ * Since: 0.10.25
+ */
+ g_object_class_install_property (gobject_class, PROP_APPEND,
+ g_param_spec_boolean ("append", "Append",
+ "Append to an already existing file", DEFAULT_APPEND,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gstbasesink_class->get_times = NULL;
gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_file_sink_start);
gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_file_sink_stop);
@@ -211,6 +225,7 @@ gst_file_sink_init (GstFileSink * filesink, GstFileSinkClass * g_class)
filesink->buffer_mode = DEFAULT_BUFFER_MODE;
filesink->buffer_size = DEFAULT_BUFFER_SIZE;
filesink->buffer = NULL;
+ filesink->append = FALSE;
gst_base_sink_set_sync (GST_BASE_SINK (filesink), FALSE);
}
@@ -276,6 +291,9 @@ gst_file_sink_set_property (GObject * object, guint prop_id,
case PROP_BUFFER_SIZE:
sink->buffer_size = g_value_get_uint (value);
break;
+ case PROP_APPEND:
+ sink->append = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -298,6 +316,9 @@ gst_file_sink_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_BUFFER_SIZE:
g_value_set_uint (value, sink->buffer_size);
break;
+ case PROP_APPEND:
+ g_value_set_boolean (value, sink->append);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -316,7 +337,10 @@ gst_file_sink_open_file (GstFileSink * sink)
/* FIXME, can we use g_fopen here? some people say that the FILE object is
* local to the .so that performed the fopen call, which would not be us when
* we use g_fopen. */
- sink->file = fopen (sink->filename, "wb");
+ if (sink->append)
+ sink->file = fopen (sink->filename, "ab");
+ else
+ sink->file = fopen (sink->filename, "wb");
if (sink->file == NULL)
goto open_failed;
diff --git a/plugins/elements/gstfilesink.h b/plugins/elements/gstfilesink.h
index 36b0e1967b..5bc934dc5b 100644
--- a/plugins/elements/gstfilesink.h
+++ b/plugins/elements/gstfilesink.h
@@ -62,6 +62,8 @@ struct _GstFileSink {
gint buffer_mode;
guint buffer_size;
gchar *buffer;
+
+ gboolean append;
};
struct _GstFileSinkClass {