Remove GIO plugin which has now moved to -base.

Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/gio/Makefile.am:
* ext/gio/gstgio.c:
* ext/gio/gstgio.h:
* ext/gio/gstgiobasesink.c:
* ext/gio/gstgiobasesink.h:
* ext/gio/gstgiobasesrc.c:
* ext/gio/gstgiobasesrc.h:
* ext/gio/gstgiosink.c:
* ext/gio/gstgiosink.h:
* ext/gio/gstgiosrc.c:
* ext/gio/gstgiosrc.h:
* ext/gio/gstgiostreamsink.c:
* ext/gio/gstgiostreamsink.h:
* ext/gio/gstgiostreamsrc.c:
* ext/gio/gstgiostreamsrc.h:
* tests/check/Makefile.am:
* tests/check/pipelines/.cvsignore:
* tests/check/pipelines/gio.c:
Remove GIO plugin which has now moved to -base.
This commit is contained in:
Jan Schmidt 2008-02-07 23:30:45 +00:00
parent 9749d146c6
commit 96d9b6eecf
21 changed files with 25 additions and 2305 deletions

View file

@ -1,3 +1,28 @@
2008-02-07 Jan Schmidt <jan.schmidt@sun.com>
* configure.ac:
* ext/Makefile.am:
* ext/gio/Makefile.am:
* ext/gio/gstgio.c:
* ext/gio/gstgio.h:
* ext/gio/gstgiobasesink.c:
* ext/gio/gstgiobasesink.h:
* ext/gio/gstgiobasesrc.c:
* ext/gio/gstgiobasesrc.h:
* ext/gio/gstgiosink.c:
* ext/gio/gstgiosink.h:
* ext/gio/gstgiosrc.c:
* ext/gio/gstgiosrc.h:
* ext/gio/gstgiostreamsink.c:
* ext/gio/gstgiostreamsink.h:
* ext/gio/gstgiostreamsrc.c:
* ext/gio/gstgiostreamsrc.h:
* tests/check/Makefile.am:
* tests/check/pipelines/.cvsignore:
* tests/check/pipelines/gio.c:
Remove GIO plugin which has now moved to -base.
2008-02-07 Jan Schmidt <jan.schmidt@sun.com>
* docs/plugins/Makefile.am:

View file

@ -125,8 +125,6 @@ AG_GST_ARG_ENABLE_EXTERNAL
AG_GST_ARG_ENABLE_EXPERIMENTAL
USE_GIO=$BUILD_EXPERIMENTAL
dnl *** checks for platform ***
dnl * hardware/architecture *
@ -570,17 +568,6 @@ AG_GST_CHECK_FEATURE(FBDEV, [linux framebuffer], fbdevsink, [
fi
])
dnl *** libgio ***
translit(dnm, m, l) AM_CONDITIONAL(USE_GIO, true)
AG_GST_CHECK_FEATURE(GIO, [GIO library], gio, [
PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.15.2, HAVE_GIO="yes", [
HAVE_GIO="no"
AC_MSG_RESULT(no)
])
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
])
dnl *** gsm ***
translit(dnm, m, l) AM_CONDITIONAL(USE_GSM, true)
AG_GST_CHECK_FEATURE(GSM, [GSM library], gsmenc gsmdec, [
@ -973,7 +960,6 @@ AM_CONDITIONAL(USE_DIVX, false)
AM_CONDITIONAL(USE_FAAC, false)
AM_CONDITIONAL(USE_FAAD, false)
AM_CONDITIONAL(USE_FBDEV, false)
AM_CONDITIONAL(USE_GIO, false)
AM_CONDITIONAL(USE_GSM, false)
AM_CONDITIONAL(USE_IVORBIS, false)
AM_CONDITIONAL(USE_JACK, false)
@ -1115,7 +1101,6 @@ ext/dts/Makefile
ext/metadata/Makefile
ext/faac/Makefile
ext/faad/Makefile
ext/gio/Makefile
ext/gsm/Makefile
ext/ivorbis/Makefile
ext/jack/Makefile

View file

@ -94,12 +94,6 @@ endif
G729_DIR=
#endif
if USE_GIO
GIO_DIR=gio
else
GIO_DIR=
endif
if USE_GSM
GSM_DIR=gsm
else
@ -302,7 +296,6 @@ SUBDIRS=\
$(DTS_DIR) \
$(FAAC_DIR) \
$(FAAD_DIR) \
$(GIO_DIR) \
$(GSM_DIR) \
$(G729_DIR) \
$(HERMES_DIR) \
@ -345,7 +338,6 @@ DIST_SUBDIRS = \
directfb \
faac \
faad \
gio \
gsm \
ivorbis \
ladspa \

View file

@ -1,28 +0,0 @@
# plugindir is set in configure
plugin_LTLIBRARIES = libgstgio.la
# sources used to compile this plug-in
libgstgio_la_SOURCES = \
gstgio.c \
gstgiobasesink.c \
gstgiobasesrc.c \
gstgiosink.c \
gstgiosrc.c \
gstgiostreamsink.c \
gstgiostreamsrc.c
libgstgio_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GIO_CFLAGS)
libgstgio_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GIO_LIBS)
libgstgio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_GIO_LDFLAGS)
# headers we need but don't want installed
noinst_HEADERS = \
gstgio.h \
gstgiobasesink.h \
gstgiobasesrc.h \
gstgiosink.h \
gstgiosrc.h \
gstgiostreamsink.h \
gstgiostreamsrc.h

View file

