Skip to main content

DemuxInput

Struct DemuxInput 

Source
pub struct DemuxInput { /* private fields */ }
Expand description

A container opened for reading under an input policy: only the demuxers it names, only the file protocol, and an interrupt callback the reader binds to its own cancellation.

The format context is read through Deref, and moved only by the methods here. FFmpeg holds a pointer to this input’s interrupt state, which lives exactly as long as the input, so the context can never be taken out of it and outlive that state:

ⓘ
let stolen = std::mem::replace(&mut *demux, other);
drop(demux);

Implementations§

Source§

impl DemuxInput

Source

pub fn interrupt_when(&self, check: impl Fn() -> bool + Send + Sync + 'static)

Makes every FFmpeg call on this input that waits on I/O, from now until the next call to this, stop with AVERROR_EXIT once check returns true.

Source

pub fn best_stream( &self, media_type: AVMediaType, ) -> Result<Option<usize>, RsmpegError>

The stream of media_type a reader shows, by its AVStream index: the one av_find_best_stream picks among those with a decoder, never an attached picture (a song’s cover art is metadata, not its video). When FFmpeg picks an attached picture, the first other stream of the type that has a decoder is chosen, in stream order.

None when the input has no such stream, or none that this runtime can decode: a stream without a decoder leaves the type unselected rather than failing the input, whose other streams may decode.

§Errors

Any other av_find_best_stream failure.

Source

pub fn read_packet(&mut self) -> Result<Option<AVPacket>, RsmpegError>

The next packet in file order (av_read_frame), or None at the end of the file.

§Errors

The FFmpeg read failure, or AVERROR_EXIT when the interrupt check stopped it.

Source

pub fn seek( &mut self, stream_index: i32, timestamp: i64, flags: i32, ) -> Result<(), RsmpegError>

Seeks to the key frame at timestamp of stream_index (av_seek_frame; -1 for AV_TIME_BASE units).

§Errors

The FFmpeg seek failure, or AVERROR_EXIT when the interrupt check stopped it.

Source

pub fn discard_all_but(&mut self, index: usize)

Has the demuxer skip every stream but index: a reader of one stream then neither reads nor copies the others’ packets (AVDISCARD_ALL), which demuxers such as mov do not even fetch from the file.

Source

pub fn keep_only(&mut self, kept: &[usize])

Self::discard_all_but for a reader of the streams kept.

Methods from Deref<Target = AVFormatContextInput>§

Source

pub fn as_ptr(&self) -> *const AVFormatContext

Source

pub fn find_best_stream( &self, media_type: i32, ) -> Result<Option<(usize, AVCodecRef<'static>)>, RsmpegError>

Return the stream index and stream decoder if there is any “best” stream. “best” means the most likely what the user wants.

Source

pub fn streams(&'stream self) -> &'stream [AVStreamRef<'stream>]

Return slice of AVStreamRef.

Source

pub fn iformat(&'stream self) -> AVInputFormatRef<'stream>

Source

pub fn metadata(&'stream self) -> Option<AVDictionaryRef<'stream>>

Get metadata of the ffi::AVFormatContext in crate::avutil::AVDictionary. demuxing: set by libavformat in avformat_open_input() muxing: may be set by the caller before avformat_write_header()

Trait Implementations§

Source§

impl Deref for DemuxInput

Source§

type Target = AVFormatContextInput

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.