**NOTE: this page describes what is a Jami Plugin and how to install and use them.**
# Jami Plugins
As from September of 2020, Jami team has added plugins as a call feature for Linux, Windows, and Android users.
This meaning that now you can personalize your call experience by using one of our available plugins.
But that is not all, you can also transform your awesome ideas into a brand new plugin!
* To properly setup a plugin you must follow the steps in [#How to use it?](#how-to-use-it).
* To build a available plugin, please refer to [#How to build?](#how-to-build) instructions.
* To create your own plugin, please refer to [Create Plugin](http://git.jami.net/savoirfairelinux/ring-project/wikis/technical/Create_Plugin) instructions.
## How it works?
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.
## How to use it?
### Setup
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.
#### Android
To setup a plugin for Android you must go under Setting, enable plugins if they are disabled, and select a plugin file from your phone.
After installed it is automaticaly loaded.
Optionally, you can manually perform load/unload using the checkbox button on the plugin list.
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.
A difficulty for a lot of people working with tensorflow is how to properly build it.
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.
Here we carefully guide you through the proper build of tensorflow LITE Native and Tensorflow C++ API for our three supported platforms.
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.
#### Linux
Tensorflow LITE does not support desktops GPU. If you want to use them, please consider using C++ API
If you want to build Tensorflow C++ API with GPU suport, be sure to have a CUDA capable GPU and that you have
followed all installation steps for the Nvidia drivers, CUDA Toolkit, CUDNN, Tensor RT, that their versions
matches and that they are correct for the Tensorflow version you want to build.
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.
#### Android - Tensorflow LITE Native
For mobile applications Tensorflow LITE is the only option you want to consider and to succesfully build it you will also need:
* Android NDK 18r
Setup your build options with:
```bash
./configure
>> Do you wish to build TensorFlow with XLA JIT support? [Y/n]: n
>> Do you wish to download a fresh release of clang? (Experimental)[y/N]: y
>> Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: y
>> Please specify the home path of the Android NDK to use. [Default is /home/<username>/Android/Sdk/ndk-bundle]: put the right path to ndk 18r