summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2013-02-15 12:04:46 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2013-02-15 17:16:09 +0100
commit558c7c651ace8b07bb5991d79b049b74084a5e6d (patch)
tree20fc63a6451fa0659baab9a36ea6566f5907617e
parente6e1479b75f2bd45e61852a32b4647fb880c405c (diff)
cache: add cache element stubs
-rw-r--r--configure.ac2
-rw-r--r--gst/cache/Makefile.am28
-rw-r--r--gst/cache/gstcache.c44
-rw-r--r--gst/cache/gstcachesink.c167
-rw-r--r--gst/cache/gstcachesink.h56
-rw-r--r--gst/cache/gstcachesrc.c190
-rw-r--r--gst/cache/gstcachesrc.h56
7 files changed, 543 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 1ff3958c3..df39e5757 100644
--- a/configure.ac
+++ b/configure.ac
@@ -340,6 +340,7 @@ AG_GST_CHECK_PLUGIN(asfmux)
AG_GST_CHECK_PLUGIN(audiovisualizers)
AG_GST_CHECK_PLUGIN(autoconvert)
AG_GST_CHECK_PLUGIN(bayer)
+AG_GST_CHECK_PLUGIN(cache)
AG_GST_CHECK_PLUGIN(camerabin2)
AG_GST_CHECK_PLUGIN(cdxaparse)
AG_GST_CHECK_PLUGIN(coloreffects)
@@ -2213,6 +2214,7 @@ gst/asfmux/Makefile
gst/audiovisualizers/Makefile
gst/autoconvert/Makefile
gst/bayer/Makefile
+gst/cache/Makefile
gst/camerabin2/Makefile
gst/cdxaparse/Makefile
gst/coloreffects/Makefile
diff --git a/gst/cache/Makefile.am b/gst/cache/Makefile.am
new file mode 100644
index 000000000..c9d7f0e30
--- /dev/null
+++ b/gst/cache/Makefile.am
@@ -0,0 +1,28 @@
+plugin_LTLIBRARIES = libgstcache.la
+
+libgstcache_la_SOURCES = \
+ gstcache.c \
+ gstcachesink.c \
+ gstcachesrc.c
+
+libgstcache_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
+ $(GST_CFLAGS)
+libgstcache_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS)
+libgstcache_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstcache_la_LIBTOOLFLAGS = --tag=disable-static
+
+Android.mk: Makefile.am $(BUILT_SOURCES)
+ androgenizer \
+ -:PROJECT libgstcache -:SHARED libgstcache \
+ -:TAGS eng debug \
+ -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+ -:SOURCES $(libgstcache_la_SOURCES) \
+ $(nodist_libgstcache_la_SOURCES) \
+ -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstcache_la_CFLAGS) \
+ -:LDFLAGS $(libgstcache_la_LDFLAGS) \
+ $(libgstcache_la_LIBADD) \
+ $(libgstcache_la_LIBTOOLFLAGS) \
+ -ldl \
+ -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+ LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-1.0' \
+ > $@
diff --git a/gst/cache/gstcache.c b/gst/cache/gstcache.c
new file mode 100644
index 000000000..1efd12b05
--- /dev/null
+++ b/gst/cache/gstcache.c
@@ -0,0 +1,44 @@
+/* GStreamer
+ * Copyright (C) 2013 Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+#include "gstcachesink.h"
+#include "gstcachesrc.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ gst_element_register (plugin, "cachesink", GST_RANK_NONE,
+ gst_cache_sink_get_type ());
+ gst_element_register (plugin, "cachesrc", GST_RANK_NONE,
+ gst_cache_src_get_type ());
+
+ return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ cache,
+ "Elements to read and write to a cache",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/gst/cache/gstcachesink.c b/gst/cache/gstcachesink.c
new file mode 100644
index 000000000..bdc065934
--- /dev/null
+++ b/gst/cache/gstcachesink.c
@@ -0,0 +1,167 @@
+/* GStreamer
+ * Copyright (C) <2013> Wim Taymans <wim.taymans@gmail.com
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+/**
+ * SECTION:element-cachesink
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstcachesink.h"
+
+#include <gst/gst.h>
+
+#include <string.h>
+
+/* signals */
+enum
+{
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0,
+};
+
+GST_DEBUG_CATEGORY_STATIC (cachesink_debug);
+#define GST_CAT_DEFAULT cachesink_debug
+
+static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+#define gst_cache_sink_parent_class parent_class
+G_DEFINE_TYPE (GstCacheSink, gst_cache_sink, GST_TYPE_BASE_SINK);
+
+static void gst_cache_sink_finalize (GObject * object);
+static void gst_cache_sink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cache_sink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_cache_sink_start (GstBaseSink * bsink);
+static gboolean gst_cache_sink_stop (GstBaseSink * bsink);
+static GstFlowReturn gst_cache_sink_render (GstBaseSink * bsink,
+ GstBuffer * buf);
+
+static gboolean gst_cache_sink_unlock (GstBaseSink * bsink);
+static gboolean gst_cache_sink_unlock_stop (GstBaseSink * bsink);
+
+static void
+gst_cache_sink_init (GstCacheSink * sink)
+{
+}
+
+static void
+gst_cache_sink_class_init (GstCacheSinkClass * 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_cache_sink_finalize;
+ gobject_class->set_property = gst_cache_sink_set_property;
+ gobject_class->get_property = gst_cache_sink_get_property;
+
+ gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_cache_sink_start);
+ gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_cache_sink_stop);
+ gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_cache_sink_render);
+ gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_cache_sink_unlock);
+ gstbasesink_class->unlock_stop =
+ GST_DEBUG_FUNCPTR (gst_cache_sink_unlock_stop);
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sinktemplate));
+
+ gst_element_class_set_static_metadata (gstelement_class,
+ "Cache writer Sink",
+ "Sink",
+ "Write buffers into a cache file", "Wim Taymans <wim.taymans@gmail.com>");
+
+ GST_DEBUG_CATEGORY_INIT (cachesink_debug, "cachesink", 0, "Cache sink");
+}
+
+static void
+gst_cache_sink_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/*
+ * Set the value of a property for the server sink.
+ */
+static void
+gst_cache_sink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_cache_sink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static gboolean
+gst_cache_sink_start (GstBaseSink * bsink)
+{
+ return TRUE;
+}
+
+static gboolean
+gst_cache_sink_stop (GstBaseSink * bsink)
+{
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_cache_sink_render (GstBaseSink * bsink, GstBuffer * buf)
+{
+ return GST_FLOW_OK;
+}
+
+static gboolean
+gst_cache_sink_unlock (GstBaseSink * bsink)
+{
+ return TRUE;
+}
+
+static gboolean
+gst_cache_sink_unlock_stop (GstBaseSink * bsink)
+{
+ return TRUE;
+}
diff --git a/gst/cache/gstcachesink.h b/gst/cache/gstcachesink.h
new file mode 100644
index 000000000..149616f96
--- /dev/null
+++ b/gst/cache/gstcachesink.h
@@ -0,0 +1,56 @@
+/* GStreamer
+ * Copyright (C) <2013> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_CACHE_SINK_H__
+#define __GST_CACHE_SINK_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesink.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_CACHE_SINK \
+ (gst_cache_sink_get_type())
+#define GST_CACHE_SINK(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CACHE_SINK,GstCacheSink))
+#define GST_CACHE_SINK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CACHE_SINK,GstCacheSinkClass))
+#define GST_IS_CACHE_SINK(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CACHE_SINK))
+#define GST_IS_CACHE_SINK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CACHE_SINK))
+
+typedef struct _GstCacheSink GstCacheSink;
+typedef struct _GstCacheSinkClass GstCacheSinkClass;
+
+struct _GstCacheSink
+{
+ GstBaseSink element;
+};
+
+struct _GstCacheSinkClass
+{
+ GstBaseSinkClass parent_class;
+};
+
+GType gst_cache_sink_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_CACHE_SINK_H__ */
diff --git a/gst/cache/gstcachesrc.c b/gst/cache/gstcachesrc.c
new file mode 100644
index 000000000..30931d5e9
--- /dev/null
+++ b/gst/cache/gstcachesrc.c
@@ -0,0 +1,190 @@
+/* GStreamer
+ * Copyright (C) <2013> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+/**
+ * SECTION:element-cachesrc
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstcachesrc.h"
+
+#include <gst/gst.h>
+
+#include <string.h>
+
+/* signals */
+enum
+{
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0,
+};
+
+GST_DEBUG_CATEGORY_STATIC (cachesrc_debug);
+#define GST_CAT_DEFAULT cachesrc_debug
+
+static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+#define gst_cache_src_parent_class parent_class
+G_DEFINE_TYPE (GstCacheSrc, gst_cache_src, GST_TYPE_BASE_SRC);
+
+static void gst_cache_src_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cache_src_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_cache_src_finalize (GObject * object);
+static gboolean gst_cache_src_start (GstBaseSrc * bsrc);
+static gboolean gst_cache_src_stop (GstBaseSrc * bsrc);
+static GstFlowReturn gst_cache_src_create (GstBaseSrc * src, guint64 offset,
+ guint size, GstBuffer ** buf);
+static gboolean gst_cache_src_unlock (GstBaseSrc * bsrc);
+static gboolean gst_cache_src_unlock_stop (GstBaseSrc * bsrc);
+static GstStateChangeReturn gst_cache_src_change_state (GstElement * element,
+ GstStateChange transition);
+
+static void
+gst_cache_src_class_init (GstCacheSrcClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+ GstBaseSrcClass *gstbasesrc_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstbasesrc_class = (GstBaseSrcClass *) klass;
+
+ gobject_class->set_property = gst_cache_src_set_property;
+ gobject_class->get_property = gst_cache_src_get_property;
+ gobject_class->finalize = gst_cache_src_finalize;
+
+ gstelement_class->change_state = gst_cache_src_change_state;
+
+ gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_cache_src_start);
+ gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_cache_src_stop);
+ gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_cache_src_unlock);
+ gstbasesrc_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_cache_src_unlock_stop);
+
+ gstbasesrc_class->create = gst_cache_src_create;
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&srctemplate));
+
+ gst_element_class_set_static_metadata (gstelement_class,
+ "Cache reader Source",
+ "Source", "Read from cached data", "Wim Taymans <wim.taymans@gmail.com>");
+
+ GST_DEBUG_CATEGORY_INIT (cachesrc_debug, "cachesrc", 0, "Cached data Source");
+}
+
+static void
+gst_cache_src_init (GstCacheSrc * self)
+{
+}
+
+static void
+gst_cache_src_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static void
+gst_cache_src_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_cache_src_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+gst_cache_src_start (GstBaseSrc * bsrc)
+{
+ return TRUE;
+}
+
+static gboolean
+gst_cache_src_stop (GstBaseSrc * bsrc)
+{
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_cache_src_create (GstBaseSrc * src, guint64 offset, guint size,
+ GstBuffer ** buf)
+{
+ return GST_FLOW_OK;
+}
+
+static GstStateChangeReturn
+gst_cache_src_change_state (GstElement * element, GstStateChange transition)
+{
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+
+ switch (transition) {
+ default:
+ break;
+ }
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ return ret;
+
+ switch (transition) {
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+static gboolean
+gst_cache_src_unlock (GstBaseSrc * bsrc)
+{
+ return TRUE;
+}
+
+static gboolean
+gst_cache_src_unlock_stop (GstBaseSrc * bsrc)
+{
+ return TRUE;
+}
diff --git a/gst/cache/gstcachesrc.h b/gst/cache/gstcachesrc.h
new file mode 100644
index 000000000..216895914
--- /dev/null
+++ b/gst/cache/gstcachesrc.h
@@ -0,0 +1,56 @@
+/* GStreamer
+ * Copyright (C) <2013> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_CACHE_SRC_H__
+#define __GST_CACHE_SRC_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesrc.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_CACHE_SRC \
+ (gst_cache_src_get_type())
+#define GST_CACHE_SRC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CACHE_SRC,GstCacheSrc))
+#define GST_CACHE_SRC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CACHE_SRC,GstCacheSrcClass))
+#define GST_IS_CACHE_SRC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CACHE_SRC))
+#define GST_IS_CACHE_SRC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CACHE_SRC))
+
+typedef struct _GstCacheSrc GstCacheSrc;
+typedef struct _GstCacheSrcClass GstCacheSrcClass;
+
+struct _GstCacheSrc
+{
+ GstBaseSrc element;
+};
+
+struct _GstCacheSrcClass
+{
+ GstBaseSrcClass parent_class;
+};
+
+GType gst_cache_src_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_CACHE_SRC_H__ */