commit 5218c17e6d229d99cd347702ff292a40735d4685 Author: Johannes Berg Date: Thu Aug 20 17:25:22 2009 +0200 add gst-app module wrapper AppSrc is currently incomplete, and callbacks are missing for both AppSrc and AppSink, also AppBuffer is missing completely. 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 a0e1e2b..db8d91c 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 pygstminiobject.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..f04a3fb --- /dev/null +++ b/gst/app.defs @@ -0,0 +1,172 @@ +;; -*- 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 "GstBaseSource") + (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-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_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") +) + +; app src missing: +; stream_type +; max_bytes +; push_buffer +; callbacks +; end_of_stream diff --git a/gst/app.override b/gst/app.override new file mode 100644 index 0000000..32c076a --- /dev/null +++ b/gst/app.override @@ -0,0 +1,60 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +/* gst-python + * Copyright (C) 2008 + * Copyright (C) 2009 Johannes Berg + * + * 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 +#endif + +#define NO_IMPORT_PYGOBJECT +#include "common.h" + +#include +#include +#include + +#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.BaseSource as PyGstBaseSource_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..68cdb6a --- /dev/null +++ b/gst/appmodule.c @@ -0,0 +1,53 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +/* gst-python + * Copyright (C) 2008 Edward Hervey + * Copyright (C) 2009 Johannes Berg + * + * 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 +#include +#include + +void pyapp_register_classes (PyObject * d); + +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); + + if (PyErr_Occurred ()) { + PyErr_Print (); + Py_FatalError ("can't initialize module gst.app"); + } +}