Skip to main content

MediaDescription

Struct MediaDescription 

Source
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

MediaDescription represents a media type.

§Specifications

Fields§

§media_name: MediaName

m=<media> <port>/<number of ports> <proto> <fmt> ...

https://tools.ietf.org/html/rfc4566#section-5.14

§media_title: Option<Information>§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).

https://www.rfc-editor.org/rfc/rfc8866#section-5.7

§bandwidth: Vec<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.

https://tools.ietf.org/html/rfc4566#section-5.12

Implementations§

Source§

impl MediaDescription

Source

pub fn has_attribute(&self, key: &str) -> bool

Returns whether an attribute exists

Source

pub fn attribute(&self, key: &str) -> Option<Option<&str>>

attribute returns the value of an attribute and if it exists

Source

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.

Source

pub fn bandwidth_of(&self, kind: BandwidthKind) -> Option<u64>

The value of the first b= line of kind, in the unit of that modifier.

Source

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.

Source

pub fn typed_all<T: TypedAttribute>(&self) -> Result<Vec<T>>

Every a=<T::NAME> attribute at this level, parsed, in order.

Source

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.

Source

pub fn with_typed<T: TypedAttribute>(self, value: &T) -> Self

Appends the a= line of a typed attribute.

Source

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.

Source

pub fn extmaps(&self) -> Result<Vec<ExtMap>>

a=extmap lines at this level (RFC 8285).

Source

pub fn extmap_allow_mixed(&self) -> Result<bool>

Whether a=extmap-allow-mixed is present at this level (RFC 8285 section 6).

Source

pub fn ice_ufrag(&self) -> Result<Option<IceUfrag>>

a=ice-ufrag at this level (RFC 8839 section 5.4).

Source

pub fn ice_pwd(&self) -> Result<Option<IcePwd>>

a=ice-pwd at this level (RFC 8839 section 5.4).

Source

pub fn ice_options(&self) -> Result<Option<IceOptions>>

a=ice-options at this level (RFC 8839 section 5.6).

Source

pub fn fingerprints(&self) -> Result<Vec<Fingerprint>>

a=fingerprint lines at this level (RFC 8122 section 5).

Source

pub fn setup(&self) -> Result<Option<Setup>>

a=setup at this level (RFC 4145 section 4, RFC 8842).

Source

pub fn tls_id(&self) -> Result<Option<TlsId>>

a=tls-id at this level (RFC 8842 section 4).

Source

pub fn rtcp_xr(&self) -> Result<Option<RtcpXr>>

a=rtcp-xr at this level (RFC 3611 section 5.1).

Source

pub fn cryptex(&self) -> Result<bool>

Whether a=cryptex is present at this level (RFC 9335 section 4).

Source

pub fn mid(&self) -> Result<Option<Mid>>

a=mid (RFC 5888 section 4).

Source

pub fn msids(&self) -> Result<Vec<Msid>>

a=msid lines (RFC 8830 section 2): one per MediaStream the track is in.

Source

pub fn ssrcs(&self) -> Result<Vec<Ssrc>>

a=ssrc lines (RFC 5576 section 4.1), one per source attribute.

Source

pub fn ssrc_groups(&self) -> Result<Vec<SsrcGroup>>

a=ssrc-group lines (RFC 5576 section 4.2).

Source

pub fn rids(&self) -> Result<Vec<Rid>>

a=rid lines (RFC 8851 section 10).

Source

pub fn simulcast(&self) -> Result<Option<Simulcast>>

a=simulcast (RFC 8853 section 5.1).

Source

pub fn rtcp(&self) -> Result<Option<Rtcp>>

a=rtcp (RFC 3605 section 2.1).

Source

pub fn rtcp_mux(&self) -> Result<bool>

Whether a=rtcp-mux is present (RFC 5761 section 5.1.1).

Source

pub fn rtcp_mux_only(&self) -> Result<bool>

Whether a=rtcp-mux-only is present (RFC 8858 section 3).

Source

pub fn rtcp_rsize(&self) -> Result<bool>

Whether a=rtcp-rsize is present (RFC 5506 section 5).

Source

pub fn rtcp_fbs(&self) -> Result<Vec<RtcpFb>>

a=rtcp-fb lines (RFC 4585 section 4.2), the wildcard ones included.

Source

pub fn rtpmaps(&self) -> Result<Vec<RtpMap>>

a=rtpmap lines (RFC 8866 section 6.6).

Source

pub fn fmtps(&self) -> Result<Vec<Fmtp>>

a=fmtp lines (RFC 8866 section 6.15).

Source

pub fn ptime(&self) -> Result<Option<Ptime>>

a=ptime (RFC 8866 section 6.4).

Source

pub fn maxptime(&self) -> Result<Option<MaxPtime>>

a=maxptime (RFC 8866 section 6.5).

Source

pub fn framerate(&self) -> Result<Option<FrameRate>>

a=framerate (RFC 8866 section 6.13).

Source

pub fn imageattrs(&self) -> Result<Vec<ImageAttr>>

a=imageattr lines (RFC 6236 section 3.1).

Source

pub fn content(&self) -> Result<Option<Content>>

a=content (RFC 4796 section 5).

Source

pub fn candidates(&self) -> Result<Vec<Candidate>>

a=candidate lines (RFC 8839 section 5.1).

Source

pub fn end_of_candidates(&self) -> Result<bool>

Whether a=end-of-candidates is present (RFC 8840).

Source

pub fn remote_candidates(&self) -> Result<Option<RemoteCandidates>>

a=remote-candidates (RFC 8839 section 5.2).

Source

pub fn sctp_port(&self) -> Result<Option<SctpPort>>

a=sctp-port (RFC 8841 section 5).

Source

pub fn max_message_size(&self) -> Result<Option<MaxMessageSize>>

a=max-message-size (RFC 8841 section 6).

Source

pub fn sctpmap(&self) -> Result<Option<SctpMap>>

a=sctpmap, the form a=sctp-port replaced (draft-ietf-mmusic-sctp-sdp-05).

Source

pub fn orient(&self) -> Result<Option<Orient>>

a=orient (RFC 8866 section 6.8).

Source

pub fn quality(&self) -> Result<Option<Quality>>

a=quality (RFC 8866 section 6.14).

Source

pub fn bundle_only(&self) -> Result<bool>

Whether a=bundle-only is present (RFC 9143 section 6).

Source

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.

Source

pub fn with_property_attribute(self, key: String) -> Self

with_property_attribute adds a property attribute ‘a=key’ to the media description

Source

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

Source

pub fn with_fingerprint(self, algorithm: String, value: String) -> Self

with_fingerprint adds a fingerprint to the media description

Source

pub fn with_ice_credentials(self, username: String, password: String) -> Self

with_ice_credentials adds ICE credentials to the media description

Source

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

Source

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

Source

pub fn with_candidate(self, value: String) -> Self

with_candidate adds an ICE candidate to the media description Deprecated: use WithICECandidate instead

Source

pub fn with_extmap(self, e: ExtMap) -> Self

Appends an a=extmap header-extension declaration.

Source

pub fn with_transport_cc_extmap(self) -> Self

with_transport_cc_extmap adds an extmap to the media description

Trait Implementations§

Source§

impl Clone for MediaDescription

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MediaDescription

Source§

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

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

impl Default for MediaDescription

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.