pub struct Conn {Show 42 fields
pub state: ConnState,
pub handshake: Handshake,
pub recv_buffer: Buffer,
pub send_buffer: Buffer,
pub chunk_reg: ChunkRegistry,
pub chunk_size: u32,
pub window_ack_size: u32,
pub bytes_received: u64,
pub bytes_at_last_ack: u64,
pub media_bytes_received: u64,
pub media_bytes_sent: u64,
pub client_fd: i32,
pub conn_id: u64,
pub remote_addr: String,
pub transport: Option<Transport>,
pub app: String,
pub relay_key: String,
pub next_stream_id: u32,
pub current_stream: Option<Box<Stream>>,
pub connect_cb_fired: bool,
pub send_mutex: Mutex<()>,
pub pending_relay: Vec<RelayFrame>,
pub needs_init_frames: bool,
pub detected_video_codec: Option<String>,
pub detected_audio_codec: Option<String>,
pub detected_video_width: Option<u32>,
pub detected_video_height: Option<u32>,
pub detected_video_framerate: Option<f64>,
pub detected_audio_sample_rate: Option<u32>,
pub detected_audio_channels: Option<u32>,
pub relay_enabled: bool,
pub defer_media_relay: bool,
pub max_pending_relay_bytes: usize,
pub on_frame_cb: Option<fn(&Frame)>,
pub on_media_cb: Option<fn(u64, FrameType, Option<&str>) -> bool>,
pub on_connect_cb: Option<fn()>,
pub on_publish_cb: Option<fn(conn_id: u64, app: &str, stream_name: &str) -> bool>,
pub on_play_cb: Option<fn(conn_id: u64, app: &str, stream_name: &str) -> bool>,
pub pending_cache_evictions: Vec<(String, String)>,
pub rtt_ms: f64,
pub negotiated_caps: NegotiatedCaps,
pub buffer_length_ms: u32,
/* private fields */
}Fields§
§state: ConnState§handshake: Handshake§recv_buffer: Buffer§send_buffer: Buffer§chunk_reg: ChunkRegistry§chunk_size: u32Target chunk size announced to the peer (from server config).
window_ack_size: u32§bytes_received: u64§bytes_at_last_ack: u64§media_bytes_received: u64Audio/video payload bytes received (excludes handshake/control overhead).
media_bytes_sent: u64Audio/video payload bytes sent to this peer.
client_fd: i32§conn_id: u64Stable per-connection id (monotonic, never reused while the server runs).
remote_addr: StringPeer socket address for logging (not persisted).
transport: Option<Transport>§app: String§relay_key: StringCanonical relay route key. When set, publisher/player media is matched on this value instead of the RTMP stream name (e.g. separate publish/play keys).
next_stream_id: u32§current_stream: Option<Box<Stream>>§connect_cb_fired: bool§send_mutex: Mutex<()>§pending_relay: Vec<RelayFrame>§needs_init_frames: bool§detected_video_codec: Option<String>§detected_audio_codec: Option<String>§detected_video_width: Option<u32>§detected_video_height: Option<u32>§detected_video_framerate: Option<f64>§detected_audio_sample_rate: Option<u32>§detected_audio_channels: Option<u32>§relay_enabled: bool§defer_media_relay: boolWhen true, media relay stays off until the integrator sets relay_enabled
after its own post-auth bookkeeping (used by librtmp2-server).
max_pending_relay_bytes: usizeCap on queued relay payload bytes for this connection.
on_frame_cb: Option<fn(&Frame)>§on_media_cb: Option<fn(u64, FrameType, Option<&str>) -> bool>When set, must return true before audio/video is queued for relay.
For a multitrack (ManyTracks/ManyTracksManyCodecs) container, this
is called once per track with that track’s codec, not once per frame —
any single denial rejects the whole frame.
on_connect_cb: Option<fn()>§on_publish_cb: Option<fn(conn_id: u64, app: &str, stream_name: &str) -> bool>§on_play_cb: Option<fn(conn_id: u64, app: &str, stream_name: &str) -> bool>§pending_cache_evictions: Vec<(String, String)>Cache keys to evict after the publisher renames its stream.
rtt_ms: f64Last measured client↔server RTT in milliseconds (RTMP UserControl ping).
negotiated_caps: NegotiatedCapsE-RTMP caps agreed during connect (empty when legacy connect).
buffer_length_ms: u32Player-side buffer length from SetBufferLength user control (ms).
Implementations§
Source§impl Conn
impl Conn
pub fn new() -> Self
Sourcepub fn session_setup_timed_out(&self) -> bool
pub fn session_setup_timed_out(&self) -> bool
True when an inbound peer has held a connection slot without being an
active publisher or player for longer than
[RTMP_SESSION_SETUP_TIMEOUT]. Covers incomplete handshakes, post-
connect idle sessions that only answer server pings, and sessions
that stopped publishing/playing and haven’t resumed within a fresh
grace window (session_setup_started is reset on every such
transition – see FCUnpublish/deleteStream/closeStream in
handle_command).
Sourcepub fn has_buffered_messages(&self) -> bool
pub fn has_buffered_messages(&self) -> bool
True if the last recv/process pass stopped early because the
per-call message budget was exhausted while complete messages were
still buffered. Callers (e.g. the server poll loop) should keep
calling recv(&[]) until this returns false so a batch larger than
the budget doesn’t stall waiting on the peer to send more bytes.
Sourcepub fn relay_route_key(&self) -> String
pub fn relay_route_key(&self) -> String
Key used to route relayed media between publishers and players.
pub fn accepts_multitrack(&self) -> bool
pub fn get_fd(&self) -> i32
pub fn recv(&mut self, data: &[u8]) -> Result<()>
pub fn process(&mut self, messages_budget: &mut usize) -> i32
pub fn do_handshake(&mut self) -> i32
pub fn read_messages(&mut self, messages_budget: &mut usize) -> i32
Sourcepub fn apply_chunk_size(&mut self, chunk_size: u32)
pub fn apply_chunk_size(&mut self, chunk_size: u32)
Apply a chunk size to outbound writes and inbound reassembly.
Sourcepub fn maybe_send_ping(&mut self) -> Result<()>
pub fn maybe_send_ping(&mut self) -> Result<()>
Send an RTMP ping when due and measure RTT from the client’s response.
pub fn handle_command(&mut self, payload: &[u8]) -> Result<()>
pub fn send_connect_response( &mut self, transaction_id: f64, caps: Option<&NegotiatedCaps>, ) -> Result<()>
pub fn send_command_error( &mut self, transaction_id: f64, code: &str, description: &str, ) -> Result<()>
pub fn send_create_stream_response( &mut self, transaction_id: f64, stream_id: u32, ) -> Result<()>
pub fn send_onstatus( &mut self, stream_id: u32, level: &str, code: &str, description: &str, ) -> Result<()>
pub fn flush(&mut self) -> Result<()>
Sourcepub fn disconnect_transport(&mut self)
pub fn disconnect_transport(&mut self)
Drop the transport and clear the embedder-visible fd copy.