commit d3b506adfac70e0fb96331307ac7ea8cc9e891be
Author: Johannes Berg <johannes@sipsolutions.net>
Date:   Thu Aug 20 17:25:22 2009 +0200

    Add gst-app module wrapper. Fixes #592473.
    
    This adds python wrapping for AppSrc and AppSink,
    but callbacks are missing completely. AppBuffer
    is also missing -- all that as a consequence of
    me not knowing how to make C-callbacks in the
    wrapper for calling into python.

diff --git a/configure.ac b/configure.ac
index 89ef790..0bf9d3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -204,6 +204,11 @@ then
     AC_DEFINE_UNQUOTED(HAVE_GST_TAG, 1, [We can use the gst-tag library])
   fi
 
+  if test $GST_PB_MINOR_VERSION -ge "23"
+  then
+    AC_DEFINE_UNQUOTED(HAVE_GST_APP, 1, [We can use the gst-app library])
+  fi
+
   if test $GST_PB_MINOR_VERSION -lt "23"
   then
     IGNORE_GST_PB_0_10_23="gst-pb-0.10.23.ignore"
@@ -229,6 +234,7 @@ else
   AC_DEFINE_UNQUOTED(HAVE_GST_AUDIO, 1, [We can use the gst-audio library])
   AC_DEFINE_UNQUOTED(HAVE_GST_VIDEO, 1, [We can use the gst-video library])
   AC_DEFINE_UNQUOTED(HAVE_GST_TAG, 1, [We can use the gst-tag library])
+  AC_DEFINE_UNQUOTED(HAVE_GST_APP, 1, [We can use the gst-app library])
 fi
 AC_DEFINE_UNQUOTED(HAVE_VIDEO_ORIENTATION_INTERFACE, 1, [We can use the videoorientation interface])
 AC_SUBST(IGNORE_GST_0_10_13)
@@ -250,6 +256,7 @@ AC_SUBST(HAVE_PLUGINS_INSTALL)
 AM_CONDITIONAL(HAVE_GST_AUDIO, $HAVE_GST_AUDIO)
 AM_CONDITIONAL(HAVE_GST_VIDEO, $HAVE_GST_VIDEO)
 AM_CONDITIONAL(HAVE_GST_TAG, $HAVE_GST_TAG)
