pub trait VideoSource: VideoParts {
Show 21 methods
// Required methods
fn width(&self) -> u32;
fn height(&self) -> u32;
fn pixel_format(&self) -> PixelFormat;
fn frame_rate(&self) -> FrameRate;
fn picture_aspect_ratio(&self) -> PictureAspectRatio;
fn scan_type(&self) -> ScanType;
fn timecode(&self) -> Timecode;
fn timestamp(&self) -> Option<ReceivedTimestamp>;
fn line_stride_bytes(&self) -> usize;
fn metadata(&self) -> Option<&str>;
fn metadata_status(&self) -> FrameMetadataStatus;
fn color_info(&self) -> Result<Option<ColorInfo>>;
fn plane(&self, index: usize) -> Option<VideoPlane<'_>>;
fn planes(&self) -> VideoPlanes<'_> ⓘ;
fn data(&self) -> Option<&[u8]>;
fn to_owned(&self) -> VideoFrame;
fn copy_into(&self, destination: &mut VideoFrame);
fn sends_in_place(&self) -> bool;
fn encode_image(&self, options: &ImageOptions) -> Result<Vec<u8>>;
fn encode_image_to<W: Write>(
&self,
options: &ImageOptions,
out: W,
) -> Result<()>
where Self: Sized;
fn encode_image_data_url(&self, options: &ImageOptions) -> Result<String>;
}Expand description
A validated uncompressed video input for synchronous sending and owned copies.
Implemented by VideoFrame, crate::BorrowedVideoFrame,
VideoFrameRef and FrameSyncVideoRef. This trait is sealed: applications
cannot claim that unchecked storage is a valid frame. It exposes no SDK
pointers or allocation ownership. Operations borrow their input and preserve
its lifetime and thread restrictions; converting a captured frame is unnecessary.
Required Methods§
Sourcefn pixel_format(&self) -> PixelFormat
fn pixel_format(&self) -> PixelFormat
Validated uncompressed pixel format.
Sourcefn frame_rate(&self) -> FrameRate
fn frame_rate(&self) -> FrameRate
Frame rate, including its rational representation.
Sourcefn picture_aspect_ratio(&self) -> PictureAspectRatio
fn picture_aspect_ratio(&self) -> PictureAspectRatio
Display width divided by height; zero means square pixels.
Sourcefn timestamp(&self) -> Option<ReceivedTimestamp>
fn timestamp(&self) -> Option<ReceivedTimestamp>
Source-dependent timestamp supplied by the SDK for a captured frame.
Sourcefn line_stride_bytes(&self) -> usize
fn line_stride_bytes(&self) -> usize
Distance in bytes between first-plane row starts.
Sourcefn metadata(&self) -> Option<&str>
fn metadata(&self) -> Option<&str>
UTF-8 frame metadata; an explicit empty string differs from no metadata.
Unreadable received text is withheld; inspect Self::metadata_status.
Sourcefn metadata_status(&self) -> FrameMetadataStatus
fn metadata_status(&self) -> FrameMetadataStatus
Whether per-frame metadata is absent, readable, or withheld as unreadable.
Sourcefn color_info(&self) -> Result<Option<ColorInfo>>
fn color_info(&self) -> Result<Option<ColorInfo>>
Read the frame’s ndi_color_info description without copying metadata.
§Errors
Error::InvalidFrame for malformed, truncated or conflicting color
metadata or withheld received text, with the same semantics as
VideoFrame::color_info.
Sourcefn plane(&self, index: usize) -> Option<VideoPlane<'_>>
fn plane(&self, index: usize) -> Option<VideoPlane<'_>>
One plane’s initialized active rows, excluding row padding.
Sourcefn planes(&self) -> VideoPlanes<'_> ⓘ
fn planes(&self) -> VideoPlanes<'_> ⓘ
All initialized active planes in SDK order, without allocating.
Sourcefn data(&self) -> Option<&[u8]>
fn data(&self) -> Option<&[u8]>
Contiguous active pixels, or None when row/plane padding separates them.
Padding and SDK trailing read room are never exposed through this slice.
Sourcefn to_owned(&self) -> VideoFrame
fn to_owned(&self) -> VideoFrame
Copy active pixels and readable metadata into a new, tightly packed owned frame. Withheld metadata keeps its status without its text. Allocates pixel storage and, when present, readable metadata storage.
Sourcefn copy_into(&self, destination: &mut VideoFrame)
fn copy_into(&self, destination: &mut VideoFrame)
Copy active pixels and metadata into an owned destination, preserving
the header and timestamp. Row padding is omitted. Pixel and metadata
allocations are reused when their capacities/layouts permit; this has
the same allocation behavior as a captured frame’s copy_into. A copy
without metadata retains the destination’s text allocation.
Sourcefn sends_in_place(&self) -> bool
fn sends_in_place(&self) -> bool
Whether synchronous sending can read this frame directly, without a wrapper pixel copy. The query allocates nothing and makes no SDK call.
Captured padding is never assumed initialized. Padded captures and
formats requiring trailing SDK room therefore use reusable staging;
owned frames and eligible packed captures send directly. An external
crate::BorrowedVideoFrame retains its explicit padding/tail policy.
Sourcefn encode_image(&self, options: &ImageOptions) -> Result<Vec<u8>>
fn encode_image(&self, options: &ImageOptions) -> Result<Vec<u8>>
Encode this frame using the image format and conversion options.
Sourcefn encode_image_to<W: Write>(
&self,
options: &ImageOptions,
out: W,
) -> Result<()>where
Self: Sized,
fn encode_image_to<W: Write>(
&self,
options: &ImageOptions,
out: W,
) -> Result<()>where
Self: Sized,
Encode into a writer, flushing it when encoding succeeds.
Sourcefn encode_image_data_url(&self, options: &ImageOptions) -> Result<String>
fn encode_image_data_url(&self, options: &ImageOptions) -> Result<String>
Encode this frame as a base64 data URL.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".