Mercurial > libervia-backend
view doc/developer.rst @ 4231:e11b13418ba6
plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Implement XEP-0343: Signaling WebRTC Data Channels in Jingle. The current version of the
XEP (0.3.1) has no implementation and contains some flaws. After discussing this on xsf@,
Daniel (from Conversations) mentioned that they had a sprint with Larma (from Dino) to
work on another version and provided me with this link:
https://gist.github.com/iNPUTmice/6c56f3e948cca517c5fb129016d99e74 . I have used it for my
implementation.
This implementation reuses work done on Jingle A/V call (notably XEP-0176 and XEP-0167
plugins), with adaptations. When used, XEP-0234 will not handle the file itself as it
normally does. This is because WebRTC has several implementations (browser for web
interface, GStreamer for others), and file/data must be handled directly by the frontend.
This is particularly important for web frontends, as the file is not sent from the backend
but from the end-user's browser device.
Among the changes, there are:
- XEP-0343 implementation.
- `file_send` bridge method now use serialised dict as output.
- New `BaseTransportHandler.is_usable` method which get content data and returns a boolean
(default to `True`) to tell if this transport can actually be used in this context (when
we are initiator). Used in webRTC case to see if call data are available.
- Support of `application` media type, and everything necessary to handle data channels.
- Better confirmation message, with file name, size and description when available.
- When file is accepted in preflight, it is specified in following `action_new` signal for
actual file transfer. This way, frontend can avoid the display or 2 confirmation
messages.
- XEP-0166: when not specified, default `content` name is now its index number instead of
a UUID. This follows the behaviour of browsers.
- XEP-0353: better handling of events such as call taken by another device.
- various other updates.
rel 441
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 06 Apr 2024 12:57:23 +0200 |
parents | d6837db456fd |
children | 00852dd54695 |
line wrap: on
line source
.. _developer: ======================= Developer Documentation ======================= This documentation is intended for people who wants to contribute or work with the internals of the project, it is not for end-users. Storage ======= Since version 0.9, Libervia uses SQLAlchemy_ with its Object–Relational Mapping as a backend to store persistent data, and Alembic_ is used to handle schema and data migrations. SQLite_ is currently the only supported database, but it is planned to add support for other ones (notably PostgreSQL), probably during the development of 0.9 version. The mapping is done in ``libervia.backend.memory.sqla_mapping`` and working with database is done through high level methods found in ``libervia.backend.memory.sqla``. Before the move to SQLAlchemy, there was a strict separation between database implementation and the rest of the code. With 0.9, objects mapping to database can be used and manipulated directly outside of ``libervia.backend.memory.sqla`` to take profit of SQLAlchemy possibilities. Database state is detected when the backend starts, and the database will be created or migrated automatically if necessary. To create a new migration script, ``Alembic`` may be used directly. To do so, be sure to have an up-to-date database (and a backup in case of troubles), then activate the virtual environment where Libervia is installed (Alembic needs to access ORM mapping), go to ``libervia/backend/memory/migration`` directory, and enter the following command:: alembic revision --autogenerate -m "some revision message" This will create a base migration file in ``versions`` directory. Adapt it to your needs, try to create both ``upgrade`` and ``downgrade`` method whenever possible, and be sure to test it in both directions (``alembic upgrade head`` and ``alembic downgrade <previous_revision>``). Please check Alembic documentation for more details. .. _SQLALchemy: https://www.sqlalchemy.org/ .. _Alembic: https://alembic.sqlalchemy.org/ .. _SQLite: https://sqlite.org Pubsub Cache ============ There is an internal cache for pubsub nodes and items, which is done in ``plugin_pubsub_cache``. The ``PubsubNode`` and ``PubsubItem`` class are the one mapping the database. The cache is operated transparently to end-user, when a pubsub request is done, it uses a trigger to check if the requested node is or must be cached, and if possible returns result directly from database, otherwise it lets the normal workflow continue and query the pubsub service. To save resources, not all nodes are fully cached. When a node is checked, a series of analysers are checked, and the first one matching is used to determine if the node must be synchronised or not. Analysers can be registered by any plugins using ``register_analyser`` method: .. automethod:: libervia.backend.plugins.plugin_pubsub_cache.PubsubCache.register_analyser If no analyser is found, ``to_sync`` is false, or an error happens during the caching, the node won't be synchronised and the pubsub service will always be requested. Specifying an optional **parser** will store parsed data in addition to the raw XML of the items. This is more space consuming, but may be desired for the following reasons: * the parsing is resource consuming (network call or some CPU intensive operations are done) * it is desirable to do queries on parsed data. Indeed the parsed data are stored in a JSON_ field and its keys may be queried individually. The Raw XML is kept as the cache operates transparently, and a plugin may need raw data, or an user may be doing a low-level pubsub request. .. _JSON: https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.JSON