pub struct AsyncFilePlayer { /* private fields */ }Expand description
A FilePlayer on a thread of its own, driven through futures.
Clones share one player.
§Dropping blocks
This applies after creation returns the handle. Dropping its creation operation before receiving the handle requests cleanup without waiting.
Dropping the last clone stops playback, removes the advertised source and
then blocks the dropping thread until the player’s thread has
destroyed the player, for as long as the SDK takes. When the drop
returns, the source is gone. A caller that must not block, such as a task
on an async executor, awaits close instead, which does the
same without blocking; dropping the clones afterwards does not block.
While a submitted close still has a live future, last-clone drop does not
wait because that future reports completion. Dropping the future makes the
last-clone drop wait for cleanup again.
A last-clone drop performed by an executor callback on a File owner, timer
or probe thread requests shutdown without waiting, so those threads can
keep delivering notifications. Await close to observe cleanup completing.
Implementations§
Source§impl AsyncFilePlayer
impl AsyncFilePlayer
Sourcepub fn create(api: &FileApi, options: &FilePlayerOptions) -> FileOperation<Self> ⓘ
pub fn create(api: &FileApi, options: &FilePlayerOptions) -> FileOperation<Self> ⓘ
Create a player and advertise its source, with the default queue sizes.
The future fails as FilePlayer::new does. The options are
only read, so they stay with the caller whatever the outcome.
Options and the required File family are checked at submission, before
an owner thread starts. Native creation runs on that thread.
§Errors
Those of FilePlayer::new, and Error::Io when the owner thread
cannot be started.
Sourcepub fn create_with_options(
api: &FileApi,
options: &FilePlayerOptions,
asynchronous: &AsyncFileOptions,
) -> FileOperation<Self> ⓘ
pub fn create_with_options( api: &FileApi, options: &FilePlayerOptions, asynchronous: &AsyncFileOptions, ) -> FileOperation<Self> ⓘ
Create a player and advertise its source, with the given queue sizes.
The future fails as create does, and with
Error::InvalidInput when a queue size is out of range.
Queue sizes, options and the required File family are checked at
submission, before an owner thread starts.
Sourcepub fn probe(api: &FileApi, path: impl AsRef<Path>) -> FileOperation<FileInfo> ⓘ
pub fn probe(api: &FileApi, path: impl AsRef<Path>) -> FileOperation<FileInfo> ⓘ
Read a recording’s duration and track layout; see FilePlayer::probe.
No player is created and nothing is advertised.
Probes run one at a time, in submission order, on one thread that every async probe in the process shares; it starts with the first probe. At most 64 wait for it. Dropping the future before its probe has begun cancels the probe.
§Errors
Those of FilePlayer::probe, and Error::QueueFull with
QueueLimit::FileProbes when 64 probes are already waiting; the same
call can succeed once they have run. Error::Io when the probe
thread is not running and cannot be started; the next probe tries to
start it again. Error::InvalidState with StateConflict::OwnerFailed
when the probe panicked; the thread goes on with the next one.
Sourcepub fn start(&self, path: impl AsRef<Path>) -> FileOperation<()> ⓘ
pub fn start(&self, path: impl AsRef<Path>) -> FileOperation<()> ⓘ
Play a file; see FilePlayer::start.
Sourcepub fn stop(&self) -> FileOperation<()> ⓘ
pub fn stop(&self) -> FileOperation<()> ⓘ
Stop the current file; the source stays advertised. The stop runs even if the future is dropped after its first poll or explicit submission.
Sourcepub fn is_running(&self) -> FileOperation<bool> ⓘ
pub fn is_running(&self) -> FileOperation<bool> ⓘ
Whether a file is playing.
Sourcepub fn next_event(&self, timeout: Duration) -> FileEventFuture<PlayerEvent> ⓘ
pub fn next_event(&self, timeout: Duration) -> FileEventFuture<PlayerEvent> ⓘ
Wait up to timeout for the player’s next event.
Sourcepub fn dropped_event_count(&self) -> FileOperation<u64> ⓘ
pub fn dropped_event_count(&self) -> FileOperation<u64> ⓘ
How many events the SDK discarded before the player’s thread took them.
Sourcepub fn notification_dropped_count(&self) -> u64
pub fn notification_dropped_count(&self) -> u64
How many events this handle’s own queue discarded because
next_event did not keep up.
Sourcepub fn stats(&self) -> FileOperation<Option<PlayerStats>> ⓘ
pub fn stats(&self) -> FileOperation<Option<PlayerStats>> ⓘ
Counters for the current or most recent file.
Sourcepub fn seek(&self, position: FilePosition) -> FileOperation<()> ⓘ
pub fn seek(&self, position: FilePosition) -> FileOperation<()> ⓘ
Seek to a position on the file’s timeline; see FilePlayer::seek.
Sourcepub fn seek_frame_approximate(&self, frame: u64) -> FileOperation<()> ⓘ
pub fn seek_frame_approximate(&self, frame: u64) -> FileOperation<()> ⓘ
Seek to an approximate frame index; see
FilePlayer::seek_frame_approximate.
Sourcepub fn set_paused(&self, paused: bool) -> FileOperation<()> ⓘ
pub fn set_paused(&self, paused: bool) -> FileOperation<()> ⓘ
Pause or resume the current file.
Sourcepub fn is_paused(&self) -> FileOperation<bool> ⓘ
pub fn is_paused(&self) -> FileOperation<bool> ⓘ
Whether the current file is paused.
Sourcepub fn set_looping(&self, looping: bool) -> FileOperation<()> ⓘ
pub fn set_looping(&self, looping: bool) -> FileOperation<()> ⓘ
Set whether playback restarts at the end of a file. The setting is kept across files.
Sourcepub fn is_looping(&self) -> FileOperation<bool> ⓘ
pub fn is_looping(&self) -> FileOperation<bool> ⓘ
Whether playback restarts at the end of a file.
Sourcepub fn duration(&self) -> FileOperation<Option<FileDuration>> ⓘ
pub fn duration(&self) -> FileOperation<Option<FileDuration>> ⓘ
The current file’s best-known duration, and whether it is final.
Sourcepub fn position(&self) -> FileOperation<Option<FilePosition>> ⓘ
pub fn position(&self) -> FileOperation<Option<FilePosition>> ⓘ
The position of the frame sent last.
Sourcepub fn source_timecode(&self) -> FileOperation<Option<Timecode>> ⓘ
pub fn source_timecode(&self) -> FileOperation<Option<Timecode>> ⓘ
The recorded source timecode of the frame sent last.
Sourcepub fn source_format(&self) -> FileOperation<Option<SourceFormat>> ⓘ
pub fn source_format(&self) -> FileOperation<Option<SourceFormat>> ⓘ
The track layout of the current file.
Sourcepub fn advertised_source(&self) -> FileOperation<Source> ⓘ
pub fn advertised_source(&self) -> FileOperation<Source> ⓘ
The NDI source this player advertises. See
FilePlayer::advertised_source for descriptor read errors.
Sourcepub fn close(&self) -> FileOperation<()> ⓘ
pub fn close(&self) -> FileOperation<()> ⓘ
Stop playback, remove the advertised source and end the player’s thread, for every clone of this handle.
The future completes when the SDK has destroyed the player. Nothing
blocks the calling thread. Once submitted by polling or calling
FileOperation::submit, the close runs even if its future is dropped.
Closing again, from this or another clone, while or after it runs
completes at the same time, with the same outcome; later
operations fail with StateConflict::Closed, and dropping the clones
afterwards does not block. It does not wait in the command queue, so
a full queue never refuses it.
§Errors
Error::InvalidState with StateConflict::OwnerFailed when the
object’s thread failed.