Skip to main content

AsyncRtspClient

Struct AsyncRtspClient 

Source
pub struct AsyncRtspClient<S> { /* private fields */ }
Expand description

An async RTSP client that owns a socket and drives a ClientSession.

Each request method (options/describe/setup/play/pause/teardown) writes the request bytes the session produces, reads the response off the socket, feeds it through the sans-IO engine, and returns the resulting ClientEvents. A Digest 401 is answered transparently: when the engine emits ClientEvent::AuthRetry, the adapter writes the retried request and reads its response before returning, so the caller only sees the final ClientEvent::Response.

Interleaved media ($-framed RTP/RTCP, §10.12) is pulled with recv_interleaved.

Implementations§

Source§

impl AsyncRtspClient<TcpStream>

Source

pub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<Self>

Connects a plain-TCP (rtsp://) client to addr.

addr is any tokio::net::ToSocketAddrs; for the RTSP default port use (host, RTSP_DEFAULT_PORT).

Source

pub async fn connect_with<A: ToSocketAddrs>( addr: A, session: ClientSession, ) -> Result<Self>

Connects a plain-TCP client to addr using a pre-configured session (e.g. one carrying Credentials).

Source§

impl<S> AsyncRtspClient<S>
where S: AsyncRead + AsyncWrite + Unpin,

Source

pub fn with_stream(stream: S, session: ClientSession) -> Self

Wraps an already-connected stream (plain or TLS) and a session.

Source

pub fn state(&self) -> SessionState

The current session state.

Source

pub fn session_id(&self) -> Option<&str>

The negotiated session id, once a SETUP response has been processed.

Source

pub fn session(&self) -> &ClientSession

Borrows the underlying sans-IO session (read-only inspection).

Source

pub async fn options(&mut self, uri: &str) -> Result<ClientEvent>

Sends OPTIONS and awaits the response.

Source

pub async fn describe(&mut self, uri: &str) -> Result<ClientEvent>

Sends DESCRIBE (with Accept: application/sdp) and awaits the response.

Source

pub async fn setup( &mut self, uri: &str, transport: &Transport, ) -> Result<ClientEvent>

Sends SETUP carrying transport and awaits the response.

Source

pub async fn play(&mut self, uri: &str) -> Result<ClientEvent>

Sends PLAY and awaits the response.

Source

pub async fn pause(&mut self, uri: &str) -> Result<ClientEvent>

Sends PAUSE and awaits the response.

Source

pub async fn teardown(&mut self, uri: &str) -> Result<ClientEvent>

Sends TEARDOWN and awaits the response.

Source

pub async fn get_parameter( &mut self, uri: &str, body: &[u8], ) -> Result<ClientEvent>

Sends GET_PARAMETER (empty body = liveness ping) and awaits the response.

Source

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

Receives the next interleaved media frame (ClientEvent::MediaData), driving the socket until one is available (§10.12).

Returns Ok(None) if the peer closes the connection cleanly before a frame arrives. Any control responses interleaved with media are consumed and their state transitions applied, but not returned here.

Source§

impl AsyncRtspClient<TlsStream<TcpStream>>

Source

pub async fn connect_tls<A: ToSocketAddrs>( addr: A, server_name: &str, config: ClientConfig, ) -> Result<Self>

Connects an rtsps:// (TLS) client to addr, verifying the server against the given config and presenting server_name for SNI/cert validation.

For the public-CA default trust store, build config with default_tls_client_config. For a self-signed camera cert, build a rustls::ClientConfig whose root store contains that cert. For the rtsps default port use (host, RTSPS_DEFAULT_PORT).

Source

pub async fn connect_tls_with<A: ToSocketAddrs>( addr: A, server_name: &str, config: ClientConfig, session: ClientSession, ) -> Result<Self>

Connects an rtsps:// (TLS) client to addr using a pre-configured session (e.g. one carrying Credentials via ClientSession::with_credentials), otherwise identical to connect_tls.

Trait Implementations§

Source§

impl<S: Debug> Debug for AsyncRtspClient<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for AsyncRtspClient<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for AsyncRtspClient<S>
where S: RefUnwindSafe,

§

impl<S> Send for AsyncRtspClient<S>
where S: Send,

§

impl<S> Sync for AsyncRtspClient<S>
where S: Sync,

§

impl<S> Unpin for AsyncRtspClient<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for AsyncRtspClient<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for AsyncRtspClient<S>
where S: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V