Skip to main content

VideoSource

Trait VideoSource 

Source
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§

Source

fn width(&self) -> u32

Frame width in pixels.

Source

fn height(&self) -> u32

Frame height in pixels.

Source

fn pixel_format(&self) -> PixelFormat

Validated uncompressed pixel format.

Source

fn frame_rate(&self) -> FrameRate

Frame rate, including its rational representation.

Source

fn picture_aspect_ratio(&self) -> PictureAspectRatio

Display width divided by height; zero means square pixels.

Source

fn scan_type(&self) -> ScanType

Progressive, interlaced, or field scanning.

Source

fn timecode(&self) -> Timecode

Frame timecode, or the sender’s synthesis sentinel.

Source

fn timestamp(&self) -> Option<ReceivedTimestamp>

Source-dependent timestamp supplied by the SDK for a captured frame.

Source

fn line_stride_bytes(&self) -> usize

Distance in bytes between first-plane row starts.

Source

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.

Source

fn metadata_status(&self) -> FrameMetadataStatus

Whether per-frame metadata is absent, readable, or withheld as unreadable.

Source

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.

Source

fn plane(&self, index: usize) -> Option<VideoPlane<'_>>

One plane’s initialized active rows, excluding row padding.

Source

fn planes(&self) -> VideoPlanes<'_> ⓘ

All initialized active planes in SDK order, without allocating.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn encode_image(&self, options: &ImageOptions) -> Result<Vec<u8>>

Encode this frame using the image format and conversion options.

Source

fn encode_image_to<W: Write>( &self, options: &ImageOptions, out: W, ) -> Result<()>
where Self: Sized,

Encode into a writer, flushing it when encoding succeeds.

Source

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".

Implementors§