pub struct CodecParameters {
Show 17 fields pub codec: CodecType, pub sample_rate: Option<u32>, pub time_base: Option<TimeBase>, pub n_frames: Option<u64>, pub start_ts: u64, pub sample_format: Option<SampleFormat>, pub bits_per_sample: Option<u32>, pub bits_per_coded_sample: Option<u32>, pub channels: Option<Channels>, pub channel_layout: Option<Layout>, pub delay: Option<u32>, pub padding: Option<u32>, pub max_frames_per_packet: Option<u64>, pub packet_data_integrity: bool, pub verification_check: Option<VerificationCheck>, pub frames_per_block: Option<u64>, pub extra_data: Option<Box<[u8]>>,
}
Expand description

Codec parameters stored in a container format’s headers and metadata may be passed to a codec using the CodecParameters structure.

Fields§

§codec: CodecType

The codec type.

§sample_rate: Option<u32>

The sample rate of the audio in Hz.

§time_base: Option<TimeBase>

The timebase of the stream.

The timebase is the length of time in seconds of a single tick of a timestamp or duration. It can be used to convert any timestamp or duration related to the stream into seconds.

§n_frames: Option<u64>

The length of the stream in number of frames.

If a timebase is available, this field can be used to calculate the total duration of the stream in seconds by using TimeBase::calc_time and passing the number of frames as the timestamp.

§start_ts: u64

The timestamp of the first frame.

§sample_format: Option<SampleFormat>

The sample format of an audio sample.

§bits_per_sample: Option<u32>

The number of bits per one decoded audio sample.

§bits_per_coded_sample: Option<u32>

The number of bits per one encoded audio sample.

§channels: Option<Channels>

A bitmask of all channels in the stream.

§channel_layout: Option<Layout>

The channel layout.

§delay: Option<u32>

The number of leading frames inserted by the encoder that should be skipped during playback.

§padding: Option<u32>

The number of trailing frames inserted by the encoder for padding that should be skipped during playback.

§max_frames_per_packet: Option<u64>

The maximum number of frames a packet will contain.

§packet_data_integrity: bool

The demuxer guarantees packet data integrity.

§verification_check: Option<VerificationCheck>

A method and expected value that may be used to perform verification on the decoded audio.

§frames_per_block: Option<u64>

The number of frames per block, in case packets are seperated in multiple blocks.

§extra_data: Option<Box<[u8]>>

Extra data (defined by the codec).

Implementations§

source§

impl CodecParameters

source

pub fn new() -> CodecParameters

source

pub fn for_codec(&mut self, codec: CodecType) -> &mut Self

Provide the CodecType.

source

pub fn with_sample_rate(&mut self, sample_rate: u32) -> &mut Self

Provide the sample rate in Hz.

source

pub fn with_time_base(&mut self, time_base: TimeBase) -> &mut Self

Provide the TimeBase.

source

pub fn with_n_frames(&mut self, n_frames: u64) -> &mut Self

Provide the total number of frames.

source

pub fn with_start_ts(&mut self, start_ts: u64) -> &mut Self

Provide the timestamp of the first frame.

source

pub fn with_sample_format(&mut self, sample_format: SampleFormat) -> &mut Self

Provide the codec’s decoded audio sample format.

source

pub fn with_bits_per_sample(&mut self, bits_per_sample: u32) -> &mut Self

Provide the bit per sample of a decoded audio sample.

source

pub fn with_bits_per_coded_sample( &mut self, bits_per_coded_sample: u32 ) -> &mut Self

Provide the bits per sample of an encoded audio sample.

source

pub fn with_channels(&mut self, channels: Channels) -> &mut Self

Provide the channel map.

source

pub fn with_channel_layout(&mut self, channel_layout: Layout) -> &mut Self

Provide the channel layout.

source

pub fn with_delay(&mut self, delay: u32) -> &mut Self

Provide the number of delay frames.

source

pub fn with_padding(&mut self, padding: u32) -> &mut Self

Provide the number of padding frames.

source

pub fn with_max_frames_per_packet(&mut self, len: u64) -> &mut Self

Provide the maximum number of frames per packet.

source

pub fn with_packet_data_integrity(&mut self, integrity: bool) -> &mut Self

Specify if the packet’s data integrity was guaranteed.

source

pub fn with_frames_per_block(&mut self, len: u64) -> &mut Self

Provide the maximum number of frames per packet.

source

pub fn with_extra_data(&mut self, data: Box<[u8]>) -> &mut Self

Provide codec extra data.

source

pub fn with_verification_code(&mut self, code: VerificationCheck) -> &mut Self

Provide a verification code of the final decoded audio.

Trait Implementations§

source§

impl Clone for CodecParameters

source§

fn clone(&self) -> CodecParameters

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CodecParameters

source§

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

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

impl Default for CodecParameters

source§

fn default() -> Self

Returns the “default value” for a type. 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> 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<F, T> IntoSample<T> for F
where T: FromSample<F>,

source§

fn into_sample(self) -> T

source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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.