pub struct MediaDescription {
pub media_name: MediaName,
pub media_title: Option<Information>,
pub connection_information: Vec<ConnectionInformation>,
pub bandwidth: Vec<Bandwidth>,
pub encryption_key: Option<EncryptionKey>,
pub attributes: Vec<Attribute>,
}Expand description
Fields§
§media_name: MediaNamem=<media> <port>/<number of ports> <proto> <fmt> ...
media_title: Option<Information>i=<session description>
connection_information: Vec<ConnectionInformation>c=<nettype> <addrtype> <connection-address>, each of the media description’s
connection lines in order: none (the session-level one applies), one, or several
(RFC 8866 section 5.7: “Multiple addresses or “c=” lines MAY be specified on a
per-media basis“, for layered multicast).
bandwidth: Vec<Bandwidth>b=<bwtype>:<bandwidth>
encryption_key: Option<EncryptionKey>Obsolete. RFC 8866 section 5.12: a k= line “MUST NOT be included in an SDP
description and MUST be discarded if received”. The parser never sets this field
and nothing writes it; it is kept so that code naming it still builds.
attributes: Vec<Attribute>Attributes are the primary means for extending SDP. Attributes may be defined to be used as “session-level” attributes, “media-level” attributes, or both.
Implementations§
Source§impl MediaDescription
impl MediaDescription
Sourcepub fn has_attribute(&self, key: &str) -> bool
pub fn has_attribute(&self, key: &str) -> bool
Returns whether an attribute exists
Sourcepub fn attribute(&self, key: &str) -> Option<Option<&str>>
pub fn attribute(&self, key: &str) -> Option<Option<&str>>
attribute returns the value of an attribute and if it exists
Sourcepub fn codecs(&self) -> HashMap<u8, Codec>
pub fn codecs(&self) -> HashMap<u8, Codec>
The codecs this media section offers, keyed by payload type.
Assembled from the a=rtpmap, a=fmtp and a=rtcp-fb attributes. An
a=rtcp-fb:* line (RFC 4585 section 4.2: “applies to all formats”) adds its
feedback type to every codec of the section, in the place the line has among the
other a=rtcp-fb lines.
A line that does not parse is left out, so that one bad codec line does not take
the others with it; MediaDescription::rtpmaps, MediaDescription::fmtps and
MediaDescription::rtcp_fbs report such a line as an error instead.
Sourcepub fn bandwidth_of(&self, kind: BandwidthKind) -> Option<u64>
pub fn bandwidth_of(&self, kind: BandwidthKind) -> Option<u64>
The value of the first b= line of kind, in the unit of that modifier.
Sourcepub fn typed<T: TypedAttribute>(&self) -> Result<Option<T>>
pub fn typed<T: TypedAttribute>(&self) -> Result<Option<T>>
The first a=<T::NAME> attribute at this level, parsed. Ok(None) when there is
none, Err when it is malformed.
Sourcepub fn typed_all<T: TypedAttribute>(&self) -> Result<Vec<T>>
pub fn typed_all<T: TypedAttribute>(&self) -> Result<Vec<T>>
Every a=<T::NAME> attribute at this level, parsed, in order.
Sourcepub fn flag(&self, name: &str) -> Result<bool>
pub fn flag(&self, name: &str) -> Result<bool>
Whether the property attribute name (one without a value, such as
rtcp-mux) is present at this level. Err when it carries a value.
Sourcepub fn with_typed<T: TypedAttribute>(self, value: &T) -> Self
pub fn with_typed<T: TypedAttribute>(self, value: &T) -> Self
Appends the a= line of a typed attribute.
Sourcepub fn direction(&self) -> Result<Option<Direction>>
pub fn direction(&self) -> Result<Option<Direction>>
The direction attribute at this level (sendrecv, sendonly, recvonly,
inactive). Ok(None) when there is none; Err when there are several
(RFC 8866 section 6.7: at most one per level) or when one carries a value.
Sourcepub fn extmap_allow_mixed(&self) -> Result<bool>
pub fn extmap_allow_mixed(&self) -> Result<bool>
Whether a=extmap-allow-mixed is present at this level (RFC 8285 section 6).
Sourcepub fn ice_ufrag(&self) -> Result<Option<IceUfrag>>
pub fn ice_ufrag(&self) -> Result<Option<IceUfrag>>
a=ice-ufrag at this level (RFC 8839 section 5.4).
Sourcepub fn ice_pwd(&self) -> Result<Option<IcePwd>>
pub fn ice_pwd(&self) -> Result<Option<IcePwd>>
a=ice-pwd at this level (RFC 8839 section 5.4).
Sourcepub fn ice_options(&self) -> Result<Option<IceOptions>>
pub fn ice_options(&self) -> Result<Option<IceOptions>>
a=ice-options at this level (RFC 8839 section 5.6).
Sourcepub fn fingerprints(&self) -> Result<Vec<Fingerprint>>
pub fn fingerprints(&self) -> Result<Vec<Fingerprint>>
a=fingerprint lines at this level (RFC 8122 section 5).
Sourcepub fn setup(&self) -> Result<Option<Setup>>
pub fn setup(&self) -> Result<Option<Setup>>
a=setup at this level (RFC 4145 section 4, RFC 8842).
Sourcepub fn rtcp_xr(&self) -> Result<Option<RtcpXr>>
pub fn rtcp_xr(&self) -> Result<Option<RtcpXr>>
a=rtcp-xr at this level (RFC 3611 section 5.1).
Sourcepub fn cryptex(&self) -> Result<bool>
pub fn cryptex(&self) -> Result<bool>
Whether a=cryptex is present at this level (RFC 9335 section 4).
Sourcepub fn msids(&self) -> Result<Vec<Msid>>
pub fn msids(&self) -> Result<Vec<Msid>>
a=msid lines (RFC 8830 section 2): one per MediaStream the track is in.
Sourcepub fn ssrcs(&self) -> Result<Vec<Ssrc>>
pub fn ssrcs(&self) -> Result<Vec<Ssrc>>
a=ssrc lines (RFC 5576 section 4.1), one per source attribute.
Sourcepub fn ssrc_groups(&self) -> Result<Vec<SsrcGroup>>
pub fn ssrc_groups(&self) -> Result<Vec<SsrcGroup>>
a=ssrc-group lines (RFC 5576 section 4.2).
Sourcepub fn rtcp_mux_only(&self) -> Result<bool>
pub fn rtcp_mux_only(&self) -> Result<bool>
Whether a=rtcp-mux-only is present (RFC 8858 section 3).
Sourcepub fn rtcp_rsize(&self) -> Result<bool>
pub fn rtcp_rsize(&self) -> Result<bool>
Whether a=rtcp-rsize is present (RFC 5506 section 5).
Sourcepub fn rtcp_fbs(&self) -> Result<Vec<RtcpFb>>
pub fn rtcp_fbs(&self) -> Result<Vec<RtcpFb>>
a=rtcp-fb lines (RFC 4585 section 4.2), the wildcard ones included.
Sourcepub fn imageattrs(&self) -> Result<Vec<ImageAttr>>
pub fn imageattrs(&self) -> Result<Vec<ImageAttr>>
a=imageattr lines (RFC 6236 section 3.1).
Sourcepub fn candidates(&self) -> Result<Vec<Candidate>>
pub fn candidates(&self) -> Result<Vec<Candidate>>
a=candidate lines (RFC 8839 section 5.1).
Sourcepub fn end_of_candidates(&self) -> Result<bool>
pub fn end_of_candidates(&self) -> Result<bool>
Whether a=end-of-candidates is present (RFC 8840).
Sourcepub fn remote_candidates(&self) -> Result<Option<RemoteCandidates>>
pub fn remote_candidates(&self) -> Result<Option<RemoteCandidates>>
a=remote-candidates (RFC 8839 section 5.2).
Sourcepub fn max_message_size(&self) -> Result<Option<MaxMessageSize>>
pub fn max_message_size(&self) -> Result<Option<MaxMessageSize>>
a=max-message-size (RFC 8841 section 6).
Sourcepub fn sctpmap(&self) -> Result<Option<SctpMap>>
pub fn sctpmap(&self) -> Result<Option<SctpMap>>
a=sctpmap, the form a=sctp-port replaced (draft-ietf-mmusic-sctp-sdp-05).
Sourcepub fn bundle_only(&self) -> Result<bool>
pub fn bundle_only(&self) -> Result<bool>
Whether a=bundle-only is present (RFC 9143 section 6).
Sourcepub fn new_jsep_media_description(
codec_type: String,
_codec_prefs: Vec<&str>,
) -> Self
pub fn new_jsep_media_description( codec_type: String, _codec_prefs: Vec<&str>, ) -> Self
new_jsep_media_description creates a new MediaName with some settings that are required by the JSEP spec.
Sourcepub fn with_property_attribute(self, key: String) -> Self
pub fn with_property_attribute(self, key: String) -> Self
with_property_attribute adds a property attribute ‘a=key’ to the media description
Sourcepub fn with_value_attribute(self, key: String, value: String) -> Self
pub fn with_value_attribute(self, key: String, value: String) -> Self
with_value_attribute adds a value attribute ‘a=key:value’ to the media description
Sourcepub fn with_fingerprint(self, algorithm: String, value: String) -> Self
pub fn with_fingerprint(self, algorithm: String, value: String) -> Self
with_fingerprint adds a fingerprint to the media description
Sourcepub fn with_ice_credentials(self, username: String, password: String) -> Self
pub fn with_ice_credentials(self, username: String, password: String) -> Self
with_ice_credentials adds ICE credentials to the media description
Sourcepub fn with_codec(
self,
payload_type: u8,
name: String,
clockrate: u32,
channels: u16,
fmtp: String,
) -> Self
pub fn with_codec( self, payload_type: u8, name: String, clockrate: u32, channels: u16, fmtp: String, ) -> Self
with_codec adds codec information to the media description
Sourcepub fn with_media_source(
self,
ssrc: u32,
cname: String,
stream_id: String,
track_id: String,
) -> Self
pub fn with_media_source( self, ssrc: u32, cname: String, stream_id: String, track_id: String, ) -> Self
with_media_source adds the source attributes of one SSRC to the media description:
a=ssrc:<ssrc> cname:<cname> (RFC 5576 section 6.1) and
a=ssrc:<ssrc> msid:<stream id> <track id>.
These are the two registered source attributes WebRTC endpoints read. The Plan B
leftovers mslabel and label, which this used to write as well, were never
registered (RFC 5576 section 4.1: source attributes are registered ones).
Sourcepub fn with_candidate(self, value: String) -> Self
pub fn with_candidate(self, value: String) -> Self
with_candidate adds an ICE candidate to the media description Deprecated: use WithICECandidate instead
Sourcepub fn with_extmap(self, e: ExtMap) -> Self
pub fn with_extmap(self, e: ExtMap) -> Self
Appends an a=extmap header-extension declaration.
Sourcepub fn with_transport_cc_extmap(self) -> Self
pub fn with_transport_cc_extmap(self) -> Self
with_transport_cc_extmap adds an extmap to the media description