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 returnnoneimmediately 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 withto_ownedwhen 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>
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 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 exceedcrate::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.
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. 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 exceedcrate::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.
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. 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 exceedcrate::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.