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§
Required Methods§
Sourcefn begin(
&mut self,
tracks: &[TrackInfo],
hint: MuxHint,
) -> Result<MuxTiming, SessionError<Self::Error>>
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.
Sourcefn write_packet(
&mut self,
packet: Packet,
pulse: Option<&dyn Pulse>,
) -> Result<(), SessionError<Self::Error>>
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.
Sourcefn pending_output(&self) -> &[u8] ⓘ
fn pending_output(&self) -> &[u8] ⓘ
Bytes ready to send, not yet consumed.
Sourcefn consume_output(&mut self, n: usize)
fn consume_output(&mut self, n: usize)
Mark the first n pending bytes as sent (clamped).
Sourcefn take_output(&mut self, into: &mut Vec<u8>)
fn take_output(&mut self, into: &mut Vec<u8>)
Append the pending bytes to into and mark them sent.
Provided Methods§
Sourcefn begin_exact_timing(
&mut self,
tracks: &[TrackInfo],
hint: MuxHint,
) -> Result<MuxTiming, SessionError<Self::Error>>
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".