@ -1,214 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstgio.h"
#include "gstgiosink.h"
#include "gstgiosrc.h"
#include "gstgiostreamsink.h"
#include "gstgiostreamsrc.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_debug);
#define GST_CAT_DEFAULT gst_gio_debug
/* @func_name: Name of the GIO function, for debugging messages.
* @err: Error location. *err may be NULL, but err must be non-NULL.
* @ret: Flow return location. May be NULL. Is set to either #GST_FLOW_ERROR
* or #GST_FLOW_WRONG_STATE.
*
* Returns: TRUE to indicate a handled error. Error at given location err will
* be freed and *err will be set to NULL. A FALSE return indicates an unhandled
* error: The err location is unchanged and guaranteed to be != NULL. ret, if
* given, is set to GST_FLOW_ERROR.
*/
gboolean
gst_gio_error (gpointer element, const gchar * func_name, GError ** err,
GstFlowReturn * ret)
{
gboolean handled = TRUE;
if (ret)
*ret = GST_FLOW_ERROR;
if (GST_GIO_ERROR_MATCHES (*err, CANCELLED)) {
GST_DEBUG_OBJECT (element, "blocking I/O call cancelled (%s)", func_name);
if (ret)
*ret = GST_FLOW_WRONG_STATE;
} else if (*err != NULL) {
handled = FALSE;
} else {
GST_ELEMENT_ERROR (element, LIBRARY, FAILED, (NULL),
("%s call failed without error set", func_name));
}
if (handled)
g_clear_error (err);
return handled;
}
GstFlowReturn
gst_gio_seek (gpointer element, GSeekable * stream, guint64 offset,
GCancellable * cancel)
{
gboolean success;
GstFlowReturn ret;
GError *err = NULL;
GST_LOG_OBJECT (element, "seeking to offset %" G_GINT64_FORMAT, offset);
success = g_seekable_seek (stream, offset, G_SEEK_SET, cancel, &err);
if (success)
ret = GST_FLOW_OK;
else if (!gst_gio_error (element, "g_seekable_seek", &err, &ret)) {
GST_ELEMENT_ERROR (element, RESOURCE, SEEK, (NULL),
("Could not seek: %s", err->message));
g_clear_error (&err);
}
return ret;
}
static gchar **
gst_gio_get_supported_protocols (void)
{
return g_strdupv ((gchar **)
g_vfs_get_supported_uri_schemes (g_vfs_get_default ()));
}
static GstURIType
gst_gio_uri_handler_get_type_sink (void)
{
return GST_URI_SINK;
}
static GstURIType
gst_gio_uri_handler_get_type_src (void)
{
return GST_URI_SRC;
}
static gchar **
gst_gio_uri_handler_get_protocols (void)
{
static gchar **protocols = NULL;
if (!protocols)
protocols = gst_gio_get_supported_protocols ();
return protocols;
}
static const gchar *
gst_gio_uri_handler_get_uri (GstURIHandler * handler)
{
GstElement *element = GST_ELEMENT (handler);
const gchar *uri;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_object_get (G_OBJECT (element), "location", &uri, NULL);
return uri;
}
static gboolean
gst_gio_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
{
GstElement *element = GST_ELEMENT (handler);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
if (GST_STATE (element) == GST_STATE_PLAYING ||
GST_STATE (element) == GST_STATE_PAUSED)
return FALSE;
g_object_set (G_OBJECT (element), "location", uri, NULL);
return TRUE;
}
static void
gst_gio_uri_handler_init (gpointer g_iface, gpointer iface_data)
{
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
gboolean sink = GPOINTER_TO_INT (iface_data); /* See in do_init below. */
if (sink)
iface->get_type = gst_gio_uri_handler_get_type_sink;
else
iface->get_type = gst_gio_uri_handler_get_type_src;
iface->get_protocols = gst_gio_uri_handler_get_protocols;
iface->get_uri = gst_gio_uri_handler_get_uri;
iface->set_uri = gst_gio_uri_handler_set_uri;
}
void
gst_gio_uri_handler_do_init (GType type)
{
GInterfaceInfo uri_handler_info = {
gst_gio_uri_handler_init,
NULL,
NULL
};
/* Store information for uri_handler_init to use for distinguishing the
* element types. This lets us use a single interface implementation for both
* classes. */
uri_handler_info.interface_data = GINT_TO_POINTER (g_type_is_a (type,
GST_TYPE_BASE_SINK));
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &uri_handler_info);
}
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean ret = TRUE;
GST_DEBUG_CATEGORY_INIT (gst_gio_debug, "gio", 0, "GIO elements");
/* FIXME: Rank is MARGINAL for now, should be at least SECONDARY+1 in the future
* to replace gnomevfssink/src. For testing purposes PRIMARY+1 one makes sense
* so it gets autoplugged and preferred over filesrc/sink. */
ret &= gst_element_register (plugin, "giosink", GST_RANK_MARGINAL,
GST_TYPE_GIO_SINK);
ret &= gst_element_register (plugin, "giosrc", GST_RANK_MARGINAL,
GST_TYPE_GIO_SRC);
ret &= gst_element_register (plugin, "giostreamsink", GST_RANK_NONE,
GST_TYPE_GIO_STREAM_SINK);
ret &= gst_element_register (plugin, "giostreamsrc", GST_RANK_NONE,
GST_TYPE_GIO_STREAM_SRC);
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "gio",
"GIO elements", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
GST_PACKAGE_ORIGIN)

View file

