Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 13 fields pub remote: SocketAddr, pub codec: Codec, pub payload_type: Option<u8>, pub receive_payload_type: Option<u8>, pub channels: usize, pub srtp: Option<SrtpKeys>, pub packet_duration: Duration, pub clock_rate: u32, pub jitter_depth: usize, pub jitter_max_depth: Option<usize>, pub rtcp_interval: Option<Duration>, pub rtcp_mode: RtcpMode, pub dtmf_payload_type: Option<u8>,
}
Expand description

How a session is configured.

Fields§

§remote: SocketAddr

Where to send until symmetric RTP learns better.

§codec: Codec

Which codec.

§payload_type: Option<u8>

The payload type to send with, when the codec’s own is not the negotiated one.

None uses Codec::payload_type. A dynamic codec has no number of its own — Opus has none at all (RFC 7587 §7) — so the number comes from the a=rtpmap the two sides agreed on, and it may differ from the one sipx would have proposed. Assuming otherwise sends audio on a number the far end has assigned to something else.

§receive_payload_type: Option<u8>

The payload type accepted for this codec when our description assigned a different dynamic number from the peer’s.

None mirrors Self::wire_payload_type, which preserves the ordinary symmetric case. Offer/answer may nevertheless assign the same codec independently in each direction: outgoing packets use the peer’s number and incoming packets use ours (RFC 3264 §6.1).

§channels: usize

How many channels the codec carries. One, for telephony.

§srtp: Option<SrtpKeys>

SRTP keys, if the media is to be encrypted (RFC 3711).

None sends and expects plain RTP. There is deliberately no middle setting — no “accept either” — because a session that falls back to cleartext when a packet fails to authenticate is a session an attacker can downgrade by sending one bad packet.

§packet_duration: Duration

How much audio each packet carries. 20 ms is universal; values below 1 ms are rejected by Self::validate and every session-start API.

§clock_rate: u32

RTP-clock samples per second for the exact negotiated format.

G.711 is always 8000; L16 may use its static 44100 clock or a dynamically mapped rate.

§jitter_depth: usize

How many packets the jitter buffer holds, and never fewer.

§jitter_max_depth: Option<usize>

The deepest it may grow when the network misbehaves, in packets.

None fixes the depth at Self::jitter_depth, which is what the comparison tests in sipx-rtp measure the adaptive buffer against. Adapting is the default because being too shallow is audible and being too deep is not — but the ceiling is a real ceiling: a call with a quarter-second of delay is still a call, and one with three seconds is not.

§rtcp_interval: Option<Duration>

How often to send RTCP receiver reports. None disables RTCP entirely; a configured interval must be at least 1 ms.

RFC 3550 §6.2 scales the interval with the session’s bandwidth and membership; for a two-party call that arithmetic lands at the five-second minimum, so sipx uses it directly rather than implementing a calculation that would always return the same answer.

§rtcp_mode: RtcpMode

Whether RTCP uses the RTP socket or its adjacent control socket (RFC 5761).

§dtmf_payload_type: Option<u8>

The payload type carrying telephone-event, if the SDP negotiated one.

It is dynamic, so the number is whatever the answer said — assuming 101 because that is what sipx offers would decode another endpoint’s codec as keypresses.

Implementations§

Source§

impl Config

Source

pub fn wire_payload_type(&self) -> u8

The payload type this session puts on the wire.

Source

pub fn receive_wire_payload_type(&self) -> u8

The payload type this session accepts for its negotiated codec.

Source

pub fn new(remote: SocketAddr, codec: Codec) -> Self

A session to a peer in this codec, with the settings everything uses.

Source

pub fn samples_per_packet(&self) -> usize

How many samples one packet carries.

Source

pub fn validate(&self) -> Result<(), SetupError>

Check the values used by worker timers before any worker or socket starts.

§Errors

Returns SetupError::PacketDurationTooShort or SetupError::RtcpIntervalTooShort for a duration below one millisecond.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

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,