pub struct Rtpmap<'a> { /* private fields */ }Expand description
The format an a=rtpmap value names.
<encoding name>/<clock rate>[/<encoding parameters>] (RFC 8866 §6.6). For audio the encoding
parameter is the channel count, and an omitted one means one channel.
Deliberately not PartialEq. Derived equality would compare the encoding name as bytes,
and the name compares case-insensitively — so == would be a second, wrong answer to the
question this module exists to answer once. Rtpmap::same_format_as is the only comparison.
Implementations§
Source§impl<'a> Rtpmap<'a>
impl<'a> Rtpmap<'a>
Sourcepub fn parse(value: &'a str) -> Result<Self, RtpmapError>
pub fn parse(value: &'a str) -> Result<Self, RtpmapError>
Read the format a value names.
The value is the part of the attribute after the payload type — PCMU/8000, not
0 PCMU/8000 — which is what crate::MediaDescription::rtpmap returns.
§Errors
RtpmapError when the value is not RFC 8866 §6.6’s grammar. This is a parser for data
that arrived from the network, so every rejection is a returned error: an empty rate, a
rate that is not digits, a rate too large for a u32, and a value carrying a field the
grammar does not have.
Sourcepub fn clock_rate(&self) -> u32
pub fn clock_rate(&self) -> u32
The RTP clock rate, which for several codecs is not the sample rate.
Sourcepub fn channels(&self) -> u32
pub fn channels(&self) -> u32
The channel count, with RFC 8866 §6.6’s default of one already applied.
Sourcepub fn same_format_as(&self, other: &Rtpmap<'_>) -> bool
pub fn same_format_as(&self, other: &Rtpmap<'_>) -> bool
Whether two values name the same format.
RFC 8866 §6.6: the encoding name compares case-insensitively, and the clock rate and channel count are part of the format’s identity — the same codec at two rates is two formats.
The rate and the count compare by value, because they are numbers and the identity of a
number is numeric. Comparing them as text answers a different question — whether they are
spelled the same — and answering that one by accident is exactly the defect M-31 fixed.