@ -1,42 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifndef __GST_GIO_H__
#define __GST_GIO_H__
#include <gio/gio.h>
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_GIO_ERROR_MATCHES(err, code) g_error_matches (err, G_IO_ERROR, G_IO_ERROR_##code)
#define GST_GIO_STREAM_IS_SEEKABLE(stream) (G_IS_SEEKABLE (stream) && g_seekable_can_seek (G_SEEKABLE (stream)))
gboolean gst_gio_error (gpointer element, const gchar *func_name,
GError **err, GstFlowReturn *ret);
GstFlowReturn gst_gio_seek (gpointer element, GSeekable *stream, guint64 offset,
GCancellable *cancel);
void gst_gio_uri_handler_do_init (GType type);
G_END_DECLS
#endif /* __GST_GIO_H__ */

View file

@ -1,337 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstgiobasesink.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_base_sink_debug);
#define GST_CAT_DEFAULT gst_gio_base_sink_debug
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GST_BOILERPLATE (GstGioBaseSink, gst_gio_base_sink, GstBaseSink,
GST_TYPE_BASE_SINK);
static void gst_gio_base_sink_finalize (GObject * object);
static gboolean gst_gio_base_sink_start (GstBaseSink * base_sink);
static gboolean gst_gio_base_sink_stop (GstBaseSink * base_sink);
static gboolean gst_gio_base_sink_unlock (GstBaseSink * base_sink);
static gboolean gst_gio_base_sink_unlock_stop (GstBaseSink * base_sink);
static gboolean gst_gio_base_sink_event (GstBaseSink * base_sink,
GstEvent * event);
static GstFlowReturn gst_gio_base_sink_render (GstBaseSink * base_sink,
GstBuffer * buffer);
static gboolean gst_gio_base_sink_query (GstPad * pad, GstQuery * query);
static void
gst_gio_base_sink_base_init (gpointer gclass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
GST_DEBUG_CATEGORY_INIT (gst_gio_base_sink_debug, "gio_base_sink", 0,
"GIO base sink");
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
}
static void
gst_gio_base_sink_class_init (GstGioBaseSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSinkClass *gstbasesink_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gobject_class->finalize = gst_gio_base_sink_finalize;
gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_gio_base_sink_start);
gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_gio_base_sink_stop);
gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_gio_base_sink_unlock);
gstbasesink_class->unlock_stop =
GST_DEBUG_FUNCPTR (gst_gio_base_sink_unlock_stop);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_gio_base_sink_event);
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_gio_base_sink_render);
}
static void
gst_gio_base_sink_init (GstGioBaseSink * sink, GstGioBaseSinkClass * gclass)
{
gst_pad_set_query_function (GST_BASE_SINK_PAD (sink),
GST_DEBUG_FUNCPTR (gst_gio_base_sink_query));
gst_base_sink_set_sync (GST_BASE_SINK (sink), FALSE);
sink->cancel = g_cancellable_new ();
}
static void
gst_gio_base_sink_finalize (GObject * object)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (object);
if (sink->cancel) {
g_object_unref (sink->cancel);
sink->cancel = NULL;
}
if (sink->stream) {
g_object_unref (sink->stream);
sink->stream = NULL;
}
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
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;
}
sink->position = 0;
GST_DEBUG_OBJECT (sink, "started stream");
return TRUE;
}
static void
close_stream_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (user_data);
gboolean success;
GError *err = NULL;
success = g_output_stream_close_finish (G_OUTPUT_STREAM (object), res, &err);
if (!success
&& !gst_gio_error (sink, "g_output_stream_close_async", &err, NULL)) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, (NULL),
("g_output_stream_close_async failed: %s", err->message));
g_clear_error (&err);
}
GST_DEBUG_OBJECT (sink, "closed stream");
g_object_unref (sink);
}
static gboolean
gst_gio_base_sink_stop (GstBaseSink * base_sink)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
if (G_IS_OUTPUT_STREAM (sink->stream)) {
GST_DEBUG_OBJECT (sink, "closing stream");
g_output_stream_close_async (sink->stream, 0, sink->cancel, close_stream_cb,
g_object_ref (sink));
g_object_unref (sink->stream);
sink->stream = NULL;
}
return TRUE;
}
static gboolean
gst_gio_base_sink_unlock (GstBaseSink * base_sink)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
GST_LOG_OBJECT (sink, "triggering cancellation");
g_cancellable_cancel (sink->cancel);
return TRUE;
}
static gboolean
gst_gio_base_sink_unlock_stop (GstBaseSink * base_sink)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
GST_LOG_OBJECT (sink, "resetting cancellable");
g_cancellable_reset (sink->cancel);
return TRUE;
}
static gboolean
gst_gio_base_sink_event (GstBaseSink * base_sink, GstEvent * event)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
GstFlowReturn ret = GST_FLOW_OK;
if (sink->stream == NULL)
return TRUE;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
if (G_IS_OUTPUT_STREAM (sink->stream)) {
GstFormat format;
gint64 offset;
gst_event_parse_new_segment (event, NULL, NULL, &format, &offset, NULL,
NULL);
if (format != GST_FORMAT_BYTES) {
GST_WARNING_OBJECT (sink, "ignored NEWSEGMENT event in %s format",
gst_format_get_name (format));
break;
}
if (GST_GIO_STREAM_IS_SEEKABLE (sink->stream)) {
ret = gst_gio_seek (sink, G_SEEKABLE (sink->stream), offset,
sink->cancel);
if (ret == GST_FLOW_OK)
sink->position = offset;
} else {
ret = GST_FLOW_NOT_SUPPORTED;
}
}
break;
case GST_EVENT_EOS:
case GST_EVENT_FLUSH_START:
if (G_IS_OUTPUT_STREAM (sink->stream)) {
gboolean success;
GError *err = NULL;
success = g_output_stream_flush (sink->stream, sink->cancel, &err);
if (!success && !gst_gio_error (sink, "g_output_stream_flush", &err,
&ret)) {
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
("flush failed: %s", err->message));
g_clear_error (&err);
}
}
break;
default:
break;
}
return (ret == GST_FLOW_OK);
}
static GstFlowReturn
gst_gio_base_sink_render (GstBaseSink * base_sink, GstBuffer * buffer)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
gssize written;
gboolean success;
GError *err = NULL;
g_return_val_if_fail (G_IS_OUTPUT_STREAM (sink->stream), GST_FLOW_ERROR);
GST_LOG_OBJECT (sink, "writing %u bytes to offset %" G_GUINT64_FORMAT,
GST_BUFFER_SIZE (buffer), sink->position);
written = g_output_stream_write (sink->stream,
GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), sink->cancel, &err);
success = (written >= 0);
if (G_UNLIKELY (success && written < GST_BUFFER_SIZE (buffer))) {
/* FIXME: Can this happen? Should we handle it gracefully? gnomevfssink
* doesn't... */
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
("Could not write to stream: (short write, only %"
G_GUINT64_FORMAT " bytes of %d bytes written)",
written, GST_BUFFER_SIZE (buffer)));
return GST_FLOW_ERROR;
}
if (success) {
sink->position += written;
return GST_FLOW_OK;
} else {
GstFlowReturn ret;
if (!gst_gio_error (sink, "g_output_stream_write", &err, &ret)) {
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
("Could not write to stream: %s", err->message));
g_clear_error (&err);
}
return ret;
}
}
static gboolean
gst_gio_base_sink_query (GstPad * pad, GstQuery * query)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (GST_PAD_PARENT (pad));
GstFormat format;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
gst_query_parse_position (query, &format, NULL);
switch (format) {
case GST_FORMAT_BYTES:
case GST_FORMAT_DEFAULT:
gst_query_set_position (query, GST_FORMAT_BYTES, sink->position);
return TRUE;
default:
return FALSE;
}
case GST_QUERY_FORMATS:
gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
return TRUE;
default:
return gst_pad_query_default (pad, query);
}
}
void
gst_gio_base_sink_set_stream (GstGioBaseSink * sink, GOutputStream * stream)
{
g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
g_return_if_fail ((GST_STATE (sink) != GST_STATE_PLAYING &&
GST_STATE (sink) != GST_STATE_PAUSED));
if (G_IS_OUTPUT_STREAM (sink->stream)) {
GST_DEBUG_OBJECT (sink, "closing old stream");
g_output_stream_close_async (sink->stream, 0, sink->cancel, close_stream_cb,
g_object_ref (sink));
g_object_unref (sink->stream);
sink->stream = NULL;
}
sink->stream = stream;
}

View file

