Skip to main content

Capabilities

Struct Capabilities 

Source
pub struct Capabilities {
    pub address: IpAddr,
    pub audio_port: u16,
    pub audio_formats: Vec<String>,
    pub rtpmaps: Vec<(String, String)>,
    pub direction: Direction,
    pub session_id: u64,
    pub session_version: u64,
    pub crypto: Option<Crypto>,
    pub dtls: Option<Fingerprint>,
    pub rtcp_mux: bool,
    pub dtls_setup: SetupCapabilities,
}
Expand description

What this side can do.

Fields§

§address: IpAddr

Where to receive media.

§audio_port: u16

The port to receive audio on. Zero rejects audio entirely.

§audio_formats: Vec<String>

Payload types this side supports, as offered.

§rtpmaps: Vec<(String, String)>

rtpmap values by payload type, for the formats above.

§direction: Direction

The direction this side wants.

§session_id: u64

The session identifier to use.

§session_version: u64

The session version to use.

§crypto: Option<Crypto>

The SRTP keying this side offers, if the media is to be encrypted (RFC 4568).

None means plain RTP. It is None unless the signalling is secure, because crate::crypto::Crypto::offer will not produce a key over a path that anyone can read.

§dtls: Option<Fingerprint>

The certificate fingerprint this side offers, if the media is to be keyed with DTLS-SRTP (RFC 5763 / 8122).

Exclusive with crypto: they are different m= protocols, and a stream cannot be keyed both ways at once.

§rtcp_mux: bool

Whether this side can put RTP and RTCP on the media port (RFC 5761).

§dtls_setup: SetupCapabilities

DTLS roles the local handshake can hold.

Implementations§

Source§

impl Capabilities

Source

pub fn g711(address: IpAddr, audio_port: u16) -> Self

The G.711 pair plus RFC 4733 DTMF, which is what practically every endpoint accepts.

Source

pub fn with_opus(address: IpAddr, audio_port: u16) -> Self

Opus first, then the G.711 pair, then DTMF.

Order matters in an offer — it is how this side says what it would rather use — and not in an answer, where RFC 3264 §6.1 gives the order to the offerer. So this is the list to offer with; answering an offer that puts G.711 first still answers G.711 first, which is the point.

G.711 stays in the list rather than being replaced. Opus is better when both ends have it and useless when they do not, and an endpoint that offered only Opus would fail to call most of the telephone network.

The payload type is 111 by convention rather than by standard: Opus has no static type (RFC 7587 §7 assigns none), so the number means nothing on its own and the rtpmap is what the far end matches on. 48000/2 is likewise fixed by RFC 7587 §7 regardless of the rate the audio is sampled at or the number of channels actually sent.

Source

pub fn with_srtp(self, secure_signalling: bool) -> Self

The same capabilities, offering SRTP.

secure_signalling decides whether a key is generated at all: SDES carries the master key in the SDP body, so offering one over cleartext SIP publishes it (RFC 4568 §7.1). Passing false therefore leaves the offer as plain RTP rather than offering encryption that would not be encryption.

Source

pub fn with_dtls_srtp(self, fingerprint: Fingerprint) -> Self

The same capabilities, offering DTLS-SRTP (RFC 5763).

fingerprint is of the certificate this endpoint will present on the media path. Unlike Capabilities::with_srtp there is no secure_signalling flag, and its absence is the point: SDES needs one because the SDP carries the key, and here it carries only a hash of a certificate. That is what makes DTLS-SRTP usable over signalling sipx does not control — a proxy that terminates the TLS learns nothing it can decrypt with.

What it can do is substitute a fingerprint of its own. RFC 8122 §7 says so plainly, and it is the reason this is a keying improvement rather than an authentication one.

The role offered is actpass, which RFC 5763 §5 requires of an offerer: the answerer picks, and picking active means its ClientHello opens the NAT it sits behind.

Source

pub fn with_rtcp_mux(self) -> Self

Offer or answer RTP/RTCP multiplexing on the media port (RFC 5761).

Source

pub fn with_dtls_setup_capabilities(self, setup: SetupCapabilities) -> Self

Limit the DTLS setup roles this capability set may negotiate.

Source

pub fn protocol(&self) -> &'static str

The media transport this side offers.

UDP/TLS/RTP/SAVP for DTLS-SRTP (RFC 5764 §8), RTP/SAVP for SDES, RTP/AVP otherwise. The token is not decoration: it is what tells the far end which keying to expect, and an RTP/SAVP line with an a=fingerprint describes a stream nobody can key.

Source

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

The fingerprint this side offers, if it is offering DTLS-SRTP.

Trait Implementations§

Source§

impl Clone for Capabilities

Source§

fn clone(&self) -> Capabilities

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 Capabilities

Source§

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

Formats the value using the given formatter. 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> 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,