Skip to main content

AsyncFilePlayer

Struct AsyncFilePlayer 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn start(&self, path: impl AsRef<Path>) -> FileOperation<()> ⓘ

Play a file; see FilePlayer::start.

Source

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.

Source

pub fn is_running(&self) -> FileOperation<bool> ⓘ

Whether a file is playing.

Source

pub fn next_event(&self, timeout: Duration) -> FileEventFuture<PlayerEvent> ⓘ

Wait up to timeout for the player’s next event.

Source

pub fn dropped_event_count(&self) -> FileOperation<u64> ⓘ

How many events the SDK discarded before the player’s thread took them.

Source

pub fn notification_dropped_count(&self) -> u64

How many events this handle’s own queue discarded because next_event did not keep up.

Source

pub fn stats(&self) -> FileOperation<Option<PlayerStats>> ⓘ

Counters for the current or most recent file.

Source

pub fn seek(&self, position: FilePosition) -> FileOperation<()> ⓘ

Seek to a position on the file’s timeline; see FilePlayer::seek.

Source

pub fn seek_frame_approximate(&self, frame: u64) -> FileOperation<()> ⓘ

Seek to an approximate frame index; see FilePlayer::seek_frame_approximate.

Source

pub fn set_paused(&self, paused: bool) -> FileOperation<()> ⓘ

Pause or resume the current file.

Source

pub fn is_paused(&self) -> FileOperation<bool> ⓘ

Whether the current file is paused.

Source

pub fn set_looping(&self, looping: bool) -> FileOperation<()> ⓘ

Set whether playback restarts at the end of a file. The setting is kept across files.

Source

pub fn is_looping(&self) -> FileOperation<bool> ⓘ

Whether playback restarts at the end of a file.

Source

pub fn duration(&self) -> FileOperation<Option<FileDuration>> ⓘ

The current file’s best-known duration, and whether it is final.

Source

pub fn position(&self) -> FileOperation<Option<FilePosition>> ⓘ

The position of the frame sent last.

Source

pub fn source_timecode(&self) -> FileOperation<Option<Timecode>> ⓘ

The recorded source timecode of the frame sent last.

Source

pub fn source_format(&self) -> FileOperation<Option<SourceFormat>> ⓘ

The track layout of the current file.

Source

pub fn advertised_source(&self) -> FileOperation<Source> ⓘ

The NDI source this player advertises. See FilePlayer::advertised_source for descriptor read errors.

Source

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.

Trait Implementations§

Source§

impl Clone for AsyncFilePlayer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AsyncFilePlayer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.