@ -1,65 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifndef __GST_GIO_BASE_SINK_H__
#define __GST_GIO_BASE_SINK_H__
#include "gstgio.h"
#include <gst/base/gstbasesink.h>
G_BEGIN_DECLS
#define GST_TYPE_GIO_BASE_SINK \
(gst_gio_base_sink_get_type())
#define GST_GIO_BASE_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_BASE_SINK,GstGioBaseSink))
#define GST_GIO_BASE_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_BASE_SINK,GstGioBaseSinkClass))
#define GST_IS_GIO_BASE_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_BASE_SINK))
#define GST_IS_GIO_BASE_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_BASE_SINK))
typedef struct _GstGioBaseSink GstGioBaseSink;
typedef struct _GstGioBaseSinkClass GstGioBaseSinkClass;
struct _GstGioBaseSink
{
GstBaseSink sink;
GCancellable *cancel;
guint64 position;
GOutputStream *stream;
};
struct _GstGioBaseSinkClass
{
GstBaseSinkClass parent_class;
};
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__ */

View file

@ -1,370 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstgiobasesrc.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_base_src_debug);
#define GST_CAT_DEFAULT gst_gio_base_src_debug
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GST_BOILERPLATE (GstGioBaseSrc, gst_gio_base_src, GstBaseSrc,
GST_TYPE_BASE_SRC);
static void gst_gio_base_src_finalize (GObject * object);
static gboolean gst_gio_base_src_start (GstBaseSrc * base_src);
static gboolean gst_gio_base_src_stop (GstBaseSrc * base_src);
static gboolean gst_gio_base_src_get_size (GstBaseSrc * base_src,
guint64 * size);
static gboolean gst_gio_base_src_is_seekable (GstBaseSrc * base_src);
static gboolean gst_gio_base_src_unlock (GstBaseSrc * base_src);
static gboolean gst_gio_base_src_unlock_stop (GstBaseSrc * base_src);
static gboolean gst_gio_base_src_check_get_range (GstBaseSrc * base_src);
static GstFlowReturn gst_gio_base_src_create (GstBaseSrc * base_src,
guint64 offset, guint size, GstBuffer ** buf);
static void
gst_gio_base_src_base_init (gpointer gclass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
GST_DEBUG_CATEGORY_INIT (gst_gio_base_src_debug, "gio_base_src", 0,
"GIO base source");
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
}
static void
gst_gio_base_src_class_init (GstGioBaseSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gobject_class->finalize = gst_gio_base_src_finalize;
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_gio_base_src_start);
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_gio_base_src_stop);
gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_gio_base_src_get_size);
gstbasesrc_class->is_seekable =
GST_DEBUG_FUNCPTR (gst_gio_base_src_is_seekable);
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_gio_base_src_unlock);
gstbasesrc_class->unlock_stop =
GST_DEBUG_FUNCPTR (gst_gio_base_src_unlock_stop);
gstbasesrc_class->check_get_range =
GST_DEBUG_FUNCPTR (gst_gio_base_src_check_get_range);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_gio_base_src_create);
}
static void
gst_gio_base_src_init (GstGioBaseSrc * src, GstGioBaseSrcClass * gclass)
{
src->cancel = g_cancellable_new ();
}
static void
gst_gio_base_src_finalize (GObject * object)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (object);
if (src->cancel) {
g_object_unref (src->cancel);
src->cancel = NULL;
}
if (src->stream) {
g_object_unref (src->stream);
src->stream = NULL;
}
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
static gboolean
gst_gio_base_src_start (GstBaseSrc * base_src)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
if (!G_IS_INPUT_STREAM (src->stream)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("No stream given yet"));
return FALSE;
}
src->position = 0;
GST_DEBUG_OBJECT (src, "started stream");
return TRUE;
}
static void
close_stream_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (user_data);
gboolean success;
GError *err = NULL;
success = g_input_stream_close_finish (G_INPUT_STREAM (object), res, &err);
if (!success
&& !gst_gio_error (src, "g_input_stream_close_async", &err, NULL)) {
GST_ELEMENT_ERROR (src, RESOURCE, CLOSE, (NULL),
("g_input_stream_close_async failed: %s", err->message));
g_clear_error (&err);
}
GST_DEBUG_OBJECT (src, "closed stream");
g_object_unref (src);
}
static gboolean
gst_gio_base_src_stop (GstBaseSrc * base_src)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
if (G_IS_INPUT_STREAM (src->stream)) {
GST_DEBUG_OBJECT (src, "closing stream");
g_input_stream_close_async (src->stream, 0, src->cancel, close_stream_cb,
g_object_ref (src));
g_object_unref (src->stream);
src->stream = NULL;
}
return TRUE;
}
static gboolean
gst_gio_base_src_get_size (GstBaseSrc * base_src, guint64 * size)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
if (G_IS_FILE_INPUT_STREAM (src->stream)) {
GFileInfo *info;
GError *err = NULL;
info = g_file_input_stream_query_info (G_FILE_INPUT_STREAM (src->stream),
G_FILE_ATTRIBUTE_STANDARD_SIZE, src->cancel, &err);
if (info != NULL) {
*size = g_file_info_get_size (info);
g_object_unref (info);
GST_DEBUG_OBJECT (src, "found size: %" G_GUINT64_FORMAT, *size);
return TRUE;
}
if (!gst_gio_error (src, "g_file_input_stream_query_info", &err, NULL)) {
if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED))
GST_DEBUG_OBJECT (src, "size information not available");
else
GST_WARNING_OBJECT (src, "size information retrieval failed: %s",
err->message);
g_clear_error (&err);
}
} else if (GST_GIO_STREAM_IS_SEEKABLE (src->stream)) {
goffset old;
goffset stream_size;
gboolean ret;
GSeekable *seekable = G_SEEKABLE (src->stream);
GError *err = NULL;
old = g_seekable_tell (seekable);
ret = g_seekable_seek (seekable, 0, G_SEEK_END, src->cancel, &err);
if (!ret) {
if (!gst_gio_error (src, "g_seekable_seek", &err, NULL)) {
if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED))
GST_DEBUG_OBJECT (src,
"Seeking to the end of stream is not supported");
else
GST_WARNING_OBJECT (src, "Seeking to end of stream failed: %s",
err->message);
g_clear_error (&err);
} else {
GST_WARNING_OBJECT (src, "Seeking to end of stream failed");
}
return FALSE;
}
stream_size = g_seekable_tell (seekable);
ret = g_seekable_seek (seekable, old, G_SEEK_SET, src->cancel, &err);
if (!ret) {
if (!gst_gio_error (src, "g_seekable_seek", &err, NULL)) {
if (GST_GIO_ERROR_MATCHES (err, NOT_SUPPORTED))
GST_ERROR_OBJECT (src, "Seeking to the old position not supported");
else
GST_ERROR_OBJECT (src, "Seeking to the old position failed: %s",
err->message);
g_clear_error (&err);
} else {
GST_ERROR_OBJECT (src, "Seeking to the old position faile");
}
return FALSE;
}
if (stream_size >= 0) {
*size = stream_size;
return TRUE;
}
}
return FALSE;
}
static gboolean
gst_gio_base_src_is_seekable (GstBaseSrc * base_src)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
gboolean seekable;
seekable = GST_GIO_STREAM_IS_SEEKABLE (src->stream);
GST_DEBUG_OBJECT (src, "can seek: %d", seekable);
return seekable;
}
static gboolean
gst_gio_base_src_unlock (GstBaseSrc * base_src)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
GST_LOG_OBJECT (src, "triggering cancellation");
g_cancellable_cancel (src->cancel);
return TRUE;
}
static gboolean
gst_gio_base_src_unlock_stop (GstBaseSrc * base_src)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
GST_LOG_OBJECT (src, "resetting cancellable");
g_cancellable_reset (src->cancel);
return TRUE;
}
static gboolean
gst_gio_base_src_check_get_range (GstBaseSrc * base_src)
{
/* FIXME: Implement dry-run variant using guesswork like gnomevfssrc? */
return GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS,
check_get_range, (base_src), FALSE);
}
static GstFlowReturn
gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
GstBuffer ** buf_return)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
GstBuffer *buf;
gssize read;
gboolean success, eos;
GstFlowReturn ret = GST_FLOW_OK;
GError *err = NULL;
g_return_val_if_fail (G_IS_INPUT_STREAM (src->stream), GST_FLOW_ERROR);
if (G_UNLIKELY (offset != src->position)) {
if (!GST_GIO_STREAM_IS_SEEKABLE (src->stream))
return GST_FLOW_NOT_SUPPORTED;
ret = gst_gio_seek (src, G_SEEKABLE (src->stream), offset, src->cancel);
if (ret == GST_FLOW_OK)
src->position = offset;
return ret;
}
buf = gst_buffer_new_and_alloc (size);
GST_LOG_OBJECT (src, "reading %u bytes from offset %" G_GUINT64_FORMAT,
size, offset);
read =
g_input_stream_read (G_INPUT_STREAM (src->stream), GST_BUFFER_DATA (buf),
size, src->cancel, &err);
success = (read >= 0);
eos = (size > 0 && read == 0);
if (!success && !gst_gio_error (src, "g_input_stream_read", &err, &ret)) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Could not read from stream: %s", err->message));
g_clear_error (&err);
}
if (success && !eos) {
src->position += read;
GST_BUFFER_OFFSET (buf) = offset;
GST_BUFFER_SIZE (buf) = read;
*buf_return = buf;
} else {
/* !success || eos */
gst_buffer_unref (buf);
}
if (eos)
ret = GST_FLOW_UNEXPECTED;
return ret;
}
void
gst_gio_base_src_set_stream (GstGioBaseSrc * src, GInputStream * stream)
{
g_return_if_fail (G_IS_INPUT_STREAM (stream));
g_return_if_fail ((GST_STATE (src) != GST_STATE_PLAYING &&
GST_STATE (src) != GST_STATE_PAUSED));
if (G_IS_INPUT_STREAM (src->stream)) {
GST_DEBUG_OBJECT (src, "closing old stream");
g_input_stream_close_async (src->stream, 0, src->cancel, close_stream_cb,
g_object_ref (src));
g_object_unref (src->stream);
src->stream = NULL;
}
src->stream = stream;
}

