summaryrefslogtreecommitdiff
path: root/gst/inter
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2011-06-03 19:41:33 -0700
committerDavid Schleef <ds@schleef.org>2011-07-04 16:47:50 -0700
commite9f0e275966de64ec994b184498b9d8e2d8560a7 (patch)
treecf91839402e91dcfc316b107135070c4bf284ad5 /gst/inter
parent2573de106218e3b7827d7679ef79ae5eda76d576 (diff)
downloadgstreamer-plugins-bad-e9f0e275966de64ec994b184498b9d8e2d8560a7.tar.gz
inter: new intermediate surface plugin
This set of elements allows easily rendering audio and video to an intermediate surface that is then used as a source in a different pipeline.
Diffstat (limited to 'gst/inter')
-rw-r--r--gst/inter/Makefile.am56
-rw-r--r--gst/inter/gstinter.c51
-rw-r--r--gst/inter/gstinteraudiosink.c342
-rw-r--r--gst/inter/gstinteraudiosink.h58
-rw-r--r--gst/inter/gstinteraudiosrc.c481
-rw-r--r--gst/inter/gstinteraudiosrc.h57
-rw-r--r--gst/inter/gstintersurface.c42
-rw-r--r--gst/inter/gstintersurface.h58
-rw-r--r--gst/inter/gstintertest.c502
-rw-r--r--gst/inter/gstintervideosink.c332
-rw-r--r--gst/inter/gstintervideosink.h58
-rw-r--r--gst/inter/gstintervideosrc.c510
-rw-r--r--gst/inter/gstintervideosrc.h62
13 files changed, 2609 insertions, 0 deletions
diff --git a/gst/inter/Makefile.am b/gst/inter/Makefile.am
new file mode 100644
index 000000000..ce39e50fc
--- /dev/null
+++ b/gst/inter/Makefile.am
@@ -0,0 +1,56 @@
+plugin_LTLIBRARIES = libgstinter.la
+
+noinst_PROGRAMS = gstintertest
+
+libgstinter_la_SOURCES = \
+ gstinteraudiosink.c \
+ gstinteraudiosrc.c \
+ gstintervideosink.c \
+ gstintervideosrc.c \
+ gstinter.c \
+ gstintersurface.c
+
+noinst_HEADERS = \
+ gstinteraudiosink.h \
+ gstinteraudiosrc.h \
+ gstintervideosink.h \
+ gstintervideosrc.h \
+ gstintersurface.h
+
+libgstinter_la_CFLAGS = \
+ $(GST_CFLAGS) \
+ $(GST_PLUGINS_BASE_CFLAGS)
+
+libgstinter_la_LIBADD = \
+ $(GST_LIBS) \
+ $(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@ -lgstaudio-@GST_MAJORMINOR@ \
+ $(LIBM)
+
+libgstinter_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstinter_la_LIBTOOLFLAGS = --tag=disable-static
+
+gstintertest_SOURCES = \
+ gstintertest.c
+
+gstintertest_CFLAGS = \
+ $(GST_CFLAGS) \
+ $(GST_PLUGINS_BASE_CFLAGS)
+
+gstintertest_LDADD = \
+ $(GST_LIBS) \
+ $(GST_PLUGINS_BASE_LIBS) \
+ $(LIBM)
+
+Android.mk: Makefile.am $(BUILT_SOURCES)
+ androgenizer \
+ -:PROJECT libgstinter -:SHARED libgstinter \
+ -:TAGS eng debug \
+ -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+ -:SOURCES $(libgstinter_la_SOURCES) \
+ -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstinter_la_CFLAGS) \
+ -:LDFLAGS $(libgstinter_la_LDFLAGS) \
+ $(libgstinter_la_LIBADD) \
+ -ldl \
+ -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+ LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
+ > $@
diff --git a/gst/inter/gstinter.c b/gst/inter/gstinter.c
new file mode 100644
index 000000000..2ecc71df6
--- /dev/null
+++ b/gst/inter/gstinter.c
@@ -0,0 +1,51 @@
+/* GStreamer
+ * Copyright (C) 2011 FIXME <fixme@example.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 Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstinteraudiosrc.h"
+#include "gstinteraudiosink.h"
+#include "gstintervideosrc.h"
+#include "gstintervideosink.h"
+#include "gstintersurface.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ gst_element_register (plugin, "interaudiosrc", GST_RANK_NONE,
+ GST_TYPE_INTER_AUDIO_SRC);
+ gst_element_register (plugin, "interaudiosink", GST_RANK_NONE,
+ GST_TYPE_INTER_AUDIO_SINK);
+ gst_element_register (plugin, "intervideosrc", GST_RANK_NONE,
+ GST_TYPE_INTER_VIDEO_SRC);
+ gst_element_register (plugin, "intervideosink", GST_RANK_NONE,
+ GST_TYPE_INTER_VIDEO_SINK);
+
+ gst_inter_surface_init ();
+
+ return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "inter",
+ "plugin for inter-pipeline communication",
+ plugin_init, VERSION, "LGPL", PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/gst/inter/gstinteraudiosink.c b/gst/inter/gstinteraudiosink.c
new file mode 100644
index 000000000..d5eb98b0f
--- /dev/null
+++ b/gst/inter/gstinteraudiosink.c
@@ -0,0 +1,342 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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., 51 Franklin Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+/**
+ * SECTION:element-gstinteraudiosink
+ *
+ * The interaudiosink element does FIXME stuff.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v fakesrc ! interaudiosink ! FIXME ! fakesink
+ * ]|
+ * FIXME Describe what the pipeline does.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesink.h>
+#include <gst/audio/audio.h>
+#include "gstinteraudiosink.h"
+#include <string.h>
+
+GST_DEBUG_CATEGORY_STATIC (gst_inter_audio_sink_debug_category);
+#define GST_CAT_DEFAULT gst_inter_audio_sink_debug_category
+
+/* prototypes */
+
+
+static void gst_inter_audio_sink_set_property (GObject * object,
+ guint property_id, const GValue * value, GParamSpec * pspec);
+static void gst_inter_audio_sink_get_property (GObject * object,
+ guint property_id, GValue * value, GParamSpec * pspec);
+static void gst_inter_audio_sink_dispose (GObject * object);
+static void gst_inter_audio_sink_finalize (GObject * object);
+
+static GstCaps *gst_inter_audio_sink_get_caps (GstBaseSink * sink);
+static gboolean gst_inter_audio_sink_set_caps (GstBaseSink * sink,
+ GstCaps * caps);
+static GstFlowReturn gst_inter_audio_sink_buffer_alloc (GstBaseSink * sink,
+ guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
+static void gst_inter_audio_sink_get_times (GstBaseSink * sink,
+ GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
+static gboolean gst_inter_audio_sink_start (GstBaseSink * sink);
+static gboolean gst_inter_audio_sink_stop (GstBaseSink * sink);
+static gboolean gst_inter_audio_sink_unlock (GstBaseSink * sink);
+static gboolean gst_inter_audio_sink_event (GstBaseSink * sink,
+ GstEvent * event);
+static GstFlowReturn gst_inter_audio_sink_preroll (GstBaseSink * sink,
+ GstBuffer * buffer);
+static GstFlowReturn gst_inter_audio_sink_render (GstBaseSink * sink,
+ GstBuffer * buffer);
+static GstStateChangeReturn gst_inter_audio_sink_async_play (GstBaseSink *
+ sink);
+static gboolean gst_inter_audio_sink_activate_pull (GstBaseSink * sink,
+ gboolean active);
+static gboolean gst_inter_audio_sink_unlock_stop (GstBaseSink * sink);
+
+enum
+{
+ PROP_0
+};
+
+/* pad templates */
+
+static GstStaticPadTemplate gst_inter_audio_sink_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
+ );
+
+
+/* class initialization */
+
+#define DEBUG_INIT(bla) \
+ GST_DEBUG_CATEGORY_INIT (gst_inter_audio_sink_debug_category, "interaudiosink", 0, \
+ "debug category for interaudiosink element");
+
+GST_BOILERPLATE_FULL (GstInterAudioSink, gst_inter_audio_sink, GstBaseSink,
+ GST_TYPE_BASE_SINK, DEBUG_INIT);
+
+static void
+gst_inter_audio_sink_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_inter_audio_sink_sink_template));
+
+ gst_element_class_set_details_simple (element_class, "FIXME Long name",
+ "Generic", "FIXME Description", "FIXME <fixme@example.com>");
+}
+
+static void
+gst_inter_audio_sink_class_init (GstInterAudioSinkClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
+
+ gobject_class->set_property = gst_inter_audio_sink_set_property;
+ gobject_class->get_property = gst_inter_audio_sink_get_property;
+ gobject_class->dispose = gst_inter_audio_sink_dispose;
+ gobject_class->finalize = gst_inter_audio_sink_finalize;
+ base_sink_class->get_caps = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_get_caps);
+ base_sink_class->set_caps = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_set_caps);
+ if (0)
+ base_sink_class->buffer_alloc =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_sink_buffer_alloc);
+ base_sink_class->get_times =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_sink_get_times);
+ base_sink_class->start = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_start);
+ base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_stop);
+ base_sink_class->unlock = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_unlock);
+ if (0)
+ base_sink_class->event = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_event);
+ //if (0)
+ base_sink_class->preroll = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_preroll);
+ base_sink_class->render = GST_DEBUG_FUNCPTR (gst_inter_audio_sink_render);
+ if (0)
+ base_sink_class->async_play =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_sink_async_play);
+ if (0)
+ base_sink_class->activate_pull =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_sink_activate_pull);
+ base_sink_class->unlock_stop =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_sink_unlock_stop);
+
+}
+
+static void
+gst_inter_audio_sink_init (GstInterAudioSink * interaudiosink,
+ GstInterAudioSinkClass * interaudiosink_class)
+{
+
+ interaudiosink->sinkpad =
+ gst_pad_new_from_static_template (&gst_inter_audio_sink_sink_template,
+ "sink");
+
+ interaudiosink->surface = gst_inter_surface_get ("default");
+}
+
+void
+gst_inter_audio_sink_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ /* GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_audio_sink_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ /* GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_audio_sink_dispose (GObject * object)
+{
+ /* GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (object); */
+
+ /* clean up as possible. may be called multiple times */
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+void
+gst_inter_audio_sink_finalize (GObject * object)
+{
+ /* GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (object); */
+
+ /* clean up object here */
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+
+static GstCaps *
+gst_inter_audio_sink_get_caps (GstBaseSink * sink)
+{
+
+ return NULL;
+}
+
+static gboolean
+gst_inter_audio_sink_set_caps (GstBaseSink * sink, GstCaps * caps)
+{
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_inter_audio_sink_buffer_alloc (GstBaseSink * sink, guint64 offset,
+ guint size, GstCaps * caps, GstBuffer ** buf)
+{
+
+ return GST_FLOW_ERROR;
+}
+
+static void
+gst_inter_audio_sink_get_times (GstBaseSink * sink, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end)
+{
+ GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (sink);
+
+ if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) {
+ *start = GST_BUFFER_TIMESTAMP (buffer);
+ if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
+ *end = *start + GST_BUFFER_DURATION (buffer);
+ } else {
+ if (interaudiosink->fps_n > 0) {
+ *end = *start +
+ gst_util_uint64_scale_int (GST_SECOND, interaudiosink->fps_d,
+ interaudiosink->fps_n);
+ }
+ }
+ }
+
+
+}
+
+static gboolean
+gst_inter_audio_sink_start (GstBaseSink * sink)
+{
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_sink_stop (GstBaseSink * sink)
+{
+ GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (sink);
+
+ GST_DEBUG ("stop");
+
+ g_mutex_lock (interaudiosink->surface->mutex);
+ gst_adapter_clear (interaudiosink->surface->audio_adapter);
+ g_mutex_unlock (interaudiosink->surface->mutex);
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_sink_unlock (GstBaseSink * sink)
+{
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_sink_event (GstBaseSink * sink, GstEvent * event)
+{
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_inter_audio_sink_preroll (GstBaseSink * sink, GstBuffer * buffer)
+{
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_inter_audio_sink_render (GstBaseSink * sink, GstBuffer * buffer)
+{
+ GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (sink);
+ int n;
+
+ GST_DEBUG ("render %d", GST_BUFFER_SIZE (buffer));
+
+ g_mutex_lock (interaudiosink->surface->mutex);
+ n = gst_adapter_available (interaudiosink->surface->audio_adapter) / 4;
+ if (n > (800 * 2 * 2)) {
+ GST_INFO ("flushing 800 samples");
+ gst_adapter_flush (interaudiosink->surface->audio_adapter, 800 * 4);
+ n -= 800;
+ }
+ gst_adapter_push (interaudiosink->surface->audio_adapter,
+ gst_buffer_ref (buffer));
+ g_mutex_unlock (interaudiosink->surface->mutex);
+
+ return GST_FLOW_OK;
+}
+
+static GstStateChangeReturn
+gst_inter_audio_sink_async_play (GstBaseSink * sink)
+{
+
+ return GST_STATE_CHANGE_SUCCESS;
+}
+
+static gboolean
+gst_inter_audio_sink_activate_pull (GstBaseSink * sink, gboolean active)
+{
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_sink_unlock_stop (GstBaseSink * sink)
+{
+
+ return TRUE;
+}
diff --git a/gst/inter/gstinteraudiosink.h b/gst/inter/gstinteraudiosink.h
new file mode 100644
index 000000000..53597e7c9
--- /dev/null
+++ b/gst/inter/gstinteraudiosink.h
@@ -0,0 +1,58 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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_INTER_AUDIO_SINK_H_
+#define _GST_INTER_AUDIO_SINK_H_
+
+#include <gst/base/gstbasesink.h>
+#include "gstintersurface.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_INTER_AUDIO_SINK (gst_inter_audio_sink_get_type())
+#define GST_INTER_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_INTER_AUDIO_SINK,GstInterAudioSink))
+#define GST_INTER_AUDIO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_INTER_AUDIO_SINK,GstInterAudioSinkClass))
+#define GST_IS_INTER_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_INTER_AUDIO_SINK))
+#define GST_IS_INTER_AUDIO_SINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_INTER_AUDIO_SINK))
+
+typedef struct _GstInterAudioSink GstInterAudioSink;
+typedef struct _GstInterAudioSinkClass GstInterAudioSinkClass;
+
+struct _GstInterAudioSink
+{
+ GstBaseSink base_interaudiosink;
+
+ GstInterSurface *surface;
+
+ GstPad *sinkpad;
+
+ int fps_n;
+ int fps_d;
+};
+
+struct _GstInterAudioSinkClass
+{
+ GstBaseSinkClass base_interaudiosink_class;
+};
+
+GType gst_inter_audio_sink_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gst/inter/gstinteraudiosrc.c b/gst/inter/gstinteraudiosrc.c
new file mode 100644
index 000000000..df7c16f70
--- /dev/null
+++ b/gst/inter/gstinteraudiosrc.c
@@ -0,0 +1,481 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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., 51 Franklin Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+/**
+ * SECTION:element-gstinteraudiosrc
+ *
+ * The interaudiosrc element does FIXME stuff.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v fakesrc ! interaudiosrc ! FIXME ! fakesink
+ * ]|
+ * FIXME Describe what the pipeline does.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesrc.h>
+#include "gstinteraudiosrc.h"
+#include <string.h>
+
+GST_DEBUG_CATEGORY_STATIC (gst_inter_audio_src_debug_category);
+#define GST_CAT_DEFAULT gst_inter_audio_src_debug_category
+
+/* prototypes */
+
+
+static void gst_inter_audio_src_set_property (GObject * object,
+ guint property_id, const GValue * value, GParamSpec * pspec);
+static void gst_inter_audio_src_get_property (GObject * object,
+ guint property_id, GValue * value, GParamSpec * pspec);
+static void gst_inter_audio_src_dispose (GObject * object);
+static void gst_inter_audio_src_finalize (GObject * object);
+
+static GstCaps *gst_inter_audio_src_get_caps (GstBaseSrc * src);
+static gboolean gst_inter_audio_src_set_caps (GstBaseSrc * src, GstCaps * caps);
+static gboolean gst_inter_audio_src_negotiate (GstBaseSrc * src);
+static gboolean gst_inter_audio_src_newsegment (GstBaseSrc * src);
+static gboolean gst_inter_audio_src_start (GstBaseSrc * src);
+static gboolean gst_inter_audio_src_stop (GstBaseSrc * src);
+static void
+gst_inter_audio_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end);
+static gboolean gst_inter_audio_src_is_seekable (GstBaseSrc * src);
+static gboolean gst_inter_audio_src_unlock (GstBaseSrc * src);
+static gboolean gst_inter_audio_src_event (GstBaseSrc * src, GstEvent * event);
+static GstFlowReturn
+gst_inter_audio_src_create (GstBaseSrc * src, guint64 offset, guint size,
+ GstBuffer ** buf);
+static gboolean gst_inter_audio_src_do_seek (GstBaseSrc * src,
+ GstSegment * segment);
+static gboolean gst_inter_audio_src_query (GstBaseSrc * src, GstQuery * query);
+static gboolean gst_inter_audio_src_check_get_range (GstBaseSrc * src);
+static void gst_inter_audio_src_fixate (GstBaseSrc * src, GstCaps * caps);
+static gboolean gst_inter_audio_src_unlock_stop (GstBaseSrc * src);
+static gboolean
+gst_inter_audio_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
+ GstSegment * segment);
+
+enum
+{
+ PROP_0
+};
+
+/* pad templates */
+
+static GstStaticPadTemplate gst_inter_audio_src_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
+ );
+
+
+/* class initialization */
+
+#define DEBUG_INIT(bla) \
+ GST_DEBUG_CATEGORY_INIT (gst_inter_audio_src_debug_category, "interaudiosrc", 0, \
+ "debug category for interaudiosrc element");
+
+GST_BOILERPLATE_FULL (GstInterAudioSrc, gst_inter_audio_src, GstBaseSrc,
+ GST_TYPE_BASE_SRC, DEBUG_INIT);
+
+static void
+gst_inter_audio_src_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_inter_audio_src_src_template));
+
+ gst_element_class_set_details_simple (element_class, "FIXME Long name",
+ "Generic", "FIXME Description", "FIXME <fixme@example.com>");
+}
+
+static void
+gst_inter_audio_src_class_init (GstInterAudioSrcClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstBaseSrcClass *base_src_class = GST_BASE_SRC_CLASS (klass);
+
+ gobject_class->set_property = gst_inter_audio_src_set_property;
+ gobject_class->get_property = gst_inter_audio_src_get_property;
+ gobject_class->dispose = gst_inter_audio_src_dispose;
+ gobject_class->finalize = gst_inter_audio_src_finalize;
+ base_src_class->get_caps = GST_DEBUG_FUNCPTR (gst_inter_audio_src_get_caps);
+ base_src_class->set_caps = GST_DEBUG_FUNCPTR (gst_inter_audio_src_set_caps);
+ if (0)
+ base_src_class->negotiate =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_src_negotiate);
+ base_src_class->newsegment =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_src_newsegment);
+ base_src_class->start = GST_DEBUG_FUNCPTR (gst_inter_audio_src_start);
+ base_src_class->stop = GST_DEBUG_FUNCPTR (gst_inter_audio_src_stop);
+ base_src_class->get_times = GST_DEBUG_FUNCPTR (gst_inter_audio_src_get_times);
+ if (0)
+ base_src_class->is_seekable =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_src_is_seekable);
+ base_src_class->unlock = GST_DEBUG_FUNCPTR (gst_inter_audio_src_unlock);
+ base_src_class->event = GST_DEBUG_FUNCPTR (gst_inter_audio_src_event);
+ base_src_class->create = GST_DEBUG_FUNCPTR (gst_inter_audio_src_create);
+ if (0)
+ base_src_class->do_seek = GST_DEBUG_FUNCPTR (gst_inter_audio_src_do_seek);
+ base_src_class->query = GST_DEBUG_FUNCPTR (gst_inter_audio_src_query);
+ if (0)
+ base_src_class->check_get_range =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_src_check_get_range);
+ base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_inter_audio_src_fixate);
+ if (0)
+ base_src_class->unlock_stop =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_src_unlock_stop);
+ if (0)
+ base_src_class->prepare_seek_segment =
+ GST_DEBUG_FUNCPTR (gst_inter_audio_src_prepare_seek_segment);
+
+
+}
+
+static void
+gst_inter_audio_src_init (GstInterAudioSrc * interaudiosrc,
+ GstInterAudioSrcClass * interaudiosrc_class)
+{
+
+ interaudiosrc->srcpad =
+ gst_pad_new_from_static_template (&gst_inter_audio_src_src_template,
+ "src");
+
+ gst_base_src_set_live (GST_BASE_SRC (interaudiosrc), TRUE);
+ gst_base_src_set_blocksize (GST_BASE_SRC (interaudiosrc), -1);
+
+ interaudiosrc->surface = gst_inter_surface_get ("default");
+}
+
+void
+gst_inter_audio_src_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ /* GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_audio_src_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ /* GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_audio_src_dispose (GObject * object)
+{
+ /* GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (object); */
+
+ /* clean up as possible. may be called multiple times */
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+void
+gst_inter_audio_src_finalize (GObject * object)
+{
+ /* GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (object); */
+
+ /* clean up object here */
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static GstCaps *
+gst_inter_audio_src_get_caps (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "get_caps");
+
+ return NULL;
+}
+
+static gboolean
+gst_inter_audio_src_set_caps (GstBaseSrc * src, GstCaps * caps)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+ const GstStructure *structure;
+ gboolean ret;
+ int sample_rate;
+
+ GST_DEBUG_OBJECT (interaudiosrc, "set_caps");
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ ret = gst_structure_get_int (structure, "rate", &sample_rate);
+ if (ret) {
+ interaudiosrc->sample_rate = sample_rate;
+ }
+
+ return ret;
+}
+
+static gboolean
+gst_inter_audio_src_negotiate (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "negotiate");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_src_newsegment (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "newsegment");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_src_start (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "start");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_src_stop (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "stop");
+
+ return TRUE;
+}
+
+static void
+gst_inter_audio_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "get_times");
+
+ /* for live sources, sync on the timestamp of the buffer */
+ if (gst_base_src_is_live (src)) {
+ GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);
+
+ if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
+ /* get duration to calculate end time */
+ GstClockTime duration = GST_BUFFER_DURATION (buffer);
+
+ if (GST_CLOCK_TIME_IS_VALID (duration)) {
+ *end = timestamp + duration;
+ }
+ *start = timestamp;
+ }
+ } else {
+ *start = -1;
+ *end = -1;
+ }
+}
+
+static gboolean
+gst_inter_audio_src_is_seekable (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "is_seekable");
+
+ return FALSE;
+}
+
+static gboolean
+gst_inter_audio_src_unlock (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "unlock");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_src_event (GstBaseSrc * src, GstEvent * event)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "event");
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_inter_audio_src_create (GstBaseSrc * src, guint64 offset, guint size,
+ GstBuffer ** buf)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+ GstBuffer *buffer;
+ int n;
+
+ GST_DEBUG_OBJECT (interaudiosrc, "create");
+
+ buffer = NULL;
+
+ g_mutex_lock (interaudiosrc->surface->mutex);
+ n = gst_adapter_available (interaudiosrc->surface->audio_adapter) / 4;
+ if (n > 1600 * 2) {
+ GST_DEBUG ("flushing %d samples", 800);
+ gst_adapter_flush (interaudiosrc->surface->audio_adapter, 800 * 4);
+ n -= 800;
+ }
+ if (n > 1600)
+ n = 1600;
+ if (n > 0) {
+ buffer = gst_adapter_take_buffer (interaudiosrc->surface->audio_adapter,
+ n * 4);
+ }
+ g_mutex_unlock (interaudiosrc->surface->mutex);
+
+ if (n < 1600) {
+ GstBuffer *newbuf = gst_buffer_new_and_alloc (1600 * 4);
+
+ GST_DEBUG ("creating %d samples of silence", 1600 - n);
+ memset (GST_BUFFER_DATA (newbuf) + n * 4, 0, 1600 * 4 - n * 4);
+ if (buffer) {
+ memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (buffer), n * 4);
+ gst_buffer_unref (buffer);
+ }
+ buffer = newbuf;
+ }
+ n = 1600;
+
+ GST_BUFFER_OFFSET (buffer) = interaudiosrc->n_samples;
+ GST_BUFFER_OFFSET_END (buffer) = interaudiosrc->n_samples + n;
+ GST_BUFFER_TIMESTAMP (buffer) =
+ gst_util_uint64_scale_int (interaudiosrc->n_samples, GST_SECOND,
+ interaudiosrc->sample_rate);
+ GST_DEBUG_OBJECT (interaudiosrc, "create ts %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+ GST_BUFFER_DURATION (buffer) =
+ gst_util_uint64_scale_int (interaudiosrc->n_samples + n, GST_SECOND,
+ interaudiosrc->sample_rate) - GST_BUFFER_TIMESTAMP (buffer);
+ GST_BUFFER_OFFSET (buffer) = interaudiosrc->n_samples;
+ GST_BUFFER_OFFSET_END (buffer) = -1;
+ GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DISCONT);
+ if (interaudiosrc->n_samples == 0) {
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
+ }
+ gst_buffer_set_caps (buffer, GST_PAD_CAPS (GST_BASE_SRC_PAD (interaudiosrc)));
+ interaudiosrc->n_samples += n;
+
+ *buf = buffer;
+
+ return GST_FLOW_OK;
+}
+
+static gboolean
+gst_inter_audio_src_do_seek (GstBaseSrc * src, GstSegment * segment)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "do_seek");
+
+ return FALSE;
+}
+
+static gboolean
+gst_inter_audio_src_query (GstBaseSrc * src, GstQuery * query)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "query");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_src_check_get_range (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "get_range");
+
+ return FALSE;
+}
+
+static void
+gst_inter_audio_src_fixate (GstBaseSrc * src, GstCaps * caps)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+ GstStructure *structure;
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "fixate");
+
+ gst_structure_fixate_field_nearest_int (structure, "channels", 2);
+ gst_structure_fixate_field_nearest_int (structure, "rate", 48000);
+
+}
+
+static gboolean
+gst_inter_audio_src_unlock_stop (GstBaseSrc * src)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "stop");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_audio_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
+ GstSegment * segment)
+{
+ GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
+
+ GST_DEBUG_OBJECT (interaudiosrc, "seek_segment");
+
+ return FALSE;
+}
diff --git a/gst/inter/gstinteraudiosrc.h b/gst/inter/gstinteraudiosrc.h
new file mode 100644
index 000000000..cac928f70
--- /dev/null
+++ b/gst/inter/gstinteraudiosrc.h
@@ -0,0 +1,57 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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_INTER_AUDIO_SRC_H_
+#define _GST_INTER_AUDIO_SRC_H_
+
+#include <gst/base/gstbasesrc.h>
+#include "gstintersurface.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_INTER_AUDIO_SRC (gst_inter_audio_src_get_type())
+#define GST_INTER_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_INTER_AUDIO_SRC,GstInterAudioSrc))
+#define GST_INTER_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_INTER_AUDIO_SRC,GstInterAudioSrcClass))
+#define GST_IS_INTER_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_INTER_AUDIO_SRC))
+#define GST_IS_INTER_AUDIO_SRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_INTER_AUDIO_SRC))
+
+typedef struct _GstInterAudioSrc GstInterAudioSrc;
+typedef struct _GstInterAudioSrcClass GstInterAudioSrcClass;
+
+struct _GstInterAudioSrc
+{
+ GstBaseSrc base_interaudiosrc;
+
+ GstPad *srcpad;
+ GstInterSurface *surface;
+
+ guint64 n_samples;
+ int sample_rate;
+};
+
+struct _GstInterAudioSrcClass
+{
+ GstBaseSrcClass base_interaudiosrc_class;
+};
+
+GType gst_inter_audio_src_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gst/inter/gstintersurface.c b/gst/inter/gstintersurface.c
new file mode 100644
index 000000000..9a43fb9a4
--- /dev/null
+++ b/gst/inter/gstintersurface.c
@@ -0,0 +1,42 @@
+/* GStreamer
+ * Copyright (C) 2011 FIXME <fixme@example.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 Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstintersurface.h"
+
+static GstInterSurface *surface;
+
+
+GstInterSurface *
+gst_inter_surface_get (const char *name)
+{
+ return surface;
+
+}
+
+void
+gst_inter_surface_init (void)
+{
+ surface = g_malloc0 (sizeof (GstInterSurface));
+ surface->mutex = g_mutex_new ();
+ surface->audio_adapter = gst_adapter_new ();
+}
diff --git a/gst/inter/gstintersurface.h b/gst/inter/gstintersurface.h
new file mode 100644
index 000000000..92440448a
--- /dev/null
+++ b/gst/inter/gstintersurface.h
@@ -0,0 +1,58 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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_INTER_SURFACE_H_
+#define _GST_INTER_SURFACE_H_
+
+#include <gst/base/gstadapter.h>
+#include <gst/video/video.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GstInterSurface GstInterSurface;
+
+struct _GstInterSurface
+{
+ GMutex *mutex;
+
+ /* video */
+ GstVideoFormat format;
+ int fps_n;
+ int fps_d;
+ int width;
+ int height;
+ int n_frames;
+ int video_buffer_count;
+
+ /* audio */
+ int sample_rate;
+ int n_channels;
+
+ GstBuffer *video_buffer;
+ GstAdapter *audio_adapter;
+};
+
+
+GstInterSurface * gst_inter_surface_get (const char *name);
+void gst_inter_surface_init (void);
+
+
+G_END_DECLS
+
+#endif
diff --git a/gst/inter/gstintertest.c b/gst/inter/gstintertest.c
new file mode 100644
index 000000000..cb7b08c66
--- /dev/null
+++ b/gst/inter/gstintertest.c
@@ -0,0 +1,502 @@
+/* GstInterTest
+ * Copyright (C) 2011 FIXME <fixme@example.com>
+ * Copyright (C) 2010 Entropy Wave Inc
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <stdlib.h>
+
+//#define GETTEXT_PACKAGE "intertest"
+
+
+typedef struct _GstInterTest GstInterTest;
+struct _GstInterTest
+{
+ GstElement *pipeline;
+ GstBus *bus;
+ GMainLoop *main_loop;
+
+ GstElement *source_element;
+ GstElement *sink_element;
+
+ gboolean paused_for_buffering;
+ guint timer_id;
+};
+
+GstInterTest *gst_inter_test_new (void);
+void gst_inter_test_free (GstInterTest * intertest);
+void gst_inter_test_create_pipeline_server (GstInterTest * intertest);
+void gst_inter_test_create_pipeline_vts (GstInterTest * intertest);
+void gst_inter_test_create_pipeline_playbin (GstInterTest * intertest,
+ const char *uri);
+void gst_inter_test_start (GstInterTest * intertest);
+void gst_inter_test_stop (GstInterTest * intertest);
+
+static gboolean gst_inter_test_handle_message (GstBus * bus,
+ GstMessage * message, gpointer data);
+static gboolean onesecond_timer (gpointer priv);
+
+
+gboolean verbose;
+
+static GOptionEntry entries[] = {
+ {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL},
+
+ {NULL}
+
+};
+
+int
+main (int argc, char *argv[])
+{
+ GError *error = NULL;
+ GOptionContext *context;
+ GstInterTest *intertest1;
+ GstInterTest *intertest2;
+ GMainLoop *main_loop;
+
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
+ context = g_option_context_new ("- FIXME");
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, gst_init_get_option_group ());
+ if (!g_option_context_parse (context, &argc, &argv, &error)) {
+ g_print ("option parsing failed: %s\n", error->message);
+ exit (1);
+ }
+ g_option_context_free (context);
+
+ intertest1 = gst_inter_test_new ();
+ gst_inter_test_create_pipeline_server (intertest1);
+ gst_inter_test_start (intertest1);
+
+ intertest2 = gst_inter_test_new ();
+ gst_inter_test_create_pipeline_playbin (intertest2, NULL);
+ gst_inter_test_start (intertest2);
+
+ main_loop = g_main_loop_new (NULL, TRUE);
+ intertest1->main_loop = main_loop;
+ intertest2->main_loop = main_loop;
+
+ g_main_loop_run (main_loop);
+
+ exit (0);
+}
+
+
+GstInterTest *
+gst_inter_test_new (void)
+{
+ GstInterTest *intertest;
+
+ intertest = g_new0 (GstInterTest, 1);
+
+ return intertest;
+}
+
+void
+gst_inter_test_free (GstInterTest * intertest)
+{
+ if (intertest->source_element) {
+ gst_object_unref (intertest->source_element);
+ intertest->source_element = NULL;
+ }
+ if (intertest->sink_element) {
+ gst_object_unref (intertest->sink_element);
+ intertest->sink_element = NULL;
+ }
+
+ if (intertest->pipeline) {
+ gst_element_set_state (intertest->pipeline, GST_STATE_NULL);
+ gst_object_unref (intertest->pipeline);
+ intertest->pipeline = NULL;
+ }
+ g_free (intertest);
+}
+
+void
+gst_inter_test_create_pipeline_playbin (GstInterTest * intertest,
+ const char *uri)
+{
+ GstElement *pipeline;
+ GError *error = NULL;
+
+ if (uri == NULL) {
+ gst_inter_test_create_pipeline_vts (intertest);
+ return;
+ }
+
+ pipeline = gst_pipeline_new (NULL);
+ gst_bin_add (GST_BIN (pipeline),
+ gst_element_factory_make ("playbin2", "source"));
+
+ if (error) {
+ g_print ("pipeline parsing error: %s\n", error->message);
+ gst_object_unref (pipeline);
+ return;
+ }
+
+ intertest->pipeline = pipeline;
+
+ gst_pipeline_set_auto_flush_bus (GST_PIPELINE (pipeline), FALSE);
+ intertest->bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+ gst_bus_add_watch (intertest->bus, gst_inter_test_handle_message, intertest);
+
+ intertest->source_element =
+ gst_bin_get_by_name (GST_BIN (pipeline), "source");
+ g_print ("source_element is %p\n", intertest->source_element);
+
+ g_print ("setting uri to %s\n", uri);
+ g_object_set (intertest->source_element, "uri", uri, NULL);
+}
+
+void
+gst_inter_test_create_pipeline_vts (GstInterTest * intertest)
+{
+ GString *pipe_desc;
+ GstElement *pipeline;
+ GError *error = NULL;
+
+ pipe_desc = g_string_new ("");
+
+ g_string_append (pipe_desc, "videotestsrc name=source num-buffers=10000 ! ");
+ g_string_append (pipe_desc,
+ "video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! ");
+ g_string_append (pipe_desc, "timeoverlay ! ");
+ g_string_append (pipe_desc, "intervideosink name=sink sync=true ");
+ g_string_append (pipe_desc,
+ "audiotestsrc samplesperbuffer=1600 num-buffers=100 ! ");
+ g_string_append (pipe_desc, "interaudiosink ");
+
+ if (verbose)
+ g_print ("pipeline: %s\n", pipe_desc->str);
+
+ pipeline = (GstElement *) gst_parse_launch (pipe_desc->str, &error);
+ g_string_free (pipe_desc, FALSE);
+
+ if (error) {
+ g_print ("pipeline parsing error: %s\n", error->message);
+ gst_object_unref (pipeline);
+ return;
+ }
+
+ intertest->pipeline = pipeline;
+
+ gst_pipeline_set_auto_flush_bus (GST_PIPELINE (pipeline), FALSE);
+ intertest->bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+ gst_bus_add_watch (intertest->bus, gst_inter_test_handle_message, intertest);
+
+ intertest->source_element =
+ gst_bin_get_by_name (GST_BIN (pipeline), "source");
+ intertest->sink_element = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
+}
+
+void
+gst_inter_test_create_pipeline_server (GstInterTest * intertest)
+{
+ GString *pipe_desc;
+ GstElement *pipeline;
+ GError *error = NULL;
+
+ pipe_desc = g_string_new ("");
+
+ g_string_append (pipe_desc, "intervideosrc ! queue ! ");
+ g_string_append (pipe_desc, "xvimagesink name=sink ");
+ g_string_append (pipe_desc, "interaudiosrc ! queue ! ");
+ g_string_append (pipe_desc, "alsasink latency-time=100000000 ");
+
+ if (verbose)
+ g_print ("pipeline: %s\n", pipe_desc->str);
+
+ pipeline = (GstElement *) gst_parse_launch (pipe_desc->str, &error);
+ g_string_free (pipe_desc, FALSE);
+
+ if (error) {
+ g_print ("pipeline parsing error: %s\n", error->message);
+ gst_object_unref (pipeline);
+ return;
+ }
+
+ intertest->pipeline = pipeline;
+
+ gst_pipeline_set_auto_flush_bus (GST_PIPELINE (pipeline), FALSE);
+ intertest->bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+ gst_bus_add_watch (intertest->bus, gst_inter_test_handle_message, intertest);
+
+ intertest->source_element =
+ gst_bin_get_by_name (GST_BIN (pipeline), "source");
+ intertest->sink_element = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
+}
+
+void
+gst_inter_test_start (GstInterTest * intertest)
+{
+ gst_element_set_state (intertest->pipeline, GST_STATE_READY);
+
+ intertest->timer_id = g_timeout_add (1000, onesecond_timer, intertest);
+}
+
+void
+gst_inter_test_stop (GstInterTest * intertest)
+{
+ gst_element_set_state (intertest->pipeline, GST_STATE_NULL);
+
+ g_source_remove (intertest->timer_id);
+}
+
+static void
+gst_inter_test_handle_eos (GstInterTest * intertest)
+{
+ gst_inter_test_stop (intertest);
+}
+
+static void
+gst_inter_test_handle_error (GstInterTest * intertest, GError * error,
+ const char *debug)
+{
+ g_print ("error: %s\n", error->message);
+ gst_inter_test_stop (intertest);
+}
+
+static void
+gst_inter_test_handle_warning (GstInterTest * intertest, GError * error,
+ const char *debug)
+{
+ g_print ("warning: %s\n", error->message);
+}
+
+static void
+gst_inter_test_handle_info (GstInterTest * intertest, GError * error,
+ const char *debug)
+{
+ g_print ("info: %s\n", error->message);
+}
+
+static void
+gst_inter_test_handle_null_to_ready (GstInterTest * intertest)
+{
+ gst_element_set_state (intertest->pipeline, GST_STATE_PAUSED);
+
+}
+
+static void
+gst_inter_test_handle_ready_to_paused (GstInterTest * intertest)
+{
+ if (!intertest->paused_for_buffering) {
+ gst_element_set_state (intertest->pipeline, GST_STATE_PLAYING);
+ }
+}
+
+static void
+gst_inter_test_handle_paused_to_playing (GstInterTest * intertest)
+{
+
+}
+
+static void
+gst_inter_test_handle_playing_to_paused (GstInterTest * intertest)
+{
+
+}
+
+static void
+gst_inter_test_handle_paused_to_ready (GstInterTest * intertest)
+{
+
+}
+
+static void
+gst_inter_test_handle_ready_to_null (GstInterTest * intertest)
+{
+ g_main_loop_quit (intertest->main_loop);
+
+}
+
+
+static gboolean
+gst_inter_test_handle_message (GstBus * bus, GstMessage * message,
+ gpointer data)
+{
+ GstInterTest *intertest = (GstInterTest *) data;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_EOS:
+ gst_inter_test_handle_eos (intertest);
+ break;
+ case GST_MESSAGE_ERROR:
+ {
+ GError *error = NULL;
+ gchar *debug;
+
+ gst_message_parse_error (message, &error, &debug);
+ gst_inter_test_handle_error (intertest, error, debug);
+ }
+ break;
+ case GST_MESSAGE_WARNING:
+ {
+ GError *error = NULL;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &error, &debug);
+ gst_inter_test_handle_warning (intertest, error, debug);
+ }
+ break;
+ case GST_MESSAGE_INFO:
+ {
+ GError *error = NULL;
+ gchar *debug;
+
+ gst_message_parse_info (message, &error, &debug);
+ gst_inter_test_handle_info (intertest, error, debug);
+ }
+ break;
+ case GST_MESSAGE_TAG:
+ {
+ GstTagList *tag_list;
+
+ gst_message_parse_tag (message, &tag_list);
+ if (verbose)
+ g_print ("tag\n");
+ }
+ break;
+ case GST_MESSAGE_STATE_CHANGED:
+ {
+ GstState oldstate, newstate, pending;
+
+ gst_message_parse_state_changed (message, &oldstate, &newstate, &pending);
+ if (GST_ELEMENT (message->src) == intertest->pipeline) {
+ if (verbose)
+ g_print ("state change from %s to %s\n",
+ gst_element_state_get_name (oldstate),
+ gst_element_state_get_name (newstate));
+ switch (GST_STATE_TRANSITION (oldstate, newstate)) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ gst_inter_test_handle_null_to_ready (intertest);
+ break;
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ gst_inter_test_handle_ready_to_paused (intertest);
+ break;
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
+ gst_inter_test_handle_paused_to_playing (intertest);
+ break;
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+ gst_inter_test_handle_playing_to_paused (intertest);
+ break;
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ gst_inter_test_handle_paused_to_ready (intertest);
+ break;
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ gst_inter_test_handle_ready_to_null (intertest);
+ break;
+ default:
+ if (verbose)
+ g_print ("unknown state change from %s to %s\n",
+ gst_element_state_get_name (oldstate),
+ gst_element_state_get_name (newstate));
+ }
+ }
+ }
+ break;
+ case GST_MESSAGE_BUFFERING:
+ {
+ int percent;
+ gst_message_parse_buffering (message, &percent);
+ //g_print("buffering %d\n", percent);
+ if (!intertest->paused_for_buffering && percent < 100) {
+ g_print ("pausing for buffing\n");
+ intertest->paused_for_buffering = TRUE;
+ gst_element_set_state (intertest->pipeline, GST_STATE_PAUSED);
+ } else if (intertest->paused_for_buffering && percent == 100) {
+ g_print ("unpausing for buffing\n");
+ intertest->paused_for_buffering = FALSE;
+ gst_element_set_state (intertest->pipeline, GST_STATE_PLAYING);
+ }
+ }
+ break;
+ case GST_MESSAGE_STATE_DIRTY:
+ case GST_MESSAGE_CLOCK_PROVIDE:
+ case GST_MESSAGE_CLOCK_LOST:
+ case GST_MESSAGE_NEW_CLOCK:
+ case GST_MESSAGE_STRUCTURE_CHANGE:
+ case GST_MESSAGE_STREAM_STATUS:
+ break;
+ case GST_MESSAGE_STEP_DONE:
+ case GST_MESSAGE_APPLICATION:
+ case GST_MESSAGE_ELEMENT:
+ case GST_MESSAGE_SEGMENT_START:
+ case GST_MESSAGE_SEGMENT_DONE:
+ case GST_MESSAGE_DURATION:
+ case GST_MESSAGE_LATENCY:
+ case GST_MESSAGE_ASYNC_START:
+ case GST_MESSAGE_ASYNC_DONE:
+ case GST_MESSAGE_REQUEST_STATE:
+ case GST_MESSAGE_STEP_START:
+ default:
+ if (verbose) {
+ g_print ("message: %s\n", GST_MESSAGE_TYPE_NAME (message));
+ }
+ break;
+ case GST_MESSAGE_QOS:
+ break;
+ }
+
+ return TRUE;
+}
+
+
+
+static gboolean
+onesecond_timer (gpointer priv)
+{
+ //GstInterTest *intertest = (GstInterTest *)priv;
+
+ g_print (".\n");
+
+ return TRUE;
+}
+
+
+
+/* helper functions */
+
+#if 0
+gboolean
+have_element (const gchar * element_name)
+{
+ GstPluginFeature *feature;
+
+ feature = gst_default_registry_find_feature (element_name,
+ GST_TYPE_ELEMENT_FACTORY);
+ if (feature) {
+ g_object_unref (feature);
+ return TRUE;
+ }
+ return FALSE;
+}
+#endif
diff --git a/gst/inter/gstintervideosink.c b/gst/inter/gstintervideosink.c
new file mode 100644
index 000000000..940d7b27e
--- /dev/null
+++ b/gst/inter/gstintervideosink.c
@@ -0,0 +1,332 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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., 51 Franklin Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+/**
+ * SECTION:element-gstintervideosink
+ *
+ * The intervideosink element does FIXME stuff.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v fakesrc ! intervideosink ! FIXME ! fakesink
+ * ]|
+ * FIXME Describe what the pipeline does.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesink.h>
+#include <gst/video/video.h>
+#include "gstintervideosink.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_inter_video_sink_debug_category);
+#define GST_CAT_DEFAULT gst_inter_video_sink_debug_category
+
+/* prototypes */
+
+
+static void gst_inter_video_sink_set_property (GObject * object,
+ guint property_id, const GValue * value, GParamSpec * pspec);
+static void gst_inter_video_sink_get_property (GObject * object,
+ guint property_id, GValue * value, GParamSpec * pspec);
+static void gst_inter_video_sink_dispose (GObject * object);
+static void gst_inter_video_sink_finalize (GObject * object);
+
+static GstCaps *gst_inter_video_sink_get_caps (GstBaseSink * sink);
+static gboolean gst_inter_video_sink_set_caps (GstBaseSink * sink,
+ GstCaps * caps);
+static GstFlowReturn gst_inter_video_sink_buffer_alloc (GstBaseSink * sink,
+ guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
+static void gst_inter_video_sink_get_times (GstBaseSink * sink,
+ GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
+static gboolean gst_inter_video_sink_start (GstBaseSink * sink);
+static gboolean gst_inter_video_sink_stop (GstBaseSink * sink);
+static gboolean gst_inter_video_sink_unlock (GstBaseSink * sink);
+static gboolean gst_inter_video_sink_event (GstBaseSink * sink,
+ GstEvent * event);
+static GstFlowReturn gst_inter_video_sink_preroll (GstBaseSink * sink,
+ GstBuffer * buffer);
+static GstFlowReturn gst_inter_video_sink_render (GstBaseSink * sink,
+ GstBuffer * buffer);
+static GstStateChangeReturn gst_inter_video_sink_async_play (GstBaseSink *
+ sink);
+static gboolean gst_inter_video_sink_activate_pull (GstBaseSink * sink,
+ gboolean active);
+static gboolean gst_inter_video_sink_unlock_stop (GstBaseSink * sink);
+
+enum
+{
+ PROP_0
+};
+
+/* pad templates */
+
+static GstStaticPadTemplate gst_inter_video_sink_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
+
+
+/* class initialization */
+
+#define DEBUG_INIT(bla) \
+ GST_DEBUG_CATEGORY_INIT (gst_inter_video_sink_debug_category, "intervideosink", 0, \
+ "debug category for intervideosink element");
+
+GST_BOILERPLATE_FULL (GstInterVideoSink, gst_inter_video_sink, GstBaseSink,
+ GST_TYPE_BASE_SINK, DEBUG_INIT);
+
+static void
+gst_inter_video_sink_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_inter_video_sink_sink_template));
+
+ gst_element_class_set_details_simple (element_class, "FIXME Long name",
+ "Generic", "FIXME Description", "FIXME <fixme@example.com>");
+}
+
+static void
+gst_inter_video_sink_class_init (GstInterVideoSinkClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
+
+ gobject_class->set_property = gst_inter_video_sink_set_property;
+ gobject_class->get_property = gst_inter_video_sink_get_property;
+ gobject_class->dispose = gst_inter_video_sink_dispose;
+ gobject_class->finalize = gst_inter_video_sink_finalize;
+ base_sink_class->get_caps = GST_DEBUG_FUNCPTR (gst_inter_video_sink_get_caps);
+ base_sink_class->set_caps = GST_DEBUG_FUNCPTR (gst_inter_video_sink_set_caps);
+ if (0)
+ base_sink_class->buffer_alloc =
+ GST_DEBUG_FUNCPTR (gst_inter_video_sink_buffer_alloc);
+ base_sink_class->get_times =
+ GST_DEBUG_FUNCPTR (gst_inter_video_sink_get_times);
+ base_sink_class->start = GST_DEBUG_FUNCPTR (gst_inter_video_sink_start);
+ base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_inter_video_sink_stop);
+ base_sink_class->unlock = GST_DEBUG_FUNCPTR (gst_inter_video_sink_unlock);
+ if (0)
+ base_sink_class->event = GST_DEBUG_FUNCPTR (gst_inter_video_sink_event);
+ //if (0)
+ base_sink_class->preroll = GST_DEBUG_FUNCPTR (gst_inter_video_sink_preroll);
+ base_sink_class->render = GST_DEBUG_FUNCPTR (gst_inter_video_sink_render);
+ if (0)
+ base_sink_class->async_play =
+ GST_DEBUG_FUNCPTR (gst_inter_video_sink_async_play);
+ if (0)
+ base_sink_class->activate_pull =
+ GST_DEBUG_FUNCPTR (gst_inter_video_sink_activate_pull);
+ base_sink_class->unlock_stop =
+ GST_DEBUG_FUNCPTR (gst_inter_video_sink_unlock_stop);
+
+}
+
+static void
+gst_inter_video_sink_init (GstInterVideoSink * intervideosink,
+ GstInterVideoSinkClass * intervideosink_class)
+{
+
+ intervideosink->sinkpad =
+ gst_pad_new_from_static_template (&gst_inter_video_sink_sink_template,
+ "sink");
+
+ intervideosink->surface = gst_inter_surface_get ("default");
+}
+
+void
+gst_inter_video_sink_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ /* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_video_sink_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ /* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_video_sink_dispose (GObject * object)
+{
+ /* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
+
+ /* clean up as possible. may be called multiple times */
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+void
+gst_inter_video_sink_finalize (GObject * object)
+{
+ /* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
+
+ /* clean up object here */
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+
+static GstCaps *
+gst_inter_video_sink_get_caps (GstBaseSink * sink)
+{
+
+ return NULL;
+}
+
+static gboolean
+gst_inter_video_sink_set_caps (GstBaseSink * sink, GstCaps * caps)
+{
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_inter_video_sink_buffer_alloc (GstBaseSink * sink, guint64 offset,
+ guint size, GstCaps * caps, GstBuffer ** buf)
+{
+
+ return GST_FLOW_ERROR;
+}
+
+static void
+gst_inter_video_sink_get_times (GstBaseSink * sink, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end)
+{
+ GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (sink);
+
+ if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) {
+ *start = GST_BUFFER_TIMESTAMP (buffer);
+ if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
+ *end = *start + GST_BUFFER_DURATION (buffer);
+ } else {
+ if (intervideosink->fps_n > 0) {
+ *end = *start +
+ gst_util_uint64_scale_int (GST_SECOND, intervideosink->fps_d,
+ intervideosink->fps_n);
+ }
+ }
+ }
+
+
+}
+
+static gboolean
+gst_inter_video_sink_start (GstBaseSink * sink)
+{
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_sink_stop (GstBaseSink * sink)
+{
+ GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (sink);
+
+ g_mutex_lock (intervideosink->surface->mutex);
+ if (intervideosink->surface->video_buffer) {
+ gst_buffer_unref (intervideosink->surface->video_buffer);
+ }
+ intervideosink->surface->video_buffer = NULL;
+ g_mutex_unlock (intervideosink->surface->mutex);
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_sink_unlock (GstBaseSink * sink)
+{
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_sink_event (GstBaseSink * sink, GstEvent * event)
+{
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_inter_video_sink_preroll (GstBaseSink * sink, GstBuffer * buffer)
+{
+ //return gst_inter_video_sink_render (sink, buffer);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_inter_video_sink_render (GstBaseSink * sink, GstBuffer * buffer)
+{
+ GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (sink);
+
+ g_mutex_lock (intervideosink->surface->mutex);
+ if (intervideosink->surface->video_buffer) {
+ gst_buffer_unref (intervideosink->surface->video_buffer);
+ }
+ intervideosink->surface->video_buffer = gst_buffer_ref (buffer);
+ intervideosink->surface->video_buffer_count = 0;
+ g_mutex_unlock (intervideosink->surface->mutex);
+
+ return GST_FLOW_OK;
+}
+
+static GstStateChangeReturn
+gst_inter_video_sink_async_play (GstBaseSink * sink)
+{
+
+ return GST_STATE_CHANGE_SUCCESS;
+}
+
+static gboolean
+gst_inter_video_sink_activate_pull (GstBaseSink * sink, gboolean active)
+{
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_sink_unlock_stop (GstBaseSink * sink)
+{
+
+ return TRUE;
+}
diff --git a/gst/inter/gstintervideosink.h b/gst/inter/gstintervideosink.h
new file mode 100644
index 000000000..00bbd6e85
--- /dev/null
+++ b/gst/inter/gstintervideosink.h
@@ -0,0 +1,58 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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_INTER_VIDEO_SINK_H_
+#define _GST_INTER_VIDEO_SINK_H_
+
+#include <gst/base/gstbasesink.h>
+#include "gstintersurface.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_INTER_VIDEO_SINK (gst_inter_video_sink_get_type())
+#define GST_INTER_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_INTER_VIDEO_SINK,GstInterVideoSink))
+#define GST_INTER_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_INTER_VIDEO_SINK,GstInterVideoSinkClass))
+#define GST_IS_INTER_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_INTER_VIDEO_SINK))
+#define GST_IS_INTER_VIDEO_SINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_INTER_VIDEO_SINK))
+
+typedef struct _GstInterVideoSink GstInterVideoSink;
+typedef struct _GstInterVideoSinkClass GstInterVideoSinkClass;
+
+struct _GstInterVideoSink
+{
+ GstBaseSink base_intervideosink;
+
+ GstInterSurface *surface;
+
+ GstPad *sinkpad;
+
+ int fps_n;
+ int fps_d;
+};
+
+struct _GstInterVideoSinkClass
+{
+ GstBaseSinkClass base_intervideosink_class;
+};
+
+GType gst_inter_video_sink_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gst/inter/gstintervideosrc.c b/gst/inter/gstintervideosrc.c
new file mode 100644
index 000000000..04d965530
--- /dev/null
+++ b/gst/inter/gstintervideosrc.c
@@ -0,0 +1,510 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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., 51 Franklin Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+/**
+ * SECTION:element-gstintervideosrc
+ *
+ * The intervideosrc element does FIXME stuff.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v fakesrc ! intervideosrc ! FIXME ! fakesink
+ * ]|
+ * FIXME Describe what the pipeline does.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesrc.h>
+#include <gst/video/video.h>
+#include "gstintervideosrc.h"
+#include <string.h>
+
+GST_DEBUG_CATEGORY_STATIC (gst_inter_video_src_debug_category);
+#define GST_CAT_DEFAULT gst_inter_video_src_debug_category
+
+/* prototypes */
+
+
+static void gst_inter_video_src_set_property (GObject * object,
+ guint property_id, const GValue * value, GParamSpec * pspec);
+static void gst_inter_video_src_get_property (GObject * object,
+ guint property_id, GValue * value, GParamSpec * pspec);
+static void gst_inter_video_src_dispose (GObject * object);
+static void gst_inter_video_src_finalize (GObject * object);
+
+static GstCaps *gst_inter_video_src_get_caps (GstBaseSrc * src);
+static gboolean gst_inter_video_src_set_caps (GstBaseSrc * src, GstCaps * caps);
+static gboolean gst_inter_video_src_negotiate (GstBaseSrc * src);
+static gboolean gst_inter_video_src_newsegment (GstBaseSrc * src);
+static gboolean gst_inter_video_src_start (GstBaseSrc * src);
+static gboolean gst_inter_video_src_stop (GstBaseSrc * src);
+static void
+gst_inter_video_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end);
+static gboolean gst_inter_video_src_is_seekable (GstBaseSrc * src);
+static gboolean gst_inter_video_src_unlock (GstBaseSrc * src);
+static gboolean gst_inter_video_src_event (GstBaseSrc * src, GstEvent * event);
+static GstFlowReturn
+gst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,
+ GstBuffer ** buf);
+static gboolean gst_inter_video_src_do_seek (GstBaseSrc * src,
+ GstSegment * segment);
+static gboolean gst_inter_video_src_query (GstBaseSrc * src, GstQuery * query);
+static gboolean gst_inter_video_src_check_get_range (GstBaseSrc * src);
+static void gst_inter_video_src_fixate (GstBaseSrc * src, GstCaps * caps);
+static gboolean gst_inter_video_src_unlock_stop (GstBaseSrc * src);
+static gboolean
+gst_inter_video_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
+ GstSegment * segment);
+
+enum
+{
+ PROP_0
+};
+
+/* pad templates */
+
+static GstStaticPadTemplate gst_inter_video_src_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
+
+
+/* class initialization */
+
+#define DEBUG_INIT(bla) \
+ GST_DEBUG_CATEGORY_INIT (gst_inter_video_src_debug_category, "intervideosrc", 0, \
+ "debug category for intervideosrc element");
+
+GST_BOILERPLATE_FULL (GstInterVideoSrc, gst_inter_video_src, GstBaseSrc,
+ GST_TYPE_BASE_SRC, DEBUG_INIT);
+
+static void
+gst_inter_video_src_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_inter_video_src_src_template));
+
+ gst_element_class_set_details_simple (element_class, "FIXME Long name",
+ "Generic", "FIXME Description", "FIXME <fixme@example.com>");
+}
+
+static void
+gst_inter_video_src_class_init (GstInterVideoSrcClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstBaseSrcClass *base_src_class = GST_BASE_SRC_CLASS (klass);
+
+ gobject_class->set_property = gst_inter_video_src_set_property;
+ gobject_class->get_property = gst_inter_video_src_get_property;
+ gobject_class->dispose = gst_inter_video_src_dispose;
+ gobject_class->finalize = gst_inter_video_src_finalize;
+ if (0)
+ base_src_class->get_caps = GST_DEBUG_FUNCPTR (gst_inter_video_src_get_caps);
+ base_src_class->set_caps = GST_DEBUG_FUNCPTR (gst_inter_video_src_set_caps);
+ if (0)
+ base_src_class->negotiate =
+ GST_DEBUG_FUNCPTR (gst_inter_video_src_negotiate);
+ if (0)
+ base_src_class->newsegment =
+ GST_DEBUG_FUNCPTR (gst_inter_video_src_newsegment);
+ base_src_class->start = GST_DEBUG_FUNCPTR (gst_inter_video_src_start);
+ base_src_class->stop = GST_DEBUG_FUNCPTR (gst_inter_video_src_stop);
+ base_src_class->get_times = GST_DEBUG_FUNCPTR (gst_inter_video_src_get_times);
+ if (0)
+ base_src_class->is_seekable =
+ GST_DEBUG_FUNCPTR (gst_inter_video_src_is_seekable);
+ base_src_class->unlock = GST_DEBUG_FUNCPTR (gst_inter_video_src_unlock);
+ base_src_class->event = GST_DEBUG_FUNCPTR (gst_inter_video_src_event);
+ base_src_class->create = GST_DEBUG_FUNCPTR (gst_inter_video_src_create);
+ if (0)
+ base_src_class->do_seek = GST_DEBUG_FUNCPTR (gst_inter_video_src_do_seek);
+ base_src_class->query = GST_DEBUG_FUNCPTR (gst_inter_video_src_query);
+ if (0)
+ base_src_class->check_get_range =
+ GST_DEBUG_FUNCPTR (gst_inter_video_src_check_get_range);
+ base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_inter_video_src_fixate);
+ if (0)
+ base_src_class->unlock_stop =
+ GST_DEBUG_FUNCPTR (gst_inter_video_src_unlock_stop);
+ if (0)
+ base_src_class->prepare_seek_segment =
+ GST_DEBUG_FUNCPTR (gst_inter_video_src_prepare_seek_segment);
+
+
+}
+
+static void
+gst_inter_video_src_init (GstInterVideoSrc * intervideosrc,
+ GstInterVideoSrcClass * intervideosrc_class)
+{
+
+ intervideosrc->srcpad =
+ gst_pad_new_from_static_template (&gst_inter_video_src_src_template,
+ "src");
+
+ gst_base_src_set_format (GST_BASE_SRC (intervideosrc), GST_FORMAT_TIME);
+ gst_base_src_set_live (GST_BASE_SRC (intervideosrc), TRUE);
+
+ intervideosrc->surface = gst_inter_surface_get ("default");
+}
+
+void
+gst_inter_video_src_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ /* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_video_src_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ /* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
+
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gst_inter_video_src_dispose (GObject * object)
+{
+ /* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
+
+ /* clean up as possible. may be called multiple times */
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+void
+gst_inter_video_src_finalize (GObject * object)
+{
+ /* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
+
+ /* clean up object here */
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static GstCaps *
+gst_inter_video_src_get_caps (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "get_caps");
+
+ return NULL;
+}
+
+static gboolean
+gst_inter_video_src_set_caps (GstBaseSrc * src, GstCaps * caps)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+ gboolean ret;
+ GstVideoFormat format;
+ int width, height;
+ int fps_n, fps_d;
+
+ GST_DEBUG_OBJECT (intervideosrc, "set_caps");
+
+ ret = gst_video_format_parse_caps (caps, &format, &width, &height);
+ ret &= gst_video_parse_caps_framerate (caps, &fps_n, &fps_d);
+
+ if (ret) {
+ intervideosrc->format = format;
+ intervideosrc->width = width;
+ intervideosrc->height = height;
+ intervideosrc->fps_n = fps_n;
+ intervideosrc->fps_d = fps_d;
+ GST_DEBUG ("fps %d/%d", fps_n, fps_d);
+ }
+
+ return ret;
+}
+
+static gboolean
+gst_inter_video_src_negotiate (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "negotiate");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_src_newsegment (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "newsegment");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_src_start (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "start");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_src_stop (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "stop");
+
+ return TRUE;
+}
+
+static void
+gst_inter_video_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "get_times");
+
+ /* for live sources, sync on the timestamp of the buffer */
+ if (gst_base_src_is_live (src)) {
+ GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);
+
+ if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
+ /* get duration to calculate end time */
+ GstClockTime duration = GST_BUFFER_DURATION (buffer);
+
+ if (GST_CLOCK_TIME_IS_VALID (duration)) {
+ *end = timestamp + duration;
+ }
+ *start = timestamp;
+ }
+ } else {
+ *start = -1;
+ *end = -1;
+ }
+}
+
+static gboolean
+gst_inter_video_src_is_seekable (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "is_seekable");
+
+ return FALSE;
+}
+
+static gboolean
+gst_inter_video_src_unlock (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "unlock");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_src_event (GstBaseSrc * src, GstEvent * event)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "event");
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,
+ GstBuffer ** buf)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+ GstBuffer *buffer;
+ guint8 *data;
+
+ GST_DEBUG_OBJECT (intervideosrc, "create");
+
+ buffer = NULL;
+
+ g_mutex_lock (intervideosrc->surface->mutex);
+ if (intervideosrc->surface->video_buffer) {
+ buffer = gst_buffer_ref (intervideosrc->surface->video_buffer);
+ intervideosrc->surface->video_buffer_count++;
+ if (intervideosrc->surface->video_buffer_count >= 30) {
+ gst_buffer_unref (intervideosrc->surface->video_buffer);
+ intervideosrc->surface->video_buffer = NULL;
+ }
+ }
+ g_mutex_unlock (intervideosrc->surface->mutex);
+
+ if (buffer == NULL) {
+ buffer =
+ gst_buffer_new_and_alloc (gst_video_format_get_size
+ (intervideosrc->format, intervideosrc->width, intervideosrc->height));
+
+ data = GST_BUFFER_DATA (buffer);
+ memset (data, 16,
+ gst_video_format_get_row_stride (intervideosrc->format, 0,
+ intervideosrc->width) *
+ gst_video_format_get_component_height (intervideosrc->format, 0,
+ intervideosrc->height));
+
+ memset (data + gst_video_format_get_component_offset (intervideosrc->format,
+ 1, intervideosrc->width, intervideosrc->height),
+ 128,
+ 2 * gst_video_format_get_row_stride (intervideosrc->format, 1,
+ intervideosrc->width) *
+ gst_video_format_get_component_height (intervideosrc->format, 1,
+ intervideosrc->height));
+
+#if 0
+ {
+ int i;
+ for (i = 0; i < 10000; i++) {
+ data[i] = g_random_int () & 0xff;
+ }
+ }
+#endif
+ }
+
+ buffer = gst_buffer_make_metadata_writable (buffer);
+
+ GST_BUFFER_TIMESTAMP (buffer) =
+ gst_util_uint64_scale_int (GST_SECOND * intervideosrc->n_frames,
+ intervideosrc->fps_d, intervideosrc->fps_n);
+ GST_DEBUG_OBJECT (intervideosrc, "create ts %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+ GST_BUFFER_DURATION (buffer) =
+ gst_util_uint64_scale_int (GST_SECOND * (intervideosrc->n_frames + 1),
+ intervideosrc->fps_d,
+ intervideosrc->fps_n) - GST_BUFFER_TIMESTAMP (buffer);
+ GST_BUFFER_OFFSET (buffer) = intervideosrc->n_frames;
+ GST_BUFFER_OFFSET_END (buffer) = -1;
+ GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DISCONT);
+ if (intervideosrc->n_frames == 0) {
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
+ }
+ gst_buffer_set_caps (buffer, GST_PAD_CAPS (GST_BASE_SRC_PAD (intervideosrc)));
+ intervideosrc->n_frames++;
+
+ *buf = buffer;
+
+ return GST_FLOW_OK;
+}
+
+static gboolean
+gst_inter_video_src_do_seek (GstBaseSrc * src, GstSegment * segment)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "do_seek");
+
+ return FALSE;
+}
+
+static gboolean
+gst_inter_video_src_query (GstBaseSrc * src, GstQuery * query)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "query");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_src_check_get_range (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "get_range");
+
+ return FALSE;
+}
+
+static void
+gst_inter_video_src_fixate (GstBaseSrc * src, GstCaps * caps)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+ GstStructure *structure;
+
+ GST_DEBUG_OBJECT (intervideosrc, "fixate");
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ gst_structure_fixate_field_nearest_int (structure, "width", 320);
+ gst_structure_fixate_field_nearest_int (structure, "height", 240);
+ gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1);
+ if (gst_structure_has_field (structure, "pixel-aspect-ratio"))
+ gst_structure_fixate_field_nearest_fraction (structure,
+ "pixel-aspect-ratio", 1, 1);
+ if (gst_structure_has_field (structure, "color-matrix"))
+ gst_structure_fixate_field_string (structure, "color-matrix", "sdtv");
+ if (gst_structure_has_field (structure, "chroma-site"))
+ gst_structure_fixate_field_string (structure, "chroma-site", "mpeg2");
+
+ if (gst_structure_has_field (structure, "interlaced"))
+ gst_structure_fixate_field_boolean (structure, "interlaced", FALSE);
+
+}
+
+static gboolean
+gst_inter_video_src_unlock_stop (GstBaseSrc * src)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "stop");
+
+ return TRUE;
+}
+
+static gboolean
+gst_inter_video_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
+ GstSegment * segment)
+{
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);
+
+ GST_DEBUG_OBJECT (intervideosrc, "seek_segment");
+
+ return FALSE;
+}
diff --git a/gst/inter/gstintervideosrc.h b/gst/inter/gstintervideosrc.h
new file mode 100644
index 000000000..909410a18
--- /dev/null
+++ b/gst/inter/gstintervideosrc.h
@@ -0,0 +1,62 @@
+/* GStreamer
+ * Copyright (C) 2011 David A. Schleef <ds@schleef.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_INTER_VIDEO_SRC_H_
+#define _GST_INTER_VIDEO_SRC_H_
+
+#include <gst/base/gstbasesrc.h>
+#include <gst/video/video.h>
+#include "gstintersurface.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_INTER_VIDEO_SRC (gst_inter_video_src_get_type())
+#define GST_INTER_VIDEO_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_INTER_VIDEO_SRC,GstInterVideoSrc))
+#define GST_INTER_VIDEO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_INTER_VIDEO_SRC,GstInterVideoSrcClass))
+#define GST_IS_INTER_VIDEO_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_INTER_VIDEO_SRC))
+#define GST_IS_INTER_VIDEO_SRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_INTER_VIDEO_SRC))
+
+typedef struct _GstInterVideoSrc GstInterVideoSrc;
+typedef struct _GstInterVideoSrcClass GstInterVideoSrcClass;
+
+struct _GstInterVideoSrc
+{
+ GstBaseSrc base_intervideosrc;
+
+ GstPad *srcpad;
+ GstInterSurface *surface;
+
+ GstVideoFormat format;
+ int fps_n;
+ int fps_d;
+ int n_frames;
+ int width;
+ int height;
+};
+
+struct _GstInterVideoSrcClass
+{
+ GstBaseSrcClass base_intervideosrc_class;
+};
+
+GType gst_inter_video_src_get_type (void);
+
+G_END_DECLS
+
+#endif