Skip to main content

SdpCodecs

Struct SdpCodecs 

Source
pub struct SdpCodecs { /* private fields */ }
Expand description

Codecs and ancillary data extracted from an SDP session description.

Produced by SdpCodecs::parse. The accessors that feed a codec string reflect the same extraction logic as FreeSWITCH’s switch_core_media_set_r_sdp_codec_string; sections is the wider view, every m= line the offer carried. See docs/codec-string-format.md for the mapping rules.

Implementations§

Source§

impl SdpCodecs

Source

pub fn parse(sdp: &str) -> Result<Self, SdpCodecError>

Parse an SDP session description from a UTF-8 string.

Source

pub fn parse_bytes(bytes: &[u8]) -> Result<Self, SdpCodecError>

Parse an SDP session description from bytes.

Source

pub fn sections(&self) -> &[SdpMediaSection]

Every m= section the offer carried, in offer order.

This is the inventory, including the sections no codec string can reach — a held or declined stream, or a media type the switch derives no codec from.

Source

pub fn entries(&self) -> impl Iterator<Item = &SdpCodecEntry>

Codec entries from the negotiable sections, in SDP offer order.

Source

pub fn len(&self) -> usize

Number of codec entries; payloads from non_codec_payloads are not counted.

Source

pub fn is_empty(&self) -> bool

true when the offer negotiates no codecs, ignoring any non-codec payloads.

Source

pub fn audio(&self) -> impl Iterator<Item = &SdpCodec>

Iterator over audio RTP codecs only.

Source

pub fn video(&self) -> impl Iterator<Item = &SdpCodec>

Iterator over video RTP codecs only.

Source

pub fn unmapped(&self) -> impl Iterator<Item = &UnmappedPayload>

Payload types that could not be named (no a=rtpmap, no static-table entry).

These are surfaced as data rather than an error so the caller can distinguish “never offered” from “offered but unresolvable”. A non-negotiable section’s unresolvable payloads stay on SdpMediaSection::unmapped.

Source

pub fn warnings(&self) -> &[SdpWarning]

Recoverable parse warnings (e.g. unparseable numeric attributes).

Covers every section, negotiable or not — the excluded ones are parsed rather than skipped, so they warn where the switch has no occasion to.

Source

pub fn non_codec_payloads(&self) -> impl Iterator<Item = &NonCodecPayload>

Payloads the switch negotiates outside the codec string, in m= order.

Never included in entries or unmapped, and drawn from the negotiable sections only; a held section’s are on SdpMediaSection::non_codec_payloads. Not deduplicated: two sections offering the same kind at one clock rate under different payload types yield two entries. See NonCodecPayload for what the switch itself retains from these.

Source

pub fn audio_codec_string( &self, options: &CodecStringOptions, warnings: Option<&mut Vec<SdpWarning>>, ) -> Result<CodecString, CodecStringError>

Build a FreeSWITCH codec string from this offer’s audio codecs.

Emits a literal t38 entry for each m=image section the offer carried, in its original m-line position among the audio entries — C writes ,t38 inside the same per-m-line loop that emits audio codecs (switch_core_media.c:13651), so an m=image section before an m=audio section puts t38 first, not last. Does not deduplicate — an offer carrying the AMR octet-aligned/bandwidth-efficient pair yields two identical entries under default options (they differ only in fmtp, which is off by default for audio). Call CodecString::dedup after composing the final string.

warnings = None is strict: any unrepresentable codec name or fmtp is Err. warnings = Some(acc) is lenient: an unrepresentable fmtp is cleared (the codec is still emitted) and an unrepresentable codec name is skipped (the codec is dropped); both push a warning to acc rather than failing the whole call. An offer past CodecString::MAX_SWITCH_ENTRIES is CodecStringError::TooManyEntries in either mode — the limit is structural, not a per-codec oddity.

Source

pub fn video_codec_string( &self, options: &CodecStringOptions, warnings: Option<&mut Vec<SdpWarning>>, ) -> Result<CodecString, CodecStringError>

Build a FreeSWITCH codec string from this offer’s video codecs.

Selects straight from the video codecs, where the audio builder walks every entry instead: only the audio string interleaves T.38, which has to keep its m-line position. Does not deduplicate; see audio_codec_string for why. warnings follows the same strict/lenient convention.

Source

pub fn fmtp_for(&self, name: &str, clock_rate: u32) -> Option<&str>

Look up the fmtp of an offered audio codec by name and clock rate.

Drives rtp_force_audio_fmtp once the caller knows which codec ended up first in its final, composed, filtered codec string — “first codec in the offer” is routinely not that codec, so this takes the name and rate explicitly rather than exposing a “primary” accessor that would often name the wrong payload map.

Several payload types commonly share one name+rate with different fmtp — the AMR octet-aligned/bandwidth-efficient pair is the recurring case. When they disagree, the first one carrying an fmtp wins; a caller driving rtp_force_audio_fmtp from this can otherwise pin octet-aligned when the switch negotiated bandwidth-efficient.

Trait Implementations§

Source§

impl Clone for SdpCodecs

Source§

fn clone(&self) -> SdpCodecs

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 SdpCodecs

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