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 returnnoneimmediately instead of blocking), then runs with zero overhead in steady state, so it is safe 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 withto_ownedwhen you need to keep or send it.
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.
Implementations§
Source§impl<'rx, K: CaptureKind> Capture<'rx, K>
impl<'rx, K: CaptureKind> Capture<'rx, K>
Sourcepub fn capture(&self, timeout: Duration) -> Result<K::Owned>
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 exactly one
non-blocking attempt.
§Arguments
timeout- Total time to wait for a frame. Must not exceedcrate::MAX_TIMEOUT(~49.7 days).
§Errors
Returns Error::FrameTimeout if no frame arrives within timeout;
other errors propagate from the capture itself.
Sourcepub fn try_capture(&self, timeout: Duration) -> Result<Option<K::Owned>>
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.
§Arguments
timeout- Maximum time to wait for a frame. Must not exceedcrate::MAX_TIMEOUT(~49.7 days).
Sourcepub fn try_capture_ref(&self, timeout: Duration) -> Result<Option<K::Ref<'rx>>>
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.
§Arguments
timeout- Maximum time to wait for a frame. Must not exceedcrate::MAX_TIMEOUT(~49.7 days).