pub struct VideoSwitch { /* private fields */ }Expand description
The handle that swaps the input of a VideoSource::switchable source.
Each call supersedes the one before: replace and
clear take effect at once, and open
cancels an open still running. The previous source is dropped before the
next one opens, so the same camera can open again. replace
and open also drop the previous source’s last frame, so no
reader gets a frame of the old source once they return. After
clear or the end of its source, the switchable source
keeps its last frame. It ends when every switch is dropped. Cheap to clone.
Implementations§
Source§impl VideoSwitch
impl VideoSwitch
Sourcepub fn replace(&self, source: VideoSource)
pub fn replace(&self, source: VideoSource)
Sourcepub fn open<F>(&self, open: F)
pub fn open<F>(&self, open: F)
Opens a source with open in the background and feeds the switchable source from it.
The current source is dropped first, so open can open the same
device again. The status reads Starting while
open runs, then Running, or
Failed with its error. A later call to any
method drops open unfinished, which for
VideoSource::capture releases the device.
§Panics
Panics when called outside a Tokio runtime.
Sourcepub fn open_spec(&self, spec: VideoSourceSpec, options: VideoOpenOptions)
pub fn open_spec(&self, spec: VideoSourceSpec, options: VideoOpenOptions)
Opens spec with options behind the switch, or clears it for VideoSourceSpec::None.
The open runs in the background as with open, so a
source picker hands its choice over in one call.
§Panics
Panics when called outside a Tokio runtime.