Skip to main content

Module rtmp

Module rtmp 

Source
Available on crate features ingest and rtmp only.
Expand description

A working RTMP InboundProtocol: publish (ingest) and play (egress) over the real Adobe wire protocol.

This is the crate’s reference implementation of the multi-protocol ingestion architecture — a real, end-to-end template for the shape an RTSP, SRT, or WHIP worker would take.

Gated behind the rtmp feature. This is not a stub over the generic TCP accept loop — it performs the simple handshake, reassembles the chunk stream, decodes AMF0 commands, and bridges FLV audio/video tags to the engine’s lock-free bus:

  • PublishconnectcreateStreampublish brings up a StreamHandle via PublishRegistry::start_publish. Incoming AVC NALUs are converted to Annex-B (keyframes self-contained with SPS/PPS) and AAC to ADTS, then pushed through StreamHandle::publish_frame — so the GOP cache, QoS counters, and any Muxer (e.g. MpegTsMuxer) work unchanged.
  • Playplay resolves an existing stream, replays the cached configs + current GOP for an instant start, then forwards live frames as FLV tags.
use arcly_stream::prelude::*;
use arcly_stream::protocol::rtmp::RtmpHandler;

let engine = Engine::builder()
    .application(AppSpec::new("live").gop_cache(120))
    .build();
// `.with_playback` enables `play`; `Arc<Engine>` coerces to both registry traits.
let handler = RtmpHandler::new("0.0.0.0:1935".parse().unwrap())
    .with_playback(engine.clone());
// Publish to rtmp://host/live/<stream>, play from the same URL.
engine.serve(vec![Box::new(handler)], CancellationToken::new()).await

Structs§

RtmpHandler
RTMP protocol handler. One instance serves an address; each connection is an independent publish or play session.

Constants§

DEFAULT_RTMP_PORT
Default RTMP port.