moq_srt/lib.rs
1//! SRT gateway for MoQ, both directions.
2//!
3//! Runs an [SRT](https://www.haivision.com/products/srt-secure-reliable-transport/)
4//! listener and routes each connection by its stream-id `m=` mode against a
5//! [`moq_net::origin::Producer`]:
6//!
7//! - `m=publish` (the default): demux the MPEG-TS the connection carries with
8//! [`moq_mux`] and publish it into the origin as an ordinary broadcast. The
9//! contribution-ingest analogue of `moq-cli import ... hls` and `moq-rtc`'s WHIP.
10//! - `m=request`: re-mux a broadcast from the origin back to MPEG-TS and stream
11//! it to the caller, so a plain SRT player (VLC, ffmpeg) can watch it.
12//!
13//! Two entry points, depending on how much control you need over each request:
14//!
15//! - [`run`]: the unauthenticated convenience. Build a [`Config`] and hand it
16//! plus an origin to [`run`]; it accepts every publisher and subscriber and
17//! routes by prefix + resource name. A relay embeds this with
18//! `run(cluster.origin.clone(), config)`.
19//! - [`Server`] / [`Request`]: bring your own auth. Loop on [`Server::accept`],
20//! inspect [`Request::resource`] / [`Request::stream_id`] (treat the stream id
21//! as a token if you like), then match on the [`Request`]: accept a [`Publish`]
22//! into an origin, or accept a [`Subscribe`] out of one, at a path of your
23//! choosing (or reject it). This is how an embedder (e.g. a relay verifying a
24//! JWT and scoping the origin per token) plugs its policy in. It mirrors
25//! `moq-native`'s `Server` / `Request`.
26//!
27//! Beyond the listener, the [`dial`] module is the *dial-out* (client) role:
28//! connect to a remote SRT listener as a caller and either [`dial::publish`] a MoQ
29//! broadcast to it (restream MoQ out to a remote SRT ingest) or [`dial::pull`] a
30//! remote stream into an origin (ingest a remote SRT source). It reuses the same
31//! MPEG-TS <-> moq bridge; only the SRT caller transport is new.
32//!
33//! A command-line interface is provided by the `moq-cli` binary, on top of this
34//! library.
35//!
36//! Pure Rust: SRT is provided by `srt-tokio`, with no libsrt or ffmpeg
37//! dependency.
38
39#![warn(missing_docs)]
40
41pub mod dial;
42mod error;
43mod listen;
44mod server;
45mod ts;
46
47pub use error::{Error, Result};
48pub use listen::{Config, run};
49pub use server::{Publish, Request, Server, Subscribe};