From: <bi...@fr...> - 2005-06-28 16:14:11
|
CVS Root: /cvs/gstreamer Module: gst-python Changes by: bilboed Date: Tue Jun 28 2005 09:14:05 PDT Log message: * codegen/codegen.py: (GstMiniObjectWrapper.constructor_tmpl): let's not forget to wrap the MiniObject :) * gst/gst-types.defs: * gst/gst.defs: Always keep up to date with the core * gst/gstelement.override: override for gst_element_query_position * gst/pygstminiobject.c: * gst/pygstminiobject.h: * gst/gst.override: PyGstMiniObject now properly wrap GstMiniObject and are referenced in a global hash table Modified files: . : ChangeLog codegen : codegen.py gst : gst-types.defs gst.defs gst.override gstelement.override pygstminiobject.c pygstminiobject.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/ChangeLog.diff?r1=1.164&r2=1.165 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/codegen/codegen.py.diff?r1=1.7&r2=1.8 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gst-types.defs.diff?r1=1.17&r2=1.18 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gst.defs.diff?r1=1.29&r2=1.30 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gst.override.diff?r1=1.49&r2=1.50 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gstelement.override.diff?r1=1.4&r2=1.5 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/pygstminiobject.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/pygstminiobject.h.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-python/ChangeLog,v retrieving revision 1.164 retrieving revision 1.165 diff -u -d -r1.164 -r1.165 --- ChangeLog 26 Jun 2005 13:59:33 -0000 1.164 +++ ChangeLog 28 Jun 2005 16:13:52 -0000 1.165 @@ -1,3 +1,21 @@ +2005-06-28 Edward Hervey <ed...@fl...> + + * codegen/codegen.py: (GstMiniObjectWrapper.constructor_tmpl): + let's not forget to wrap the MiniObject :) + * gst/gst-types.defs: + * gst/gst.defs: + Always keep up to date with the core + * gst/gstelement.override: + override for gst_element_query_position + * gst/pygstminiobject.c: + * gst/pygstminiobject.h: + * gst/gst.override: + PyGstMiniObject now properly wrap GstMiniObject and are referenced in a + global hash table 2005-06-26 Edward Hervey <ed...@fl...> * codegen/argtypes.py: Index: codegen.py RCS file: /cvs/gstreamer/gst-python/codegen/codegen.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- codegen.py 26 Jun 2005 13:59:34 -0000 1.7 +++ codegen.py 28 Jun 2005 16:13:53 -0000 1.8 @@ -832,6 +832,7 @@ ' return -1;\n' \ ' }\n' \ '%(aftercreate)s' \ + ' pygstminiobject_register_wrapper((PyObject *)self);\n' \ ' return 0;\n' \ '}\n\n' method_tmpl = \ Index: gst-types.defs RCS file: /cvs/gstreamer/gst-python/gst/gst-types.defs,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- gst-types.defs 26 Jun 2005 13:59:34 -0000 1.17 +++ gst-types.defs 28 Jun 2005 16:13:53 -0000 1.18 @@ -673,7 +673,7 @@ '("ok" "GST_FLOW_OK") '("resend" "GST_FLOW_RESEND") '("error" "GST_FLOW_ERROR") - '("not-connected" "GST_FLOW_NOT_CONNECTED") + '("not-linked" "GST_FLOW_NOT_LINKED") '("not-negotiated" "GST_FLOW_NOT_NEGOTIATED") '("wrong-state" "GST_FLOW_WRONG_STATE") '("unexpected" "GST_FLOW_UNEXPECTED") Index: gst.defs RCS file: /cvs/gstreamer/gst-python/gst/gst.defs,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- gst.defs 26 Jun 2005 13:59:34 -0000 1.29 +++ gst.defs 28 Jun 2005 16:13:53 -0000 1.30 @@ -1031,6 +1031,18 @@ (return-type "GstIterator*") ) +(define-method iterate_src_pads + (of-object "GstElement") + (c-name "gst_element_iterate_src_pads") + (return-type "GstIterator*") +) +(define-method iterate_sink_pads + (c-name "gst_element_iterate_sink_pads") (define-method send_event (of-object "GstElement") (c-name "gst_element_send_event") @@ -2646,22 +2658,28 @@ ) -(define-method ref - (of-object "GstObject") +(define-function object_ref (c-name "gst_object_ref") - (return-type "GstObject*") + (return-type "gpointer") + (parameters + '("gpointer" "object") + ) -(define-method unref +(define-function object_unref (c-name "gst_object_unref") + (return-type "none") -(define-method sink +(define-function object_sink (c-name "gst_object_sink") (return-type "none") (define-function object_replace @@ -2772,23 +2790,32 @@ (c-name "gst_pad_set_active") (return-type "gboolean") (parameters - '("GstActivateMode" "mode") + '("gboolean" "active") -(define-method peer_set_active +(define-method is_active (of-object "GstPad") - (c-name "gst_pad_peer_set_active") + (c-name "gst_pad_is_active") + (return-type "gboolean") +(define-method activate_pull + (of-object "GstPad") + (c-name "gst_pad_activate_pull") -(define-method is_active +(define-method activate_push - (c-name "gst_pad_is_active") + (c-name "gst_pad_activate_push") (define-method set_blocked @@ -2868,12 +2895,21 @@ -(define-method set_loop_function +(define-method set_activatepull_function - (c-name "gst_pad_set_loop_function") + (c-name "gst_pad_set_activatepull_function") - '("GstPadLoopFunction" "loop") + '("GstPadActivateModeFunction" "activatepull") +(define-method set_activatepush_function + (c-name "gst_pad_set_activatepush_function") + '("GstPadActivateModeFunction" "activatepush") @@ -3322,7 +3358,7 @@ (is-constructor-of "GstPipeline") (return-type "GstElement*") - '("const-gchar*" "name") + '("const-gchar*" "name" (null-ok) (default "NULL")) @@ -5257,6 +5293,11 @@ +(define-function gst_alloc_trace_print_live + (c-name "gst_alloc_trace_print_live") (define-function alloc_trace_set_flags_all (c-name "gst_alloc_trace_set_flags_all") Index: gst.override RCS file: /cvs/gstreamer/gst-python/gst/gst.override,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- gst.override 26 Jun 2005 12:35:07 -0000 1.49 +++ gst.override 28 Jun 2005 16:13:53 -0000 1.50 @@ -232,6 +232,7 @@ #endif if (!pygst_value_init()) return; + pygst_miniobject_init(); } %% modulename gst Index: gstelement.override RCS file: /cvs/gstreamer/gst-python/gst/gstelement.override,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstelement.override 26 Jun 2005 13:59:34 -0000 1.4 +++ gstelement.override 28 Jun 2005 16:13:53 -0000 1.5 @@ -92,6 +92,7 @@ GstElementState state; GstElementStateReturn ret; + /* Only returns the state for the time being */ ret = gst_element_get_state(GST_ELEMENT (self->obj), &state, NULL, NULL); if (!ret) { PyErr_SetString(PyExc_RuntimeError, "conversion could not be performed"); @@ -409,3 +410,35 @@ return list; +%% +override gst_element_query_position args +static PyObject * +_wrap_gst_element_query_position (PyGObject *self, PyObject *args) +{ + gint64 cur, end; + gint format; + PyObject *pformat; + PyObject *ret; + int i; + pformat = (PyObject*)PyTuple_GetItem(args, 0); + if (pyg_enum_get_value (GST_TYPE_FORMAT, pformat, &format)) { + PyErr_SetString(PyExc_TypeError, "argument should be a GstFormat"); + return NULL; + } + ret = PyList_New(0); + if ((gst_element_query_position(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur, &end))) { + PyList_Append(ret, PyLong_FromLong(cur)); + PyList_Append(ret, PyLong_FromLong(end)); + PyList_Append(ret, pyg_enum_from_gtype (GST_TYPE_FORMAT, format )); + } else { + for (i = 0; i < 2; i++) { + Py_INCREF(Py_None); + PyList_Append(ret, Py_None); + } + PyList_Append(ret, pformat); + return ret; +} Index: pygstminiobject.c RCS file: /cvs/gstreamer/gst-python/gst/pygstminiobject.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pygstminiobject.c 26 Jun 2005 12:35:07 -0000 1.1 +++ pygstminiobject.c 28 Jun 2005 16:13:53 -0000 1.2 @@ -31,6 +31,13 @@ static int pygstminiobject_traverse(PyGstMiniObject *self, visitproc visit, void *arg); static int pygstminiobject_clear(PyGstMiniObject *self); +static GHashTable *miniobjs; +void +pygst_miniobject_init() + miniobjs = g_hash_table_new (NULL, NULL); /** * pygstminiobject_lookup_class: @@ -112,6 +119,31 @@ + * pygstminiobject_register_wrapper: + * @self: the wrapper instance + * + * In the constructor of PyGTK wrappers, this function should be + * called after setting the obj member. It will tie the wrapper + * instance to the Gstminiobject so that the same wrapper instance will + * always be used for this Gstminiobject instance. It will also sink any + * floating references on the Gstminiobject. + */ +pygstminiobject_register_wrapper(PyObject *self) + GstMiniObject *obj = ((PyGstMiniObject *)self)->obj; + if (!pygstminiobject_wrapper_key) + pygstminiobject_wrapper_key=g_quark_from_static_string(pygstminiobject_wrapper_id); + + Py_INCREF(self); + g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self); +/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */ +/* pyg_destroy_notify); */ +/** * pygstminiobject_new: * @obj: a GstMiniObject instance. * @@ -135,25 +167,33 @@ return Py_None; } - /* create wrapper */ - PyTypeObject *tp = pygstminiobject_lookup_class(G_OBJECT_TYPE(obj)); - /* need to bump type refcount if created with - pygstminiobject_new_with_interfaces(). fixes bug #141042 */ - if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE) - Py_INCREF(tp); - self = PyObject_GC_New(PyGstMiniObject, tp); - if (self == NULL) - return NULL; - self->obj = gst_mini_object_ref(obj); - - self->inst_dict = NULL; - self->weakreflist = NULL; - /* save wrapper pointer so we can access it later */ - Py_INCREF(self); - /* g_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */ -/* pyg_destroy_notify); */ - PyObject_GC_Track((PyObject *)self); + /* we already have a wrapper for this object -- return it. */ + self = (PyGstMiniObject *)g_hash_table_lookup (miniobjs, (gpointer) obj); +/* self = (PyGstMiniObject *)gst_mini_object_get_qdata(obj, pygstminiobject_wrapper_key); */ + if (self != NULL) { + Py_INCREF(self); + /* create wrapper */ + PyTypeObject *tp = pygstminiobject_lookup_class(G_OBJECT_TYPE(obj)); + /* need to bump type refcount if created with + pygstminiobject_new_with_interfaces(). fixes bug #141042 */ + if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE) + Py_INCREF(tp); + self = PyObject_GC_New(PyGstMiniObject, tp); + if (self == NULL) + return NULL; + self->obj = gst_mini_object_make_writable(obj); + + self->inst_dict = NULL; + self->weakreflist = NULL; + /* save wrapper pointer so we can access it later */ + g_hash_table_insert (miniobjs, (gpointer) obj, (gpointer) self); +/* gst_mini_object_set_qdata_full(obj, pygstminiobject_wrapper_key, self, */ +/* pyg_destroy_notify); */ + PyObject_GC_Track((PyObject *)self); return (PyObject *)self; @@ -177,6 +217,7 @@ /* the following causes problems with subclassed types */ /* self->ob_type->tp_free((PyObject *)self); */ + g_hash_table_remove (miniobjs, (gpointer) self); PyObject_GC_Del(self); @@ -242,6 +283,7 @@ static void pygstminiobject_free(PyObject *op) { + g_hash_table_remove (miniobjs, (gpointer) op); PyObject_GC_Del(op); Index: pygstminiobject.h RCS file: /cvs/gstreamer/gst-python/gst/pygstminiobject.h,v --- pygstminiobject.h 26 Jun 2005 12:35:07 -0000 1.1 +++ pygstminiobject.h 28 Jun 2005 16:13:53 -0000 1.2 @@ -36,6 +36,11 @@ pygstminiobject_register_class(PyObject *dict, const gchar *type_name, GType gtype, PyTypeObject *type, PyObject *bases); +pygstminiobject_register_wrapper(PyObject *self); +pygst_miniobject_init(); #ifndef _INSIDE_PYGSTMINIOBJECT_ @@ -43,25 +48,6 @@ extern PyTypeObject PyGstMiniObject_Type; -#define init_pygstminiobject() { \ - PyObject *gstminiobject = PyImport_ImportModule("gstminiobject"); \ - if (gstminiobject != NULL) { \ - PyObject *mdict = PyModule_GetDict(gstminiobject); \ - PyObject *cobject = PyDict_GetItemString(mdict, "_PyGstMiniObject_API"); \ - if (PyCObject_Check(cobject)) \ - _PyGstMiniObject_API = (struct _PyGstMiniObject_Functions *)PyCObject_AsVoidPtr(cobject); \ - else { \ - PyErr_SetString(PyExc_RuntimeError, \ - "could not find _PyGstMiniObject_API object"); \ - return; \ - } \ - } else { \ - PyErr_SetString(PyExc_ImportError, \ - "could not import gst"); \ - return; \ - } \ -} - #endif /* !_INSIDE_PYGSTMINIOBJECT_ */ G_END_DECLS |