grafton_ndi/advanced/mod.rs
1//! NDI Advanced SDK operations.
2//!
3//! * Per-instance JSON configuration through the `config` setter of
4//! supported options. See [`AdvancedConfig`] for the configurable objects.
5//! * Compressed passthrough: receiving codec packets ([`PacketReceiver`]) and
6//! sending them ([`CompressedSender`]), including scatter-gather submission.
7//! * Encoder guidance, keyframe demand and stream selection on the ordinary
8//! [`Sender`](crate::Sender) and [`Receiver`](crate::Receiver).
9//! * Audio matched to video timestamps ([`AvSync`]) and reference-locked
10//! clocks ([`Genlock`]).
11//! * Remote keyboard, mouse and touch control ([`KvmSession`]).
12//! * Application-supplied memory for received frames ([`AllocatorService`]).
13//! * Asynchronous sending with completion notification ([`QueuedSender`]).
14//!
15//! # Requirements
16//!
17//! The Advanced SDK headers may not be redistributed, so this module needs
18//! three things, in this order:
19//!
20//! 1. the `advanced` Cargo feature;
21//! 2. an installed NDI Advanced SDK when the crate is built (`NDI_SDK_DIR`, or
22//! a default installation directory), from which the native declarations
23//! are generated on the build machine;
24//! 3. an Advanced SDK runtime selected when the program runs.
25//!
26//! The API is identical whether or not the build found the Advanced SDK.
27//! Without it, and against a Standard runtime, every native operation returns
28//! [`Error::UnsupportedCapability`](crate::Error::UnsupportedCapability) with
29//! the reason; the data types in this module (packets, envelopes, options)
30//! work everywhere. Core operations are unaffected in every case.
31//! An older installed Advanced SDK disables only the declaration families or
32//! receive presets it lacks. The remaining operations keep their native ABI
33//! checks and still require the matching runtime exports.
34//!
35//! Enabling this module neither selects an SDK edition nor grants a license
36//! entitlement.
37//!
38//! # Ownership
39//!
40//! An operation that takes ownership of a receiver, a sender or a frame hands
41//! it back inside [`Rejected`](crate::Rejected) when it fails.
42
43#![warn(missing_docs)]
44// An operation that fails hands its input back inside the error, so these
45// errors are as large as the frames and objects they return. Boxing them
46// would add an allocation to the very paths (back-pressure, validation) that
47// exist so that nothing is lost.
48#![allow(clippy::result_large_err)]
49
50mod aliasable;
51mod allocators;
52mod config;
53mod configured;
54mod controls;
55mod descriptors;
56mod finder;
57mod kvm;
58#[cfg(ndi_has_advanced_kvm)]
59pub(crate) use kvm::TouchPoints;
60mod kvm_receiver;
61mod packets;
62mod queued;
63mod receive;
64mod reserved_map;
65mod routing;
66mod send;
67mod send_slots;
68mod sync;
69
70/// Receiver mode held by [`PacketReceiver`], [`AllocatedReceiver<PacketAttached>`]
71/// and their [`KvmReceiver`] views. Packet capture reserves video, audio, metadata
72/// and event capture for the packet owner and its KVM view.
73#[derive(Debug)]
74pub enum PacketAttached {}
75
76/// Receiver mode held by [`AvSync`], which reserves audio for synchronization.
77/// Video, metadata and common controls remain available through its receiver.
78/// Query capabilities, [`crate::Receiver::wait_for_source_name_change`] and
79/// connection statistics because synchronization may consume notifications.
80#[derive(Debug)]
81pub enum AvSyncAttached {}
82
83/// Sender mode held exclusively by [`CompressedSender`].
84/// Video submission belongs to the wrapper; audio goes through its sender.
85#[derive(Debug)]
86pub enum CompressedAttached {}
87
88/// Sender mode held exclusively by [`QueuedSender`].
89/// It submits video and sends both uncompressed and compressed audio.
90#[derive(Debug)]
91pub enum QueueAttached {}
92
93/// Sealed sender modes that send compressed audio: compressed and queued.
94/// Their constructors require an Advanced runtime.
95pub trait CompressedAudioSendMode: crate::sender::SenderMode {}
96pub use crate::framesync::capture::FrameSyncCapture;
97pub use allocators::*;
98pub use config::AdvancedConfig;
99pub(crate) use config::RetainedConfig;
100pub(crate) use configured::Configurable;
101pub use controls::*;
102pub use finder::ExtendedSource;
103pub use kvm::*;
104pub use kvm_receiver::KvmReceiver;
105pub use packets::*;
106pub(crate) use queued::QueueLoans;
107pub use queued::*;
108pub use receive::*;
109#[cfg(ndi_has_advanced_scatter_send)]
110pub(crate) use send::ScatterVideoLoan;
111pub use send::*;
112pub(crate) use send::{PendingStreams, PendingVideo, ScatterSendable};
113pub use sync::*;
114
115/// [`Error::InvalidFrame`](crate::Error::InvalidFrame) with its typed `cause`: a frame
116/// or packet that is malformed, or that cannot be built or sent.
117fn invalid_frame(cause: crate::FrameDefect) -> crate::Error {
118 crate::Error::InvalidFrame(cause)
119}
120
121/// [`Error::InvalidInput`](crate::Error::InvalidInput) with its typed `cause`: a value
122/// this module was given that it cannot use, whatever frame it is for.
123fn invalid_input(cause: crate::InputDefect) -> crate::Error {
124 crate::Error::InvalidInput(cause)
125}