Kodi Community Forum

Full Version: Help wanted: looking for information about binary add-ons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am maintaining the Kodi video add-on for PeerTube (code here - more information about PeerTube here) which requires a BitTorrent library since PeerTube is based on this protocol.
Currently the add-on uses libtorrent, a C++ implementation of the BitTorrent protocol which provides python bindings.
The python bindings are not easily installable on all the systems though: there is no official pip package yet (even though they are working on it) but even this will not help for some systems where pip cannot be used (Android, TvOS, JeOS, etc.).

There is a Kodi add-on which provides pre-built versions of libtorrent for many systems: script.module.libtorrent
It looks like a good solution (even though the maintaining effort may be quite big to support all the systems) but then I found out that binary add-ons exists after reading this and this but I was not able to find documentation about this.
So I am asking for your help since I am quite new to Kodi development eco-system.

Do you think a binary add-on based on libtorrent code is a good option for my use case? (libtorrent is used by many software so it may be of interest for other projects)
How are binary add-ons compiled for all the systems? Is it provided somehow by Kodi "infrastructure" or is the owner of the add-on responsible for it?

Thank you in advance for your help!
Yes, binary addons are built by Kodi infrastructure (Jenkins). The rule of thumb for addon submission to the official repo is that everything must be human-readable (artwork is included in that category) so binary blobs are not accepted. However, as far as Python binary libraries are concerned, those few libraries that are included with Kodi (Pillow, pycryprodome) are built with Kodi itself, except on generic Linux distributions that use Python libraries from system repos. This means that Kodi oficial repo does not contain any third-party binary Python libraries, everything Python-related is shipped with Kodi. And I don't think that something like libtorrent will be officially shipped with Kodi.

As for script.module.libtorrent, I was one of contributors to this library (I built Windows binaries). Binaries for different platforms were provided by various people who managed to create build environments for specific platforms. And that was real PITA considering that librorrent used (or maybe still uses, I haven't followed its development for some time) quite esoteric Boost Build system. 

All this means that if you want to resurrect script.module.libtorrent you will need to build binaries for all platforms that you want to support all by yourself. And note that binaries included in script.module.libtorrent were built against Python 2.7, and now you need to build them against Python 3.x.
Also, if I remember correctly Android binaries from script.module.libtorrent stopped working on latest Android versions because of some changes in Android.
Thank you for the detailed information about the binary add-ons  and script.module.libtorrent. It is much clearer for me now.

I don't know any other BitTorrent library than libtorrent which is actively maintained and feature complete. Moreover it seems it is used by many applications and torrent clients so I guess the support will continue.
So I will try to resurrect script.module.libtorrent even though it will not be easy to maintain as you said.
Based on what I read in libtorrent repository, they invested a lot in the compilation of the python bindings so I hope it will be easier than what you had to do some years ago.
I wil start small with only a few systems supported at first and then I may add additional systems like Android or tvOS.
If anybody is interested in this project and would like to help, please contact me !
The proper way would be to create a VFS binary addon, that uses libtorrent directly instead of going through python.
see https://github.com/xbmc?q=vfs&type=&language=&sort= for a few examples
Thanks for the suggestion wsnipex but it raised many questions in my head ^^

I had a look to the examples and here is what I understood:
- the library code (libtorrent in my case) has to be added in the add-on
- a customized class CMyAddon which includes libtorrent's code has to be called by ADDONCREATOR()
Is it correct? Is there any document explaining what is expected?

How different is a VFS binary add-on compared to a "classic" binary add-on?

When you said it is the "proper way" is it because a VFS binary add-on based on C++ code (libtorrent) would be accepted in Kodi's official repo contrary to a binary add-on containing a third-party python library (which was my original idea)?
Basically, a kodi binary addon consists of a C(++) library that uses Kodis C(++) API. There are several types of addons, implementing different functions inside kodi, e.g. PVR, Visualizations, Screensavers, VFS(Virtual File System)..
There is no "classic" binary addon, just different specializations.

An addon can have it's own external dependencies, independent of kodi itself.
Everything inside a binary addon source code must be human readable, including all dependencies. This is also true for python addons.
Kodi's binary addon build system handles building such external dependencies from source, so you would link against libtorrent, not include it's source code directly.


Take a look at the API docs:
https://alwinesch.github.io/group__cpp__...__vfs.html
https://alwinesch.github.io/group__cpp__..._defs.html

Example: https://github.com/xbmc/vfs.rar/blob/Mat.../RarFile.h

And here is an example how to add external library dependencies: https://github.com/xbmc/vfs.rar/tree/Mat...on/tinyxml
Since libtorrent uses cmake already, simply suppling the URL to the source tarball could be enough.
Thank you for the additional details and links.
I think I have enough information to start now even though I am not very skilled at writing C++ code so it may take a while. If anybody is interested to help, please contact me.
I will write back here when I made some progress (or if I'm stucked...).