Struct ffmpeg::avcodec::AvBuffer

source ·
pub struct AvBuffer(*mut AVBufferRef);
Expand description

Wrapper around AVBuffer and AVBufferRef.

libavcodec can manage its own memory for input and output data. Doing so implies a transparent copy of user-provided data (packets or frames) from and to this memory, which is wasteful.

This copy can be avoided by explicitly providing our own buffers to libavcodec using AVBufferRef. Doing so means that the lifetime of these buffers becomes managed by avcodec. This struct helps make this process safe by taking full ownership of an AvBufferSource and dropping it when libavcodec is done with it.

Tuple Fields§

§0: *mut AVBufferRef

Implementations§

source§

impl AvBuffer

source

pub fn new<D: AvBufferSource + 'static>(source: D) -> Option<Self>

Create a new AvBuffer from an AvBufferSource.

Ownership of source is transferred to libavcodec, which will drop it when the number of references to this buffer reaches zero.

Returns None if the buffer could not be created due to an error in libavcodec.

source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Return a slice to the data contained in this buffer.

source

pub fn into_raw(self) -> *mut AVBufferRef

Consumes the AVBuffer, returning a AVBufferRef that can be used in AVFrame, AVPacket and others.

After calling, the caller is responsible for unref-ing the returned AVBufferRef, either directly or through one of the automatic management facilities in AVFrame, AVPacket or others.

Trait Implementations§

source§

impl Drop for AvBuffer

source§

fn drop(&mut self)

Executes the destructor for this 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<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.