pub struct Encoder { /* private fields */ }Expand description
Audio encoder over the PCM layout declared in Config::input.
Build one with Encoder::new, feed it PCM via encode,
and publish the resulting packets through a Producer
built from the same Config.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn config(&self) -> &Config
pub fn config(&self) -> &Config
The encoder config, including the latest accepted runtime bitrate.
Sourcepub fn codec(&self) -> Codec
pub fn codec(&self) -> Codec
The codec this encoder emits. A Producer must be
built for the same codec to publish its packets.
Sourcepub fn codec_rate(&self) -> u32
pub fn codec_rate(&self) -> u32
Sample rate the codec actually runs at, which is
Config::sample_rate resolved.
Sourcepub fn codec_channels(&self) -> u32
pub fn codec_channels(&self) -> u32
Channel count the codec actually runs at, which is
Config::channels resolved.
Sourcepub fn frame_size(&self) -> usize
pub fn frame_size(&self) -> usize
Number of samples per channel the codec consumes per call to
encode.
Sourcepub fn set_bitrate(&mut self, bitrate: u64) -> Result<(), Error>
pub fn set_bitrate(&mut self, bitrate: u64) -> Result<(), Error>
Retune the live Opus encoder to bitrate bits per second.
Sourcepub fn encode(&mut self, pcm: &[f32]) -> Result<Bytes, Error>
pub fn encode(&mut self, pcm: &[f32]) -> Result<Bytes, Error>
Encode one frame of interleaved f32 PCM at codec_rate.
pcm.len() must equal frame_size() * codec_channels(). The
Producer handles format conversion and resampling
before calling this; for direct use, the caller does the same.
Sourcepub fn catalog(&self) -> AudioConfig
pub fn catalog(&self) -> AudioConfig
hang catalog entry describing this encoder’s output stream.