View file

@ -1,65 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifndef __GST_GIO_BASE_SRC_H__
#define __GST_GIO_BASE_SRC_H__
#include "gstgio.h"
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#define GST_TYPE_GIO_BASE_SRC \
(gst_gio_base_src_get_type())
#define GST_GIO_BASE_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_BASE_SRC,GstGioBaseSrc))
#define GST_GIO_BASE_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_BASE_SRC,GstGioBaseSrcClass))
#define GST_IS_GIO_BASE_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_BASE_SRC))
#define GST_IS_GIO_BASE_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_BASE_SRC))
typedef struct _GstGioBaseSrc GstGioBaseSrc;
typedef struct _GstGioBaseSrcClass GstGioBaseSrcClass;
struct _GstGioBaseSrc
{
GstBaseSrc src;
GCancellable *cancel;
guint64 position;
GInputStream *stream;
};
struct _GstGioBaseSrcClass
{
GstBaseSrcClass parent_class;
};
GType gst_gio_base_src_get_type (void);
void gst_gio_base_src_set_stream (GstGioBaseSrc *src, GInputStream *stream);
G_END_DECLS
#endif /* __GST_GIO_BASE_SRC_H__ */

View file

@ -1,215 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
/**
* SECTION:element-giosink
*
* <refsect2>
* <title>Example launch line</title>
* <para>
* <programlisting>
* gst-launch audiotestsrc num-buffers=100 ! flacenc ! giosink location=file:///home/foo/bar.flac
* </programlisting>
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstgiosink.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_sink_debug);
#define GST_CAT_DEFAULT gst_gio_sink_debug
/* Filter signals and args */
enum
{
LAST_SIGNAL
};
enum
{
ARG_0,
ARG_LOCATION
};
GST_BOILERPLATE_FULL (GstGioSink, gst_gio_sink, GstGioBaseSink,
GST_TYPE_GIO_BASE_SINK, gst_gio_uri_handler_do_init);
static void gst_gio_sink_finalize (GObject * object);
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 void
gst_gio_sink_base_init (gpointer gclass)
{
static GstElementDetails element_details = {
"GIO sink",
"Sink/File",
"Write to any GIO-supported location",
"Ren\xc3\xa9 Stadler <mail@renestadler.de>, "
"Sebastian Dröge <slomo@circular-chaos.org>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
GST_DEBUG_CATEGORY_INIT (gst_gio_sink_debug, "gio_sink", 0, "GIO sink");
gst_element_class_set_details (element_class, &element_details);
}
static void
gst_gio_sink_class_init (GstGioSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSinkClass *gstbasesink_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gobject_class->finalize = gst_gio_sink_finalize;
gobject_class->set_property = gst_gio_sink_set_property;
gobject_class->get_property = gst_gio_sink_get_property;
g_object_class_install_property (gobject_class, ARG_LOCATION,
g_param_spec_string ("location", "Location", "URI location to write to",
NULL, G_PARAM_READWRITE));
gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_gio_sink_start);
}
static void
gst_gio_sink_init (GstGioSink * sink, GstGioSinkClass * gclass)
{
}
static void
gst_gio_sink_finalize (GObject * object)
{
GstGioSink *sink = GST_GIO_SINK (object);
if (sink->location) {
g_free (sink->location);
sink->location = NULL;
}
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
static void
gst_gio_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGioSink *sink = GST_GIO_SINK (object);
switch (prop_id) {
case ARG_LOCATION:
if (GST_STATE (sink) == GST_STATE_PLAYING ||
GST_STATE (sink) == GST_STATE_PAUSED)
break;
g_free (sink->location);
sink->location = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_gio_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstGioSink *sink = GST_GIO_SINK (object);
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, sink->location);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gst_gio_sink_start (GstBaseSink * base_sink)
{
GstGioSink *sink = GST_GIO_SINK (base_sink);
GFile *file;
GOutputStream *stream;
GCancellable *cancel = GST_GIO_BASE_SINK (sink)->cancel;
gboolean success;
GError *err = NULL;
if (sink->location == NULL) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
("No location given"));
return FALSE;
}
file = g_file_new_for_uri (sink->location);
if (file == NULL) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
("Malformed URI or protocol not supported (%s)", sink->location));
return FALSE;
}
stream =
G_OUTPUT_STREAM (g_file_create (file, G_FILE_CREATE_NONE, cancel, &err));
success = (stream != NULL);
g_object_unref (file);
if (!success && !gst_gio_error (sink, "g_file_create", &err, NULL)) {
/*if (GST_GIO_ERROR_MATCHES (err, EXISTS)) */
/* FIXME: Retry with replace if overwrite == TRUE! */
if (GST_GIO_ERROR_MATCHES (err, NOT_FOUND))
GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, (NULL),
("Could not open location %s for writing: %s",
sink->location, err->message));
else
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ, (NULL),
("Could not open location %s for writing: %s",
sink->location, err->message));
g_clear_error (&err);
}
if (!success)
return FALSE;
GST_DEBUG_OBJECT (sink, "opened location %s", sink->location);
gst_gio_base_sink_set_stream (GST_GIO_BASE_SINK (sink), stream);
return GST_BASE_SINK_CLASS (parent_class)->start (base_sink);
}

