Skip to main content

Crate grafton_ndi

Crate grafton_ndi 

Source
Expand description

Discover NDI sources and send and receive video, audio and metadata.

Supports NDI 6 with optional async adapters, image encoding, Advanced SDK operations, and recording/playback. Default desktop and Android builds need no SDK at build time. Advanced native operations need Advanced headers and libclang; Apple mobile targets link an SDK archive.

§Quick Start

use grafton_ndi::{Ndi, FinderOptions, Finder};
use std::time::Duration;

// Select the default NDI runtime and start it
let ndi = Ndi::new()?;

// Find sources on the network
let finder = Finder::new(&ndi, &FinderOptions::new())?;

// Discover sources
let sources = finder.find_sources(Duration::from_secs(5))?;

for source in sources {
    println!("Found: {}", source);
}

§Choose a workflow

Cargo features enable asynchronous (tokio or smol), advanced, file (file-io), and image encoders (image-encoding). None is on by default.

See the user guides for setup, platform support, examples, limitations and migration instructions.

Re-exports§

pub use capabilities::Capabilities;
pub use capabilities::Capability;
pub use capabilities::CapabilityRefusal;
pub use capabilities::CapabilityStatus;
pub use capabilities::CapabilityUnavailable;
pub use capabilities::RuntimeFeature;
pub use capabilities::RuntimeInfo;
pub use capabilities::SdkEdition;
pub use capabilities::SdkLinkage;
pub use capabilities::SdkVersion;
pub use finder::Finder;
pub use finder::FinderOptions;
pub use finder::Source;
pub use finder::SourceAddress;
pub use finder::SourceCache;
pub use finder::SourceWatch;
pub use frames::AudioChannels;
pub use frames::AudioFormat;
pub use frames::AudioFrame;
pub use frames::AudioFrameBuilder;
pub use frames::AudioFrameRef;
pub use frames::AudioSource;
pub use frames::BorrowedAudioFrame;
pub use frames::BorrowedAudioFrameBuilder;
pub use frames::BorrowedVideoFrame;
pub use frames::BorrowedVideoFrameBuilder;
pub use frames::FormatCategory;
pub use frames::FrameMetadataStatus;
pub use frames::MetadataFrame;
pub use frames::MetadataFrameRef;
pub use frames::MetadataSource;
pub use frames::PixelFormat;
pub use frames::PixelFormatInfo;
pub use frames::ScanType;
pub use frames::VideoFrame;
pub use frames::VideoFrameBuilder;
pub use frames::VideoFrameRef;
pub use frames::VideoPlane;
pub use frames::VideoPlanes;
pub use frames::VideoRows;
pub use frames::VideoSource;
pub use framesync::AudioInputFormat;
pub use framesync::FrameSync;
pub use framesync::FrameSyncAudioRef;
pub use framesync::FrameSyncAudioRequest;
pub use framesync::FrameSyncVideoRef;
pub use receiver::AudioMode;
pub use receiver::ConnectionStats;
pub use receiver::EventMode;
pub use receiver::FrameSyncAttached;
pub use receiver::MetadataMode;
pub use receiver::Ptz;
pub use receiver::RawCapture;
pub use receiver::ReceiveDelay;
pub use receiver::Receiver;
pub use receiver::ReceiverBandwidth;
pub use receiver::ReceiverColorFormat;
pub use receiver::ReceiverEvent;
pub use receiver::ReceiverItem;
pub use receiver::ReceiverItemRef;
pub use receiver::ReceiverMode;
pub use receiver::ReceiverOptions;
pub use receiver::ReceiverStatus;
pub use receiver::SettingChange;
pub use receiver::SourceNameChange;
pub use receiver::Tally;
pub use receiver::VideoMode;
pub use runtime::Ndi;
pub use runtime::ProcessLifetimeRuntime;
pub use runtime::Runtime;
pub use runtime::RuntimeOptions;
pub use sender::AudioSendMode;
pub use sender::RawSend;
pub use sender::RawVideo;
pub use sender::Sender;
pub use sender::SenderMode;
pub use sender::SenderOptions;
pub use error::*;

Modules§