+AM_CONDITIONAL(HAVE_GST_APP, $HAVE_GST_APP)
 
 dnl check for gstreamer-base; uninstalled is selected preferentially
 PKG_CHECK_MODULES(GST_BASE, gstreamer-base-$GST_MAJORMINOR >= $GST_REQ,
diff --git a/gst/.gitignore b/gst/.gitignore
index 5001f41..577ebd3 100644
--- a/gst/.gitignore
+++ b/gst/.gitignore
@@ -16,3 +16,4 @@ gstversion.override
 audio.c
 tag.c
 video.c
+app.c
diff --git a/gst/Makefile.am b/gst/Makefile.am
index 7358b7c..a61275b 100644
--- a/gst/Makefile.am
+++ b/gst/Makefile.am
@@ -174,6 +174,28 @@ tag.c: $(TAG_DEFS) $(TAG_OVERRIDES) $(GEN_FILES)
 
 endif
 
+# GStreamer app bindings
+APP_OVERRIDES = app.override
+APP_DEFS = app.defs
+CLEANFILES += app.c
+EXTRA_DIST += $(APP_DEFS) $(APP_OVERRIDES)
+defs_DATA += $(APP_DEFS)
+GEN_FILES += $(APP_DEFS)
+
+if HAVE_GST_APP
+
+ app_lib = app.la
+ pygstexec_LTLIBRARIES += $(app_lib)
+ app_la_CFLAGS = $(common_cflags) $(GST_PLUGINS_BASE_CFLAGS)
+ app_la_LIBADD = $(common_libadd) $(GST_PLUGINS_BASE_LIBS) -lgstapp-0.10
+ app_la_LDFLAGS = $(common_ldflags) \
+	-export-symbols-regex "^(initapp|_PyGObject_API).*" $(GST_PLUGINS_BASE_LIBS)
+ app_la_SOURCES = appmodule.c gst-argtypes.c
+ nodist_app_la_SOURCES = app.c
+app.c: $(APP_DEFS) $(APP_OVERRIDES) $(GEN_FILES)
+
+endif
+
 
 .defs.c: 
 	($(PYTHON) $(top_srcdir)/codegen/codegen.py \
diff --git a/gst/app.defs b/gst/app.defs
new file mode 100644
index 0000000..94013f6
--- /dev/null
+++ b/gst/app.defs
@@ -0,0 +1,222 @@
+;; -*- scheme -*-
+; object definitions
+
+(define-object AppSink
+  (in-module "GstApp")
+  (parent "GstBaseSink")
+  (c-name "GstAppSink")
+  (gtype-id "GST_TYPE_APP_SINK")
+)
+
+(define-object AppSrc
+  (in-module "GstApp")
+  (parent "GstBaseSrc")
+  (c-name "GstAppSrc")
+  (gtype-id "GST_TYPE_APP_SRC")
+)
+
+; from gstappsink.h
+
+(define-method set_caps
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_set_caps")
+  (parameters
+    '("const-GstCaps*" "caps")
+  )
+  (return-type "none")
+)
+
+(define-method get_caps
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_get_caps")
+  (return-type "GstCaps*")
+  (caller-owns-return #t)
+)
+
+(define-method is_eos
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_is_eos")
+  (return-type "gboolean")
+)
+
+(define-method set_emit_signals
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_set_emit_signals")
+  (parameters
+    '("gboolean" "emit")
+  )
+)
+
+(define-method get_emit_signals
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_get_emit_signals")
+  (return-type "gboolean")
+)
+
+(define-method set_max_buffers
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_set_max_buffers")
+  (parameters
+    '("guint" "max")
+  )
+)
+
+(define-method get_max_buffers
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_get_max_buffers")
+  (return-type "guint")
+)
+
+(define-method set_drop
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_set_drop")
+  (parameters
+    '("gboolean" "emit")
+  )
+)
+
+(define-method get_drop
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_get_drop")
+  (return-type "gboolean")
+)
+
+(define-method pull_preroll
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_pull_preroll")
+  (return-type "GstBuffer*")
+  (caller-owns-return #t)
+)
+
+(define-method pull_buffer
+  (of-object "GstAppSink")
+  (c-name "gst_app_sink_pull_buffer")
+  (return-type "GstBuffer*")
+  (caller-owns-return #t)
+)
+
+; missing: callbacks
+
+
+; from gstappsrc.h
+
+(define-enum AppStreamType
+  (in-module "GstApp")
+  (c-name "GstAppStreamType")
+  (values
+    '("stream" "GST_APP_STREAM_TYPE_STREAM")
+    '("seekable" "GST_APP_STREAM_TYPE_SEEKABLE")
+    '("random_access" "GST_APP_STREAM_TYPE_RANDOM_ACCESS")
+  )
+)
+
+(define-method set_caps
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_set_caps")
+  (parameters
+    '("const-GstCaps*" "caps")
+  )
+  (return-type "none")
+)
+
+(define-method get_caps
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_get_caps")
+  (return-type "GstCaps*")
+  (caller-owns-return #t)
+)
+
+(define-method set_latency
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_set_latency")
+  (parameters
+    '("guint64" "min")
+    '("guint64" "max")
+  )
+  (return-type "none")
+)
+
+(define-method get_latency
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_get_latency")
+  (parameters
+    '("guint64*" "min")
+    '("guint64*" "max")
+  )
+  (return-type "none")
+)
+
+(define-method set_size
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_set_size")
+  (parameters
+    '("guint64" "size")
+  )
+  (return-type "none")
+)
+
+(define-method get_size
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_get_size")
+  (return-type "guint64")
+)
+
+(define-method set_stream_type
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_set_stream_type")
+  (parameters
+    '("GstAppStreamType" "stream_type")
+  )
+  (return-type "none")
+)
+
+(define-method get_stream_type
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_get_stream_type")
+  (return-type "GstAppStreamType")
+)
+
+(define-method set_max_bytes
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_set_max_bytes")
+  (parameters
+    '("guint64" "max")
+  )
+  (return-type "none")
+)
+
+(define-method get_max_bytes
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_get_max_bytes")
+  (return-type "guint64")
+)
+
+(define-method set_emit_signals
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_set_emit_signals")
+  (parameters
+    '("gboolean" "emit")
+  )
+)
+
+(define-method get_emit_signals
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_get_emit_signals")
+  (return-type "gboolean")
+)
+
+(define-method push_buffer
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_push_buffer")
+  (parameters
+    '("GstBuffer*" "buffer" (keep-refcount))
+  )
+  (return-type "GstFlowReturn")
+)
+
+(define-method end_of_stream
+  (of-object "GstAppSrc")
+  (c-name "gst_app_src_end_of_stream")
+)
+
+; missing: callbacks
diff --git a/gst/app.override b/gst/app.override
new file mode 100644
index 0000000..349f94e
--- /dev/null
+++ b/gst/app.override
@@ -0,0 +1,60 @@
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+/* gst-python
+ * Copyright (C) 2008 <edward.hervey@collabora.co.uk>
+ * Copyright (C) 2009 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * 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.
+ */
+%%
+headers
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define NO_IMPORT_PYGOBJECT
+#include "common.h"
+
+#include <gst/gst.h>
+#include <gst/app/gstappsink.h>
+#include <gst/app/gstappsrc.h>
+
+#include "pygstminiobject.h"
+
+GST_DEBUG_CATEGORY_EXTERN (pygst_debug);
+#define GST_CAT_DEFAULT pygst_debug
+
+/* Boonky define that allows for backwards compatibility with Python 2.4 */
+#if PY_VERSION_HEX < 0x02050000
+#define Py_ssize_t int
+#endif
+
+%%
+modulename gst.app
+%%
+import gobject.GObject as PyGObject_Type
+import gst.Buffer as PyGstBuffer_Type
+import gst.BaseSink as PyGstBaseSink_Type
+import gst.BaseSrc as PyGstBaseSrc_Type
+%%
+include
+  gstversion.override
+%%
+ignore-glob
+ _*
+ *init
+ *_free
+ *_get_type
diff --git a/gst/appmodule.c b/gst/appmodule.c
new file mode 100644
index 0000000..c6fda65
--- /dev/null
+++ b/gst/appmodule.c
@@ -0,0 +1,55 @@
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+/* gst-python
+ * Copyright (C) 2008 Edward Hervey <edward.hervey@collabora.co.uk>
+ * Copyright (C) 2009 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* include this first, before NO_IMPORT_PYGOBJECT is defined */
+#include <pygobject.h>
+#include <gst/gst.h>
+#include <gst/app/gstappsink.h>
+
+void pyapp_register_classes (PyObject * d);
+void pyapp_add_constants (PyObject * module, const gchar * strip_prefix);
+
+extern PyMethodDef pyapp_functions[];
+
+GST_DEBUG_CATEGORY (pygst_debug);       /* for python code */
+
+DL_EXPORT (void)
+initapp (void)
+{
+  PyObject *m, *d;
+
+  init_pygobject ();
+
+  m = Py_InitModule ("app", pyapp_functions);
+  d = PyModule_GetDict (m);
+
+  pyapp_register_classes (d);
+  pyapp_add_constants (m, "GST_APP_");
+
+  if (PyErr_Occurred ()) {
+    PyErr_Print ();
+    Py_FatalError ("can't initialize module gst.app");
+  }
+}
