use kithara_platform::time::Duration;
pub(crate) use kithara_stream::PrerollHint;
use kithara_stream::{AudioCodec, PendingReason};
use crate::{codec::CodecPriming, 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, priming: CodecPriming) -> DecodeResult<DemuxSeekOutcome>;
fn track_info(&self) -> &TrackInfo;
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub(crate) struct TrackInfo {
pub(crate) codec: AudioCodec,
pub(crate) duration: Option<Duration>,
pub(crate) gapless: Option<crate::GaplessInfo>,
pub(crate) extra_data: Vec<u8>,
pub(crate) channels: u16,
pub(crate) sample_rate: u32,
}
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub(crate) struct Frame<'a> {
pub(crate) data: &'a [u8],
pub(crate) packet_desc: &'a [u8],
pub(crate) duration: Duration,
pub(crate) 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>,
preroll: PrerollHint,
},
PastEof { duration: Duration },
}