Skip to main content

pinray_core/
audio.rs

1/// Sample encoding of [`AudioFrame::data`].
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum SampleFormat {
4    I16,
5    I32,
6    F32,
7    F64,
8}
9
10/// Channel layout of the raw sample bytes.
11#[derive(Debug, Clone, PartialEq)]
12pub enum AudioData {
13    /// Samples alternate across channels: `L R L R …`.
14    Interleaved(Vec<u8>),
15    /// One byte buffer per channel.
16    Planar(Vec<Vec<u8>>),
17}
18
19/// One captured audio packet (typically ~10 ms of samples).
20#[derive(Debug, Clone, PartialEq)]
21pub struct AudioFrame {
22    /// Capture timestamp in nanoseconds; same clock as
23    /// [`VideoFrame::stream_time_ns`](crate::VideoFrame::stream_time_ns)
24    /// within a session.
25    pub stream_time_ns: i64,
26    /// Per-stream packet counter; a jump means packets were dropped.
27    pub sequence: u64,
28    pub sample_rate: u32,
29    pub channels: u16,
30    pub sample_format: SampleFormat,
31    pub data: AudioData,
32}