pub struct ClientSession { /* private fields */ }Expand description
A driveable RTSP client session (RFC 2326 §A.1).
Implementations§
Source§impl ClientSession
impl ClientSession
Sourcepub fn with_credentials(self, credentials: Credentials) -> Self
pub fn with_credentials(self, credentials: Credentials) -> Self
Attaches credentials so the engine can answer 401 challenges (§14).
Sourcepub fn last_challenge(&self) -> Option<&str>
pub fn last_challenge(&self) -> Option<&str>
The most recent WWW-Authenticate (else Proxy-Authenticate) header value seen on any
response, kept even when no credentials are configured so the caller can learn the scheme
and realm to ask for.
Sourcepub fn authenticate_with(
&mut self,
credentials: Credentials,
challenge: Option<&str>,
) -> Result<()>
pub fn authenticate_with( &mut self, credentials: Credentials, challenge: Option<&str>, ) -> Result<()>
Attaches credentials to a live session and, when challenge (else the last challenge
seen) is available, builds the authenticator from it so the very next request already
carries an Authorization header instead of waiting for another 401.
§Errors
Error::Auth when the challenge cannot be answered with these credentials.
Sourcepub fn with_user_agent(self, ua: impl Into<String>) -> Self
pub fn with_user_agent(self, ua: impl Into<String>) -> Self
Overrides the User-Agent header value sent on requests.
Sourcepub fn state(&self) -> SessionState
pub fn state(&self) -> SessionState
The current session state.
Sourcepub fn peek_next_cseq(&self) -> u32
pub fn peek_next_cseq(&self) -> u32
The CSeq the next request-builder call (options/describe/…) will
assign. Lets an IO adapter capture which response it must wait for
before building the request, since building it also consumes this
value (audit run-09 W7: io::AsyncRtspClient::exchange needs this to
tell “the” response apart from a stray one for an abandoned request).
Sourcepub fn session_warning_count(&self) -> usize
pub fn session_warning_count(&self) -> usize
Total number of Session warnings recorded, including ones that have
since been dropped from session_warnings.
Sourcepub fn session_warnings(&self) -> &[String]
pub fn session_warnings(&self) -> &[String]
Warnings about Session response headers (a malformed or zero timeout
that fell back to the 60 s default, or an unusable header), oldest first.
Each is also emitted with log::warn!.
Sourcepub fn has_buffered_input(&self) -> bool
pub fn has_buffered_input(&self) -> bool
True if a partial message or frame is buffered (bytes fed to
handle_data that did not yet form a whole one). An
adapter uses it to tell a clean end of stream from a truncated one.
Sourcepub fn mark_activity(&mut self, now: Instant)
pub fn mark_activity(&mut self, now: Instant)
Records that a request was written at now. The core never reads a clock;
now is always caller-supplied. Only requests count: the server’s
session timeout is refreshed by requests (RFC 2326 §12.37), not by
inbound media or responses.
Sourcepub fn poll_timeout(&self) -> Option<Instant>
pub fn poll_timeout(&self) -> Option<Instant>
Next keepalive deadline: last_activity + timeout/2 once a Session id
exists (timeout = the SETUP response’s timeout=, else the RFC 2326
§12.37 default of 60 s). None before SETUP, after TEARDOWN, or if no
activity was ever recorded.
Sourcepub fn handle_timeout(&mut self, now: Instant) -> Result<Option<Vec<u8>>>
pub fn handle_timeout(&mut self, now: Instant) -> Result<Option<Vec<u8>>>
If now >= poll_timeout(), the bytes of a GET_PARAMETER keepalive on
the last request URI (and activity is re-armed at now); Ok(None)
otherwise.
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_timeout(&self) -> Option<u64>
pub fn session_timeout(&self) -> Option<u64>
The session timeout in seconds, if the SETUP response declared one.
Sourcepub fn negotiated_transport(&self) -> Option<&Transport>
pub fn negotiated_transport(&self) -> Option<&Transport>
The transport negotiated in the SETUP response, if any.
Sourcepub fn take_rtp_info(&mut self) -> Vec<RtpInfoEntry>
pub fn take_rtp_info(&mut self) -> Vec<RtpInfoEntry>
Takes the RTP-Info entries (RFC 2326 12.33) of the most recent successful PLAY response,
leaving none behind. Empty when the response carried no usable RTP-Info.
Sourcepub fn take_negotiated_transport(&mut self) -> Option<Transport>
pub fn take_negotiated_transport(&mut self) -> Option<Transport>
Takes the transport negotiated by the most recent SETUP response, leaving none behind, so
a later SETUP reply that carries no Transport header cannot be mistaken for it.
Sourcepub fn content_base(&self) -> Option<&str>
pub fn content_base(&self) -> Option<&str>
The base URI for relative a=control values (RFC 2326 Appendix C.1.1): the
Content-Base of the most recent successful DESCRIBE response, else its
Content-Location, else None (the caller then uses the request URI).
Sourcepub fn redirect_location(&self) -> Option<&str>
pub fn redirect_location(&self) -> Option<&str>
The Location header of the most recent redirection (3xx) response, None when that
response carried none or the most recent response was not a redirection
(ClientEvent::Response carries no headers).
Sourcepub fn options(&mut self, uri: &str) -> Result<Vec<u8>>
pub fn options(&mut self, uri: &str) -> Result<Vec<u8>>
Builds an OPTIONS request (state-neutral).
Sourcepub fn describe(&mut self, uri: &str) -> Result<Vec<u8>>
pub fn describe(&mut self, uri: &str) -> Result<Vec<u8>>
Builds a DESCRIBE request with Accept: application/sdp (state-neutral).
Sourcepub fn setup(&mut self, uri: &str, transport: &Transport) -> Result<Vec<u8>>
pub fn setup(&mut self, uri: &str, transport: &Transport) -> Result<Vec<u8>>
Builds a SETUP request carrying the given Transport (Init/Ready/…).
Sourcepub fn play(&mut self, uri: &str) -> Result<Vec<u8>>
pub fn play(&mut self, uri: &str) -> Result<Vec<u8>>
Builds a PLAY request (valid in Ready/Playing).
Sourcepub fn pause(&mut self, uri: &str) -> Result<Vec<u8>>
pub fn pause(&mut self, uri: &str) -> Result<Vec<u8>>
Builds a PAUSE request (valid in Playing/Recording).
Sourcepub fn teardown(&mut self, uri: &str) -> Result<Vec<u8>>
pub fn teardown(&mut self, uri: &str) -> Result<Vec<u8>>
Builds a TEARDOWN request (valid in any non-Init state, and Init).
Sourcepub fn announce(&mut self, uri: &str, sdp: &str) -> Result<Vec<u8>>
pub fn announce(&mut self, uri: &str, sdp: &str) -> Result<Vec<u8>>
Builds an ANNOUNCE request carrying an SDP body (RFC 2326 §10.3).
Sourcepub fn record(&mut self, uri: &str) -> Result<Vec<u8>>
pub fn record(&mut self, uri: &str) -> Result<Vec<u8>>
Builds a RECORD request (RFC 2326 §10.11, valid in Ready).
Sourcepub fn get_parameter(&mut self, uri: &str, body: &[u8]) -> Result<Vec<u8>>
pub fn get_parameter(&mut self, uri: &str, body: &[u8]) -> Result<Vec<u8>>
Builds a GET_PARAMETER request, optionally with a body (state-neutral;
an empty body is the liveness ping).
Sourcepub fn handle_data(&mut self, data: &[u8]) -> HandleOutcome
pub fn handle_data(&mut self, data: &[u8]) -> HandleOutcome
Feeds inbound bytes and returns everything decoded from them.
Retains any partial trailing message or frame internally for the next
call. A failure never discards what was already decoded in the same
call (audit T16, #1144): the HandleOutcome carries the events
produced before the failure together with the terminal
HandleOutcome::error, if any. A terminal error means the TCP
framing is lost (an unparseable message head, an over-long header, an
unfulfillable Content-Length) and the session cannot continue; an
interleaved $ frame is opaque at this layer (it is handed up whole as
ClientEvent::MediaData), so a malformed RTP/RTCP payload inside one
is the consumer’s to skip without ending the session.
Sourcepub fn handle_data_strict(&mut self, data: &[u8]) -> Result<Vec<ClientEvent>>
pub fn handle_data_strict(&mut self, data: &[u8]) -> Result<Vec<ClientEvent>>
All-or-nothing form of handle_data: Ok(events)
when decoding ran clean, Err (discarding any events decoded before
it) otherwise. For callers - simple scripts, tests - that treat any
protocol error as fatal; a long-lived session should use
handle_data so events decoded before a failure
are not lost.