Skip to main content

Application

Enum Application 

Source
#[non_exhaustive]
pub enum Application { Voip = 2_048, Audio = 2_049, RestrictedLowDelay = 2_051, RestrictedSilk = 2_052, RestrictedCelt = 2_053, }
Expand description

What an encoder is tuned for: libopus OPUS_APPLICATION_*, the application argument of OpusEncoder::new.

Voip and Audio only steer the encoder’s choices. The three restricted applications also limit them: to CELT-only packets, or to SILK-only packets.

That limit holds for every packet that carries audio. A packet without audio can name another mode in its TOC byte, as in libopus. The encoder writes such a packet when there is no room to code the frame: the output buffer has fewer than 3 bytes, or the bitrate gives fewer than 3 bytes per frame, or, for a frame of 40 ms or more, the bitrate is below 2400 b/s or the output buffer holds fewer than 300 bytes per second. The packet is the TOC byte, with a frame count byte for some frames of 60 ms or more, padded when the bitrate is constant (libopus’s “PLC” packet). libopus takes its mode from the last frame the encoder coded, except that a frame shorter than 10 ms is marked CELT-only and a frame of 60 ms or more in a 1-byte buffer SILK-only. Before the first coded frame, and after reset_state, the last mode is libopus’s initial one, Hybrid at fullband. So a restricted encoder whose bitrate is too low to code any frame can write a TOC byte that names Hybrid in every packet. A decoder conceals a packet without audio like a lost one.

The number of each value is the libopus constant of the same name (to_raw). More values may be added in a later release, so a match on it needs a _ arm.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Voip = 2_048

libopus OPUS_APPLICATION_VOIP (2048): speech, for example in a call. The encoder leans towards SILK and keeps speech intelligible.

§

Audio = 2_049

libopus OPUS_APPLICATION_AUDIO (2049): music and other audio that should sound as close to the input as possible.

§

RestrictedLowDelay = 2_051

libopus OPUS_APPLICATION_RESTRICTED_LOWDELAY (2051): the lowest delay. Every packet that carries audio is CELT-only (see above for packets without audio), and the encoder has no 4 ms look-ahead.

§

RestrictedSilk = 2_052

libopus OPUS_APPLICATION_RESTRICTED_SILK (2052, new in libopus 1.6): every packet that carries audio is SILK-only, for a decoder that only has SILK (see above for packets without audio).

  • The bandwidth is at most wideband (8 kHz of audio), whatever is set.
  • Frames are 10 ms or longer. An encode call with 2.5 or 5 ms is refused with BadArg.
  • The speech and music analysis does not run.
  • The look-ahead (OpusEncoder::lookahead) is 6.5 ms, as with Voip and Audio.

It can only be chosen when the encoder is created: OpusEncoder::set_application refuses to change to it or from it.

§

RestrictedCelt = 2_053

libopus OPUS_APPLICATION_RESTRICTED_CELT (2053, new in libopus 1.6): every packet that carries audio is CELT-only, for a decoder that only has CELT (see above for packets without audio). The encoder codes as with RestrictedLowDelay: the same packets, and no 4 ms look-ahead.

It can only be chosen when the encoder is created: OpusEncoder::set_application refuses to change to it or from it.

Implementations§

Source§

impl Application

Source

pub const fn to_raw(self) -> i32

The libopus number of the value, for example 2048 for Voip.

Trait Implementations§

Source§

impl Clone for Application

Source§

fn clone(&self) -> Self

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 Copy for Application

Source§

impl Debug for Application

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Application

Source§

impl Hash for Application

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Application

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Application

Source§

impl TryFrom<i32> for Application

Source§

fn try_from(value: i32) -> Result<Self, Self::Error>

The value with the libopus number value. Any other number is refused with BadArg, as libopus opus_encoder_create refuses it.

Source§

type Error = Error

The type returned in the event of a conversion error.

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.