pub struct PcmMeta {
pub end_timestamp: Duration,
pub timestamp: Duration,
pub segment_index: Option<u32>,
pub source_byte_offset: Option<u64>,
pub variant_index: Option<usize>,
pub spec: PcmSpec,
pub frames: u32,
pub epoch: u64,
pub frame_offset: u64,
pub source_bytes: u64,
}Expand description
Timeline metadata for a PCM chunk.
Combines audio format specification with position on the logical timeline.
Each chunk gets unique timeline coordinates; PcmSpec is the static part.
Intentionally without #[non_exhaustive]: external crates construct
it via PcmMeta { spec, ..Default::default() } for fixtures; the
pattern survives field additions, and non_exhaustive would block
the struct-literal idiom altogether.
Fields§
§end_timestamp: DurationWall-clock position after this chunk’s frames have played
out, computed by the decoder from its own frame counter. Used
by Timeline::advance_committed_chunk to update the playhead
without re-doing frames * 1e9 / sample_rate arithmetic on the
consumer side. For frame-based decoders (MP3 / AAC) the last
chunk may legitimately push this a few ms past the rounded
total_duration; the timeline clamps to duration on write.
timestamp: DurationTimestamp of the first frame in this chunk.
segment_index: Option<u32>Segment index within playlist (None for progressive files).
source_byte_offset: Option<u64>Absolute byte offset of this chunk’s source data within the input
stream, when the decoder reports it. Apple’s AudioFile exposes
this via AudioStreamPacketDescription.mStartOffset; other
backends (Symphonia, Android MediaExtractor) do not surface
per-packet byte offsets through their public API and leave this
None. When present, downstream code can pin the chunk to an
exact byte range without recomputing rate × time.
variant_index: Option<usize>Variant/quality level index (None for progressive files).
spec: PcmSpecAudio format (channels, sample rate).
frames: u32Number of audio frames this chunk represents (one frame =
spec.channels interleaved samples). Decoder fills it from the
output buffer length; consumer-side splits update it in place
when slicing a chunk into consumed/remaining halves.
epoch: u64Decoder generation — increments on each ABR switch / decoder recreation.
frame_offset: u64Absolute frame offset from the start of the track.
source_bytes: u64Number of source-stream bytes that produced this chunk’s PCM, as
reported by the underlying decoder packet (e.g. Packet.data.len()
for Symphonia, mDataByteSize for Apple AudioConverter,
readSampleData return for Android MediaExtractor).
Lets the consumer correlate chunk frames with the source byte
position without recomputing rate × time externally — the decoder
already knows the exact mapping for variable-bitrate compressed
formats and arbitrary-sized PCM packets. 0 means “unknown” (mock
decoders, post-EOF flush chunks).