Skip to main content

Capture

Struct Capture 

Source
pub struct Capture<'rx, K: CaptureKind> { /* private fields */ }
Expand description

A typed view over a Receiver for capturing frames of one kind.

Created by Receiver::video, Receiver::audio, and Receiver::metadata. The view is a cheap borrow of the receiver and does nothing on its own — call one of its verbs to capture:

  • capture — reliable owned capture with built-in retry. The primary method. It absorbs the NDI SDK’s initial-sync warm-up (the first few polls after connecting may return none immediately instead of blocking). It can be used in a continuous capture loop.
  • try_capture — a single owned poll; Ok(None) when no frame is ready. For manual polling where you handle timing yourself.
  • try_capture_ref — a single zero-copy poll that borrows the SDK’s buffer in place (no allocation, no memcpy). The recommended API for performance-critical, in-place processing: for a 1920×1080 BGRA frame it avoids ~8.3 MB of copying per frame (~475 MB/s at 60 fps). Convert to an owned frame with to_owned when you need to keep or send it.

Media capture retains status notifications for Receiver::poll_status_change, even when retries later time out.

Every verb holds a shared capture guard for the duration of a single SDK call, so captures of different kinds run concurrently with each other but never overlap a Receiver::reconnect. Each timeout budget starts when the verb is called and includes waiting for that guard. A zero timeout never waits for the guard; if it is unavailable, no SDK capture is attempted. SDK calls and owned-frame copying may finish after the budget expires, so the timeout is not a strict wall-clock completion guarantee.

Only the ordinary receiver mode exposes a video view. FrameSync owns video capture until crate::FrameSync::into_receiver restores the ordinary mode.

Implementations§

Source§

impl<'rx, K: CaptureKind> Capture<'rx, K>

Source

pub fn capture(&self, timeout: Duration) -> Result<K::Owned>

Reliable owned capture: blocks up to timeout, retrying across the NDI SDK’s initial-sync warm-up.

timeout is a total retry budget; each individual SDK poll is capped to the remaining budget, and Duration::ZERO performs one non-blocking attempt, skipping the SDK call if the capture guard is unavailable. Waiting for a reconnect lock consumes the same budget. The SDK itself may return after its requested timeout, so this budget is not a strict wall-clock completion guarantee.

§Arguments
  • timeout - Total time to wait for a frame. Must not exceed crate::MAX_TIMEOUT (~49.7 days).
§Errors

Returns Error::FrameTimeout if no frame arrives within timeout; returns Error::InvalidConfiguration for an excessive timeout. SDK and frame-validation errors propagate from the capture itself.

Source

pub fn try_capture(&self, timeout: Duration) -> Result<Option<K::Owned>>

Single owned poll: returns Ok(None) if no frame is available within timeout.

Prefer capture for reliable capture; this variant does not retry the SDK’s warm-up misses. The timeout includes waiting for a reconnect lock; see Capture for the shared timeout contract.

§Arguments
  • timeout - Maximum time to wait for a frame. Must not exceed crate::MAX_TIMEOUT (~49.7 days).
§Errors

Returns Error::InvalidConfiguration for an excessive timeout. SDK connection errors return Error::CaptureFailed; malformed frame descriptors also return errors.

Source

pub fn try_capture_ref(&self, timeout: Duration) -> Result<Option<K::Ref<'rx>>>

Single zero-copy poll: returns a borrowed view of the SDK’s buffer, or Ok(None) if no frame is available within timeout.

The returned reference borrows the Receiver (not this temporary view), so it may outlive the Capture while keeping the receiver borrowed. The timeout includes waiting for a reconnect lock; see Capture for the shared timeout contract.

§Arguments
  • timeout - Maximum time to wait for a frame. Must not exceed crate::MAX_TIMEOUT (~49.7 days).
§Errors

Returns Error::InvalidConfiguration for an excessive timeout. SDK connection errors return Error::CaptureFailed; malformed frame descriptors also return errors.

Auto Trait Implementations§

§

impl<'rx, K> !RefUnwindSafe for Capture<'rx, K>

§

impl<'rx, K> !UnwindSafe for Capture<'rx, K>

§

impl<'rx, K> Freeze for Capture<'rx, K>

§

impl<'rx, K> Send for Capture<'rx, K>
where K: Send,

§

impl<'rx, K> Sync for Capture<'rx, K>
where K: Sync,

§

impl<'rx, K> Unpin for Capture<'rx, K>
where K: Unpin,

§

impl<'rx, K> UnsafeUnpin for Capture<'rx, K>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.