pub struct CodecStringEntry { /* private fields */ }Expand description
A single entry in a FreeSWITCH codec string.
All fields are private. Use CodecStringEntry::new plus the with_* builder
methods to construct, and the read accessors plus Display to
inspect and emit.
Implementations§
Source§impl CodecStringEntry
impl CodecStringEntry
Sourcepub fn new(name: impl Into<String>) -> Result<Self, CodecStringError>
pub fn new(name: impl Into<String>) -> Result<Self, CodecStringError>
Create a new entry with the given codec name.
Returns CodecStringError::InvalidCodecName if the name is empty,
CodecStringError::WireInjection if it contains \n or \r, or
CodecStringError::InvalidCharInName if it contains any codec-string
grammar delimiter (, @ ~ . ' \ or ASCII whitespace).
Sourcepub fn with_module(
self,
modname: impl Into<String>,
) -> Result<Self, CodecStringError>
pub fn with_module( self, modname: impl Into<String>, ) -> Result<Self, CodecStringError>
Set the module prefix (e.g. "mod_opus").
Returns CodecStringError::WireInjection if the value contains \n or \r,
or CodecStringError::InvalidCharInName if it contains a grammar delimiter.
Sourcepub fn with_fmtp(
self,
fmtp: impl Into<String>,
) -> Result<Self, CodecStringError>
pub fn with_fmtp( self, fmtp: impl Into<String>, ) -> Result<Self, CodecStringError>
Set format parameters (~fmtp in the grammar).
§Errors
CodecStringError::AtInFmtp—@is unrepresentable in fmtp (the@split precedes the~split in FreeSWITCH’s parser).CodecStringError::DotInFmtpWithoutModule— a.in fmtp without a module prefix becomes the module-name boundary; the codec is silently dropped. Set the module prefix first withwith_module.CodecStringError::WireInjection—\nor\rcan inject ESL commands.
Sourcepub fn with_ptime(self, ptime: u32) -> Self
pub fn with_ptime(self, ptime: u32) -> Self
Set the ptime qualifier (@<n>i).
Sourcepub fn with_bitrate(self, bitrate: u32) -> Self
pub fn with_bitrate(self, bitrate: u32) -> Self
Set the bitrate qualifier (@<n>b).
Sourcepub fn with_channels(self, channels: u32) -> Self
pub fn with_channels(self, channels: u32) -> Self
Set the channel count qualifier (@<n>c).
FreeSWITCH reads this as atoi into a uint32_t; the field is u32 here
to match. SdpCodec::channels stays Option<u8> (from a=rtpmap, realistically tiny)
and widens losslessly at the merge boundary.
Sourcepub fn bitrate_mut(&mut self) -> &mut Option<u32>
pub fn bitrate_mut(&mut self) -> &mut Option<u32>
Mutable access to the bitrate qualifier.
Sourcepub fn channels_mut(&mut self) -> &mut Option<u32>
pub fn channels_mut(&mut self) -> &mut Option<u32>
Mutable access to the channel count qualifier.
Sourcepub fn set_name(
&mut self,
name: impl Into<String>,
) -> Result<(), CodecStringError>
pub fn set_name( &mut self, name: impl Into<String>, ) -> Result<(), CodecStringError>
Set or replace the codec encoding name.
Returns CodecStringError::InvalidCodecName if empty,
CodecStringError::WireInjection if the value contains \n or \r, or
CodecStringError::InvalidCharInName if it contains a grammar delimiter.
Sourcepub fn set_module(
&mut self,
modname: impl Into<String>,
) -> Result<(), CodecStringError>
pub fn set_module( &mut self, modname: impl Into<String>, ) -> Result<(), CodecStringError>
Set or replace the module prefix.
Returns CodecStringError::WireInjection if the value contains \n or \r,
or CodecStringError::InvalidCharInName if it contains a grammar delimiter.
Sourcepub fn set_fmtp(
&mut self,
fmtp: impl Into<String>,
) -> Result<(), CodecStringError>
pub fn set_fmtp( &mut self, fmtp: impl Into<String>, ) -> Result<(), CodecStringError>
Set or replace the format parameters (~fmtp).
Returns the same errors as with_fmtp.
Sourcepub fn clear_fmtp(&mut self)
pub fn clear_fmtp(&mut self)
Clear the format parameters.
Sourcepub fn clear_module(&mut self) -> Result<(), CodecStringError>
pub fn clear_module(&mut self) -> Result<(), CodecStringError>
Clear the module prefix.
Returns CodecStringError::DotInFmtpWithoutModule if the current fmtp
contains a . — removing the prefix would make the entry re-parse with the
dot as the module boundary, silently dropping the codec. The entry is left
unchanged on error.
Sourcepub fn clear_rate(&mut self)
pub fn clear_rate(&mut self)
Clear the rate qualifier.
Infallible analog to clear_fmtp; use to strip a qualifier that matched no
loaded implementation (see CodecString::qualified).
Sourcepub fn clear_ptime(&mut self)
pub fn clear_ptime(&mut self)
Clear the ptime qualifier.
Infallible analog to clear_fmtp; use to strip a qualifier that matched no
loaded implementation (see CodecString::qualified).
Sourcepub fn clear_bitrate(&mut self)
pub fn clear_bitrate(&mut self)
Clear the bitrate qualifier.
Infallible analog to clear_fmtp; use to strip a qualifier that matched no
loaded implementation (see CodecString::qualified).
Sourcepub fn clear_channels(&mut self)
pub fn clear_channels(&mut self)
Clear the channel count qualifier.
Infallible analog to clear_fmtp; use to strip a qualifier that matched no
loaded implementation (see CodecString::qualified).
Sourcepub fn simplify(&mut self)
pub fn simplify(&mut self)
Drop qualifiers whose value already equals the FreeSWITCH default for this codec
(default_rate/default_ptime, ported from switch_core.c:2033-2055), leaving
bitrate alone. G.722 is exempt entirely.
Precondition: only safe on an entry that already matched a loaded
implementation, e.g. one that survived
CodecString::retain_available —
stripping compares against a per-name table, not against what an implementation
registered, so it can make an unmatched qualifier start matching. Both that and
the G.722 carve-out are in docs/codec-string-format.md.
Trait Implementations§
Source§impl Clone for CodecStringEntry
impl Clone for CodecStringEntry
Source§fn clone(&self) -> CodecStringEntry
fn clone(&self) -> CodecStringEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CodecStringEntry
impl Debug for CodecStringEntry
Source§impl Display for CodecStringEntry
impl Display for CodecStringEntry
impl Eq for CodecStringEntry
Source§impl Extend<CodecStringEntry> for CodecString
impl Extend<CodecStringEntry> for CodecString
Source§fn extend<I: IntoIterator<Item = CodecStringEntry>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = CodecStringEntry>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<CodecStringEntry> for CodecString
impl FromIterator<CodecStringEntry> for CodecString
Source§fn from_iter<I: IntoIterator<Item = CodecStringEntry>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = CodecStringEntry>>(iter: I) -> Self
Source§impl FromStr for CodecStringEntry
impl FromStr for CodecStringEntry
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a single codec-string entry from a string.
Reuses the same escape/quote-aware split as CodecString’s parser, then
delegates to the same single-entry parser. A top-level (unescaped) comma is
CodecStringError::MultipleEntries, not a silent take-first.
Source§type Err = CodecStringError
type Err = CodecStringError
Source§impl PartialEq for CodecStringEntry
impl PartialEq for CodecStringEntry
impl StructuralPartialEq for CodecStringEntry
Auto Trait Implementations§
impl Freeze for CodecStringEntry
impl RefUnwindSafe for CodecStringEntry
impl Send for CodecStringEntry
impl Sync for CodecStringEntry
impl Unpin for CodecStringEntry
impl UnsafeUnpin for CodecStringEntry
impl UnwindSafe for CodecStringEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.