Skip to main content

EncoderContext

Struct EncoderContext 

Source
pub struct EncoderContext(/* private fields */);
Expand description

An encoder context that is closed under the MediaFoundation lock when it is one of the _mf encoders (see open_codec_context), and dropped as usual otherwise. It reads and writes as the AVCodecContext it holds.

Methods from Deref<Target = AVCodecContext>§

Source

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

Source

pub fn as_mut_ptr(&mut self) -> *mut AVCodecContext

Source

pub unsafe fn set_ptr(&mut self, ptr: NonNull<AVCodecContext>)

§Safety

This function should only be called when the pointer is valid and the data it’s pointing to can be dropped.

Source

pub fn set_framerate(&mut self, framerate: AVRational)

Source

pub fn set_ch_layout(&mut self, ch_layout: AVChannelLayout)

Source

pub fn set_height(&mut self, height: i32)

Source

pub fn set_width(&mut self, width: i32)

Source

pub fn set_sample_aspect_ratio(&mut self, sample_aspect_ratio: AVRational)

Source

pub fn set_pix_fmt(&mut self, pix_fmt: i32)

Source

pub fn set_time_base(&mut self, time_base: AVRational)

Source

pub fn set_pkt_timebase(&mut self, pkt_timebase: AVRational)

Source

pub fn set_sample_rate(&mut self, sample_rate: i32)

Source

pub fn set_sample_fmt(&mut self, sample_fmt: i32)

Source

pub fn set_flags(&mut self, flags: i32)

Source

pub fn set_bit_rate(&mut self, bit_rate: i64)

Source

pub fn set_strict_std_compliance(&mut self, strict_std_compliance: i32)

Source

pub fn set_gop_size(&mut self, gop_size: i32)

Source

pub fn set_max_b_frames(&mut self, max_b_frames: i32)

Source

pub fn set_get_format( &mut self, get_format: Option<unsafe extern "C" fn(*mut AVCodecContext, *const i32) -> i32>, )

Source

pub fn open( &mut self, dict: Option<AVDictionary>, ) -> Result<Option<AVDictionary>, RsmpegError>

Initialize the AVCodecContext.

dict: A AVDictionary filled with AVCodecContext and AVCodec private options. Function returns a AVDictionary filled with options that were not found if given dictionary. It can usually be ignored.

Note: Always call this function before using decoding routines, such as Self::receive_frame().

Source

pub fn send_packet( &mut self, packet: Option<&AVPacket>, ) -> Result<(), RsmpegError>

Trying to push a packet to current decoding_context(AVCodecContext).

Source

pub fn receive_frame(&mut self) -> Result<AVFrame, RsmpegError>

Trying to pull a frame from current decoding_context(AVCodecContext).

Source

pub fn send_frame(&mut self, frame: Option<&AVFrame>) -> Result<(), RsmpegError>

Trying to push a frame to current encoding_context(AVCodecContext).

Source

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

Trying to pull a packet from current encoding_context(AVCodecContext).

Source

pub fn decode_subtitle( &mut self, packet: Option<&mut AVPacket>, ) -> Result<Option<AVSubtitle>, RsmpegError>

Decode a subtitle message.

Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input and output. This means that for some packets they will not immediately produce decoded output and need to be flushed at the end of decoding to get all the decoded data. Flushing is done by calling this function with None.

Source

pub fn encode_subtitle( &mut self, subtitle: &AVSubtitle, buf: &mut [u8], ) -> Result<(), RsmpegError>

Encode subtitle to buffer.

Source

pub fn apply_codecpar( &mut self, codecpar: &AVCodecParameters, ) -> Result<(), RsmpegError>

Fill the codec context based on the values from the supplied codec parameters.

ATTENTION: There is no codecpar field in AVCodecContext, this function just fill the codec context based on the values from the supplied codec parameters. Any allocated fields in current AVCodecContext that have a corresponding field in codecpar are freed and replaced with duplicates of the corresponding field in codecpar. Fields in current AVCodecContext that do not have a counterpart in given codecpar are not touched.

Source

pub fn extract_codecpar(&self) -> AVCodecParameters

Get a filled AVCodecParameters based on the values from current AVCodecContext.

Source

pub fn ch_layout(&self) -> AVChannelLayoutRef<'_>

Get channel layout

Source

pub fn hw_frames_ctx(&self) -> Option<AVHWFramesContextRef<'_>>

Source

pub fn hw_frames_ctx_mut(&mut self) -> Option<AVHWFramesContextMut<'_>>

Source

pub fn set_hw_frames_ctx(&mut self, hw_frames_ctx: AVHWFramesContext)

Source

pub fn set_hw_device_ctx(&mut self, hw_device_ctx: AVHWDeviceContext)

Source

pub fn get_supported_pix_fmts( &self, codec: Option<&AVCodec>, ) -> Result<&[i32], RsmpegError>

Retrieve a list of all supported pixel formats. Returns Some(&[]) if all possible pixel formats are supported

  • avctx: codec The codec to query, or None to use self.codec
Source

pub fn get_supported_sample_fmts( &self, codec: Option<&AVCodec>, ) -> Result<&[i32], RsmpegError>

Retrieve a list of all supported sample formats. Returns Some(&[]) if all possible sample formats are supported

  • avctx: codec The codec to query, or None to use self.codec
Source

pub unsafe fn get_supported_config<T>( &self, codec: Option<&AVCodec>, config: u32, ) -> Result<&[T], RsmpegError>

Retrieve a list of all supported values for a given configuration type.

§Safety

config should matches T

Source

pub fn is_hwaccel(&self) -> bool

Is hardware accelaration enabled in this codec context.

Source

pub fn flush_buffers(&mut self)

Reset the internal codec state / flush internal buffers. Should be called e.g. when seeking or when switching to a different stream.

For decoders, this function just releases any references the decoder might keep internally, but the caller’s references remain valid.

For encoders, this function will only do something if the encoder declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder will drain any remaining packets, and can then be re-used for a different stream (as opposed to sending a null frame which will leave the encoder in a permanent EOF state after draining). This can be desirable if the cost of tearing down and replacing the encoder instance is high.

Source

pub fn codec(&'ctx self) -> AVCodecRef<'ctx>

Get a reference to the AVCodec in current codec context.

Trait Implementations§

Source§

impl Deref for EncoderContext

Source§

type Target = AVCodecContext

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl DerefMut for EncoderContext

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for EncoderContext

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl From<AVCodecContext> for EncoderContext

Source§

fn from(context: AVCodecContext) -> Self

Converts to this type from the input type.

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.