diff options
Diffstat (limited to 'ext/gio')
-rw-r--r-- | ext/gio/Makefile.am | 29 | ||||
-rw-r--r-- | ext/gio/gstgio.c | 259 | ||||
-rw-r--r-- | ext/gio/gstgio.h | 42 | ||||
-rw-r--r-- | ext/gio/gstgiobasesink.c | 377 | ||||
-rw-r--r-- | ext/gio/gstgiobasesink.h | 71 | ||||
-rw-r--r-- | ext/gio/gstgiobasesrc.c | 447 | ||||
-rw-r--r-- | ext/gio/gstgiobasesrc.h | 72 | ||||
-rw-r--r-- | ext/gio/gstgiosink.c | 319 | ||||
-rw-r--r-- | ext/gio/gstgiosink.h | 68 | ||||
-rw-r--r-- | ext/gio/gstgiosrc.c | 339 | ||||
-rw-r--r-- | ext/gio/gstgiosrc.h | 68 | ||||
-rw-r--r-- | ext/gio/gstgiostreamsink.c | 198 | ||||
-rw-r--r-- | ext/gio/gstgiostreamsink.h | 68 | ||||
-rw-r--r-- | ext/gio/gstgiostreamsrc.c | 191 | ||||
-rw-r--r-- | ext/gio/gstgiostreamsrc.h | 68 |
15 files changed, 0 insertions, 2616 deletions
diff --git a/ext/gio/Makefile.am b/ext/gio/Makefile.am deleted file mode 100644 index 237cfdd2..00000000 --- a/ext/gio/Makefile.am +++ /dev/null @@ -1,29 +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_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) -libgstgio_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(GIO_LIBS) -libgstgio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GIO_LDFLAGS) -libgstgio_la_LIBTOOLFLAGS = --tag=disable-static - -# headers we need but don't want installed -noinst_HEADERS = \ - gstgio.h \ - gstgiobasesink.h \ - gstgiobasesrc.h \ - gstgiosink.h \ - gstgiosrc.h \ - gstgiostreamsink.h \ - gstgiostreamsrc.h - diff --git a/ext/gio/gstgio.c b/ext/gio/gstgio.c deleted file mode 100644 index be0a940b..00000000 --- a/ext/gio/gstgio.c +++ /dev/null @@ -1,259 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * Copyright (C) 2007 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 - * 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" - -#include <string.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 gpointer -_internal_get_supported_protocols (gpointer data) -{ - const gchar *const *schemes; - gchar **our_schemes; - guint num; - gint i, j; - - schemes = g_vfs_get_supported_uri_schemes (g_vfs_get_default ()); - num = g_strv_length ((gchar **) schemes); - - if (num == 0) { - GST_WARNING ("No GIO supported URI schemes found"); - return NULL; - } - - our_schemes = g_new0 (gchar *, num + 1); - - /* - Filter http/https as we can't support the icy stuff with GIO. - * Use souphttpsrc if you need that. - * - Filter cdda as it doesn't support musicbrainz stuff and everything - * else one expects from a cdda source. Use cdparanoiasrc or cdiosrc - * for cdda. - */ - for (i = 0, j = 0; i < num; i++) { - if (strcmp (schemes[i], "http") == 0 || strcmp (schemes[i], "https") == 0 - || strcmp (schemes[i], "cdda") == 0) - continue; - - our_schemes[j] = g_strdup (schemes[i]); - j++; - } - - return our_schemes; -} - -static gchar ** -gst_gio_get_supported_protocols (void) -{ - static GOnce once = G_ONCE_INIT; - - g_once (&once, _internal_get_supported_protocols, NULL); - return (gchar **) once.retval; -} - -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), NULL); - - 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"); - - gst_plugin_add_dependency_simple (plugin, NULL, GIO_MODULE_DIR, NULL, - GST_PLUGIN_DEPENDENCY_FLAG_NONE); - gst_plugin_add_dependency_simple (plugin, "LD_LIBRARY_PATH", GIO_LIBDIR, - "gvfsd", GST_PLUGIN_DEPENDENCY_FLAG_NONE); - - /* 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) diff --git a/ext/gio/gstgio.h b/ext/gio/gstgio.h deleted file mode 100644 index 01183e13..00000000 --- a/ext/gio/gstgio.h +++ /dev/null @@ -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__ */ diff --git a/ext/gio/gstgiobasesink.c b/ext/gio/gstgiobasesink.c deleted file mode 100644 index 2b16909b..00000000 --- a/ext/gio/gstgiobasesink.c +++ /dev/null @@ -1,377 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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 = (GObjectClass *) klass; - GstBaseSinkClass *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); - GstGioBaseSinkClass *gbsink_class = GST_GIO_BASE_SINK_GET_CLASS (sink); - - sink->position = 0; - - /* 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; - } else if (G_UNLIKELY (g_output_stream_is_closed (sink->stream))) { - GST_ELEMENT_ERROR (sink, LIBRARY, FAILED, (NULL), - ("Output stream is already closed")); - return FALSE; - } - - GST_DEBUG_OBJECT (sink, "started sink"); - - return TRUE; -} - -static gboolean -gst_gio_base_sink_stop (GstBaseSink * base_sink) -{ - GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink); - GstGioBaseSinkClass *klass = GST_GIO_BASE_SINK_GET_CLASS (sink); - gboolean success; - GError *err = NULL; - - if (klass->close_on_stop && G_IS_OUTPUT_STREAM (sink->stream)) { - GST_DEBUG_OBJECT (sink, "closing stream"); - - /* FIXME: can block but unfortunately we can't use async operations - * here because they require a running main loop */ - success = g_output_stream_close (sink->stream, sink->cancel, &err); - - if (!success && !gst_gio_error (sink, "g_output_stream_close", &err, NULL)) { - GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL), - ("gio_output_stream_close failed: %s", err->message)); - g_clear_error (&err); - } else if (!success) { - GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL), - ("g_output_stream_close failed")); - } else { - GST_DEBUG_OBJECT (sink, "g_outut_stream_close succeeded"); - } - - g_object_unref (sink->stream); - sink->stream = NULL; - } else { - success = g_output_stream_flush (sink->stream, sink->cancel, &err); - - if (!success && !gst_gio_error (sink, "g_output_stream_flush", &err, NULL)) { - GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL), - ("gio_output_stream_flush failed: %s", err->message)); - g_clear_error (&err); - } else if (!success) { - GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL), - ("g_output_stream_flush failed")); - } else { - GST_DEBUG_OBJECT (sink, "g_outut_stream_flush succeeded"); - } - - 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_GSSIZE_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; - case GST_QUERY_URI: - if (GST_IS_URI_HANDLER (sink)) { - const gchar *uri; - - uri = gst_uri_handler_get_uri (GST_URI_HANDLER (sink)); - gst_query_set_uri (query, uri); - return TRUE; - } - return FALSE; - 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)) { - gboolean success; - GError *err = NULL; - - GST_DEBUG_OBJECT (sink, "closing old stream"); - - /* FIXME: can block but unfortunately we can't use async operations - * here because they require a running main loop */ - success = g_output_stream_close (sink->stream, sink->cancel, &err); - - if (!success && !gst_gio_error (sink, "g_output_stream_close", &err, NULL)) { - GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL), - ("g_output_stream_close failed: %s", err->message)); - g_clear_error (&err); - } else if (!success) { - GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL), - ("g_output_stream_close failed")); - } else { - GST_DEBUG_OBJECT (sink, "g_output_stream_close succeeded"); - } - - g_object_unref (sink->stream); - sink->stream = NULL; - } - - sink->stream = stream; -} diff --git a/ext/gio/gstgiobasesink.h b/ext/gio/gstgiobasesink.h deleted file mode 100644 index 7f13a854..00000000 --- a/ext/gio/gstgiobasesink.h +++ /dev/null @@ -1,71 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GIO_BASE_SINK, GstGioBaseSinkClass)) -#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; - - /* < protected > */ - GCancellable *cancel; - guint64 position; - - /* < private > */ - GOutputStream *stream; -}; - -struct _GstGioBaseSinkClass -{ - GstBaseSinkClass parent_class; - - GOutputStream * (*get_stream) (GstGioBaseSink *bsink); - gboolean close_on_stop; -}; - -GType gst_gio_base_sink_get_type (void); - -G_END_DECLS - -#endif /* __GST_GIO_BASE_SINK_H__ */ diff --git a/ext/gio/gstgiobasesrc.c b/ext/gio/gstgiobasesrc.c deleted file mode 100644 index 133e12c2..00000000 --- a/ext/gio/gstgiobasesrc.c +++ /dev/null @@ -1,447 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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" - -#include <gst/base/gsttypefindhelper.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 gboolean gst_gio_base_src_query (GstBaseSrc * base_src, - GstQuery * query); - -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 = (GObjectClass *) klass; - GstBaseSrcClass *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); - gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_gio_base_src_query); -} - -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; - } - - if (src->cache) { - gst_buffer_unref (src->cache); - src->cache = 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); - GstGioBaseSrcClass *gbsrc_class = GST_GIO_BASE_SRC_GET_CLASS (src); - - src->position = 0; - - /* FIXME: This will likely block */ - src->stream = gbsrc_class->get_stream (src); - if (G_UNLIKELY (!G_IS_INPUT_STREAM (src->stream))) { - GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), - ("No input stream provided by subclass")); - return FALSE; - } else if (G_UNLIKELY (g_input_stream_is_closed (src->stream))) { - GST_ELEMENT_ERROR (src, LIBRARY, FAILED, (NULL), - ("Input stream is already closed")); - return FALSE; - } - - if (G_IS_SEEKABLE (src->stream)) - src->position = g_seekable_tell (G_SEEKABLE (src->stream)); - - GST_DEBUG_OBJECT (src, "started source"); - - return TRUE; -} - -static gboolean -gst_gio_base_src_stop (GstBaseSrc * base_src) -{ - GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src); - GstGioBaseSrcClass *klass = GST_GIO_BASE_SRC_GET_CLASS (src); - gboolean success; - GError *err = NULL; - - if (klass->close_on_stop && G_IS_INPUT_STREAM (src->stream)) { - GST_DEBUG_OBJECT (src, "closing stream"); - - /* FIXME: can block but unfortunately we can't use async operations - * here because they require a running main loop */ - success = g_input_stream_close (src->stream, src->cancel, &err); - - if (!success && !gst_gio_error (src, "g_input_stream_close", &err, NULL)) { - GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL), - ("g_input_stream_close failed: %s", err->message)); - g_clear_error (&err); - } else if (!success) { - GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL), - ("g_input_stream_close failed")); - } else { - GST_DEBUG_OBJECT (src, "g_input_stream_close succeeded"); - } - - g_object_unref (src->stream); - src->stream = NULL; - } else { - 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); - } - } - - 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) -{ - 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; - GstFlowReturn ret = GST_FLOW_OK; - - g_return_val_if_fail (G_IS_INPUT_STREAM (src->stream), GST_FLOW_ERROR); - - /* If we have the requested part in our cache take a subbuffer of that, - * otherwise fill the cache again with at least 4096 bytes from the - * requested offset and return a subbuffer of that. - * - * We need caching because every read/seek operation will need to go - * over DBus if our backend is GVfs and this is painfully slow. */ - if (src->cache && offset >= GST_BUFFER_OFFSET (src->cache) && - offset + size <= GST_BUFFER_OFFSET_END (src->cache)) { - GST_DEBUG_OBJECT (src, "Creating subbuffer from cached buffer: offset %" - G_GUINT64_FORMAT " length %u", offset, size); - - buf = gst_buffer_create_sub (src->cache, - offset - GST_BUFFER_OFFSET (src->cache), size); - - GST_BUFFER_OFFSET (buf) = offset; - GST_BUFFER_OFFSET_END (buf) = offset + size; - GST_BUFFER_SIZE (buf) = size; - } else { - guint cachesize = MAX (4096, size); - gssize read, res; - gboolean success, eos; - GError *err = NULL; - - if (src->cache) { - gst_buffer_unref (src->cache); - src->cache = NULL; - } - - if (G_UNLIKELY (offset != src->position)) { - if (!GST_GIO_STREAM_IS_SEEKABLE (src->stream)) - return GST_FLOW_NOT_SUPPORTED; - - GST_DEBUG_OBJECT (src, "Seeking to position %" G_GUINT64_FORMAT, offset); - ret = gst_gio_seek (src, G_SEEKABLE (src->stream), offset, src->cancel); - - if (ret == GST_FLOW_OK) - src->position = offset; - else - return ret; - } - - src->cache = gst_buffer_try_new_and_alloc (cachesize); - if (G_UNLIKELY (src->cache == NULL)) { - GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", cachesize); - return GST_FLOW_ERROR; - } - - GST_LOG_OBJECT (src, "Reading %u bytes from offset %" G_GUINT64_FORMAT, - cachesize, offset); - - /* GIO sometimes gives less bytes than requested although - * it's not at the end of file. SMB for example only - * supports reads up to 64k. So we loop here until we get at - * at least the requested amount of bytes or a read returns - * nothing. */ - read = 0; - while (size - read > 0 && (res = - g_input_stream_read (G_INPUT_STREAM (src->stream), - GST_BUFFER_DATA (src->cache) + read, cachesize - read, - src->cancel, &err)) > 0) { - read += res; - } - - success = (read >= 0); - eos = (cachesize > 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_SIZE (src->cache) = read; - - GST_BUFFER_OFFSET (src->cache) = offset; - GST_BUFFER_OFFSET_END (src->cache) = offset + read; - - GST_DEBUG_OBJECT (src, "Read successful"); - GST_DEBUG_OBJECT (src, "Creating subbuffer from new " - "cached buffer: offset %" G_GUINT64_FORMAT " length %u", offset, - size); - - buf = gst_buffer_create_sub (src->cache, 0, MIN (size, read)); - - GST_BUFFER_OFFSET (buf) = offset; - GST_BUFFER_OFFSET_END (buf) = offset + MIN (size, read); - GST_BUFFER_SIZE (buf) = MIN (size, read); - } else { - GST_DEBUG_OBJECT (src, "Read not successful"); - gst_buffer_unref (src->cache); - src->cache = NULL; - buf = NULL; - } - - if (eos) - ret = GST_FLOW_UNEXPECTED; - } - - *buf_return = buf; - - return ret; -} - -static gboolean -gst_gio_base_src_query (GstBaseSrc * base_src, GstQuery * query) -{ - gboolean ret = FALSE; - GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src); - - switch (GST_QUERY_TYPE (query)) { - case GST_QUERY_URI: - if (GST_IS_URI_HANDLER (src)) { - const gchar *uri = gst_uri_handler_get_uri (GST_URI_HANDLER (src)); - gst_query_set_uri (query, uri); - ret = TRUE; - } - break; - default: - ret = FALSE; - break; - } - - if (!ret) - ret = GST_BASE_SRC_CLASS (parent_class)->query (base_src, query); - - return ret; -} diff --git a/ext/gio/gstgiobasesrc.h b/ext/gio/gstgiobasesrc.h deleted file mode 100644 index 7a14859c..00000000 --- a/ext/gio/gstgiobasesrc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GIO_BASE_SRC, GstGioBaseSrcClass)) -#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; - - /* < protected > */ - GCancellable *cancel; - guint64 position; - - /* < private > */ - GInputStream *stream; - GstBuffer *cache; -}; - -struct _GstGioBaseSrcClass -{ - GstBaseSrcClass parent_class; - - GInputStream * (*get_stream) (GstGioBaseSrc *bsrc); - gboolean close_on_stop; -}; - -GType gst_gio_base_src_get_type (void); - -G_END_DECLS - -#endif /* __GST_GIO_BASE_SRC_H__ */ diff --git a/ext/gio/gstgiosink.c b/ext/gio/gstgiosink.c deleted file mode 100644 index 69e05e50..00000000 --- a/ext/gio/gstgiosink.c +++ /dev/null @@ -1,319 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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 - * @see_also: #GstFileSink, #GstGnomeVFSSink, #GstGioSrc - * - * This plugin writes incoming data to a local or remote location specified - * by an URI. This location can be specified using any protocol supported by - * the GIO library or it's VFS backends. Common protocols are 'file', 'ftp', - * or 'smb'. - * - * If the URI or #GFile already exists giosink will post a message of - * type %GST_MESSAGE_ELEMENT with name "file-exists" on the bus. The message - * also contains the #GFile and the corresponding URI. - * Applications can use the "file-exists" message to notify the user about - * the problem and to set a different target location or to remove the - * existing file. Note that right after the "file-exists" message a normal - * error message is posted on the bus which should be ignored if "file-exists" - * is handled by the application, for example by calling - * gst_bus_set_flushing(bus, TRUE) after the "file-exists" message was - * received and gst_bus_set_flushing(bus, FALSE) after the problem is - * resolved. - * - * Similar to the "file-exist" message a "not-mounted" message is posted - * on the bus if the target location is not mounted yet and needs to be - * mounted. This message can be used by application to mount the location - * and retry after the location was mounted successfully. - * - * <refsect2> - * <title>Example pipelines</title> - * |[ - * gst-launch -v filesrc location=input.xyz ! giosink location=file:///home/joe/out.xyz - * ]| The above pipeline will simply copy a local file. Instead of giosink, - * we could just as well have used the filesink element here. - * |[ - * gst-launch -v filesrc location=foo.mp3 ! mad ! flacenc ! giosink location=smb://othercomputer/foo.flac - * ]| The above pipeline will re-encode an mp3 file into FLAC format and store - * it on a remote host using the Samba protocol. - * |[ - * gst-launch -v audiotestsrc num-buffers=100 ! vorbisenc ! oggmux ! giosink location=file:///home/foo/bar.ogg - * ]| The above pipeline will encode a 440Hz sine wave to Ogg Vorbis and stores - * it in the home directory of user foo. - * </refsect2> - */ - -/* FIXME: We would like to mount the enclosing volume of an URL - * if it isn't mounted yet but this is possible async-only. - * Unfortunately this requires a running main loop from the - * default context and we can't guarantuee this! - * - * We would also like to do authentication while mounting. - */ - -#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 -{ - PROP_0, - PROP_LOCATION, - PROP_FILE -}; - -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 GOutputStream *gst_gio_sink_get_stream (GstGioBaseSink * base_sink); - -static void -gst_gio_sink_base_init (gpointer gclass) -{ - 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_simple (element_class, "GIO sink", - "Sink/File", - "Write to any GIO-supported location", - "Ren\xc3\xa9 Stadler <mail@renestadler.de>, " - "Sebastian Dröge <sebastian.droege@collabora.co.uk>"); -} - -static void -gst_gio_sink_class_init (GstGioSinkClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GstGioBaseSinkClass *gstgiobasesink_class = (GstGioBaseSinkClass *) 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, PROP_LOCATION, - g_param_spec_string ("location", "Location", "URI location to write to", - NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - /** - * GstGioSink:file - * - * %GFile to write to. - * - * Since: 0.10.20 - **/ - g_object_class_install_property (gobject_class, PROP_FILE, - g_param_spec_object ("file", "File", "GFile to write to", - G_TYPE_FILE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - gstgiobasesink_class->get_stream = - GST_DEBUG_FUNCPTR (gst_gio_sink_get_stream); - gstgiobasesink_class->close_on_stop = TRUE; -} - -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->file) { - g_object_unref (sink->file); - sink->file = 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 PROP_LOCATION:{ - const gchar *uri = NULL; - - if (GST_STATE (sink) == GST_STATE_PLAYING || - GST_STATE (sink) == GST_STATE_PAUSED) { - GST_WARNING - ("Setting a new location or GFile not supported in PLAYING or PAUSED state"); - break; - } - - GST_OBJECT_LOCK (GST_OBJECT (sink)); - if (sink->file) - g_object_unref (sink->file); - - uri = g_value_get_string (value); - - if (uri) { - sink->file = g_file_new_for_uri (uri); - - if (!sink->file) { - GST_ERROR ("Could not create GFile for URI '%s'", uri); - } - } else { - sink->file = NULL; - } - GST_OBJECT_UNLOCK (GST_OBJECT (sink)); - break; - } - case PROP_FILE: - if (GST_STATE (sink) == GST_STATE_PLAYING || - GST_STATE (sink) == GST_STATE_PAUSED) { - GST_WARNING - ("Setting a new location or GFile not supported in PLAYING or PAUSED state"); - break; - } - - GST_OBJECT_LOCK (GST_OBJECT (sink)); - if (sink->file) - g_object_unref (sink->file); - - sink->file = g_value_dup_object (value); - - GST_OBJECT_UNLOCK (GST_OBJECT (sink)); - 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 PROP_LOCATION:{ - gchar *uri; - - GST_OBJECT_LOCK (GST_OBJECT (sink)); - if (sink->file) { - uri = g_file_get_uri (sink->file); - g_value_set_string (value, uri); - g_free (uri); - } else { - g_value_set_string (value, NULL); - } - GST_OBJECT_UNLOCK (GST_OBJECT (sink)); - break; - } - case PROP_FILE: - GST_OBJECT_LOCK (GST_OBJECT (sink)); - g_value_set_object (value, sink->file); - GST_OBJECT_UNLOCK (GST_OBJECT (sink)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static GOutputStream * -gst_gio_sink_get_stream (GstGioBaseSink * bsink) -{ - GstGioSink *sink = GST_GIO_SINK (bsink); - GOutputStream *stream; - GCancellable *cancel = GST_GIO_BASE_SINK (sink)->cancel; - GError *err = NULL; - gchar *uri; - - if (sink->file == NULL) { - GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL), - ("No location or GFile given")); - return NULL; - } - - uri = g_file_get_uri (sink->file); - if (!uri) - uri = g_strdup ("(null)"); - - stream = - G_OUTPUT_STREAM (g_file_create (sink->file, G_FILE_CREATE_NONE, cancel, - &err)); - - if (!stream) { - if (!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", uri, err->message)); - } else if (GST_GIO_ERROR_MATCHES (err, EXISTS)) { - gst_element_post_message (GST_ELEMENT_CAST (sink), - gst_message_new_element (GST_OBJECT_CAST (sink), - gst_structure_new ("file-exists", "file", G_TYPE_FILE, - sink->file, "uri", G_TYPE_STRING, uri, NULL))); - - GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL), - ("Location %s already exists: %s", uri, err->message)); - } else if (GST_GIO_ERROR_MATCHES (err, NOT_MOUNTED)) { - gst_element_post_message (GST_ELEMENT_CAST (sink), - gst_message_new_element (GST_OBJECT_CAST (sink), - gst_structure_new ("not-mounted", "file", G_TYPE_FILE, - sink->file, "uri", G_TYPE_STRING, uri, NULL))); - - GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL), - ("Location %s not mounted: %s", uri, err->message)); - } else { - GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL), - ("Could not open location %s for writing: %s", uri, err->message)); - } - - g_clear_error (&err); - } - g_free (uri); - return NULL; - } - - GST_DEBUG_OBJECT (sink, "opened location %s", uri); - - g_free (uri); - - return stream; -} diff --git a/ext/gio/gstgiosink.h b/ext/gio/gstgiosink.h deleted file mode 100644 index 494d5db3..00000000 --- a/ext/gio/gstgiosink.h +++ /dev/null @@ -1,68 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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 >*/ - GFile *file; -}; - -struct _GstGioSinkClass -{ - GstGioBaseSinkClass parent_class; -}; - -GType gst_gio_sink_get_type (void); - -G_END_DECLS - -#endif /* __GST_GIO_SINK_H__ */ diff --git a/ext/gio/gstgiosrc.c b/ext/gio/gstgiosrc.c deleted file mode 100644 index 5fd810e7..00000000 --- a/ext/gio/gstgiosrc.c +++ /dev/null @@ -1,339 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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 - * @see_also: #GstFileSrc, #GstGnomeVFSSrc, #GstGioSink - * - * This plugin reads data from a local or remote location specified - * by an URI. This location can be specified using any protocol supported by - * the GIO library or it's VFS backends. Common protocols are 'file', 'http', - * 'ftp', or 'smb'. - * - * If an URI or #GFile is not mounted giosrc will post a message of type - * %GST_MESSAGE_ELEMENT with name "not-mounted" on the bus. The message - * also contains the #GFile and the corresponding URI. - * Applications can use the "not-mounted" message to mount the #GFile - * by calling g_file_mount_enclosing_volume() and then restart the - * pipeline after the mounting has succeeded. Note that right after the - * "not-mounted" message a normal error message is posted on the bus which - * should be ignored if "not-mounted" is handled by the application, for - * example by calling gst_bus_set_flushing(bus, TRUE) after the "not-mounted" - * message was received and gst_bus_set_flushing(bus, FALSE) after the - * mounting was successful. - * - * <refsect2> - * <title>Example launch lines</title> - * |[ - * gst-launch -v giosrc location=file:///home/joe/foo.xyz ! fakesink - * ]| The above pipeline will simply read a local file and do nothing with the - * data read. Instead of giosrc, we could just as well have used the - * filesrc element here. - * |[ - * gst-launch -v giosrc location=smb://othercomputer/foo.xyz ! filesink location=/home/joe/foo.xyz - * ]| The above pipeline will copy a file from a remote host to the local file - * system using the Samba protocol. - * |[ - * gst-launch -v giosrc location=http://music.foobar.com/demo.mp3 ! mad ! audioconvert ! audioresample ! alsasink - * ]| The above pipeline will read and decode and play an mp3 file from a - * web server using the http protocol. - * </refsect2> - */ - -/* FIXME: We would like to mount the enclosing volume of an URL - * if it isn't mounted yet but this is possible async-only. - * Unfortunately this requires a running main loop from the - * default context and we can't guarantuee this! - * - * We would also like to do authentication while mounting. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gstgiosrc.h" -#include <string.h> - -GST_DEBUG_CATEGORY_STATIC (gst_gio_src_debug); -#define GST_CAT_DEFAULT gst_gio_src_debug - -enum -{ - PROP_0, - PROP_LOCATION, - PROP_FILE -}; - -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 GInputStream *gst_gio_src_get_stream (GstGioBaseSrc * bsrc); - -static gboolean gst_gio_src_check_get_range (GstBaseSrc * base_src); - -static void -gst_gio_src_base_init (gpointer gclass) -{ - 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_simple (element_class, "GIO source", - "Source/File", - "Read from any GIO-supported location", - "Ren\xc3\xa9 Stadler <mail@renestadler.de>, " - "Sebastian Dröge <sebastian.droege@collabora.co.uk>"); -} - -static void -gst_gio_src_class_init (GstGioSrcClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *) klass; - GstGioBaseSrcClass *gstgiobasesrc_class = (GstGioBaseSrcClass *) 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, PROP_LOCATION, - g_param_spec_string ("location", "Location", "URI location to read from", - NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - /** - * GstGioSrc:file - * - * %GFile to read from. - * - * Since: 0.10.20 - **/ - g_object_class_install_property (gobject_class, PROP_FILE, - g_param_spec_object ("file", "File", "GFile to read from", - G_TYPE_FILE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - gstbasesrc_class->check_get_range = - GST_DEBUG_FUNCPTR (gst_gio_src_check_get_range); - - gstgiobasesrc_class->get_stream = GST_DEBUG_FUNCPTR (gst_gio_src_get_stream); - gstgiobasesrc_class->close_on_stop = TRUE; -} - -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->file) { - g_object_unref (src->file); - src->file = 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 PROP_LOCATION:{ - const gchar *uri = NULL; - - if (GST_STATE (src) == GST_STATE_PLAYING || - GST_STATE (src) == GST_STATE_PAUSED) { - GST_WARNING - ("Setting a new location or GFile not supported in PLAYING or PAUSED state"); - break; - } - - GST_OBJECT_LOCK (GST_OBJECT (src)); - if (src->file) - g_object_unref (src->file); - - uri = g_value_get_string (value); - - if (uri) { - src->file = g_file_new_for_uri (uri); - - if (!src->file) { - GST_ERROR ("Could not create GFile for URI '%s'", uri); - } - } else { - src->file = NULL; - } - GST_OBJECT_UNLOCK (GST_OBJECT (src)); - break; - } - case PROP_FILE: - if (GST_STATE (src) == GST_STATE_PLAYING || - GST_STATE (src) == GST_STATE_PAUSED) { - GST_WARNING - ("Setting a new location or GFile not supported in PLAYING or PAUSED state"); - break; - } - - GST_OBJECT_LOCK (GST_OBJECT (src)); - if (src->file) - g_object_unref (src->file); - - src->file = g_value_dup_object (value); - - GST_OBJECT_UNLOCK (GST_OBJECT (src)); - 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 PROP_LOCATION:{ - gchar *uri; - - GST_OBJECT_LOCK (GST_OBJECT (src)); - if (src->file) { - uri = g_file_get_uri (src->file); - g_value_set_string (value, uri); - g_free (uri); - } else { - g_value_set_string (value, NULL); - } - GST_OBJECT_UNLOCK (GST_OBJECT (src)); - break; - } - case PROP_FILE: - GST_OBJECT_LOCK (GST_OBJECT (src)); - g_value_set_object (value, src->file); - GST_OBJECT_UNLOCK (GST_OBJECT (src)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static gboolean -gst_gio_src_check_get_range (GstBaseSrc * base_src) -{ - GstGioSrc *src = GST_GIO_SRC (base_src); - gchar *scheme; - - if (src->file == NULL) - goto done; - - scheme = g_file_get_uri_scheme (src->file); - if (scheme == NULL) - goto done; - - if (strcmp (scheme, "file") == 0) { - GST_LOG_OBJECT (src, "local URI, assuming random access is possible"); - g_free (scheme); - return TRUE; - } else if (strcmp (scheme, "http") == 0 || strcmp (scheme, "https") == 0) { - GST_LOG_OBJECT (src, "blacklisted protocol '%s', " - "no random access possible", scheme); - g_free (scheme); - return FALSE; - } - - g_free (scheme); - -done: - - GST_DEBUG_OBJECT (src, "undecided about random access, asking base class"); - - return GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS, - check_get_range, (base_src), FALSE); -} - - -static GInputStream * -gst_gio_src_get_stream (GstGioBaseSrc * bsrc) -{ - GstGioSrc *src = GST_GIO_SRC (bsrc); - GError *err = NULL; - GInputStream *stream; - GCancellable *cancel = bsrc->cancel; - gchar *uri = NULL; - - if (src->file == NULL) { - GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), - ("No location or GFile given")); - return NULL; - } - - uri = g_file_get_uri (src->file); - if (!uri) - uri = g_strdup ("(null)"); - - stream = G_INPUT_STREAM (g_file_read (src->file, cancel, &err)); - - 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", uri, err->message)); - } else if (GST_GIO_ERROR_MATCHES (err, NOT_MOUNTED)) { - gst_element_post_message (GST_ELEMENT_CAST (src), - gst_message_new_element (GST_OBJECT_CAST (src), - gst_structure_new ("not-mounted", "file", G_TYPE_FILE, src->file, - "uri", G_TYPE_STRING, uri, NULL))); - - GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), - ("Location %s not mounted: %s", uri, err->message)); - } else { - GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), - ("Could not open location %s for reading: %s", uri, err->message)); - } - - g_free (uri); - g_clear_error (&err); - return NULL; - } else if (stream == NULL) { - g_free (uri); - return NULL; - } - - GST_DEBUG_OBJECT (src, "opened location %s", uri); - g_free (uri); - - return stream; -} diff --git a/ext/gio/gstgiosrc.h b/ext/gio/gstgiosrc.h deleted file mode 100644 index 080d3d8f..00000000 --- a/ext/gio/gstgiosrc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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 >*/ - GFile *file; -}; - -struct _GstGioSrcClass -{ - GstGioBaseSrcClass parent_class; -}; - -GType gst_gio_src_get_type (void); - -G_END_DECLS - -#endif /* __GST_GIO_SRC_H__ */ diff --git a/ext/gio/gstgiostreamsink.c b/ext/gio/gstgiostreamsink.c deleted file mode 100644 index 02dac71f..00000000 --- a/ext/gio/gstgiostreamsink.c +++ /dev/null @@ -1,198 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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 - * - * This plugin writes incoming data to a custom GIO #GOutputStream. - * - * It can, for example, be used to write a stream to memory with a - * #GMemoryOuputStream or to write to a file with a #GFileOuputStream. - * - * <refsect2> - * <title>Example code</title> - * <para> - * The following example writes the received data to a #GMemoryOutputStream. - * |[ - -#include <gst/gst.h> -#include <gio/gio.h> - -... - -GstElement *sink; -GMemoryOuputStream *stream; -// out_data will contain the received data -guint8 *out_data; - -... - -stream = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0, - (GReallocFunc) g_realloc, (GDestroyNotify) g_free)); -sink = gst_element_factory_make ("giostreamsink", "sink"); -g_object_set (G_OBJECT (sink), "stream", stream, NULL); - -... - -// after processing get the written data -out_data = g_memory_ouput_stream_get_data (G_MEMORY_OUTPUT_STREAM (stream)); - -... - - * ]| - * </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 -{ - PROP_0, - PROP_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 GOutputStream *gst_gio_stream_sink_get_stream (GstGioBaseSink * bsink); - -static void -gst_gio_stream_sink_base_init (gpointer gclass) -{ - 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_simple (element_class, "GIO stream sink", - "Sink", - "Write to any GIO stream", - "Sebastian Dröge <sebastian.droege@collabora.co.uk>"); -} - -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; - gobject_class->get_property = gst_gio_stream_sink_get_property; - - 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 -gst_gio_stream_sink_init (GstGioStreamSink * sink, - GstGioStreamSinkClass * gclass) -{ -} - -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)); -} - -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 PROP_STREAM:{ - GObject *stream; - - if (GST_STATE (sink) == GST_STATE_PLAYING || - GST_STATE (sink) == GST_STATE_PAUSED) { - GST_WARNING - ("Setting a new stream not supported in PLAYING or PAUSED state"); - break; - } - - stream = g_value_dup_object (value); - if (sink->stream) - g_object_unref (sink->stream); - sink->stream = 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 PROP_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; - } -} - -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; -} diff --git a/ext/gio/gstgiostreamsink.h b/ext/gio/gstgiostreamsink.h deleted file mode 100644 index 5e6206b5..00000000 --- a/ext/gio/gstgiostreamsink.h +++ /dev/null @@ -1,68 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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; - - /* < private > */ - GOutputStream *stream; -}; - -struct _GstGioStreamSinkClass -{ - GstGioBaseSinkClass parent_class; -}; - -GType gst_gio_stream_sink_get_type (void); - -G_END_DECLS - -#endif /* __GST_GIO_STREAM_SINK_H__ */ diff --git a/ext/gio/gstgiostreamsrc.c b/ext/gio/gstgiostreamsrc.c deleted file mode 100644 index b031de6b..00000000 --- a/ext/gio/gstgiostreamsrc.c +++ /dev/null @@ -1,191 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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 - * - * This plugin reads data from a custom GIO #GInputStream. - * - * It can, for example, be used to read data from memory with a - * #GMemoryInputStream or to read from a file with a - * #GFileInputStream. - * - * <refsect2> - * <title>Example code</title> - * <para> - * The following example reads data from a #GMemoryOutputStream. - * |[ - -#include <gst/gst.h> -#include <gio/gio.h> - -... - -GstElement *src; -GMemoryInputStream *stream; -// in_data will contain the data to send -guint8 *in_data; -gint i; - -... -in_data = g_new (guint8, 512); -for (i = 0; i < 512; i++) - in_data[i] = i % 256; - -stream = G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (in_data, 512, - (GDestroyNotify) g_free)); -src = gst_element_factory_make ("giostreamsrc", "src"); -g_object_set (G_OBJECT (src), "stream", stream, NULL); - -... - - * ]| - * </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 -{ - PROP_0, - PROP_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 GInputStream *gst_gio_stream_src_get_stream (GstGioBaseSrc * bsrc); - -static void -gst_gio_stream_src_base_init (gpointer gclass) -{ - 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_simple (element_class, "GIO stream source", - "Source", - "Read from any GIO stream", - "Sebastian Dröge <sebastian.droege@collabora.co.uk>"); -} - -static void -gst_gio_stream_src_class_init (GstGioStreamSrcClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GstGioBaseSrcClass *gstgiobasesrc_class = (GstGioBaseSrcClass *) 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, PROP_STREAM, - g_param_spec_object ("stream", "Stream", "Stream to read from", - G_TYPE_INPUT_STREAM, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - gstgiobasesrc_class->get_stream = - GST_DEBUG_FUNCPTR (gst_gio_stream_src_get_stream); -} - -static void -gst_gio_stream_src_init (GstGioStreamSrc * src, GstGioStreamSrcClass * gclass) -{ -} - -static void -gst_gio_stream_src_finalize (GObject * object) -{ - GstGioStreamSrc *src = GST_GIO_STREAM_SRC (object); - - if (src->stream) { - g_object_unref (src->stream); - src->stream = NULL; - } - - 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 PROP_STREAM:{ - GObject *stream; - - if (GST_STATE (src) == GST_STATE_PLAYING || - GST_STATE (src) == GST_STATE_PAUSED) { - GST_WARNING - ("Setting a new stream not supported in PLAYING or PAUSED state"); - break; - } - - stream = g_value_dup_object (value); - if (src->stream) - g_object_unref (src->stream); - src->stream = 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 PROP_STREAM: - g_value_set_object (value, src->stream); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static GInputStream * -gst_gio_stream_src_get_stream (GstGioBaseSrc * bsrc) -{ - GstGioStreamSrc *src = GST_GIO_STREAM_SRC (bsrc); - - return (src->stream) ? g_object_ref (src->stream) : NULL; -} diff --git a/ext/gio/gstgiostreamsrc.h b/ext/gio/gstgiostreamsrc.h deleted file mode 100644 index 975a2775..00000000 --- a/ext/gio/gstgiostreamsrc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2007 Rene Stadler <mail@renestadler.de> - * 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 - * 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; - - /* < private > */ - GInputStream *stream; -}; - -struct _GstGioStreamSrcClass -{ - GstGioBaseSrcClass parent_class; -}; - -GType gst_gio_stream_src_get_type (void); - -G_END_DECLS - -#endif /* __GST_GIO_STREAM_SRC_H__ */ |