View file

@ -1,68 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifndef __GST_GIO_SINK_H__
#define __GST_GIO_SINK_H__
#include "gstgio.h"
#include "gstgiobasesink.h"
#include <gst/base/gstbasesink.h>
G_BEGIN_DECLS
#define GST_TYPE_GIO_SINK \
(gst_gio_sink_get_type())
#define GST_GIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_SINK,GstGioSink))
#define GST_GIO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_SINK,GstGioSinkClass))
#define GST_IS_GIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_SINK))
#define GST_IS_GIO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_SINK))
typedef struct _GstGioSink GstGioSink;
typedef struct _GstGioSinkClass GstGioSinkClass;
/**
* GstGioSink:
*
* Opaque data structure.
*/
struct _GstGioSink
{
GstGioBaseSink sink;
/*< private >*/
gchar *location;
};
struct _GstGioSinkClass
{
GstGioBaseSinkClass parent_class;
};
GType gst_gio_sink_get_type (void);
G_END_DECLS
#endif /* __GST_GIO_SINK_H__ */

View file

@ -1,204 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
/**
* SECTION:element-giosrc
*
* <refsect2>
* <title>Example launch line</title>
* <para>
* <programlisting>
* gst-launch giosrc location=file:///home/foo/bar.ext ! fakesink
* </programlisting>
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstgiosrc.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_src_debug);
#define GST_CAT_DEFAULT gst_gio_src_debug
enum
{
ARG_0,
ARG_LOCATION
};
GST_BOILERPLATE_FULL (GstGioSrc, gst_gio_src, GstGioBaseSrc,
GST_TYPE_GIO_BASE_SRC, gst_gio_uri_handler_do_init);
static void gst_gio_src_finalize (GObject * object);
static void gst_gio_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gio_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_gio_src_start (GstBaseSrc * base_src);
static void
gst_gio_src_base_init (gpointer gclass)
{
static GstElementDetails element_details = {
"GIO source",
"Source/File",
"Read from any GIO-supported location",
"Ren\xc3\xa9 Stadler <mail@renestadler.de>, "
"Sebastian Dröge <slomo@circular-chaos.org>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
GST_DEBUG_CATEGORY_INIT (gst_gio_src_debug, "gio_src", 0, "GIO source");
gst_element_class_set_details (element_class, &element_details);
}
static void
gst_gio_src_class_init (GstGioSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gobject_class->finalize = gst_gio_src_finalize;
gobject_class->set_property = gst_gio_src_set_property;
gobject_class->get_property = gst_gio_src_get_property;
g_object_class_install_property (gobject_class, ARG_LOCATION,
g_param_spec_string ("location", "Location", "URI location to read from",
NULL, G_PARAM_READWRITE));
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_gio_src_start);
}
static void
gst_gio_src_init (GstGioSrc * src, GstGioSrcClass * gclass)
{
}
static void
gst_gio_src_finalize (GObject * object)
{
GstGioSrc *src = GST_GIO_SRC (object);
if (src->location) {
g_free (src->location);
src->location = NULL;
}
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
static void
gst_gio_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGioSrc *src = GST_GIO_SRC (object);
switch (prop_id) {
case ARG_LOCATION:
if (GST_STATE (src) == GST_STATE_PLAYING ||
GST_STATE (src) == GST_STATE_PAUSED)
break;
g_free (src->location);
src->location = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_gio_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstGioSrc *src = GST_GIO_SRC (object);
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, src->location);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gst_gio_src_start (GstBaseSrc * base_src)
{
GstGioSrc *src = GST_GIO_SRC (base_src);
GFile *file;
GError *err = NULL;
GInputStream *stream;
GCancellable *cancel = GST_GIO_BASE_SRC (src)->cancel;
if (src->location == NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No location given"));
return FALSE;
}
file = g_file_new_for_uri (src->location);
if (file == NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Malformed URI or protocol not supported (%s)", src->location));
return FALSE;
}
stream = G_INPUT_STREAM (g_file_read (file, cancel, &err));
g_object_unref (file);
if (stream == NULL && !gst_gio_error (src, "g_file_read", &err, NULL)) {
if (GST_GIO_ERROR_MATCHES (err, NOT_FOUND))
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
("Could not open location %s for reading: %s",
src->location, err->message));
else
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Could not open location %s for reading: %s",
src->location, err->message));
g_clear_error (&err);
return FALSE;
} else if (stream == NULL) {
return FALSE;
}
gst_gio_base_src_set_stream (GST_GIO_BASE_SRC (src), stream);
GST_DEBUG_OBJECT (src, "opened location %s", src->location);
return GST_BASE_SRC_CLASS (parent_class)->start (base_src);
}

View file

@ -1,68 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifndef __GST_GIO_SRC_H__
#define __GST_GIO_SRC_H__
#include "gstgio.h"
#include "gstgiobasesrc.h"
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#define GST_TYPE_GIO_SRC \
(gst_gio_src_get_type())
#define GST_GIO_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_SRC,GstGioSrc))
#define GST_GIO_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_SRC,GstGioSrcClass))
#define GST_IS_GIO_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_SRC))
#define GST_IS_GIO_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_SRC))
typedef struct _GstGioSrc GstGioSrc;
typedef struct _GstGioSrcClass GstGioSrcClass;
/**
* GstGioSrc:
*
* Opaque data structure.
*/
struct _GstGioSrc
{
GstGioBaseSrc src;
/*< private >*/
gchar *location;
};
struct _GstGioSrcClass
{
GstGioBaseSrcClass parent_class;
};
GType gst_gio_src_get_type (void);
G_END_DECLS
#endif /* __GST_GIO_SRC_H__ */

