mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
gst/elements/gstfilesink.c (gst_file_sink_start)
Original commit message from CVS: 2005-11-09 Andy Wingo <wingo@pobox.com> * gst/elements/gstfilesink.c (gst_file_sink_start) (gst_file_sink_stop): New functions, replace the state change handler. (gst_file_sink_class_init): Hook up the start and stop functions. (gst_file_sink_base_init): Don't set the state change handler any more. It was a bit ugly too, being set from here... (gst_file_sink_get_property, gst_file_sink_set_property): Cleanups... (gst_file_sink_set_location): More robust check that doesn't call GST_STATE. Ugggggg.
This commit is contained in:
parent
a80ccecd5b
commit
2d000e0460
3 changed files with 53 additions and 122 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2005-11-09 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
|
* gst/elements/gstfilesink.c (gst_file_sink_start)
|
||||||
|
(gst_file_sink_stop): New functions, replace the state change
|
||||||
|
handler.
|
||||||
|
(gst_file_sink_class_init): Hook up the start and stop functions.
|
||||||
|
(gst_file_sink_base_init): Don't set the state change handler any
|
||||||
|
more. It was a bit ugly too, being set from here...
|
||||||
|
(gst_file_sink_get_property, gst_file_sink_set_property):
|
||||||
|
Cleanups...
|
||||||
|
(gst_file_sink_set_location): More robust check that doesn't call
|
||||||
|
GST_STATE. Ugggggg.
|
||||||
|
|
||||||
2005-11-08 Tim-Philipp Müller <tim at centricular dot net>
|
2005-11-08 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst/base/gstbasetransform.c: (gst_base_transform_event):
|
* gst/base/gstbasetransform.c: (gst_base_transform_event):
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* @short_description: write stream to a file
|
* @short_description: write stream to a file
|
||||||
* @see_also: #GstFileSrc
|
* @see_also: #GstFileSrc
|
||||||
*
|
*
|
||||||
* Wrtite incomming data to a file in the local file system.
|
* Write incoming data to a file in the local file system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -58,15 +58,6 @@ GST_ELEMENT_DETAILS ("File Sink",
|
||||||
"Write stream to a file",
|
"Write stream to a file",
|
||||||
"Thomas <thomas@apestaart.org>");
|
"Thomas <thomas@apestaart.org>");
|
||||||
|
|
||||||
|
|
||||||
/* FileSink signals and args */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* FILL ME */
|
|
||||||
SIGNAL_HANDOFF,
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0,
|
ARG_0,
|
||||||
|
@ -83,6 +74,8 @@ static void gst_file_sink_get_property (GObject * object, guint prop_id,
|
||||||
static gboolean gst_file_sink_open_file (GstFileSink * sink);
|
static gboolean gst_file_sink_open_file (GstFileSink * sink);
|
||||||
static void gst_file_sink_close_file (GstFileSink * sink);
|
static void gst_file_sink_close_file (GstFileSink * sink);
|
||||||
|
|
||||||
|
static gboolean gst_file_sink_start (GstBaseSink * sink);
|
||||||
|
static gboolean gst_file_sink_stop (GstBaseSink * sink);
|
||||||
static gboolean gst_file_sink_event (GstBaseSink * sink, GstEvent * event);
|
static gboolean gst_file_sink_event (GstBaseSink * sink, GstEvent * event);
|
||||||
static GstFlowReturn gst_file_sink_render (GstBaseSink * sink,
|
static GstFlowReturn gst_file_sink_render (GstBaseSink * sink,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
|
@ -92,10 +85,6 @@ static gboolean gst_file_sink_query (GstPad * pad, GstQuery * query);
|
||||||
static void gst_file_sink_uri_handler_init (gpointer g_iface,
|
static void gst_file_sink_uri_handler_init (gpointer g_iface,
|
||||||
gpointer iface_data);
|
gpointer iface_data);
|
||||||
|
|
||||||
static GstStateChangeReturn gst_file_sink_change_state (GstElement * element,
|
|
||||||
GstStateChange transition);
|
|
||||||
|
|
||||||
//static guint gst_file_sink_signals[LAST_SIGNAL] = { 0 };
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_do_init (GType filesink_type)
|
_do_init (GType filesink_type)
|
||||||
|
@ -120,7 +109,6 @@ gst_file_sink_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
||||||
|
|
||||||
gstelement_class->change_state = gst_file_sink_change_state;
|
|
||||||
gst_element_class_add_pad_template (gstelement_class,
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
gst_static_pad_template_get (&sinktemplate));
|
gst_static_pad_template_get (&sinktemplate));
|
||||||
gst_element_class_set_details (gstelement_class, &gst_file_sink_details);
|
gst_element_class_set_details (gstelement_class, &gst_file_sink_details);
|
||||||
|
@ -142,6 +130,8 @@ gst_file_sink_class_init (GstFileSinkClass * klass)
|
||||||
gobject_class->dispose = gst_file_sink_dispose;
|
gobject_class->dispose = gst_file_sink_dispose;
|
||||||
|
|
||||||
gstbasesink_class->get_times = NULL;
|
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);
|
||||||
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
|
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
|
||||||
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
|
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
|
||||||
|
|
||||||
|
@ -181,9 +171,11 @@ gst_file_sink_dispose (GObject * object)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_file_sink_set_location (GstFileSink * sink, const gchar * location)
|
gst_file_sink_set_location (GstFileSink * sink, const gchar * location)
|
||||||
{
|
{
|
||||||
/* the element must be stopped or paused in order to do this */
|
if (sink->file) {
|
||||||
if (GST_STATE (sink) >= GST_STATE_PAUSED)
|
g_warning ("Changing the `location' property on filesink when "
|
||||||
|
"a file is open not supported.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
g_free (sink->filename);
|
g_free (sink->filename);
|
||||||
g_free (sink->uri);
|
g_free (sink->uri);
|
||||||
|
@ -201,9 +193,7 @@ static void
|
||||||
gst_file_sink_set_property (GObject * object, guint prop_id,
|
gst_file_sink_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstFileSink *sink;
|
GstFileSink *sink = GST_FILE_SINK (object);
|
||||||
|
|
||||||
sink = GST_FILE_SINK (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_LOCATION:
|
case ARG_LOCATION:
|
||||||
|
@ -219,11 +209,7 @@ static void
|
||||||
gst_file_sink_get_property (GObject * object, guint prop_id, GValue * value,
|
gst_file_sink_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
GParamSpec * pspec)
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstFileSink *sink;
|
GstFileSink *sink = GST_FILE_SINK (object);
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_FILE_SINK (object));
|
|
||||||
|
|
||||||
sink = GST_FILE_SINK (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_LOCATION:
|
case ARG_LOCATION:
|
||||||
|
@ -442,44 +428,17 @@ handle_error:
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static gboolean
|
||||||
gst_file_sink_change_state (GstElement * element, GstStateChange transition)
|
gst_file_sink_start (GstBaseSink * basesink)
|
||||||
{
|
{
|
||||||
GstStateChangeReturn ret;
|
return gst_file_sink_open_file (GST_FILE_SINK (basesink));
|
||||||
|
}
|
||||||
|
|
||||||
switch (transition) {
|
static gboolean
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
gst_file_sink_stop (GstBaseSink * basesink)
|
||||||
break;
|
{
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
gst_file_sink_close_file (GST_FILE_SINK (basesink));
|
||||||
if (!gst_file_sink_open_file (GST_FILE_SINK (element)))
|
return TRUE;
|
||||||
goto open_error;
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
||||||
gst_file_sink_close_file (GST_FILE_SINK (element));
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
open_error:
|
|
||||||
{
|
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** GSTURIHANDLER INTERFACE *************************************************/
|
/*** GSTURIHANDLER INTERFACE *************************************************/
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* @short_description: write stream to a file
|
* @short_description: write stream to a file
|
||||||
* @see_also: #GstFileSrc
|
* @see_also: #GstFileSrc
|
||||||
*
|
*
|
||||||
* Wrtite incomming data to a file in the local file system.
|
* Write incoming data to a file in the local file system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -58,15 +58,6 @@ GST_ELEMENT_DETAILS ("File Sink",
|
||||||
"Write stream to a file",
|
"Write stream to a file",
|
||||||
"Thomas <thomas@apestaart.org>");
|
"Thomas <thomas@apestaart.org>");
|
||||||
|
|
||||||
|
|
||||||
/* FileSink signals and args */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* FILL ME */
|
|
||||||
SIGNAL_HANDOFF,
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0,
|
ARG_0,
|
||||||
|
@ -83,6 +74,8 @@ static void gst_file_sink_get_property (GObject * object, guint prop_id,
|
||||||
static gboolean gst_file_sink_open_file (GstFileSink * sink);
|
static gboolean gst_file_sink_open_file (GstFileSink * sink);
|
||||||
static void gst_file_sink_close_file (GstFileSink * sink);
|
static void gst_file_sink_close_file (GstFileSink * sink);
|
||||||
|
|
||||||
|
static gboolean gst_file_sink_start (GstBaseSink * sink);
|
||||||
|
static gboolean gst_file_sink_stop (GstBaseSink * sink);
|
||||||
static gboolean gst_file_sink_event (GstBaseSink * sink, GstEvent * event);
|
static gboolean gst_file_sink_event (GstBaseSink * sink, GstEvent * event);
|
||||||
static GstFlowReturn gst_file_sink_render (GstBaseSink * sink,
|
static GstFlowReturn gst_file_sink_render (GstBaseSink * sink,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
|
@ -92,10 +85,6 @@ static gboolean gst_file_sink_query (GstPad * pad, GstQuery * query);
|
||||||
static void gst_file_sink_uri_handler_init (gpointer g_iface,
|
static void gst_file_sink_uri_handler_init (gpointer g_iface,
|
||||||
gpointer iface_data);
|
gpointer iface_data);
|
||||||
|
|
||||||
static GstStateChangeReturn gst_file_sink_change_state (GstElement * element,
|
|
||||||
GstStateChange transition);
|
|
||||||
|
|
||||||
//static guint gst_file_sink_signals[LAST_SIGNAL] = { 0 };
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_do_init (GType filesink_type)
|
_do_init (GType filesink_type)
|
||||||
|
@ -120,7 +109,6 @@ gst_file_sink_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
||||||
|
|
||||||
gstelement_class->change_state = gst_file_sink_change_state;
|
|
||||||
gst_element_class_add_pad_template (gstelement_class,
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
gst_static_pad_template_get (&sinktemplate));
|
gst_static_pad_template_get (&sinktemplate));
|
||||||
gst_element_class_set_details (gstelement_class, &gst_file_sink_details);
|
gst_element_class_set_details (gstelement_class, &gst_file_sink_details);
|
||||||
|
@ -142,6 +130,8 @@ gst_file_sink_class_init (GstFileSinkClass * klass)
|
||||||
gobject_class->dispose = gst_file_sink_dispose;
|
gobject_class->dispose = gst_file_sink_dispose;
|
||||||
|
|
||||||
gstbasesink_class->get_times = NULL;
|
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);
|
||||||
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
|
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
|
||||||
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
|
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
|
||||||
|
|
||||||
|
@ -181,9 +171,11 @@ gst_file_sink_dispose (GObject * object)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_file_sink_set_location (GstFileSink * sink, const gchar * location)
|
gst_file_sink_set_location (GstFileSink * sink, const gchar * location)
|
||||||
{
|
{
|
||||||
/* the element must be stopped or paused in order to do this */
|
if (sink->file) {
|
||||||
if (GST_STATE (sink) >= GST_STATE_PAUSED)
|
g_warning ("Changing the `location' property on filesink when "
|
||||||
|
"a file is open not supported.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
g_free (sink->filename);
|
g_free (sink->filename);
|
||||||
g_free (sink->uri);
|
g_free (sink->uri);
|
||||||
|
@ -201,9 +193,7 @@ static void
|
||||||
gst_file_sink_set_property (GObject * object, guint prop_id,
|
gst_file_sink_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstFileSink *sink;
|
GstFileSink *sink = GST_FILE_SINK (object);
|
||||||
|
|
||||||
sink = GST_FILE_SINK (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_LOCATION:
|
case ARG_LOCATION:
|
||||||
|
@ -219,11 +209,7 @@ static void
|
||||||
gst_file_sink_get_property (GObject * object, guint prop_id, GValue * value,
|
gst_file_sink_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
GParamSpec * pspec)
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstFileSink *sink;
|
GstFileSink *sink = GST_FILE_SINK (object);
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_FILE_SINK (object));
|
|
||||||
|
|
||||||
sink = GST_FILE_SINK (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_LOCATION:
|
case ARG_LOCATION:
|
||||||
|
@ -442,44 +428,17 @@ handle_error:
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static gboolean
|
||||||
gst_file_sink_change_state (GstElement * element, GstStateChange transition)
|
gst_file_sink_start (GstBaseSink * basesink)
|
||||||
{
|
{
|
||||||
GstStateChangeReturn ret;
|
return gst_file_sink_open_file (GST_FILE_SINK (basesink));
|
||||||
|
}
|
||||||
|
|
||||||
switch (transition) {
|
static gboolean
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
gst_file_sink_stop (GstBaseSink * basesink)
|
||||||
break;
|
{
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
gst_file_sink_close_file (GST_FILE_SINK (basesink));
|
||||||
if (!gst_file_sink_open_file (GST_FILE_SINK (element)))
|
return TRUE;
|
||||||
goto open_error;
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
||||||
gst_file_sink_close_file (GST_FILE_SINK (element));
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
open_error:
|
|
||||||
{
|
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** GSTURIHANDLER INTERFACE *************************************************/
|
/*** GSTURIHANDLER INTERFACE *************************************************/
|
||||||
|
|
Loading…
Reference in a new issue