pub struct Stream { /* private fields */ }
Expand description
Information about a stream offered within a presentation.
Currently if multiple formats are offered, this only describes the first.
Implementations§
source§impl Stream
impl Stream
sourcepub fn media(&self) -> &str
pub fn media(&self) -> &str
Returns the media type, as specified in the IANA SDP parameters media registry.
sourcepub fn encoding_name(&self) -> &str
pub fn encoding_name(&self) -> &str
An encoding name, as specified in the IANA media type registry, with ASCII characters in lowercase.
Commonly used but not specified in that registry: the ONVIF types claimed in the ONVIF Streaming Spec:
vnd.onvif.metadata
vnd.onvif.metadata.gzip
,vnd.onvif.metadata.exi.onvif
vnd.onvif.metadata.exi.ext
sourcepub fn rtp_payload_type(&self) -> u8
pub fn rtp_payload_type(&self) -> u8
Returns the RTP payload type.
See the registry. It’s common to use one of the dynamically assigned values, 96–127.
sourcepub fn clock_rate_hz(&self) -> u32
pub fn clock_rate_hz(&self) -> u32
Returns the RTP clock rate, in Hz.
sourcepub fn channels(&self) -> Option<NonZeroU16>
pub fn channels(&self) -> Option<NonZeroU16>
Returns the number of audio channels, if applicable (media
is audio
) and known.
sourcepub fn framerate(&self) -> Option<f32>
pub fn framerate(&self) -> Option<f32>
Returns the video framerate if present in SDP attributes.
sourcepub fn control(&self) -> Option<&Url>
pub fn control(&self) -> Option<&Url>
Returns the specified control URL.
This is needed with multiple streams to send SETUP
requests and
interpret the PLAY
response’s RTP-Info
header.
RFC 2326 section C.3
says the server is allowed to omit it when there is only a single stream.
source§impl Stream
impl Stream
sourcepub fn parameters(&self) -> Option<ParametersRef<'_>>
pub fn parameters(&self) -> Option<ParametersRef<'_>>
Returns codec-specified parameters for this stream, if available.
Returns None
on unknown codecs, bad parameters, or if parameters aren’t (yet) known.
This is initially populated from the DESCRIBE
response’s SDP. Not all codecs guarantee
parameters are provided in the SDP. Notably, H.264 allows parameters to be specified
“in-band” (with the data packets) instead of or in addition to “out-of-band” (via SDP).
Thus, it’s unspecified whether a parameters
call immediately after Session::describe
will return Some
or None
.
With Demuxed
When using Demuxed
’s frame-by-frame futures::Stream
impl, parameters
reflects
all parameters as of returned frames that have been returned from from poll_next
via
Poll::Ready
.
It’s guaranteed to not reflect any parameter changes in the upcoming frame, even after
a Poll::Pending
return.
If there is no packet loss, parameters are generally available after the first frame is returned. In the case of H.264, RFC 6184 section 8.4 says “when parameter sets are added or updated, care SHOULD be taken to ensure that any parameter set is delivered prior to its usage.”
Without Demuxed
When directly using Session
’s packet-by-packet futures::Stream
impl, codec
depacketization logic is bypassed. The parameters returned by this function may be out of
date.
sourcepub fn ctx(&self) -> Option<&StreamContext>
pub fn ctx(&self) -> Option<&StreamContext>
Returns a context for this stream, if it has been set up.