mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
gio: Add vfunc for requesting the stream for the sinks too
This commit is contained in:
parent
7483a4834c
commit
7e72ceb3f2
7 changed files with 60 additions and 31 deletions
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
|
||||
* Copyright (C) 2007 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
* Copyright (C) 2007-2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -109,16 +109,19 @@ static gboolean
|
|||
gst_gio_base_sink_start (GstBaseSink * base_sink)
|
||||
{
|
||||
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
|
||||
|
||||
if (!G_IS_OUTPUT_STREAM (sink->stream)) {
|
||||
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
|
||||
("No stream given yet"));
|
||||
return FALSE;
|
||||
}
|
||||
GstGioBaseSinkClass *gbsink_class = GST_GIO_BASE_SINK_GET_CLASS (sink);
|
||||
|
||||
sink->position = 0;
|
||||
|
||||
GST_DEBUG_OBJECT (sink, "started stream");
|
||||
/* FIXME: This will likely block */
|
||||
sink->stream = gbsink_class->get_stream (sink);
|
||||
if (G_UNLIKELY (!G_IS_OUTPUT_STREAM (sink->stream))) {
|
||||
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
|
||||
("No output stream provided by subclass"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (sink, "started sink");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
|
||||
* Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
* Copyright (C) 2007-2009 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -48,20 +48,23 @@ struct _GstGioBaseSink
|
|||
{
|
||||
GstBaseSink sink;
|
||||
|
||||
/* < protected > */
|
||||
GCancellable *cancel;
|
||||
guint64 position;
|
||||
|
||||
/* < private > */
|
||||
GOutputStream *stream;
|
||||
};
|
||||
|
||||
struct _GstGioBaseSinkClass
|
||||
{
|
||||
GstBaseSinkClass parent_class;
|
||||
|
||||
GOutputStream * (*get_stream) (GstGioBaseSink *bsink);
|
||||
};
|
||||
|
||||
GType gst_gio_base_sink_get_type (void);
|
||||
|
||||
void gst_gio_base_sink_set_stream (GstGioBaseSink *sink, GOutputStream *stream);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_GIO_BASE_SINK_H__ */
|
||||
|
|
|
@ -48,10 +48,12 @@ struct _GstGioBaseSrc
|
|||
{
|
||||
GstBaseSrc src;
|
||||
|
||||
/* < protected > */
|
||||
GCancellable *cancel;
|
||||
guint64 position;
|
||||
GInputStream *stream;
|
||||
|
||||
/* < private > */
|
||||
GInputStream *stream;
|
||||
GstBuffer *cache;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
|
||||
* Copyright (C) 2007 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
* Copyright (C) 2007-2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -83,7 +83,7 @@ static void gst_gio_sink_set_property (GObject * object, guint prop_id,
|
|||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_gio_sink_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static gboolean gst_gio_sink_start (GstBaseSink * base_sink);
|
||||
static GOutputStream *gst_gio_sink_get_stream (GstGioBaseSink * base_sink);
|
||||
|
||||
static void
|
||||
gst_gio_sink_base_init (gpointer gclass)
|
||||
|
@ -103,7 +103,7 @@ static void
|
|||
gst_gio_sink_class_init (GstGioSinkClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
GstBaseSinkClass *gstbasesink_class = (GstBaseSinkClass *) klass;
|
||||
GstGioBaseSinkClass *gstgiobasesink_class = (GstGioBaseSinkClass *) klass;
|
||||
|
||||
gobject_class->finalize = gst_gio_sink_finalize;
|
||||
gobject_class->set_property = gst_gio_sink_set_property;
|
||||
|
@ -124,7 +124,8 @@ gst_gio_sink_class_init (GstGioSinkClass * klass)
|
|||
g_param_spec_object ("file", "File", "GFile to write to",
|
||||
G_TYPE_FILE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_gio_sink_start);
|
||||
gstgiobasesink_class->get_stream =
|
||||
GST_DEBUG_FUNCPTR (gst_gio_sink_get_stream);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -234,10 +235,10 @@ gst_gio_sink_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gio_sink_start (GstBaseSink * base_sink)
|
||||
static GOutputStream *
|
||||
gst_gio_sink_get_stream (GstGioBaseSink * bsink)
|
||||
{
|
||||
GstGioSink *sink = GST_GIO_SINK (base_sink);
|
||||
GstGioSink *sink = GST_GIO_SINK (bsink);
|
||||
GOutputStream *stream;
|
||||
GCancellable *cancel = GST_GIO_BASE_SINK (sink)->cancel;
|
||||
GError *err = NULL;
|
||||
|
@ -246,7 +247,7 @@ gst_gio_sink_start (GstBaseSink * base_sink)
|
|||
if (sink->file == NULL) {
|
||||
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
|
||||
("No location or GFile given"));
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uri = g_file_get_uri (sink->file);
|
||||
|
@ -272,14 +273,12 @@ gst_gio_sink_start (GstBaseSink * base_sink)
|
|||
g_clear_error (&err);
|
||||
}
|
||||
g_free (uri);
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (sink, "opened location %s", uri);
|
||||
|
||||
g_free (uri);
|
||||
|
||||
gst_gio_base_sink_set_stream (GST_GIO_BASE_SINK (sink), stream);
|
||||
|
||||
return GST_BASE_SINK_CLASS (parent_class)->start (base_sink);
|
||||
return stream;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
|
||||
* Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
* Copyright (C) 2007-2009 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
|
||||
* Copyright (C) 2007 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
* Copyright (C) 2007-2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -91,6 +91,7 @@ static void gst_gio_stream_sink_set_property (GObject * object, guint prop_id,
|
|||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_gio_stream_sink_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static GOutputStream *gst_gio_stream_sink_get_stream (GstGioBaseSink * bsink);
|
||||
|
||||
static void
|
||||
gst_gio_stream_sink_base_init (gpointer gclass)
|
||||
|
@ -110,6 +111,7 @@ static void
|
|||
gst_gio_stream_sink_class_init (GstGioStreamSinkClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
GstGioBaseSinkClass *ggbsink_class = (GstGioBaseSinkClass *) klass;
|
||||
|
||||
gobject_class->finalize = gst_gio_stream_sink_finalize;
|
||||
gobject_class->set_property = gst_gio_stream_sink_set_property;
|
||||
|
@ -118,6 +120,9 @@ gst_gio_stream_sink_class_init (GstGioStreamSinkClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_STREAM,
|
||||
g_param_spec_object ("stream", "Stream", "Stream to write to",
|
||||
G_TYPE_OUTPUT_STREAM, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
ggbsink_class->get_stream =
|
||||
GST_DEBUG_FUNCPTR (gst_gio_stream_sink_get_stream);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -129,6 +134,13 @@ gst_gio_stream_sink_init (GstGioStreamSink * sink,
|
|||
static void
|
||||
gst_gio_stream_sink_finalize (GObject * object)
|
||||
{
|
||||
GstGioStreamSink *sink = GST_GIO_STREAM_SINK (object);
|
||||
|
||||
if (sink->stream) {
|
||||
g_object_unref (sink->stream);
|
||||
sink->stream = NULL;
|
||||
}
|
||||
|
||||
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
||||
}
|
||||
|
||||
|
@ -150,10 +162,9 @@ gst_gio_stream_sink_set_property (GObject * object, guint prop_id,
|
|||
}
|
||||
|
||||
stream = g_value_dup_object (value);
|
||||
if (G_IS_OUTPUT_STREAM (stream))
|
||||
gst_gio_base_sink_set_stream (GST_GIO_BASE_SINK (sink),
|
||||
G_OUTPUT_STREAM (stream));
|
||||
|
||||
if (sink->stream)
|
||||
g_object_unref (sink->stream);
|
||||
sink->stream = G_OUTPUT_STREAM (stream);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -177,3 +188,11 @@ gst_gio_stream_sink_get_property (GObject * object, guint prop_id,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static GOutputStream *
|
||||
gst_gio_stream_sink_get_stream (GstGioBaseSink * bsink)
|
||||
{
|
||||
GstGioStreamSink *sink = GST_GIO_STREAM_SINK (bsink);
|
||||
|
||||
return (sink->stream) ? g_object_ref (sink->stream) : NULL;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
|
||||
* Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
* Copyright (C) 2007-2009 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -51,6 +51,9 @@ typedef struct _GstGioStreamSinkClass GstGioStreamSinkClass;
|
|||
struct _GstGioStreamSink
|
||||
{
|
||||
GstGioBaseSink sink;
|
||||
|
||||
/* < private > */
|
||||
GOutputStream *stream;
|
||||
};
|
||||
|
||||
struct _GstGioStreamSinkClass
|
||||
|
|
Loading…
Reference in a new issue