Skip to main content

audio_frame_from

Function audio_frame_from 

Source
pub fn audio_frame_from(
    frame: &Audio,
    time_base: Timebase,
    limits: FrameLimits,
) -> Result<AudioFrame<SampleFormat, ChannelLayoutDescription, AudioFrameExtra, FfmpegBytes>, ConvertError>
Expand description

Safe wrapper around av_frame_to_audio_frame taking a borrowed ffmpeg::frame::Audio.

Borrowed source, owned lane. This road copies, on purpose and without a lane to choose. ffmpeg_next’s frame wrappers lend &mut [u8] through data_mut and share their buffers by refcount with no copy-on-write, so a caller who still holds the frame holds a mutable alias of every byte a view would read — and both sides are Send, so the two halves need not even be on one thread. No safe signature that borrows a frame can hand out a window onto it.

The view lane reaches frames the way it is meant to: through a decoder, which owns the AVFrame it decoded into and never lends it out. A caller holding an AVFrame of their own can use the unsafe entry point below, whose contract names the obligation this signature cannot express.