pub struct ReceiverOptions { /* private fields */ }Expand description
Configuration for creating a Receiver, including an optional initial
source and how the receiver delivers media.
new and disconnected start from the
defaults. The presets start from settings suited to one use. Every setter
replaces one setting.
§Examples
// In real usage, obtain the source from Finder::find_sources().
let options = ReceiverOptions::new(source)
.color_format(ReceiverColorFormat::UyvyBgra)
.bandwidth(ReceiverBandwidth::Lowest)
.name("Multiviewer");
let receiver = Receiver::new(&ndi, &options)?;Implementations§
Source§impl ReceiverOptions
impl ReceiverOptions
Sourcepub fn source(self, source: Source) -> Self
pub fn source(self, source: Source) -> Self
Replace the source, preserving every other receiver setting. An empty name and an absent or empty address clear the source.
Sourcepub fn clear_source(self) -> Self
pub fn clear_source(self) -> Self
Clear the initial source, preserving every other receiver setting.
Sourcepub fn clear_name(self) -> Self
pub fn clear_name(self) -> Self
Let the SDK choose the receiver name again.
Sourcepub fn clear_config(self) -> Self
pub fn clear_config(self) -> Self
Remove the per-instance Advanced configuration override.
Sourcepub fn configured_source(&self) -> Option<&Source>
pub fn configured_source(&self) -> Option<&Source>
The optional initial source, independent of later live source changes.
Sourcepub fn configured_color_format(&self) -> ReceiverColorFormat
pub fn configured_color_format(&self) -> ReceiverColorFormat
The stored color choice. Packet passthrough presets may override this when creating a native receiver.
Sourcepub fn configured_bandwidth(&self) -> ReceiverBandwidth
pub fn configured_bandwidth(&self) -> ReceiverBandwidth
The requested bandwidth, before native creation.
Sourcepub fn configured_allow_video_fields(&self) -> bool
pub fn configured_allow_video_fields(&self) -> bool
Whether the requested configuration permits video fields.
Sourcepub fn configured_name(&self) -> Option<&str>
pub fn configured_name(&self) -> Option<&str>
The requested receiver name, or None to let the SDK choose one.
Sourcepub fn configured_config(&self) -> Option<&AdvancedConfig>
pub fn configured_config(&self) -> Option<&AdvancedConfig>
The stored Advanced configuration, when explicitly set. Reading it does not expose its JSON or test native support.
Sourcepub fn new(source: Source) -> Self
pub fn new(source: Source) -> Self
Receive from source with the settings of Self::disconnected.
An empty name and an absent or empty address leave the receiver
disconnected. An address alone can identify a source.
Sourcepub fn disconnected() -> Self
pub fn disconnected() -> Self
Start without a source, using ReceiverColorFormat::BgrxBgra,
ReceiverBandwidth::Highest, video fields allowed, and a receiver
name the SDK chooses. Use
Receiver::connect_to after selecting a source.
Sourcepub fn snapshot_preset(source: Source) -> Self
pub fn snapshot_preset(source: Source) -> Self
Settings for capturing snapshots: RGB color, low bandwidth, whole frames.
Suited to image export, thumbnails and analysis pipelines, and to networks with little bandwidth to spare:
- color format
ReceiverColorFormat::RgbxRgba, convenient for encoding untagged sources directly; - bandwidth
ReceiverBandwidth::Lowest, the source’s preview stream; - video fields not allowed, so interlaced video arrives as whole frames.
The SDK converts YUV to RGB with BT.709 limited range even when
ndi_color_info names another matrix. This preset’s RGB frames already
carry that conversion. See the
image encoding color guidance
for receiving YUV when the tag’s matrix matters, including alpha and
high bit depth sources. Tags still control HDR refusal and PNG tagging.
§Example
let options = ReceiverOptions::snapshot_preset(source).name("Snapshot Receiver");
let receiver = Receiver::new(&ndi, &options)?;
// Capture and encode in one line (requires image-encoding feature)
#[cfg(feature = "image-encoding")]
if let Some(frame) = receiver.capture_video(Duration::from_secs(5))? {
let png_bytes = frame.encode_image(&grafton_ndi::image_encoding::ImageOptions::new(
grafton_ndi::image_encoding::ImageFormat::Png,
))?;
std::fs::write("snapshot.png", &png_bytes)?;
}Sourcepub fn high_quality_preset(source: Source) -> Self
pub fn high_quality_preset(source: Source) -> Self
Settings for full-quality video processing: RGB color, full bandwidth, interlaced video as fields.
Suited to recording, broadcast and analysis that needs every pixel:
- color format
ReceiverColorFormat::RgbxRgba; - bandwidth
ReceiverBandwidth::Highest, the source’s program stream; - video fields allowed, so interlaced video keeps its fields.
RGB is convenient for untagged sources. For tagged YUV, the SDK has
already converted to BT.709 limited range, ignoring ndi_color_info;
image encoding cannot apply the tagged matrix to these RGB frames.
See the
image encoding color guidance
for receiving YUV when the tag’s matrix matters, including alpha and
high bit depth sources. Tags still control HDR refusal and PNG tagging.
§Example
let options =
ReceiverOptions::high_quality_preset(source).name("High Quality Receiver");
let receiver = Receiver::new(&ndi, &options)?;
// Capture full quality frames
if let Some(frame) = receiver.capture_video(Duration::from_secs(5))? {
println!("Captured {width}x{height} frame", width = frame.width(), height = frame.height());
}Sourcepub fn monitoring_preset(source: Source) -> Self
pub fn monitoring_preset(source: Source) -> Self
Settings for monitoring a connection and controlling the source, without its video or audio.
Suited to polling connection state with Receiver::is_connected or
Receiver::connection_stats, tally and PTZ control. Connection loss
need not produce a ReceiverEvent::StatusChanged event.
Uses these settings:
- bandwidth
ReceiverBandwidth::MetadataOnly; - the default color format, which no frame uses;
- video fields not allowed.
§Example
let options = ReceiverOptions::monitoring_preset(source).name("Status Monitor");
let receiver = Receiver::new(&ndi, &options)?;
println!("Connected: {}", receiver.is_connected());
println!("Active connections: {}", receiver.connection_stats()?.connections());Sourcepub fn color_format(self, color_format: ReceiverColorFormat) -> Self
pub fn color_format(self, color_format: ReceiverColorFormat) -> Self
Set the pixel formats the receiver delivers video in.
Sourcepub fn bandwidth(self, bandwidth: ReceiverBandwidth) -> Self
pub fn bandwidth(self, bandwidth: ReceiverBandwidth) -> Self
Set which of the source’s streams the receiver takes, and at what quality.
Sourcepub fn allow_video_fields(self, allow: bool) -> Self
pub fn allow_video_fields(self, allow: bool) -> Self
Set whether interlaced video is delivered as individual fields rather than whole frames.
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Set the receiver’s own name, which the SDK otherwise chooses.
Sourcepub fn config(self, config: AdvancedConfig) -> Self
pub fn config(self, config: AdvancedConfig) -> Self
Create the receiver with this per-instance Advanced SDK configuration, which it keeps for as long as it lives.
Receiver::new then needs an Advanced runtime, and a build with the
Advanced SDK.