From: <tho...@fr...> - 2005-09-18 11:54:52
|
CVS Root: /cvs/gstreamer Module: gst-python Changes by: thomasvs Date: Sun Sep 18 2005 04:54:46 PDT Log message: update for new plugin API Modified files: . : ChangeLog configure.ac gst : gst.defs gst.override gstmodule.c testsuite : test_registry.py Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/ChangeLog.diff?r1=1.238&r2=1.239 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/configure.ac.diff?r1=1.71&r2=1.72 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gst.defs.diff?r1=1.52&r2=1.53 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gst.override.diff?r1=1.65&r2=1.66 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gstmodule.c.diff?r1=1.26&r2=1.27 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/testsuite/test_registry.py.diff?r1=1.3&r2=1.4 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-python/ChangeLog,v retrieving revision 1.238 retrieving revision 1.239 diff -u -d -r1.238 -r1.239 --- ChangeLog 18 Sep 2005 11:06:41 -0000 1.238 +++ ChangeLog 18 Sep 2005 11:54:34 -0000 1.239 @@ -1,5 +1,14 @@ 2005-09-18 Thomas Vander Stichele <thomas at apestaart dot org> + * configure.ac: + * gst/gst.defs: + * gst/gst.override: + * gst/gstmodule.c: (init_gst): + * testsuite/test_registry.py: + update for new plugin API + +2005-09-18 Thomas Vander Stichele <thomas at apestaart dot org> * gst/gst-types.defs: * gst/gst.override: * testsuite/test_registry.py: Index: configure.ac RCS file: /cvs/gstreamer/gst-python/configure.ac,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- configure.ac 3 Aug 2005 16:54:57 -0000 1.71 +++ configure.ac 18 Sep 2005 11:54:34 -0000 1.72 @@ -23,7 +23,7 @@ ACLOCAL="$ACLOCAL -I common/m4 $ACLOCAL_FLAGS" dnl required versions of other packages -AC_SUBST(PYGTK_REQ, 2.6.1) +AC_SUBST(PYGTK_REQ, 2.4.1) AC_SUBST(GLIB_REQ, 2.0.0) AC_SUBST(GTK_REQ, 2.0.0) AC_SUBST(GST_REQ, 0.9.0) Index: gst.defs RCS file: /cvs/gstreamer/gst-python/gst/gst.defs,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- gst.defs 16 Sep 2005 12:33:07 -0000 1.52 +++ gst.defs 18 Sep 2005 11:54:34 -0000 1.53 @@ -3782,22 +3782,6 @@ ) ) -(define-method get_feature_list - (of-object "GstPlugin") - (c-name "gst_plugin_get_feature_list") - (return-type "GList*") -) - -(define-method find_feature - (c-name "gst_plugin_find_feature") - (return-type "GstPluginFeature*") - (parameters - '("const-gchar*" "name") - '("GType" "type") - ) (define-function plugin_check_file (c-name "gst_plugin_check_file") (return-type "gboolean") @@ -3816,14 +3800,6 @@ -(define-method add_feature - (c-name "gst_plugin_add_feature") - (return-type "none") - '("GstPluginFeature*" "feature") (define-method load (of-object "GstPlugin") @@ -4128,6 +4104,15 @@ +(define-method find_plugin + (of-object "GstRegistry") + (c-name "gst_registry_find_plugin") + (return-type "GstPlugin*") + (parameters + '("const-gchar*" "name") + ) +) (define-method feature_filter (of-object "GstRegistry") (c-name "gst_registry_feature_filter") @@ -4148,15 +4133,25 @@ -(define-method find_plugin +(define-method add_feature - (c-name "gst_registry_find_plugin") - (return-type "GstPlugin*") + (c-name "gst_registry_add_feature") + (return-type "none") (parameters + '("GstPluginFeature*" "feature") +(define-method remove_feature + (c-name "gst_registry_remove_feature") (define-method find_feature (c-name "gst_registry_find_feature") @@ -4167,6 +4162,15 @@ +(define-method lookup_feature + (c-name "gst_registry_lookup_feature") + (return-type "GstPluginFeature*") + '("const-char*" "name") (define-method lookup (c-name "gst_registry_lookup") Index: gst.override RCS file: /cvs/gstreamer/gst-python/gst/gst.override,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- gst.override 18 Sep 2005 11:06:41 -0000 1.65 +++ gst.override 18 Sep 2005 11:54:34 -0000 1.66 @@ -604,35 +604,7 @@ g_free (repr); return ret; } -%% -override gst_plugin_get_feature_list noargs -static PyObject * -_wrap_gst_plugin_get_feature_list(PyGObject *self) -{ - PyObject *ret; - PyObject *item; - GList *l, *features; - features = gst_plugin_get_feature_list (GST_PLUGIN (self->obj)); - ret = PyList_New(0); - for (l = features; l; l = g_list_next(l)) { - item = pygobject_new((GObject *) GST_PLUGIN_FEATURE(l->data)); - if (!item) { - Py_DECREF(ret); - return NULL; - } - PyList_Append(ret, item); - Py_DECREF(item); - } - g_list_free(features); - return ret; -} %% override gst_type_find_factory_get_caps noargs static PyObject * @@ -696,6 +668,29 @@ +override gst_registry_get_path_list +static PyObject * +_wrap_gst_registry_get_path_list (PyGObject *self) +{ + GstRegistry *registry; + GList *l, *paths; + PyObject *list; + + registry = GST_REGISTRY (self->obj); + paths = gst_registry_get_path_list (registry); + list = PyList_New (0); + for (l = paths; l; l = l->next) { + gchar *path = (gchar *) l->data; + PyList_Append (list, PyString_FromString(path)); + } + g_list_free (paths); + return list; +} +%% override gst_registry_get_plugin_list _wrap_gst_registry_get_plugin_list (PyGObject *self) @@ -718,25 +713,38 @@ return list; +override gst_registry_get_feature_list kwargs -_wrap_gst_registry_get_feature_list (PyGObject *self) +_wrap_gst_registry_get_feature_list (PyGObject *self, PyObject *args, PyObject *kwargs) { - GstRegistry *registry; - GList *l, *features; - PyObject *list; + static char *kwlist[] = { "type", NULL }; + PyObject *py_type = NULL; + GType type; + GstRegistry *registry; + GList *l, *features; + PyObject *list; - registry = GST_REGISTRY (self->obj); - features = gst_registry_get_feature_list (registry); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GstRegistry.get_feature_list", kwlist, &py_type)) + return NULL; + if ((type = pyg_type_from_object(py_type)) == 0) - list = PyList_New (0); - for (l = features; l; l = l->next) { - GstPluginFeature *feature = (GstPluginFeature *) l->data; - PyList_Append (list, pygobject_new (G_OBJECT (feature))); - g_list_free (features); + registry = GST_REGISTRY (self->obj); + features = gst_registry_get_feature_list (registry, type); + list = PyList_New (0); + for (l = features; l; l = l->next) { + GstPluginFeature *feature = (GstPluginFeature *) l->data; + PyList_Append (list, pygobject_new (G_OBJECT (feature))); + } + g_list_free (features); - return list; + return list; Index: gstmodule.c RCS file: /cvs/gstreamer/gst-python/gst/gstmodule.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstmodule.c 1 Sep 2005 14:41:28 -0000 1.26 +++ gstmodule.c 18 Sep 2005 11:54:34 -0000 1.27 @@ -45,6 +45,22 @@ GST_DEBUG_CATEGORY (pygst_debug); /* for bindings code */ GST_DEBUG_CATEGORY (python_debug); /* for python code */ +/* copied from pygtk to register GType */ +#define REGISTER_TYPE(d, type, name) \ + type.ob_type = &PyType_Type; \ + type.tp_alloc = PyType_GenericAlloc; \ + type.tp_new = PyType_GenericNew; \ + if (PyType_Ready(&type)) \ + return; \ + PyDict_SetItemString(d, name, (PyObject *)&type); +#define REGISTER_GTYPE(d, type, name, gtype) \ + REGISTER_TYPE(d, type, name); \ + PyDict_SetItemString(type.tp_dict, "__gtype__", \ + o=pyg_type_wrapper_new(gtype)); \ + Py_DECREF(o); /* This is a timeout that gets added to the mainloop to handle SIGINT (Ctrl-C) * Other signals get handled at some other point where transition from * C -> Python is being made. @@ -148,6 +164,7 @@ PyDict_SetItemString(d, "pygst_version", tuple); Py_DECREF(tuple); + /* clock stuff */ PyModule_AddIntConstant(m, "SECOND", GST_SECOND); PyModule_AddIntConstant(m, "MSECOND", GST_MSECOND); PyModule_AddIntConstant(m, "NSECOND", GST_NSECOND); @@ -170,6 +187,14 @@ pygst_register_classes (d); pygst_add_constants (m, "GST_"); + /* make our types available */ + PyModule_AddObject (m, "TYPE_ELEMENT_FACTORY", + pyg_type_wrapper_new(GST_TYPE_ELEMENT_FACTORY)); + PyModule_AddObject (m, "TYPE_INDEX_FACTORY", + pyg_type_wrapper_new(GST_TYPE_INDEX_FACTORY)); + PyModule_AddObject (m, "TYPE_TYPE_FIND_FACTORY", + pyg_type_wrapper_new(GST_TYPE_TYPE_FIND_FACTORY)); /* Initialize debugging category */ GST_DEBUG_CATEGORY_INIT (pygst_debug, "pygst", 0, "GStreamer python bindings"); GST_DEBUG_CATEGORY_INIT (python_debug, "python", 0, "python code using gst-python"); Index: test_registry.py RCS file: /cvs/gstreamer/gst-python/testsuite/test_registry.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_registry.py 18 Sep 2005 11:06:42 -0000 1.3 +++ test_registry.py 18 Sep 2005 11:54:34 -0000 1.4 @@ -35,10 +35,25 @@ def testFeatureList(self): registry = gst.registry_get_default() - features = registry.get_feature_list() + self.assertRaises(TypeError, registry.get_feature_list, "kaka") + + features = registry.get_feature_list(gst.TYPE_ELEMENT_FACTORY) elements = map(lambda f: f.get_name(), features) self.failUnless('fakesink' in elements) + features = registry.get_feature_list(gst.TYPE_TYPE_FIND_FACTORY) + typefinds = map(lambda f: f.get_name(), features) + features = registry.get_feature_list(gst.TYPE_INDEX_FACTORY) + indexers = map(lambda f: f.get_name(), features) + self.failUnless('memindex' in indexers) + def testGetPathList(self): + # FIXME: this returns an empty list; probably due to core; + # examine problem + registry = gst.registry_get_default() + paths = registry.get_path_list() if __name__ == "__main__": unittest.main() |