GNOME Bugzilla – Bug 159366
Some additions to gst-python
Last modified: 2005-06-30 15:31:56 UTC
In order to make a DVD virtual machine written almost entirely in Python work, I had to make some enhancements to GstPython. The attached patch contains them: * gst/gst.override (_wrap_gst_event_new_any) (_wrap_gst_event_new_discontinuous) (_wrap_gst_event_any_get_structure) (_wrap_gst_registry_pool_plugin_list): * gst/gst.defs (get_data, event_new_any, any_get_structure): Added basic support for "ANY" (navigation) events. Added basic support for discont events (only one value for now, we are limited by the GStreamer API). Now it is possible to access data in a GstBuffer as a string Added a definition for method get_data of GstBuffer. * gst/gst.override (_wrap_gst_structure_set_value): Add an optional parameter to allow selection of the right G_TYPE. If no type is specified, make an educated guess. Since I never commited code to gst-python, I'm posting the patch here. Johan: please let me know if it'd be OK to directly commit similar patches in the future.
Created attachment 34103 [details] [review] Various enhancements to gst-python Patch referenced in the main bug description.
Martin, thanks for submitting the patch, it looks good apart from _wrap_gst_structure_set_value. I'm not really convinced that the type of the structure needs to be sent as an argument, a most important goal of the bindings is to integrate well into the python language, and passing the type around is not very pythonish. However, I am aware that the type of a GstStructure might be a little hard to map properly to a PyObject. So I would prefer that only pyg_type_from_object should be used, and when it doesn't work correctly pygtk itself should be fixed. Can you please tell me why you feel that it's not working as expected and we should work out so pyg_type_from_object gets a little smarter. However, since it's optional I'm not so much against it.
The issue with _wrap_gst_structure_set_value: Unfortunately, the set of Python types is not as wide as the set of glib types. My issue, is that I generate DVD events directly from Python. One particular event contains two GstClockTime fields, which are represented in the structure as guint64 fields. There is no way to achive the right values using pyg_type_from_object, and if the type doesn't match exactly, elements down the pipeline (dvddemux) will complain. I really tried to find a nicer solution, but it looks hard. My proposal is to commit the patch now as is, and look for a better solution in the near future.
Martin committed this to cvs.