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>
impl AsyncRtspClient<TcpStream>
Sourcepub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<Self>
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).
Sourcepub async fn connect_with<A: ToSocketAddrs>(
addr: A,
session: ClientSession,
) -> Result<Self>
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>
impl<S> AsyncRtspClient<S>
Sourcepub fn with_stream(stream: S, session: ClientSession) -> Self
pub fn with_stream(stream: S, session: ClientSession) -> Self
Wraps an already-connected stream (plain or TLS) and a session.
Sourcepub fn state(&self) -> SessionState
pub fn state(&self) -> SessionState
The current session state.
Sourcepub fn session_id(&self) -> Option<&str>
pub fn session_id(&self) -> Option<&str>
The negotiated session id, once a SETUP response has been processed.
Sourcepub fn session(&self) -> &ClientSession
pub fn session(&self) -> &ClientSession
Borrows the underlying sans-IO session (read-only inspection).
Sourcepub async fn options(&mut self, uri: &str) -> Result<ClientEvent>
pub async fn options(&mut self, uri: &str) -> Result<ClientEvent>
Sends OPTIONS and awaits the response.
Sourcepub async fn describe(&mut self, uri: &str) -> Result<ClientEvent>
pub async fn describe(&mut self, uri: &str) -> Result<ClientEvent>
Sends DESCRIBE (with Accept: application/sdp) and awaits the response.
Sourcepub async fn setup(
&mut self,
uri: &str,
transport: &Transport,
) -> Result<ClientEvent>
pub async fn setup( &mut self, uri: &str, transport: &Transport, ) -> Result<ClientEvent>
Sends SETUP carrying transport and awaits the response.
Sourcepub async fn play(&mut self, uri: &str) -> Result<ClientEvent>
pub async fn play(&mut self, uri: &str) -> Result<ClientEvent>
Sends PLAY and awaits the response.
Sourcepub async fn pause(&mut self, uri: &str) -> Result<ClientEvent>
pub async fn pause(&mut self, uri: &str) -> Result<ClientEvent>
Sends PAUSE and awaits the response.
Sourcepub async fn teardown(&mut self, uri: &str) -> Result<ClientEvent>
pub async fn teardown(&mut self, uri: &str) -> Result<ClientEvent>
Sends TEARDOWN and awaits the response.
Sourcepub async fn get_parameter(
&mut self,
uri: &str,
body: &[u8],
) -> Result<ClientEvent>
pub async fn get_parameter( &mut self, uri: &str, body: &[u8], ) -> Result<ClientEvent>
Sends GET_PARAMETER (empty body = liveness ping) and awaits the response.
Sourcepub async fn recv_interleaved(&mut self) -> Result<Option<ClientEvent>>
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>>
impl AsyncRtspClient<TlsStream<TcpStream>>
Sourcepub async fn connect_tls<A: ToSocketAddrs>(
addr: A,
server_name: &str,
config: ClientConfig,
) -> Result<Self>
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).
Sourcepub async fn connect_tls_with<A: ToSocketAddrs>(
addr: A,
server_name: &str,
config: ClientConfig,
session: ClientSession,
) -> Result<Self>
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.