+2008-01-01 Edward Hervey <edward.hervey@collabora.co.uk>
+
+ * gst/Makefile.am:
+ * gst/common.h:
+ * gst/pbutils.defs:
+ * gst/pbutils.override:
+ * gst/pbutilsmodule.c: (initpbutils):
+ new gst.pbutils module that wraps the gst-plugins-base pbutils
+ helper library.
+ * testsuite/Makefile.am:
+ * testsuite/common.py:
+ * testsuite/test_pbutils.py:
+ Test case for gst.pbutils
+ Fixes #472822
+
2007-12-18 Andy Wingo <wingo@pobox.com>
* examples/switch.py: New file, a basic demo for a single-stream
pygst_PYTHON = __init__.py
pygstexecdir = $(pkgpyexecdir)
-pygstexec_LTLIBRARIES = _gst.la $(interface_lib)
+pygstexec_LTLIBRARIES = _gst.la $(interface_lib) $(pbutils_lib)
interface_lib = interfaces.la
+pbutils_lib = pbutils.la
defs_DATA = gst-types.defs \
gst-extrafuncs.defs \
libs.defs \
- base.defs
+ base.defs \
+ pbutils.defs
defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
noinst_HEADERS = common.h pygstvalue.h pygstminiobject.h pygstexception.h
INCLUDES = $(PYTHON_INCLUDES)
EXTRA_DIST = $(defs_DATA) $(versioned_overrides) common.h arg-types.py
-GEN_FILES = arg-types.py gst-types.defs libs.defs base.defs
+GEN_FILES = arg-types.py gst-types.defs libs.defs base.defs pbutils.defs
# GStreamer bindings
_gst_la_CFLAGS = $(common_cflags)
EXTRA_DIST += $(INTERFACES_DEFS) $(INTERFACES_OVERRIDES)
interfaces.c: $(INTERFACES_DEFS) $(INTERFACES_OVERRIDES) $(GEN_FILES)
+# GStreamer pbutils bindings
+pbutils_la_CFLAGS = $(common_cflags) $(GST_PLUGINS_BASE_CFLAGS)
+pbutils_la_LIBADD = $(common_libadd) $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-0.10
+pbutils_la_LDFLAGS = $(common_ldflags) \
+ -export-symbols-regex "^(initpbutils|_PyGObject_API).*" $(GST_PLUGINS_BASE_LIBS)
+pbutils_la_SOURCES = pbutilsmodule.c gst-argtypes.c
+nodist_pbutils_la_SOURCES = pbutils.c
+PBUTILS_OVERRIDES = pbutils.override
+PBUTILS_DEFS = pbutils.defs
+CLEANFILES += pbutils.c
+EXTRA_DIST += $(PBUTILS_DEFS) $(PBUTILS_OVERRIDES)
+pbutils.c: $(PBUTILS_DEFS) $(PBUTILS_OVERRIDES) $(GEN_FILES)
+
.defs.c:
($(PYTHON) $(top_srcdir)/codegen/codegen.py \
--load-types $(srcdir)/arg-types.py \
GstIterator *iter;
} PyGstIterator;
-PyTypeObject PyGstIterator_Type;
+extern PyTypeObject PyGstIterator_Type;
/* from gst-types.c */
--- /dev/null
+;; -*- scheme -*-
+; object definitions ...
+;; Enumerations and flags ...
+
+(define-enum InstallPluginsReturn
+ (in-module "Gst")
+ (c-name "GstInstallPluginsReturn")
+ (gtype-id "GST_TYPE_INSTALL_PLUGINS_RETURN")
+ (values
+ '("success" "GST_INSTALL_PLUGINS_SUCCESS")
+ '("not-found" "GST_INSTALL_PLUGINS_NOT_FOUND")
+ '("error" "GST_INSTALL_PLUGINS_ERROR")
+ '("partial-success" "GST_INSTALL_PLUGINS_PARTIAL_SUCCESS")
+ '("user-abort" "GST_INSTALL_PLUGINS_USER_ABORT")
+ '("crashed" "GST_INSTALL_PLUGINS_CRASHED")
+ '("invalid" "GST_INSTALL_PLUGINS_INVALID")
+ '("started-ok" "GST_INSTALL_PLUGINS_STARTED_OK")
+ '("internal-failure" "GST_INSTALL_PLUGINS_INTERNAL_FAILURE")
+ '("helper-missing" "GST_INSTALL_PLUGINS_HELPER_MISSING")
+ '("install-in-progress" "GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS")
+ )
+)
+
+
+;; From descriptions.h
+
+(define-function add_codec_description_to_tag_list
+ (c-name "gst_pb_utils_add_codec_description_to_tag_list")
+ (return-type "gboolean")
+ (parameters
+ '("GstTagList*" "taglist")
+ '("const-gchar*" "codec_tag")
+ '("const-GstCaps*" "caps")
+ )
+)
+
+(define-function get_codec_description
+ (c-name "gst_pb_utils_get_codec_description")
+ (return-type "gchar*")
+ (parameters
+ '("const-GstCaps*" "caps")
+ )
+)
+
+(define-function get_source_description
+ (c-name "gst_pb_utils_get_source_description")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "protocol")
+ )
+)
+
+(define-function get_sink_description
+ (c-name "gst_pb_utils_get_sink_description")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "protocol")
+ )
+)
+
+(define-function get_decoder_description
+ (c-name "gst_pb_utils_get_decoder_description")
+ (return-type "gchar*")
+ (parameters
+ '("const-GstCaps*" "caps")
+ )
+)
+
+(define-function get_encoder_description
+ (c-name "gst_pb_utils_get_encoder_description")
+ (return-type "gchar*")
+ (parameters
+ '("const-GstCaps*" "caps")
+ )
+)
+
+(define-function get_element_description
+ (c-name "gst_pb_utils_get_element_description")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "factory_name")
+ )
+)
+
+
+
+;; From install-plugins.h
+
+(define-function install_plugins_context_new
+ (c-name "gst_install_plugins_context_new")
+ (is-constructor-of "GstInstallPluginsContext")
+ (return-type "GstInstallPluginsContext*")
+)
+
+(define-method free
+ (of-object "GstInstallPluginsContext")
+ (c-name "gst_install_plugins_context_free")
+ (return-type "none")
+)
+
+(define-method set_xid
+ (of-object "GstInstallPluginsContext")
+ (c-name "gst_install_plugins_context_set_xid")
+ (return-type "none")
+ (parameters
+ '("guint" "xid")
+ )
+)
+
+(define-function install_plugins_async
+ (c-name "gst_install_plugins_async")
+ (return-type "GstInstallPluginsReturn")
+ (parameters
+ '("gchar**" "details")
+ '("GstInstallPluginsContext*" "ctx")
+ '("GstInstallPluginsResultFunc" "func")
+ '("gpointer" "user_data")
+ )
+)
+
+(define-function install_plugins_sync
+ (c-name "gst_install_plugins_sync")
+ (return-type "GstInstallPluginsReturn")
+ (parameters
+ '("gchar**" "details")
+ '("GstInstallPluginsContext*" "ctx")
+ )
+)
+
+(define-method get_name
+ (of-object "GstInstallPluginsReturn")
+ (c-name "gst_install_plugins_return_get_name")
+ (return-type "const-gchar*")
+)
+
+(define-function install_plugins_installation_in_progress
+ (c-name "gst_install_plugins_installation_in_progress")
+ (return-type "gboolean")
+)
+
+(define-function install_plugins_supported
+ (c-name "gst_install_plugins_supported")
+ (return-type "gboolean")
+)
+
+
+
+;; From missing-plugins.h
+
+(define-function missing_uri_source_message_new
+ (c-name "gst_missing_uri_source_message_new")
+ (is-constructor-of "GstMissingUriSourceMessage")
+ (return-type "GstMessage*")
+ (parameters
+ '("GstElement*" "element")
+ '("const-gchar*" "protocol")
+ )
+)
+
+(define-function missing_uri_sink_message_new
+ (c-name "gst_missing_uri_sink_message_new")
+ (is-constructor-of "GstMissingUriSinkMessage")
+ (return-type "GstMessage*")
+ (parameters
+ '("GstElement*" "element")
+ '("const-gchar*" "protocol")
+ )
+)
+
+(define-function missing_element_message_new
+ (c-name "gst_missing_element_message_new")
+ (is-constructor-of "GstMissingElementMessage")
+ (return-type "GstMessage*")
+ (parameters
+ '("GstElement*" "element")
+ '("const-gchar*" "factory_name")
+ )
+)
+
+(define-function missing_decoder_message_new
+ (c-name "gst_missing_decoder_message_new")
+ (is-constructor-of "GstMissingDecoderMessage")
+ (return-type "GstMessage*")
+ (parameters
+ '("GstElement*" "element")
+ '("const-GstCaps*" "decode_caps")
+ )
+)
+
+(define-function missing_encoder_message_new
+ (c-name "gst_missing_encoder_message_new")
+ (is-constructor-of "GstMissingEncoderMessage")
+ (return-type "GstMessage*")
+ (parameters
+ '("GstElement*" "element")
+ '("const-GstCaps*" "encode_caps")
+ )
+)
+
+(define-function missing_plugin_message_get_installer_detail
+ (c-name "gst_missing_plugin_message_get_installer_detail")
+ (return-type "gchar*")
+ (parameters
+ '("GstMessage*" "msg")
+ )
+)
+
+(define-function missing_plugin_message_get_description
+ (c-name "gst_missing_plugin_message_get_description")
+ (return-type "gchar*")
+ (parameters
+ '("GstMessage*" "msg")
+ )
+)
+
+(define-function is_missing_plugin_message
+ (c-name "gst_is_missing_plugin_message")
+ (return-type "gboolean")
+ (parameters
+ '("GstMessage*" "msg")
+ )
+)
+
+(define-function missing_uri_source_installer_detail_new
+ (c-name "gst_missing_uri_source_installer_detail_new")
+ (is-constructor-of "GstMissingUriSourceInstallerDetail")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "protocol")
+ )
+)
+
+(define-function missing_uri_sink_installer_detail_new
+ (c-name "gst_missing_uri_sink_installer_detail_new")
+ (is-constructor-of "GstMissingUriSinkInstallerDetail")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "protocol")
+ )
+)
+
+(define-function missing_element_installer_detail_new
+ (c-name "gst_missing_element_installer_detail_new")
+ (is-constructor-of "GstMissingElementInstallerDetail")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "factory_name")
+ )
+)
+
+(define-function missing_decoder_installer_detail_new
+ (c-name "gst_missing_decoder_installer_detail_new")
+ (is-constructor-of "GstMissingDecoderInstallerDetail")
+ (return-type "gchar*")
+ (parameters
+ '("const-GstCaps*" "decode_caps")
+ )
+)
+
+(define-function missing_encoder_installer_detail_new
+ (c-name "gst_missing_encoder_installer_detail_new")
+ (is-constructor-of "GstMissingEncoderInstallerDetail")
+ (return-type "gchar*")
+ (parameters
+ '("const-GstCaps*" "encode_caps")
+ )
+)
+
+
+
+;; From pbutils.h
+
+(define-function init
+ (c-name "gst_pb_utils_init")
+ (return-type "none")
+)
+
+
--- /dev/null
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+/* gst-python
+ * Copyright (C) 2008 <edward.hervey@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+%%
+headers
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "common.h"
+
+#include <gst/gst.h>
+
+#include <gst/pbutils/pbutils.h>
+
+%%
+modulename gst.pbutils
+%%
+import gobject.GObject as PyGObject_Type
+import gst.Object as PyGstObject_Type
+import gst.Structure as PyGstStructure_Type
+import gst.Element as PyGstElement_Type
+import gst.Message as PyGstMessage_Type
+%%
+include
+ gstversion.override
+%%
+ignore-glob
+ _*
+ *init
+ *_get_type
+%%
--- /dev/null
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+/* gst-python
+ * Copyright (C) 2008 Edward Hervey <edward.hervey@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* include this first, before NO_IMPORT_PYGOBJECT is defined */
+#include <pygobject.h>
+#include <gst/gst.h>
+#include <gst/pbutils/pbutils.h>
+
+void pypbutils_register_classes (PyObject *d);
+void pypbutils_add_constants(PyObject *module, const gchar *strip_prefix);
+
+extern PyMethodDef pypbutils_functions[];
+
+DL_EXPORT(void)
+initpbutils (void)
+{
+ PyObject *m, *d;
+
+ init_pygobject ();
+ gst_pb_utils_init ();
+
+ m = Py_InitModule ("pbutils", pypbutils_functions);
+ d = PyModule_GetDict (m);
+
+ pypbutils_register_classes (d);
+ pypbutils_add_constants (m, "GST_");
+
+ if (PyErr_Occurred ()) {
+ PyErr_Print ();
+ Py_FatalError ("can't initialize module gst.pbutils");
+ }
+}
test_struct.py \
test_segment.py \
test_taglist.py \
- test_xml.py
+ test_xml.py \
+ test_pbutils.py
check-local: testhelper.la
@PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/cleanup.py
file = gst.__file__
assert file.startswith(path), 'bad gst path: %s' % file
-# gst's interfaces and play are in topbuilddir/gst
+# gst's interfaces is in topbuilddir/gst
path = os.path.abspath(os.path.join(topbuilddir, 'gst'))
try:
import gst.interfaces
file = gst.interfaces.__file__
assert file.startswith(path), 'bad gst.interfaces path: %s' % file
+# gst's pbutils is in topbuilddir/gst
+path = os.path.abspath(os.path.join(topbuilddir, 'gst'))
+try:
+ import gst.pbutils
+except ImportError:
+ # hack: we import it from our builddir/gst/.libs instead; ugly
+ import pbutils
+ gst.pbutils = pbutils
+file = gst.pbutils.__file__
+assert file.startswith(path), 'bad gst.pbutils path: %s' % file
+
# testhelper needs gstltihooks
import gstltihooks
import testhelper
--- /dev/null
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# gst-python - Python bindings for GStreamer
+# Copyright (C) 2008 Edward Hervey <edward.hervey@collabora.co.uk>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser 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
+
+from common import gobject, gst, unittest, TestCase
+
+class Descriptions(TestCase):
+
+ def testSourceDescription(self):
+ assert hasattr(gst.pbutils, 'get_source_description')
+ self.assertEquals(gst.pbutils.get_source_description("file"),
+ "FILE protocol source")
+
+ def testSinkDescription(self):
+ assert hasattr(gst.pbutils, 'get_sink_description')
+ self.assertEquals(gst.pbutils.get_sink_description("file"),
+ "FILE protocol sink")
+
+ def testDecoderDescription(self):
+ assert hasattr(gst.pbutils, 'get_decoder_description')
+ self.assertEquals(gst.pbutils.get_decoder_description(gst.caps_from_string("audio/mpeg,mpegversion=1,layer=3")),
+ 'MPEG-1 Layer 3 (MP3) decoder')
+
+ def testCodecDescription(self):
+ assert hasattr(gst.pbutils, 'get_codec_description')
+ self.assertEquals(gst.pbutils.get_codec_description(gst.caps_from_string("audio/mpeg,mpegversion=1,layer=3")),
+ 'MPEG-1 Layer 3 (MP3)')
+
+ def testEncoderDescription(self):
+ assert hasattr(gst.pbutils, 'get_encoder_description')
+ self.assertEquals(gst.pbutils.get_encoder_description(gst.caps_from_string("audio/mpeg,mpegversion=1,layer=3")),
+ 'MPEG-1 Layer 3 (MP3) encoder')
+
+ def testElementDescription(self):
+ assert hasattr(gst.pbutils, 'get_element_description')
+ self.assertEquals(gst.pbutils.get_element_description("something"),
+ "GStreamer element something")
+
+ def testAddCodecDescription(self):
+ assert hasattr(gst.pbutils, 'add_codec_description_to_tag_list')
+
+# TODO
+# Add tests for the other parts of pbutils:
+# * missing-plugins
+# * install-plugins