use kithara_platform::time::Duration;
use kithara_stream::{AudioCodec, PendingReason};
use crate::error::DecodeResult;
pub(crate) trait Demuxer: Send {
fn current_segment_index(&self) -> Option<u32> {
None
}
fn current_variant_index(&self) -> Option<usize> {
None
}
fn duration(&self) -> Option<Duration>;
fn next_frame(&mut self) -> DecodeResult<DemuxOutcome<'_>>;
fn seek(&mut self, target: Duration) -> DecodeResult<DemuxSeekOutcome>;
fn track_info(&self) -> &TrackInfo;
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub(crate) struct TrackInfo {
pub codec: AudioCodec,
pub duration: Option<Duration>,
pub gapless: Option<crate::GaplessInfo>,
pub extra_data: Vec<u8>,
pub channels: u16,
pub sample_rate: u32,
}
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub(crate) struct Frame<'a> {
pub data: &'a [u8],
pub packet_desc: &'a [u8],
pub duration: Duration,
pub pts: Duration,
}
#[derive(Debug)]
pub(crate) enum DemuxOutcome<'a> {
Frame(Frame<'a>),
Pending(PendingReason),
Eof,
}
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub(crate) enum DemuxSeekOutcome {
Landed {
landed_at: Duration,
landed_byte: Option<u64>,
},
PastEof { duration: Duration },
}