Skip to main content

VideoFrameBuilder

Struct VideoFrameBuilder 

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

Builder for a VideoFrame, reached through VideoFrame::builder.

Implementations§

Source§

impl VideoFrameBuilder

Source

pub fn resolution(self, width: u32, height: u32) -> Self

Set the video resolution. Width must be positive and even; height must be positive (and even for 4:2:0 formats).

Source

pub fn pixel_format(self, pixel_format: PixelFormat) -> Self

Set the pixel format.

Source

pub fn frame_rate(self, frame_rate: FrameRate) -> Self

Set the frame rate.

Source

pub fn picture_aspect_ratio(self, ratio: PictureAspectRatio) -> Self

Set the picture aspect ratio, width over height as displayed; 0.0 means square pixels.

Source

pub fn scan_type(self, scan_type: ScanType) -> Self

Set the scan type (progressive, interlaced, etc.).

Source

pub fn timecode(self, timecode: Timecode) -> Self

Set the timecode.

Source

pub fn metadata<S: Into<String>>(self, metadata: S) -> Self

Set the metadata text. A refused build retains this text; recover it with Self::supplied_metadata or Self::take_metadata to repair it. An owned string retains its allocation when there is capacity for the trailing NUL; invalid metadata leaves a rejected builder unchanged.

Source

pub fn data(self, data: Vec<u8>) -> Self

Supply owned pixels without an intermediate zero-filled allocation.

build requires exactly the validated layout size. The frame keeps this allocation when its spare capacity holds the layout and scan type’s room, which is nothing for most formats, and otherwise grows it once, which may move the pixels. Use data_mut on the resulting frame for reuse.

Source

pub fn supplied_data(&self) -> Option<&[u8]>

The caller-supplied pixels, before any validation or transformation.

Source

pub fn take_data(&mut self) -> Option<Vec<u8>>

Take supplied data while retaining the builder’s other settings.

This permits repairing a refused buffer and putting it back with Self::data. Until then, building uses the zero-filled default.

Source

pub fn into_data(self) -> Option<Vec<u8>>

Recover the caller-supplied vector without building a frame.

Its allocation, capacity and bytes are unchanged, including after a failed Self::build. Returns None for zero-filled default input.

Source

pub fn clear_data(self) -> Self

Use zero-filled default data instead of a supplied buffer.

Recover the buffer first with Self::take_data when it is needed again.

Source

pub fn supplied_metadata(&self) -> Option<&str>

The supplied metadata before validation or termination.

Source

pub fn take_metadata(&mut self) -> Option<String>

Recover metadata while retaining the builder’s other settings. Its allocation and text are unchanged after a refused build.

Source

pub fn clear_metadata(self) -> Self

Remove metadata, for example to repair a rejected builder.

Source

pub fn build(self) -> Result<VideoFrame, Rejected<Self>>

Build the video frame.

Unset fields keep the defaults VideoFrame::builder lists. Building never loads or queries an NDI runtime: whether the runtime can send the pixel format is checked when the frame is sent.

§Errors

Returns the unchanged builder with Error::InvalidFrame if the resolution, pixel format, metadata size or supplied data length do not form a valid frame, and Error::InvalidCString for metadata containing a NUL byte.

Trait Implementations§

Source§

impl Clone for VideoFrameBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VideoFrameBuilder

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.