mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
filesink: Add property to allow to append to an already existing file
Fixes bug #591441.
This commit is contained in:
parent
95f555379a
commit
abafed991e
2 changed files with 27 additions and 1 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ struct _GstFileSink {
|
|||
gint buffer_mode;
|
||||
guint buffer_size;
|
||||
gchar *buffer;
|
||||
|
||||
gboolean append;
|
||||
};
|
||||
|
||||
struct _GstFileSinkClass {
|
||||
|
|
Loading…
Reference in a new issue