Skip to main content

RtmpPacketSource

Struct RtmpPacketSource 

Source
pub struct RtmpPacketSource { /* private fields */ }
Expand description

PacketSource wrapping an RtmpSession.

Constructed by open_rtmp (the registry opener) or directly from a session via RtmpPacketSource::from_session — the latter is useful for callers driving their own RtmpServer::accept loop who want the typed-packet conversion without the listen-and-validate flow.

Implementations§

Source§

impl RtmpPacketSource

Source

pub fn from_session(session: RtmpSession) -> Self

Wrap a freshly-accepted RtmpSession without any probing — streams() will be empty until the first audio / video packet flows. Suitable for callers who already know the stream shape (e.g. they are also the publisher).

Source

pub fn from_session_with_probe( session: RtmpSession, read_timeout: Option<Duration>, ) -> RtmpResult<Self>

Wrap a session and run the probing loop now: read up to PROBE_LIMIT packets, populate streams() with the observed audio + video codec ids, and buffer those packets for later next_packet calls.

read_timeout bounds individual reads so a publisher that only ever sends one stream-type doesn’t stall probing indefinitely. None keeps the socket blocking with no timeout — only safe when the caller knows the publisher will eventually send both kinds.

Source

pub fn session(&self) -> &RtmpSession

Borrow the wrapped session for advanced operations (set_read_timeout, peer_addr, …). Reading directly would interfere with the PacketSource machinery; prefer inspection-only methods.

Trait Implementations§

Source§

impl PacketSource for RtmpPacketSource

Source§

fn streams(&self) -> &[StreamInfo]

Streams advertised by this source. Stable across the lifetime of the source.
Source§

fn next_packet(&mut self) -> CoreResult<Packet>

Read the next packet from any stream. Returns Error::Eof at end of stream.
Source§

fn metadata(&self) -> &[(String, String)]

Source-level metadata as ordered (key, value) pairs. Default is empty.
Source§

fn duration_micros(&self) -> Option<i64>

Source-level duration in microseconds, if known. Default is None. Live sources (RTMP push, etc.) typically return None.

Auto Trait Implementations§

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.