pub struct Ndi { /* private fields */ }Expand description
A handle to the started NDI runtime.
Every finder, sender and receiver is created from an Ndi handle, and NDI
stays started while any handle exists: those objects each retain one, and
Clone::clone and Runtime::initialize add more. Dropping the last
handle stops NDI but leaves the selected library loaded, so NDI can be
started again. Ndi::process_lifetime keeps it started until the process
exits.
Ndi::new selects the default runtime and starts it in one call. To
inspect a runtime before starting it, or to choose which one is loaded, use
Runtime::select and then Runtime::initialize.
§Examples
use grafton_ndi::Ndi;
let ndi = Ndi::new()?;
// NDI stays started for as long as any handle exists.
let another = ndi.clone();
drop(ndi);
assert!(Ndi::is_running());
// Dropping the last handle stops it.
drop(another);Implementations§
Source§impl Ndi
impl Ndi
Sourcepub fn timestamp(&self) -> Result<SdkTimestamp>
pub fn timestamp(&self) -> Result<SdkTimestamp>
Read the selected SDK’s current timestamp, retaining its clock semantics.
Requires the NDI 6.4 timestamp helper. Missing capability is an error;
this never falls back to SystemTime or Instant.
Source§impl Ndi
impl Ndi
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Select the default NDI runtime and start it.
This is Runtime::select with the default RuntimeOptions
followed by Runtime::initialize. It is thread-safe: the first
handle starts NDI and later calls add handles to the running runtime.
See the search and trust policy
before selecting a runtime in a service or elevated process.
§Errors
Returns Error::RuntimeLoadFailed if no usable runtime library is
found in the search order.
Its crate::LoadFailure distinguishes code that loaded and was refused
from locations that could not be opened. Returns
Error::RuntimeConflict if native loading re-enters runtime selection
on the same thread. Returns Error::UnsupportedCpu if the runtime does not start because this
CPU cannot run it, and Error::InitializationFailed if it does not
start for another reason or the count of handles is exhausted.
§Examples
let ndi = Ndi::new()?;
// Use NDI operations...Sourcepub fn with_options(options: &RuntimeOptions) -> Result<Self>
pub fn with_options(options: &RuntimeOptions) -> Result<Self>
Select the NDI runtime options describe and start it.
This is Runtime::select followed by Runtime::initialize.
§Errors
Returns the errors of those two steps. A failed selection or start can
be retried; once selection has succeeded, every later call uses the
selected runtime and reports Error::RuntimeConflict for options it
does not meet, with a typed crate::SelectionConflict. A
crate::LoadFailure retains the structured attempts when loading fails.
§Examples
use grafton_ndi::{RuntimeOptions, SdkEdition, Ndi};
let ndi = Ndi::with_options(&RuntimeOptions::default().edition(SdkEdition::Advanced))?;Sourcepub fn runtime(&self) -> Runtime
pub fn runtime(&self) -> Runtime
The selected implementation this handle keeps started.
§Examples
let ndi = Ndi::new()?;
// A second handle from the same runtime, without selecting again.
let another = ndi.runtime().initialize()?;Sourcepub fn info(&self) -> &'static RuntimeInfo
pub fn info(&self) -> &'static RuntimeInfo
The selected implementation’s identity; see Runtime::info.
Sourcepub fn capabilities(&self) -> &'static Capabilities
pub fn capabilities(&self) -> &'static Capabilities
What the selected implementation supports; see Runtime::capabilities.
Sourcepub fn require_feature(&self, feature: RuntimeFeature) -> Result<()>
pub fn require_feature(&self, feature: RuntimeFeature) -> Result<()>
Reject an unavailable operation before passing newer inputs to the SDK.
§Errors
Returns Error::UnsupportedCapability naming the capability and why
the selected runtime or this build cannot provide it.
Sourcepub fn process_lifetime(&self) -> ProcessLifetimeRuntime
pub fn process_lifetime(&self) -> ProcessLifetimeRuntime
Retain an initialized runtime reference until process exit.
This is an irreversible, process-wide opt-in. It does not change ordinary reference-counted teardown unless this method is explicitly called.
Sourcepub fn is_running() -> bool
pub fn is_running() -> bool
Whether NDI is started, by this or any other handle in the process.
This only reads the current state: it never selects or loads a
runtime, and is false before one has been selected.
§Examples
if grafton_ndi::Ndi::is_running() {
println!("NDI runtime is active");
}Trait Implementations§
Source§impl Clone for Ndi
impl Clone for Ndi
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Acquires another reference to the active runtime.
§Panics
Panics if the runtime handle reference count is exhausted. The original handle and runtime remain valid.
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more