pub struct VideoFrameBuilder { /* private fields */ }Expand description
Builder for a VideoFrame, reached through VideoFrame::builder.
Implementations§
Source§impl VideoFrameBuilder
impl VideoFrameBuilder
Sourcepub fn resolution(self, width: u32, height: u32) -> Self
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).
Sourcepub fn pixel_format(self, pixel_format: PixelFormat) -> Self
pub fn pixel_format(self, pixel_format: PixelFormat) -> Self
Set the pixel format.
Sourcepub fn frame_rate(self, frame_rate: FrameRate) -> Self
pub fn frame_rate(self, frame_rate: FrameRate) -> Self
Set the frame rate.
Sourcepub fn picture_aspect_ratio(self, ratio: PictureAspectRatio) -> Self
pub fn picture_aspect_ratio(self, ratio: PictureAspectRatio) -> Self
Set the picture aspect ratio, width over height as displayed; 0.0
means square pixels.
Sourcepub fn scan_type(self, scan_type: ScanType) -> Self
pub fn scan_type(self, scan_type: ScanType) -> Self
Set the scan type (progressive, interlaced, etc.).
Sourcepub fn metadata<S: Into<String>>(self, metadata: S) -> Self
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.
Sourcepub fn data(self, data: Vec<u8>) -> Self
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.
Sourcepub fn supplied_data(&self) -> Option<&[u8]>
pub fn supplied_data(&self) -> Option<&[u8]>
The caller-supplied pixels, before any validation or transformation.
Sourcepub fn take_data(&mut self) -> Option<Vec<u8>>
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.
Sourcepub fn into_data(self) -> Option<Vec<u8>>
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.
Sourcepub fn clear_data(self) -> Self
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.
Sourcepub fn supplied_metadata(&self) -> Option<&str>
pub fn supplied_metadata(&self) -> Option<&str>
The supplied metadata before validation or termination.
Sourcepub fn take_metadata(&mut self) -> Option<String>
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.
Sourcepub fn clear_metadata(self) -> Self
pub fn clear_metadata(self) -> Self
Remove metadata, for example to repair a rejected builder.
Sourcepub fn build(self) -> Result<VideoFrame, Rejected<Self>>
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.