Skip to main content

Conn

Struct Conn 

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

Target chunk size announced to the peer (from server config).

§window_ack_size: u32§bytes_received: u64§bytes_at_last_ack: u64§media_bytes_received: u64

Audio/video payload bytes received (excludes handshake/control overhead).

§media_bytes_sent: u64

Audio/video payload bytes sent to this peer.

§client_fd: i32§conn_id: u64

Stable per-connection id (monotonic, never reused while the server runs).

§remote_addr: String

Peer socket address for logging (not persisted).

§transport: Option<Transport>§app: String§relay_key: String

Canonical 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: bool

When 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: usize

Cap 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: f64

Last measured client↔server RTT in milliseconds (RTMP UserControl ping).

§negotiated_caps: NegotiatedCaps

E-RTMP caps agreed during connect (empty when legacy connect).

§buffer_length_ms: u32

Player-side buffer length from SetBufferLength user control (ms).

Implementations§

Source§

impl Conn

Source

pub fn new() -> Self

Source

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).

Source

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.

Source

pub fn relay_route_key(&self) -> String

Key used to route relayed media between publishers and players.

Source

pub fn accepts_multitrack(&self) -> bool

Source

pub fn get_fd(&self) -> i32

Source

pub fn recv(&mut self, data: &[u8]) -> Result<()>

Source

pub fn process(&mut self, messages_budget: &mut usize) -> i32

Source

pub fn do_handshake(&mut self) -> i32

Source

pub fn read_messages(&mut self, messages_budget: &mut usize) -> i32

Source

pub fn apply_chunk_size(&mut self, chunk_size: u32)

Apply a chunk size to outbound writes and inbound reassembly.

Source

pub fn maybe_send_ping(&mut self) -> Result<()>

Send an RTMP ping when due and measure RTT from the client’s response.

Source

pub fn handle_command(&mut self, payload: &[u8]) -> Result<()>

Source

pub fn send_connect_response( &mut self, transaction_id: f64, caps: Option<&NegotiatedCaps>, ) -> Result<()>

Source

pub fn send_command_error( &mut self, transaction_id: f64, code: &str, description: &str, ) -> Result<()>

Source

pub fn send_create_stream_response( &mut self, transaction_id: f64, stream_id: u32, ) -> Result<()>

Source

pub fn send_onstatus( &mut self, stream_id: u32, level: &str, code: &str, description: &str, ) -> Result<()>

Source

pub fn flush(&mut self) -> Result<()>

Source

pub fn disconnect_transport(&mut self)

Drop the transport and clear the embedder-visible fd copy.

Source

pub fn send_frame( &mut self, frame_type: FrameType, timestamp: u32, payload: &[u8], ) -> Result<()>

Source

pub fn send_data_message( &mut self, timestamp: u32, payload: &[u8], ) -> Result<()>

Send an AMF0 data message (e.g. onMetaData) on the current stream.

Trait Implementations§

Source§

impl Default for Conn

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Conn

§

impl RefUnwindSafe for Conn

§

impl Send for Conn

§

impl Sync for Conn

§

impl Unpin for Conn

§

impl UnsafeUnpin for Conn

§

impl UnwindSafe for Conn

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.