[vlc-devel] Announce: brand new python bindings (ctypes-based)

Olivier Aubert olivier.aubert at liris.cnrs.fr
Thu Jul 30 11:03:07 CEST 2009

Hi all

There was some mention lately of the state of the python bindings, and
that some methods were missing. I have finally taken the time to toy
with an old idea, which proved to come out quite nicely.

There are now new bindings for the libvlc and mediacontrol APIs, which
are autogenerated from the include files, and using ctypes (the
now-standard python module to direcly call functions in dynamic
libraries). This brings :
* a nearly complete coverage of the APIs (there is some work to do to
properly implement event callbacks for instance), thanks to
* less distribution hassle, since the distributed file is pure python:
no compilation, no multiple versions across platforms...

In the cons section, there is some overhead (but it should not be
critical), and maintenance now means caring about a code parser/code
generator, which is more work (and also more funny) than simply writing
wrapper code.

See bindings/python-ctypes in the git repository for the generator
code/README/TODO, and http://www.advene.org/download/python-ctypes/ for
the generated module (for vlc 1.0.0 and trunk) and documentation.

Being 2-day old, it still needs some polishing and testing, but it is
already quite solid and usable.

Coding this brought about some issues :

- in include files, it is easier to parse prototypes with parameter
names, rather than prototypes with only parameter types (in the latter
case, I have to refer to the documentation to get parameter names). ATM,
both forms are present in include files. It would be nice to
progressively have only the named format. Any reactions about this?

- the (infamous for some) exception passing mechanism is quite useful to
automatize error checking and reporting. Should the new API aim at
removing exceptions in favor of more common idiom (return value/errno),
it could be more cumbersome to translate automatically. Care should be
taken here.

- the parsing code could be reused for other language bindings, in order
to automatize (at least part of) their generation too. I can also be
used to check the validity of includes. For instance, the following
are defined in include files, but are not implemented and this part of
the code has not seen any recent activity. The code should either be
implemented, or the prototypes removed from the includes.

Feel free to ask questions about it.


More information about the vlc-devel mailing list