Skip to main content

Muxer

Struct Muxer 

Source
pub struct Muxer<S = Open> { /* private fields */ }
Expand description

Sans-IO WebM muxer. S is the typestate (Open or Live).

Implementations§

Source§

impl Muxer<Open>

Source

pub fn new() -> Self

Empty muxer in track-registration state, default TimecodeScale (1ms/tick) and DEFAULT_CLUSTER_BATCH.

Source

pub fn with_options(timecode_scale: u64, batch: usize) -> Self

Muxer with a custom TimecodeScale (ns/tick) and Cluster batch size.

Source

pub fn tracks(&self) -> &[TrackInfo]

Registered tracks so far.

Source

pub fn add_track(&mut self, track: TrackInfo) -> Result<(), MuxError>

Register a track. track.track_number must be non-zero and unique.

§Errors

MuxError::InvalidTrackNumber for track_number == 0; MuxError::DuplicateTrack if already registered.

Source

pub fn begin(self) -> Muxer<Live>

Lock tracks, write the EBML header + Segment/Info/Tracks headers, and enter the live streaming state.

Source§

impl Muxer<Live>

Source

pub fn tracks(&self) -> &[TrackInfo]

Registered tracks.

Source

pub const fn timecode_scale(&self) -> u64

TimecodeScale in effect (ns per tick) — frame timecode values are in these ticks, same unit crate::Demuxer::time_base reports.

Source

pub fn push_frame( &mut self, track_number: u64, timecode: i64, is_keyframe: bool, payload: &[u8], ) -> Result<(), MuxError>

Push one frame. timecode is absolute, in TimecodeScale ticks, and must be non-decreasing per track (not enforced — an out-of-order timecode either still fits the open Cluster’s relative-offset range or forces a new Cluster, same as any large forward jump).

Frames are buffered into the open Cluster and only reach output when the Cluster closes (Self::flush, the batch/range limit, or the next push_frame that can’t share the open Cluster) — call Self::poll_bytes after to drain.

§Errors

MuxError::UnknownTrack if track_number was never registered.

Source

pub fn flush(&mut self)

Force the open Cluster (if any) to close and become available via Self::poll_bytes. Call before finishing the stream — an empty open Cluster (no frames pushed) writes nothing.

Source

pub fn poll_bytes(&mut self, out: &mut Vec<u8>) -> usize

Append available output bytes into out, same drain contract as iso_bmff::mux::Muxer::poll_bytes.

Trait Implementations§

Source§

impl<S: Debug> Debug for Muxer<S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Muxer<Open>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S = Open> !Freeze for Muxer<S>

§

impl<S> RefUnwindSafe for Muxer<S>
where S: RefUnwindSafe,

§

impl<S> Send for Muxer<S>
where S: Send,

§

impl<S> Sync for Muxer<S>
where S: Sync,

§

impl<S> Unpin for Muxer<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Muxer<S>

§

impl<S> UnwindSafe for Muxer<S>
where S: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.