Skip to main content

CaptureKind

Trait CaptureKind 

Source
pub trait CaptureKind: FrameFree<Instance = *mut NDIlib_recv_instance_type> + Sized {
    type Ref<'rx>;
    type Owned;

    const FRAME_TYPE: c_uint;

    // Required methods
    unsafe fn capture_into(
        instance: *mut NDIlib_recv_instance_type,
        frame: *mut Self::RawFrame,
        timeout_ms: u32,
    ) -> c_uint;
    unsafe fn make_ref<'rx>(guard: Guard<'rx, Self>) -> Result<Self::Ref<'rx>>;
    fn ref_to_owned(frame: &Self::Ref<'_>) -> Result<Self::Owned>;
}
Expand description

Single source of truth describing one NDI frame kind (video, audio, or metadata).

Each implementor wires together the FFI frame struct, the borrowed and owned Rust frame types, and the four SDK calls those entail — capture, the frame-type discriminant, freeing, and the borrowed/owned conversions. Every generic capture path (capture_raw, Receiver’s Capture view, and the async views) is written once against this trait, so adding or changing a kind happens in exactly one place.

This is a sealed trait — it cannot be implemented outside this crate. Implementations exist for VideoKind, AudioKind, and MetadataKind.

§Safety

Implementors must ensure the members agree on the same RawFrame: capture_into populates it via NDIlib_recv_capture_v3, free frees frames so populated, and make_ref wraps one that capture_into reported as FRAME_TYPE.

Required Associated Constants§

Source

const FRAME_TYPE: c_uint

The frame-type discriminant NDIlib_recv_capture_v3 returns for this kind.

Required Associated Types§

Source

type Ref<'rx>

The borrowed, zero-copy view of a captured frame, tied to the receiver that produced it.

Source

type Owned

The owned, 'static frame produced by copying a borrowed view.

Required Methods§

Source

unsafe fn capture_into( instance: *mut NDIlib_recv_instance_type, frame: *mut Self::RawFrame, timeout_ms: u32, ) -> c_uint

Run a capture for this kind, routing frame into the matching NDIlib_recv_capture_v3 slot and ignoring the others.

§Safety
  • instance must be a valid NDI receiver instance.
  • frame must point to a writable RawFrame.
Source

unsafe fn make_ref<'rx>(guard: Guard<'rx, Self>) -> Result<Self::Ref<'rx>>

Wrap a freshly captured frame guard in its borrowed view, validating any kind-specific invariants (e.g. FourCC) during construction.

§Safety

guard must own a frame that capture_into reported as FRAME_TYPE.

Source

fn ref_to_owned(frame: &Self::Ref<'_>) -> Result<Self::Owned>

Copy a borrowed view into an owned, 'static frame.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl CaptureKind for AudioKind

Source§

const FRAME_TYPE: c_uint = NDIlib_frame_type_e_NDIlib_frame_type_audio

Source§

type Ref<'rx> = AudioRef<'rx, AudioKind>

Source§

type Owned = AudioFrame

Source§

impl CaptureKind for MetadataKind

Source§

const FRAME_TYPE: c_uint = NDIlib_frame_type_e_NDIlib_frame_type_metadata

Source§

type Ref<'rx> = MetadataFrameRef<'rx>

Source§

type Owned = MetadataFrame

Source§

impl CaptureKind for VideoKind

Source§

const FRAME_TYPE: c_uint = NDIlib_frame_type_e_NDIlib_frame_type_video

Source§

type Ref<'rx> = VideoRef<'rx, VideoKind>

Source§

type Owned = VideoFrame