pub trait InboundProtocol:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn serve<'life0, 'async_trait>(
&'life0 self,
ctx: IngestContext,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A pluggable inbound wire-protocol worker — the unit the engine runs to ingest a transport (RTMP, RTSP, SRT, WHIP, …).
Implement this in your own crate and register it with
EngineBuilder::protocol (or pass it to
Engine::serve); the engine never needs to know the
concrete type. A worker:
- binds its listener(s) inside
serve, - accepts connections and performs each protocol handshake,
- resolves a
StreamKeyand opens aPublishSessionvia theIngestContext, - bridges decoded access units to
MediaFrames and publishes them, - tears down cleanly when a connection closes or
shutdownfires.
Any type implementing the legacy ProtocolHandler
is automatically an InboundProtocol via a blanket bridge, so existing
handlers keep working unchanged.
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Stable, human-readable protocol name ("rtmp", "rtsp", …). Used in logs
and the engine’s per-worker lifecycle tracing.
Sourcefn serve<'life0, 'async_trait>(
&'life0 self,
ctx: IngestContext,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn serve<'life0, 'async_trait>(
&'life0 self,
ctx: IngestContext,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run the protocol’s listener until shutdown is cancelled.
Return Ok(()) on a clean shutdown. Returning Err signals a fatal fault
(e.g. the listener could not bind) and trips the engine’s coordinated
teardown, winding down sibling workers too.
Implementations must observe shutdown and return promptly once it is
cancelled; the engine awaits every worker during drain.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl InboundProtocol for RtmpHandler
ingest and rtmp only.RtmpHandler is the reference InboundProtocol
implementation: a real-world template for the multi-protocol ingestion
architecture. It owns a TCP listener via
run_tcp_ingest_server, performs the
RTMP handshake per connection, and bridges FLV AVC/AAC onto the bus through the
IngestContext’s registry — exactly the shape
an RTSP, SRT, or WHIP worker would take.
impl InboundProtocol for RtspHandler
ingest and rtsp only.impl InboundProtocol for SrtHandler
ingest and srt only.impl<T: ProtocolHandler + 'static> InboundProtocol for T
Blanket bridge: every legacy ProtocolHandler is an
InboundProtocol. New protocols should implement InboundProtocol directly
for the ergonomic IngestContext; this keeps pre-existing handlers working.