Skip to main content

InboundProtocol

Trait InboundProtocol 

Source
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:

  1. binds its listener(s) inside serve,
  2. accepts connections and performs each protocol handshake,
  3. resolves a StreamKey and opens a PublishSession via the IngestContext,
  4. bridges decoded access units to MediaFrames and publishes them,
  5. tears down cleanly when a connection closes or shutdown fires.

Any type implementing the legacy ProtocolHandler is automatically an InboundProtocol via a blanket bridge, so existing handlers keep working unchanged.

Required Methods§

Source

fn name(&self) -> &'static str

Stable, human-readable protocol name ("rtmp", "rtsp", …). Used in logs and the engine’s per-worker lifecycle tracing.

Source

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§

Source§

impl InboundProtocol for RtmpHandler

Available on crate features 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.

Source§

impl InboundProtocol for RtspHandler

Available on crate features ingest and rtsp only.
Source§

impl InboundProtocol for SrtHandler

Available on crate features ingest and srt only.
Source§

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.