View file

@ -1,155 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
/**
* SECTION:element-giostreamsink
*
* <refsect2>
* <title>Example launch line</title>
* <para>
* <programlisting>
* gst-launch audiotestsrc num-buffers=100 ! flacenc ! giosink location=file:///home/foo/bar.flac
* </programlisting>
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstgiostreamsink.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_stream_sink_debug);
#define GST_CAT_DEFAULT gst_gio_stream_sink_debug
/* Filter signals and args */
enum
{
LAST_SIGNAL
};
enum
{
ARG_0,
ARG_STREAM
};
GST_BOILERPLATE (GstGioStreamSink, gst_gio_stream_sink, GstGioBaseSink,
GST_TYPE_GIO_BASE_SINK);
static void gst_gio_stream_sink_finalize (GObject * object);
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 void
gst_gio_stream_sink_base_init (gpointer gclass)
{
static GstElementDetails element_details = {
"GIO stream sink",
"Sink",
"Write to any GIO stream",
"Sebastian Dröge <slomo@circular-chaos.org>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
GST_DEBUG_CATEGORY_INIT (gst_gio_stream_sink_debug, "gio_stream_sink", 0,
"GIO stream sink");
gst_element_class_set_details (element_class, &element_details);
}
static void
gst_gio_stream_sink_class_init (GstGioStreamSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSinkClass *gstbasesink_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gobject_class->finalize = gst_gio_stream_sink_finalize;
gobject_class->set_property = gst_gio_stream_sink_set_property;
gobject_class->get_property = gst_gio_stream_sink_get_property;
g_object_class_install_property (gobject_class, ARG_STREAM,
g_param_spec_object ("stream", "Stream", "Stream to write to",
G_TYPE_OUTPUT_STREAM, G_PARAM_READWRITE));
}
static void
gst_gio_stream_sink_init (GstGioStreamSink * sink,
GstGioStreamSinkClass * gclass)
{
}
static void
gst_gio_stream_sink_finalize (GObject * object)
{
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
static void
gst_gio_stream_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGioStreamSink *sink = GST_GIO_STREAM_SINK (object);
switch (prop_id) {
case ARG_STREAM:{
GObject *stream;
if (GST_STATE (sink) == GST_STATE_PLAYING ||
GST_STATE (sink) == GST_STATE_PAUSED)
break;
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));
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_gio_stream_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstGioStreamSink *sink = GST_GIO_STREAM_SINK (object);
switch (prop_id) {
case ARG_STREAM:
g_value_set_object (value, GST_GIO_BASE_SINK (sink)->stream);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}

View file

@ -1,65 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifndef __GST_GIO_STREAM_SINK_H__
#define __GST_GIO_STREAM_SINK_H__
#include "gstgio.h"
#include "gstgiobasesink.h"
#include <gst/base/gstbasesink.h>
G_BEGIN_DECLS
#define GST_TYPE_GIO_STREAM_SINK \
(gst_gio_stream_sink_get_type())
#define GST_GIO_STREAM_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_STREAM_SINK,GstGioStreamSink))
#define GST_GIO_STREAM_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_STREAM_SINK,GstGioStreamSinkClass))
#define GST_IS_GIO_STREAM_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_STREAM_SINK))
#define GST_IS_GIO_STREAM_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_STREAM_SINK))
typedef struct _GstGioStreamSink GstGioStreamSink;
typedef struct _GstGioStreamSinkClass GstGioStreamSinkClass;
/**
* GstGioStreamSink:
*
* Opaque data structure.
*/
struct _GstGioStreamSink
{
GstGioBaseSink sink;
};
struct _GstGioStreamSinkClass
{
GstGioBaseSinkClass parent_class;
};
GType gst_gio_stream_sink_get_type (void);
G_END_DECLS
#endif /* __GST_GIO_STREAM_SINK_H__ */

View file

@ -1,148 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
/**
* SECTION:element-giostreamsrc
*
* <refsect2>
* <title>Example launch line</title>
* <para>
* <programlisting>
* gst-launch giosrc location=file:///home/foo/bar.ext ! fakesink
* </programlisting>
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstgiostreamsrc.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_stream_src_debug);
#define GST_CAT_DEFAULT gst_gio_stream_src_debug
enum
{
ARG_0,
ARG_STREAM
};
GST_BOILERPLATE (GstGioStreamSrc, gst_gio_stream_src, GstGioBaseSrc,
GST_TYPE_GIO_BASE_SRC);
static void gst_gio_stream_src_finalize (GObject * object);
static void gst_gio_stream_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gio_stream_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void
gst_gio_stream_src_base_init (gpointer gclass)
{
static GstElementDetails element_details = {
"GIO stream source",
"Source",
"Read from any GIO stream",
"Sebastian Dröge <slomo@circular-chaos.org>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
GST_DEBUG_CATEGORY_INIT (gst_gio_stream_src_debug, "gio_stream_src", 0,
"GIO source");
gst_element_class_set_details (element_class, &element_details);
}
static void
gst_gio_stream_src_class_init (GstGioStreamSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gobject_class->finalize = gst_gio_stream_src_finalize;
gobject_class->set_property = gst_gio_stream_src_set_property;
gobject_class->get_property = gst_gio_stream_src_get_property;
g_object_class_install_property (gobject_class, ARG_STREAM,
g_param_spec_object ("stream", "Stream", "Stream to read from",
G_TYPE_INPUT_STREAM, G_PARAM_READWRITE));
}
static void
gst_gio_stream_src_init (GstGioStreamSrc * src, GstGioStreamSrcClass * gclass)
{
}
static void
gst_gio_stream_src_finalize (GObject * object)
{
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
static void
gst_gio_stream_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstGioStreamSrc *src = GST_GIO_STREAM_SRC (object);
switch (prop_id) {
case ARG_STREAM:{
GObject *stream;
if (GST_STATE (src) == GST_STATE_PLAYING ||
GST_STATE (src) == GST_STATE_PAUSED)
break;
stream = g_value_dup_object (value);
if (G_IS_INPUT_STREAM (stream))
gst_gio_base_src_set_stream (GST_GIO_BASE_SRC (src),
G_INPUT_STREAM (stream));
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_gio_stream_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstGioStreamSrc *src = GST_GIO_STREAM_SRC (object);
switch (prop_id) {
case ARG_STREAM:
g_value_set_object (value, GST_GIO_BASE_SRC (src)->stream);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}

View file

@ -1,65 +0,0 @@
/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 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
* 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.
*/
#ifndef __GST_GIO_STREAM_SRC_H__
#define __GST_GIO_STREAM_SRC_H__
#include "gstgio.h"
#include "gstgiobasesrc.h"
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#define GST_TYPE_GIO_STREAM_SRC \
(gst_gio_stream_src_get_type())
#define GST_GIO_STREAM_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GIO_STREAM_SRC,GstGioStreamSrc))
#define GST_GIO_STREAM_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GIO_STREAM_SRC,GstGioStreamSrcClass))
#define GST_IS_GIO_STREAM_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GIO_STREAM_SRC))
#define GST_IS_GIO_STREAM_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GIO_STREAM_SRC))
typedef struct _GstGioStreamSrc GstGioStreamSrc;
typedef struct _GstGioStreamSrcClass GstGioStreamSrcClass;
/**
* GstGioStreamSrc:
*
* Opaque data structure.
*/
struct _GstGioStreamSrc
{
GstGioBaseSrc src;
};
struct _GstGioStreamSrcClass
{
GstGioBaseSrcClass parent_class;
};
GType gst_gio_stream_src_get_type (void);
G_END_DECLS
#endif /* __GST_GIO_STREAM_SRC_H__ */

View file

@ -29,12 +29,6 @@ SUPPRESSIONS = $(top_srcdir)/common/gst.supp $(srcdir)/gst-plugins-bad.supp
clean-local: clean-local-check
if USE_GIO
check_gio = pipelines/gio
else
check_gio =
endif
if USE_MPEG2ENC
check_mpeg2enc = elements/mpeg2enc
else
@ -69,7 +63,6 @@ VALGRIND_TESTS_DISABLE = \
check_PROGRAMS = \
generic/states \
$(check_gio) \
$(check_mpeg2enc) \
$(check_neon) \
$(check_soup) \
@ -94,8 +87,5 @@ LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS)
elements_timidity_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
elements_timidity_LDADD = $(GST_BASE_LIBS) $(LDADD)
pipelines_gio_CFLAGS = $(GIO_CFLAGS) $(AM_CFLAGS)
pipelines_gio_LDADD = $(GIO_LIBS) $(LDADD)
elements_souphttpsrc_CFLAGS = $(SOUP_CFLAGS) $(AM_CFLAGS)
elements_souphttpsrc_LDADD = $(SOUP_LIBS) $(LDADD)

View file

@ -1,2 +1 @@
.dirstamp
gio

View file

@ -1,162 +0,0 @@
/* GStreamer
*
* unit test for GIO
*
* Copyright (C) 2007 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
* 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.
*/
#include <gst/check/gstcheck.h>
#include <gst/check/gstbufferstraw.h>
#include <gio/gio.h>
static gboolean got_eos = FALSE;
static gboolean
message_handler (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
got_eos = TRUE;
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
/* Will abort the check */
g_warning ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
GST_START_TEST (test_memory_stream)
{
GMainLoop *loop;
GstElement *bin;
GstElement *src, *sink;
GstBus *bus;
GMemoryInputStream *input;
GMemoryOutputStream *output;
guint8 *in_data;
guint8 *out_data;
gint i;
GstFormat fmt = GST_FORMAT_BYTES;
gint64 duration;
got_eos = FALSE;
in_data = g_new (guint8, 512);
out_data = g_new (guint8, 512);
for (i = 0; i < 512; i++)
in_data[i] = i % 256;
input =
G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (in_data, 512,
(GDestroyNotify) g_free));
output = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (out_data, 512,
(GReallocFunc) g_realloc, (GDestroyNotify) g_free));
loop = g_main_loop_new (NULL, FALSE);
bin = gst_pipeline_new ("bin");
src = gst_element_factory_make ("giostreamsrc", "src");
fail_unless (src != NULL);
g_object_set (G_OBJECT (src), "stream", input, NULL);
sink = gst_element_factory_make ("giostreamsink", "sink");
fail_unless (sink != NULL);
g_object_set (G_OBJECT (sink), "stream", output, NULL);
gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
fail_unless (gst_element_link_many (src, sink, NULL));
bus = gst_element_get_bus (bin);
gst_bus_add_watch (bus, message_handler, loop);
gst_object_unref (bus);
gst_element_set_state (bin, GST_STATE_PAUSED);
fail_unless (gst_element_query_duration (bin, &fmt, &duration));
fail_unless_equals_int (duration, 512);
gst_element_set_state (bin, GST_STATE_PLAYING);
g_main_loop_run (loop);
gst_element_set_state (bin, GST_STATE_NULL);
gst_object_unref (bin);
fail_unless (got_eos);
for (i = 0; i < 512; i++)
fail_unless_equals_int (in_data[i], out_data[i]);
g_object_unref (input);
g_object_unref (output);
g_main_loop_unref (loop);
}
GST_END_TEST;
Suite *
gio_testsuite (void)
{
Suite *s = suite_create ("gio");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_memory_stream);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = gio_testsuite ();
SRunner *sr = srunner_create (s);
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);
srunner_free (sr);
return nf;
}