Skip to main content

Muxer

Trait Muxer 

Source
pub trait Muxer {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn begin(
        &mut self,
        tracks: &[TrackInfo],
        hint: MuxHint,
    ) -> Result<MuxTiming, SessionError<Self::Error>>;
    fn write_packet(
        &mut self,
        packet: Packet,
        pulse: Option<&dyn Pulse>,
    ) -> Result<(), SessionError<Self::Error>>;
    fn pending_output(&self) -> &[u8] ⓘ;
    fn consume_output(&mut self, n: usize);
    fn take_output(&mut self, into: &mut Vec<u8>);
    fn finish(
        self,
        pulse: Option<&dyn Pulse>,
    ) -> Result<MuxFinish, SessionError<Self::Error>>
       where Self: Sized;

    // Provided method
    fn begin_exact_timing(
        &mut self,
        tracks: &[TrackInfo],
        hint: MuxHint,
    ) -> Result<MuxTiming, SessionError<Self::Error>> { ... }
}
Expand description

A container writer whose bytes the caller pulls. See the module docs.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The implementation’s error.

Required Methods§

Source

fn begin( &mut self, tracks: &[TrackInfo], hint: MuxHint, ) -> Result<MuxTiming, SessionError<Self::Error>>

Declare the tracks and learn how bytes will arrive. A second begin is a ProtocolViolation::BeginTwice.

Source

fn write_packet( &mut self, packet: Packet, pulse: Option<&dyn Pulse>, ) -> Result<(), SessionError<Self::Error>>

Write one packet. Takes the packet so its payload can be reused without a copy.

Source

fn pending_output(&self) -> &[u8] ⓘ

Bytes ready to send, not yet consumed.

Source

fn consume_output(&mut self, n: usize)

Mark the first n pending bytes as sent (clamped).

Source

fn take_output(&mut self, into: &mut Vec<u8>)

Append the pending bytes to into and mark them sent.

Source

fn finish( self, pulse: Option<&dyn Pulse>, ) -> Result<MuxFinish, SessionError<Self::Error>>
where Self: Sized,

Finish: the bytes not yet consumed, and any patches.

Provided Methods§

Source

fn begin_exact_timing( &mut self, tracks: &[TrackInfo], hint: MuxHint, ) -> Result<MuxTiming, SessionError<Self::Error>>

Prepare a layout that preserves supplied PTS, DTS and explicit sample durations exactly, or refuse without making output available.

Unlike a capability query, success binds this muxer instance. Later packets that cannot be represented must fail before their payload or timing affects pending output. Missing timestamps/durations may be refused; values must not be guessed, rounded or rebased to make a packet fit. A missing DTS may use its PTS as decode time when the format requires one. This does not certify metadata, packet additions or workspace bounds.

Preparation cannot prove facts about future packets. A driver reports already committed output on a subsequent failure and must not retry a different layout. The default refuses: calling legacy begin alone is not evidence of this stronger contract.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§