pub struct Genlock { /* private fields */ }Expand description
Clocks locked to the timing of a reference NDI source.
A genlock paces a sender so that its frames leave in step with another
source instead of the local clock: take the two clocks with
clocks, wait on the matching one before submitting each
frame, and create the sender with its own clocking disabled. While no
reference signal arrives, the waits fall back to the system clock and say
so.
The waits block their thread and cannot be cancelled or given a deadline.
A completed paced wait does not prove live reference media; inspect the
returned ClockSource for reference versus system-clock fallback.
§Threading
A genlock is Send but not Sync: it can be created on one thread
and connected, waited on and dropped on others. Each of its two clocks
can be moved to a thread of its own while they borrow it, because the SDK
lets the video and the audio wait run on separate threads at once. The
SDK gives no such assurance for is_active, so a
shared reference to the genlock stays on one thread.
§Examples
use grafton_ndi::{advanced::{Genlock, GenlockOptions}, FrameRate, Ndi, ScanType, Source};
let ndi = Ndi::new()?;
let mut genlock = Genlock::new(&ndi, &GenlockOptions::new().source(reference))?;
let (mut video, _audio) = genlock.clocks();
let paced_by = video.wait(FrameRate::new(60_000, 1001)?, ScanType::Progressive);
println!("frame paced by {paced_by:?}");Implementations§
Source§impl Genlock
impl Genlock
Sourcepub fn new(ndi: &Ndi, options: &GenlockOptions) -> Result<Self>
pub fn new(ndi: &Ndi, options: &GenlockOptions) -> Result<Self>
Create a genlock with a reference source and native configuration from
options. With no source it follows the system clock until
connect_to names one.
§Errors
Error::UnsupportedCapability without an Advanced runtime or the
corresponding Advanced SDK declarations, and
Error::NativeOperationFailed when the SDK creates no genlock.
Sourcepub fn connect_to(&mut self, source: &Source)
pub fn connect_to(&mut self, source: &Source)
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Stop following a reference source and use the system clock.
Sourcepub fn clocks(&mut self) -> (VideoClock<'_>, AudioClock<'_>)
pub fn clocks(&mut self) -> (VideoClock<'_>, AudioClock<'_>)
The video clock and the audio clock.
Each can be moved to its own thread; both borrow the genlock, so it can be neither reconnected nor dropped while they exist.