Skip to main content

ClientSession

Struct ClientSession 

Source
pub struct ClientSession { /* private fields */ }
Expand description

A driveable RTSP client session (RFC 2326 §A.1).

Implementations§

Source§

impl ClientSession

Source

pub fn new() -> Self

Creates a fresh client session in the Init state with CSeq starting at 1.

Source

pub fn with_credentials(self, credentials: Credentials) -> Self

Attaches credentials so the engine can answer 401 challenges (§14).

Source

pub fn with_user_agent(self, ua: impl Into<String>) -> Self

Overrides the User-Agent header value sent on requests.

Source

pub fn state(&self) -> SessionState

The current session state.

Source

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

Source

pub fn session_warning_count(&self) -> usize

Total number of Session warnings recorded, including ones that have since been dropped from session_warnings.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

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

Source

pub fn session_timeout(&self) -> Option<u64>

The session timeout in seconds, if the SETUP response declared one.

Source

pub fn negotiated_transport(&self) -> Option<&Transport>

The transport negotiated in the SETUP response, if any.

Source

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

Builds an OPTIONS request (state-neutral).

Source

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

Builds a DESCRIBE request with Accept: application/sdp (state-neutral).

Source

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

Builds a SETUP request carrying the given Transport (Init/Ready/…).

Source

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

Builds a PLAY request (valid in Ready/Playing).

Source

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

Builds a PAUSE request (valid in Playing/Recording).

Source

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

Builds a TEARDOWN request (valid in any non-Init state, and Init).

Source

pub fn announce(&mut self, uri: &str, sdp: &str) -> Result<Vec<u8>>

Builds an ANNOUNCE request carrying an SDP body (RFC 2326 §10.3).

Source

pub fn record(&mut self, uri: &str) -> Result<Vec<u8>>

Builds a RECORD request (RFC 2326 §10.11, valid in Ready).

Source

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

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ClientSession

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ClientSession

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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