Skip to main content

ReceiverOptions

Struct ReceiverOptions 

Source
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

Source

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.

Source

pub fn clear_source(self) -> Self

Clear the initial source, preserving every other receiver setting.

Source

pub fn clear_name(self) -> Self

Let the SDK choose the receiver name again.

Source

pub fn clear_config(self) -> Self

Remove the per-instance Advanced configuration override.

Source

pub fn configured_source(&self) -> Option<&Source>

The optional initial source, independent of later live source changes.

Source

pub fn configured_color_format(&self) -> ReceiverColorFormat

The stored color choice. Packet passthrough presets may override this when creating a native receiver.

Source

pub fn configured_bandwidth(&self) -> ReceiverBandwidth

The requested bandwidth, before native creation.

Source

pub fn configured_allow_video_fields(&self) -> bool

Whether the requested configuration permits video fields.

Source

pub fn configured_name(&self) -> Option<&str>

The requested receiver name, or None to let the SDK choose one.

Source

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.

Source

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.

Source

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.

Source

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:

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)?;
}
Source

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:

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());
}
Source

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:

§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());
Source

pub fn color_format(self, color_format: ReceiverColorFormat) -> Self

Set the pixel formats the receiver delivers video in.

Source

pub fn bandwidth(self, bandwidth: ReceiverBandwidth) -> Self

Set which of the source’s streams the receiver takes, and at what quality.

Source

pub fn allow_video_fields(self, allow: bool) -> Self

Set whether interlaced video is delivered as individual fields rather than whole frames.

Source

pub fn name(self, name: impl Into<String>) -> Self

Set the receiver’s own name, which the SDK otherwise chooses.

Source

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.

Trait Implementations§

Source§

impl Clone for ReceiverOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReceiverOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ReceiverOptions

Source§

impl Hash for ReceiverOptions

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ReceiverOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ReceiverOptions

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.