pub struct Buffer<'a> { /* private fields */ }
Expand description

Abstraction around input buffer allocated using the NVIDIA Video Encoder API.

The buffer is automatically destroyed when dropped.

Implementations§

source§

impl<'a> Buffer<'a>

source

pub fn lock<'b>(&'b mut self) -> Result<BufferLock<'b, 'a>, EncodeError>

Lock the input buffer.

On a successful lock you get a BufferLock which can be used to write data to the input buffer. On drop, BufferLock will unlock the buffer.

This function will block until a lock is acquired. For the non-blocking version see Buffer::try_lock.

See NVIDIA docs.

Errors

Could error if we run out of memory.

Examples
//* Create encoder. *//
//* Set `encode_guid` and `buffer_format`, and check that H.264 encoding and the ARGB format are supported. *//
//* Begin encoder session. *//

// Create an input buffer.
let mut input_buffer = session
    .create_input_buffer()
    .unwrap();
unsafe { input_buffer.lock().unwrap().write(&[0; DATA_LEN]) };
source

pub fn try_lock<'b>(&'b mut self) -> Result<BufferLock<'b, 'a>, EncodeError>

Non-blocking version of Buffer::lock. See it for more info.

This function will return an error with ErrorKind::EncoderBusy or ErrorKind::LockBusy if the lock is being used. The NVIDIA documentation from the header file is unclear about this.

Errors

Could error if we run out of memory.

If this returns an error with ErrorKind::EncoderBusy or ErrorKind::LockBusy then that means the lock is still busy and the client should retry in a few milliseconds.

Trait Implementations§

source§

impl<'a> Debug for Buffer<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Buffer<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl EncoderInput for Buffer<'_>

source§

fn pitch(&self) -> u32

Get the pitch (AKA stride) of the input resource.
source§

fn handle(&mut self) -> *mut c_void

Get the handle of the input resource.
source§

impl Send for Buffer<'_>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Buffer<'a>

§

impl<'a> !Sync for Buffer<'a>

§

impl<'a> Unpin for Buffer<'a>

§

impl<'a> UnwindSafe for Buffer<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.