Skip to main content

AsyncRtmpClient

Struct AsyncRtmpClient 

Source
pub struct AsyncRtmpClient<S = TcpStream> { /* private fields */ }
Available on crate feature tokio only.
Expand description

A publishing RTMP client over a stream (a TcpStream by default): the adapter for ClientSession, mirroring RtmpConnection. Every awaited IO is bounded by Timeouts.

Implementations§

Source§

impl AsyncRtmpClient<TcpStream>

Source

pub async fn connect(target: &RtmpTarget, timeouts: Timeouts) -> Result<Self>

DNS + TCP connect bounded by timeouts.connect; publish is NOT started.

An rtmps target is refused: this adapter opens plain TCP, and sending RTMP in the clear to a TLS port (443) would leak the stream key. Wrap a TLS stream and use AsyncRtmpClient::from_stream instead.

Source§

impl<S: AsyncRead + AsyncWrite + Unpin> AsyncRtmpClient<S>

Source

pub fn from_stream(stream: S, target: &RtmpTarget, timeouts: Timeouts) -> Self

Wraps an already-connected stream; the handshake bytes are queued and go out with the first call that flushes.

Source

pub async fn publish(&mut self) -> Result<()>

Runs handshake -> connect -> createStream -> publish; returns once the server accepted the publish. Bounded by Timeouts::handshake as a whole. A server error (ClientEvent::Error) is io::ErrorKind::ConnectionRefused.

Source

pub async fn send_audio(&mut self, timestamp: u32, data: &[u8]) -> Result<()>

Sends one audio message (FLV audio tag body) at timestamp ms.

The adapter reads inbound traffic (server acks, pings, errors) only inside next_events; a caller that only sends must also drive next_events (e.g. in a select!) or the server’s acknowledgement window is never serviced.

Source

pub async fn send_video(&mut self, timestamp: u32, data: &[u8]) -> Result<()>

Sends one video message (FLV video tag body) at timestamp ms.

Source

pub async fn send_metadata( &mut self, metadata: &[(String, Amf0Value)], ) -> Result<()>

Sends @setDataFrame/onMetaData stream metadata.

Source

pub fn encode_audio(&mut self, timestamp: u32, data: &[u8]) -> Result<Vec<u8>>

Sans-IO half of send_audio: the chunk-stream-framed message bytes for one audio tag, without writing. Lets a caller driving its own egress (e.g. multimux’s PushTransportEgress) frame a message now and write it verbatim later via write_frame.

Source

pub fn encode_video(&mut self, timestamp: u32, data: &[u8]) -> Result<Vec<u8>>

Sans-IO half of send_video — see encode_audio.

Source

pub fn encode_metadata( &mut self, metadata: &[(String, Amf0Value)], ) -> Result<Vec<u8>>

Sans-IO half of send_metadata — see encode_audio.

Source

pub async fn write_frame(&mut self, bytes: Vec<u8>) -> Result<()>

Writes one already-framed message verbatim (the async half of the encode_* methods above), bounded by Timeouts::write.

Source

pub async fn next_events(&mut self) -> Result<Option<Vec<ClientEvent>>>

Next batch of server events (acks, errors, close); Ok(None) at EOF. Same deadline rules and cancel-safety as RtmpConnection::next_events.

Trait Implementations§

Source§

impl<S: Debug> Debug for AsyncRtmpClient<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Forget for AsyncRtmpClient<S>

§

impl<S> Freeze for AsyncRtmpClient<S>
where Driver<S, ClientSession>: Freeze,

§

impl<S> Move for AsyncRtmpClient<S>

§

impl<S> RefUnwindSafe for AsyncRtmpClient<S>
where Driver<S, ClientSession>: RefUnwindSafe,

§

impl<S> Send for AsyncRtmpClient<S>
where Driver<S, ClientSession>: Send,

§

impl<S> Sync for AsyncRtmpClient<S>
where Driver<S, ClientSession>: Sync,

§

impl<S> Unpin for AsyncRtmpClient<S>
where Driver<S, ClientSession>: Unpin,

§

impl<S> UnsafeUnpin for AsyncRtmpClient<S>
where Driver<S, ClientSession>: UnsafeUnpin,

§

impl<S> UnwindSafe for AsyncRtmpClient<S>
where Driver<S, ClientSession>: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.