* To create your own plugin, please refer to [Create Plugin](http://git.jami.net/savoirfairelinux/ring-project/wikis/technical/Create_Plugin) instructions.
Jami can be break down to three main components that interact together: Daemon, LRC and clients.
Daemon is the core of Jami, and although it does not interact with users, it is involved in every
command. Therefore, Daemon has a `JamiPluginManager` class that among other actions perfoms install/uninstall, load/unload, edit preferences and control plugins' usage.
Despite Daemon importance, what a plugin effectivelly does to a call video is unknown to it the same way Daemon does not know what is effectivelly done by LRC or the clients interfaces.
Plugins then can be seen as a forth interacting component in Jami.
The plugin system inside Jami exposes different APIs that can be used by the plugins. For instance, the Media Handler API enables the plugins to modify audio and video streams from Jami calls. This API is used by our GreenScreen plugin but could also be used to build a YouTube streaming system, various instagram-style filters, a real time translation service, etc.
Plugins can be composed by one or multiple media handlers that are responsible for attaching/detaching a media stream from Jami and a data process. Each media handler represent a functionality that can be totally different between them or can be a modified versions of the same core process. In our example, we have only one functionality, it being, the GreenScreen plugin has one media handler wich data process is responsible for segmenting the foreground from a video frame and applying another image to the background, just like it is done with the green screens in movies!
To use one custom functionality, it is necessary that Jami knows all plugins' media handlers, wich one is going to be used and the data that should be processed. Plugin's media handlers are created once a plugin is loaded and are shared with Daemon's Plugin Manager. The data is inside Jami flow (for a call plugin, in the event of a new call, Jami creates and stores the corresponding media stream subjects). Finally, once a user puts a plugin functionality in action Jami tells this media handler to attach the available data. When deactivated, Jami tells the media handler to dettach.
A Jami plugin is a `pluginname.jpl` file, and it must be installed to your Jami.
Once installed, Jami will add your new plugin to the available plugins list but they will not be ready for use yet. Plugins are libraries and must be loaded if you want to expose them.
Moreover, plugin may have preferences and besides install/uninstall and load/unload actions, it is possible to modify those preferences. For example, our GreenScreen plugin allows the user to change the background image displayed.
Similarly, for the client-qt available on Linux and Windows and for the client-gnome available only on Linux, you must go to Prefences, enable plugins if it is disabled, and select a plugins file from your computer.
Each plugin in the shown list is linked to two buttons beeing:
- Client-qt: a load/unload button and a preferences button;
- Client-gnome: a load/unload button and a uninstall button;
For client-gnome it is not possible to change plugin's preferences.
With that in mind we created docker images with cuda and tensorflow libraries available for GNU/Linux builds [here](https://hub.docker.com/repository/docker/sflagsantos/tensorflow-cuda) and for Android builds [here](https://hub.docker.com/repository/docker/sflagsantos/tensorflowlite). These docker can be used to build plugins for Linux and Android, however they cannot handle Windows.
We assembled Tensorflow headers needed to build plugins, to access them you only have to extract `libs.tar.gz` file found under `jami-project/plugins/contrib`. However, if you are using another tensorflow version or you want to do it by yourself, you can follow the assemble instructions for Tensorflow LITE Native and C++ API are available under [jami-plugins](https://git.jami.net/savoirfairelinux/jami-plugins) README_ASSEMBLE file.
There may be some missign references while compilling a plugin with Tensorflow C++ API. If that happens you have to rebuild you tensorflow and explicitly export the missing symbols. Fortunatelly Tensorflow now has a easy workaround to do so, you only have to feed [this]("https://github.com/tensorflow/tensorflow/blob/v2.2.0/tensorflow/tools/def_file_filter/def_file_filter.py.tpl") file with the desired symbols.