Skip to main content

MediaDescription

Struct MediaDescription 

Source
pub struct MediaDescription {
    pub media: String,
    pub port: u16,
    pub protocol: String,
    pub formats: Vec<String>,
    pub connection: Option<Connection>,
    pub attributes: Vec<Attribute>,
    pub other: Vec<(char, String)>,
}
Expand description

An m= line and everything under it.

Fields§

§media: String

audio, video, application

§port: u16

The port. Zero means the stream is rejected — and a rejected stream is still present, which is what keeps the answer’s media lines aligned with the offer’s.

§protocol: String

The transport protocol, such as RTP/AVP.

§formats: Vec<String>

Payload type numbers, in preference order.

§connection: Option<Connection>

A c= line for this stream, overriding the session’s.

§attributes: Vec<Attribute>

Attributes under this media line.

§other: Vec<(char, String)>

Lines under this media line that this crate does not model, kept so they survive a round trip.

Implementations§

Source§

impl MediaDescription

Source

pub fn audio(port: u16, formats: Vec<String>) -> Self

An audio stream offering these payload types.

Source

pub fn is_rejected(&self) -> bool

Whether this stream is rejected.

Source

pub fn direction(&self) -> Direction

The direction, defaulting to sendrecv when no attribute says otherwise.

Source

pub fn declared_direction(&self) -> Option<Direction>

The direction attribute written under this m= line, if any.

RFC 8866 §6.7: a stream without a direction of its own takes the session-level one, so an absent attribute is meaningful and not the same thing as sendrecv.

Source

pub fn set_direction(&mut self, direction: Direction)

Set the direction, replacing any existing one.

Source

pub fn crypto(&self) -> Option<Crypto>

The first a=crypto line this stream carries that sipx can act on (RFC 4568).

Several may be offered, in preference order. sipx takes the first it can perform rather than the first listed: an offer whose favourite suite is one sipx does not implement is still an offer worth answering.

Source

pub fn fingerprint(&self) -> Option<Fingerprint>

The first a=fingerprint this stream carries that sipx may act on (RFC 8122 §5).

§5.1 has an endpoint offer a fingerprint under several hash functions — “the ‘SHA-256’ hash function algorithm and the hash function used to generate the signature on the certificate” — so more than one line is normal and any of them identifies the same certificate. Taking the first sipx can compute is therefore correct rather than a shortcut; the ones it skips are md5 and md2, which §5 forbids acting on.

Looked for on the media description and not the session: a fingerprint may be given at either level, and the media-level one wins where both appear. A caller that wants the session-level fallback reads SessionDescription::fingerprint.

Source

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

The a=setup role this stream declares (RFC 4145 §4).

Source

pub fn rtcp_mux(&self) -> bool

Whether this stream carries the a=rtcp-mux flag (RFC 5761 §5).

Source

pub fn ice_candidates(&self) -> Vec<Candidate>

Every a=candidate under this stream that sipx can act on (RFC 8839 §5.1).

Media-level, and only media-level: §5.1 defines the attribute there and nowhere else.

Lines sipx cannot act on are left out of the result rather than turned into an error — an FQDN, an unsupported address family, a transport other than UDP, an unknown candidate type. §5.1 requires that a candidate be ignored, and ignoring it means ignoring the line: the attribute is still on the description and still round-trips, and the rest of the stream is still usable. A stack that refused the description instead would fail calls with peers doing nothing wrong.

Source

pub fn ice_remote_candidates(&self) -> Vec<RemoteCandidate>

The a=remote-candidates this stream carries (RFC 8839 §5.2). Media-level.

Present only in an offer from a controlling agent for a stream that is Completed, so an empty result is the normal case rather than a sign of anything.

Source

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

This stream’s own a=ice-ufrag (RFC 8839 §5.4), before the session-level default.

Read SessionDescription::ice_credentials_for instead unless the distinction matters: a stream with no fragment of its own inherits the session’s, and RFC 8839 §4.4.1.1.1 makes the pair of values, not either alone, what an ICE restart changes.

Source

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

This stream’s own a=ice-pwd (RFC 8839 §5.4), before the session-level default.

Source

pub fn ice_options(&self) -> impl Iterator<Item = &str>

The option tags this stream advertises (RFC 8839 §5.6).

Source

pub fn ice_mismatch(&self) -> bool

Whether this stream carries a=ice-mismatch (RFC 8839 §5.3). Media-level, in an answer.

It means the offer’s default destination for a component had no matching candidate attribute, and therefore that ICE MUST NOT be used for this stream — RFC 3264 procedures apply instead. Not a failure: it is the answerer saying an intermediary rewrote the addresses, which is what ICE was going to discover the hard way.

Source

pub fn rtpmap(&self, format: &str) -> Option<&str>

The rtpmap for a payload type, if the description gives one.

Source

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

The first attribute with this name.

Trait Implementations§

Source§

impl Clone for MediaDescription

Source§

fn clone(&self) -> MediaDescription

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 PartialEq for MediaDescription

Source§

fn eq(&self, other: &MediaDescription) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MediaDescription

Source§

impl StructuralPartialEq for MediaDescription

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,