pub struct AsyncRtspServer<S> { /* private fields */ }Expand description
An async RTSP server connection that owns a socket and drives a
ServerSession.
Reads requests off the socket (framed by a tokio_util codec over
rtsp_types), calls ServerSession::handle_request, writes the response
bytes back, and returns the ServerEvents. Every awaited IO is bounded by
RtspTimeouts.
Implementations§
Source§impl AsyncRtspServer<TcpStream>
impl AsyncRtspServer<TcpStream>
Sourcepub fn accept(stream: TcpStream) -> Self
pub fn accept(stream: TcpStream) -> Self
Wraps an accepted plain-TCP connection with a fresh ServerSession
whose Session ids come from the OS random source.
§Panics
When the OS random source is unavailable.
Sourcepub fn accept_with(stream: TcpStream, session: ServerSession) -> Self
pub fn accept_with(stream: TcpStream, session: ServerSession) -> Self
Wraps an accepted plain-TCP connection with a pre-configured session.
Sourcepub fn accept_with_timeouts(
stream: TcpStream,
session: ServerSession,
timeouts: RtspTimeouts,
) -> Self
pub fn accept_with_timeouts( stream: TcpStream, session: ServerSession, timeouts: RtspTimeouts, ) -> Self
Like accept_with, with explicit RtspTimeouts.
Source§impl AsyncRtspServer<TlsStream<TcpStream>>
impl AsyncRtspServer<TlsStream<TcpStream>>
Sourcepub async fn accept_tls(stream: TcpStream, config: ServerConfig) -> Result<Self>
pub async fn accept_tls(stream: TcpStream, config: ServerConfig) -> Result<Self>
Performs the TLS handshake over an accepted TCP connection (an
rtsps:// server), then wraps the TLS stream with a fresh session.
Sourcepub async fn accept_tls_with_timeouts(
stream: TcpStream,
config: ServerConfig,
timeouts: RtspTimeouts,
) -> Result<Self>
pub async fn accept_tls_with_timeouts( stream: TcpStream, config: ServerConfig, timeouts: RtspTimeouts, ) -> Result<Self>
Like accept_tls, with explicit RtspTimeouts:
handshake bounds the TLS handshake.
Source§impl<S> AsyncRtspServer<S>
impl<S> AsyncRtspServer<S>
Sourcepub fn with_stream(stream: S, session: ServerSession) -> Self
pub fn with_stream(stream: S, session: ServerSession) -> Self
Wraps an already-connected stream (plain or TLS) and a session, with the
default RtspTimeouts.
Sourcepub fn with_stream_timeouts(
stream: S,
session: ServerSession,
timeouts: RtspTimeouts,
) -> Self
pub fn with_stream_timeouts( stream: S, session: ServerSession, timeouts: RtspTimeouts, ) -> Self
Wraps an already-connected stream with explicit RtspTimeouts.
Sourcepub fn timeouts(&self) -> RtspTimeouts
pub fn timeouts(&self) -> RtspTimeouts
The timeouts this adapter applies.
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 allocated session id, once a SETUP has been handled.
Sourcepub fn stream_mut(&mut self) -> &mut S
pub fn stream_mut(&mut self) -> &mut S
Mutable access to the underlying stream, for writing raw bytes (e.g.
deliberately fragmenting an interleaved frame, or sending several frames
back-to-back) alongside the framed send_interleaved
helper.
Sourcepub async fn next_request(&mut self) -> Result<Option<Vec<ServerEvent>>>
pub async fn next_request(&mut self) -> Result<Option<Vec<ServerEvent>>>
Reads the next complete request or interleaved frame, handling a
request (writing the response back) and returning the produced
events, or surfacing an interleaved $-frame as
ServerEvent::MediaData.
The FIRST call on a connection waits at most RtspTimeouts::handshake
for a complete request; later calls wait at most
RtspTimeouts::read_idle. A frame must complete inside that single
deadline, so a client dripping bytes cannot hold the connection forever.
Cancel-safe: dropping the future while the response is being written loses neither the response bytes nor the events; the next call finishes the write and returns them.
Returns Ok(None) when the peer closes the connection cleanly before a
full request or frame arrives.