advanced
NDI Advanced SDK operations.
asynchronous
Async discovery and receivers for Tokio and smol.
audio_conversion
Checked interleaved audio inputs and native FLTP conversion helpers.
capabilities
Facts about the selected native SDK, separate from hardware and license availability.
discovery_server
Discovery Server monitoring and explicitly enabled remote control.
file
Recording NDI sources to disk and playing recordings back, through the NDI File library.
finder
NDI source discovery and network browsing.
frames
Frame types for video, audio, and metadata.
framesync
Frame synchronization for clock-corrected video/audio capture.
image_encoding
Still images from video frames: the image-encoding feature.
receiver
NDI receiving functionality for video, audio, and metadata.
routing
Redirect source selection without receiving or forwarding media in Rust.
runtime
Select an NDI implementation and manage its initialization lifetime.
sender
NDI sending functionality for video, audio, and metadata.
video_conversion
Checked native conversion between complete V210 groups and NDI P216.

Structs§

AllocationFailure
An allocation failed after the operation passed its validation and budgets.
AudioLengthDefect
Exact values reported by AudioDataLength.
ColorInfo
The color description a video frame carries in its ndi_color_info metadata.
CompactDiagnostic
Exact diagnostic evidence, inline on 64-bit targets and boxed on 32-bit targets.
DiagnosticDuration
Exact timeout evidence, stored in three 32-bit words without allocation.
DiagnosticInteger
An exact signed 64-bit diagnostic value with 32-bit alignment.
DiagnosticSize
An exact unsigned byte count with 32-bit alignment.
DiscoveryAddressFailure
The rejected native Discovery Server address, retained only for diagnostics.
FourCc
A four-character code: the SDK’s identifier for a pixel or audio format or codec.
FrameRate
A frame rate in frames per second, as the fraction numerator / denominator.
FrameRateDefect
Exact values reported by FrameRate.
LoadAttempt
One refused native library location, in the order it was tried.
LoadFailure
A failed search, with a typed cause for every attempted location.
MediaTypes
A set of media types: any combination of VIDEO, AUDIO and METADATA.
NativeFunction
The native SDK entry point that produced a result.
PictureAspectRatio
The displayed picture’s width divided by its height.
PtzDefect
Exact values reported by PtzValue.
ReceivedTimestamp
A received media timestamp in signed 100-nanosecond ticks.
Rejected
A failed operation that hands back the value it would have consumed.
SdkTimestamp
A reading of the SDK’s clock, in 100-nanosecond ticks since the Unix epoch.
SelectionFailure
A selection conflict, with the library identities needed to act on it.
Timecode
The editorial timecode a frame carries, in 100-nanosecond ticks.
VideoDimensionsDefect
Exact values reported by CompressedVideoDimensions.

Enums§

AllocationKind
The storage an operation could not allocate.
AudioCountKind
The audio count that failed validation.
ColorMetadataDefect
The syntactic defect in an ndi_color_info element.
ColorPrimaries
The color primaries of a ColorInfo.
DiscoveryDefect
The malformed native discovery data.
Error
Every error this crate reports, from the core API, the advanced module and the File API alike.
FrameDefect
Typed causes of crate::Error::InvalidFrame.
ImageAxisKind
The image axis that exceeded an encoder limit.
ImageCodecKind
The image encoder that refused output.
ImageSettingKind
A numerical codec setting checked by the image encoder.
InitializationFailure
Why the selected native runtime could not initialize.
InputDefect
Typed causes of crate::Error::InvalidInput.
LayoutDefect
A refusal of the shared media layout and value checks.
LibraryKind
Which native library a failed selection sought.
LoadOrigin
Why a native library location was considered.
LoadRefusal
Why a candidate could not provide a usable implementation.
QueueLimit
Which bounded queue was full, carried by Error::QueueFull.
ResourceKind
The resource budget exhausted by a discovery operation.
SdkResultDefect
Typed causes of crate::Error::UnexpectedSdkResult.
SelectionConflict
Why an irreversible runtime or File selection cannot meet a request.
SpawnFailure
Why an async blocking operation could not run.
StreamTier
Which of a source’s two video streams: the full-quality program stream or the low-bandwidth preview stream.
TransferFunction
The transfer function of a ColorInfo.
VersionTextDefect
Why a runtime’s version text could not be read.
YuvMatrix
The matrix that relates YCbCr to RGB, in a ColorInfo and in image encoding’s color policy.

Constants§

MAX_TIMEOUT
The largest finite timeout: u32::MAX - 1 milliseconds (~49.7 days).

Type Aliases§

Result
Alias for Result with our Error type