Skip to main content

Python asyncio implementation of the MoQT protocol

Project description

aiomoqt - Media over QUIC Transport (MoQT)

aiomoqt is an implementation of the MoQT protocol, based on asyncio and qh3.

Overview

This package implements the MoQT Specification (draft-14). It is designed for general use as an MoQT client and server library, supporting both 'publish' and 'subscribe' roles.

The architecture follows the asyncio.Protocol design pattern, and extends the qh3 QuicConnectionProtocol.

Features

  • Full draft-14 protocol compliance (all message types, enums, wire formats)
  • Supports H3/WebTransport and raw QUIC transports
  • Async context manager support for session connection management
  • Supports asynchronous and awaitable synchronous calls via an optional flag
  • High-level API for control messages with default and custom response handlers
  • Low-level API for control and data message serialization/deserialization
  • SubgroupHeader stream variants (0x10-0x1D) with flag encoding
  • ObjectDatagram variants (0x00-0x07, 0x20-0x21) with flag encoding
  • Delta-encoded object IDs in subgroup streams
  • Interop test client implementing the moq-interop-runner test cases

Interop Test Results

All 6 standard moq-interop-runner test cases pass against multiple relay implementations:

Relay Transport Tests Result
Cloudflare moq-rs (draft-14) Raw QUIC 6/6 PASS
Meta moxygen (draft-14) Raw QUIC 6/6 PASS
Meta moxygen (draft-14) WebTransport 6/6 PASS

Test cases: setup-only, announce-only, publish-namespace-done, subscribe-error, announce-subscribe, subscribe-before-announce

# Run interop tests
python -m aiomoqt.examples.moq_interop_client -r "moqt://draft-14.cloudflare.mediaoverquic.com:443"
python -m aiomoqt.examples.moq_interop_client -r "moqt://fb.mvfst.net:9448"

Installation

Install using pip:

pip install aiomoqt

Or using uv:

uv pip install aiomoqt

Usage

Basic Client Example

import asyncio
from aiomoqt.client import MOQTClient

async def main():
    client = MOQTClient('localhost', 4433, endpoint='moq')

    async with client.connect() as session:
        try:
            await session.client_session_init()
            response = await session.subscribe(
                'namespace',
                'track_name',
                wait_response=True
            )
            # wait for session close, process data and control messages
            await session.async_closed()
        except Exception as e:
            session.close()

asyncio.run(main())

The high-level control message API provides typical default values for most arguments and flexible type handling for input arguments. Messages which expect a response support blocking asyncio await via an optional flag (wait_response=True), returning the response message object. Asynchronous calls return the request message object immediately.

The message serialization/deserialization classes provide <msg>.serialize() which returns a qh3.Buffer with the entire message serialized in buf.data. The <MsgClass>.deserialize() call returns an instance populated from the deserialized data.

Examples

See aiomoqt/examples/ for complete working examples:

Example Description
pub_example.py Publisher client — SubgroupHeader streams or ObjectDatagrams
sub_example.py Subscriber client — receives data from a relay
join_example.py SUBSCRIBE + FETCH (joining mid-stream)
bench_relay.py Combined pub/sub benchmark against a relay
bench_pub.py High-performance publisher with configurable parameters
bench_sub.py Subscriber with latency/jitter/loss statistics
server_example.py WebTransport server (origin)
moq_interop_client.py Interop test client (6 standard test cases, TAP14 output)

Development

To set up a development environment:

git clone https://github.com/gmarzot/aiomoqt.git
cd aiomoqt
./bootstrap_python.sh
source .venv/bin/activate

Local Installation

uv pip install -e ".[test]"

Running Tests

pytest aiomoqt/tests/

Known Limitations

  • Raw QUIC data streams: Data stream creation (SubgroupHeader streams, ObjectDatagrams on streams) currently requires WebTransport (_h3). Control plane messages work over raw QUIC, but publishers cannot send data objects in raw QUIC mode. This will be resolved with the aiopquic transport transition.

TODO

  • Raw QUIC data stream support (via aiopquic transport transition)
  • Dockerize interop test client for moq-interop-runner registration
  • Simple relay implementation
  • Support for MOQT File Format

Contributing

Contributions are welcome! If you'd like to contribute, please:

  • Fork the repository on GitHub.
  • Create a new branch for your feature or bug fix.
  • Submit a pull request with a clear description of your changes.

For major changes, please open an issue first to discuss your proposal.

Resources


Acknowledgements

This project takes inspiration from, and has benefited from the great work done by the OpenMOQ/moxygen team, and the continued efforts of the MOQ IETF WG.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiomoqt-0.5.2.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiomoqt-0.5.2-py3-none-any.whl (69.3 kB view details)

Uploaded Python 3

File details

Details for the file aiomoqt-0.5.2.tar.gz.

File metadata

  • Download URL: aiomoqt-0.5.2.tar.gz
  • Upload date:
  • Size: 58.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for aiomoqt-0.5.2.tar.gz
Algorithm Hash digest
SHA256 5980b6edb7b22e408ee99885e4662a4e735ed0460818100d06f3f9cfccc674bb
MD5 0f13f055c617eb455ce8de70eae67437
BLAKE2b-256 83026b4a29585d7c47bbc877f4e34bc88d2085e2b4d0b1a6f90d155934e25bc9

See more details on using hashes here.

File details

Details for the file aiomoqt-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: aiomoqt-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 69.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for aiomoqt-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3af42d02847065462b6bc51a0485d7b84bb6bef8c99e80d4849aa691a032b1d0
MD5 8eb9d355edbafd5e3022248695bee6cd
BLAKE2b-256 197c916fd026e2eab313e8874bd2f63ce627275b9325cb8d169453bfa627f2bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page