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 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 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.