Metadata-Version: 2.5
Name: trytond_mediaserver_delivery
Version: 8.0.0.3
Summary: Media Server Delivery
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: delivery,media,server,streaming,tryton
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Multimedia :: Video
Requires-Python: >=3.10
Requires-Dist: trytond-mediaserver-encoding<8.1,>=8.0
Requires-Dist: trytond-mediaserver-licensing<8.1,>=8.0
Requires-Dist: trytond-mediaserver<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

Mediaserver Delivery
====================

The ``mediaserver_delivery`` module provides streaming delivery for media
files managed by the ``mediaserver`` module.

Features
--------

- **Delivery endpoints** with tokenized URLs for HLS, DASH, and progressive
  (MP4, WebM, MKV) protocols.
- **Delivery channels** for grouping endpoints with a shared base URL.
- **Delivery statistics** tracking play counts, bytes served, and unique
  sessions per endpoint per day.
- **HLS manifest rewriting**: segment URIs in HLS playlists are rewritten
  to tokenized delivery URLs at request time.
- **HTTP Range request support** for seeking in progressive and segment
  files (RFC 7233 single-range).
- **Concurrent play enforcement** via integration with
  ``mediaserver_licensing``: play sessions are started before manifest
  delivery and ended after a configurable inactivity timeout.
- **Client API** endpoint for retrieving available delivery URLs for a
  media file.

Configuration
-------------

The following options can be set in the ``[mediaserver]`` section of
``trytond.conf``:

- ``delivery_base_url`` — Base URL for constructing absolute delivery URLs.
  Falls back to the trytond ``http_host`` if not set.
- ``delivery_session_timeout`` — Inactivity timeout in seconds for play
  sessions (default: 1800).

Routes
------

- ``GET /<database>/mediaserver/delivery/manifest/<token>``
  Serve a manifest (HLS/DASH) or redirect to the file route for
  progressive protocols.
- ``GET /<database>/mediaserver/delivery/file/<token>``
  Serve an encoded file or HLS segment with Range support.
- ``GET /<database>/mediaserver/delivery/api/media/<media_file_id>``
  JSON API returning available delivery endpoints for a media file.

See ``doc/api.rst`` for the full HTTP API reference including
authentication, request/response headers, status codes, error
mapping, range request behaviour, and JSON schema.

Models
------

The module registers the following models:

.. list-table::
   :header-rows: 1
   :widths: 35 20 45

   - - Model name
     - Class
     - Description
   - - ``mediaserver_delivery.channel``
     - DeliveryChannel
     - Grouping for delivery endpoints that share a common base URL.
   - - ``mediaserver_delivery.endpoint``
     - DeliveryEndpoint
     - Tokenized delivery URL for a specific encoded file and protocol.
   - - ``mediaserver_delivery.stats``
     - DeliveryStats
     - Daily play count, bytes served, and unique sessions per endpoint.
   - - ``mediaserver_licensing.play_session``
     - PlaySession (extension)
     - Adds ``endpoint`` and ``bytes_served`` to the licensing play
       session to track which delivery endpoint initiated a stream.
   - - ``mediaserver.media_file``
     - MediaFile (extension)
     - Adds the ``delivery_endpoints`` one-to-many and the
       ``delivery_play_count`` functional field.

Cron jobs
---------

Two cron methods are registered on ``ir.cron``:

.. list-table::
   :header-rows: 1
   :widths: 40 20 40

   - - Method
     - Interval
     - Purpose
   - - ``mediaserver_delivery.endpoint|end_stale_sessions``
     - Every 5 minutes
     - End play sessions that have been inactive beyond the configured
       ``delivery_session_timeout``.
   - - ``mediaserver_delivery.stats|aggregate_daily``
     - Daily
     - Finalize the unique session counts in the daily statistics rows.

Wizards
-------

No wizards are provided by this module.
