wayle_audio/types/format.rs
1use std::collections::HashMap;
2
3/// Sample specification
4#[derive(Debug, Clone, PartialEq)]
5pub struct SampleSpec {
6 /// Sample rate in Hz
7 pub rate: u32,
8 /// Number of channels
9 pub channels: u8,
10 /// Sample format
11 pub format: SampleFormat,
12}
13
14/// Sample format enumeration
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub enum SampleFormat {
17 /// Unsigned 8-bit samples.
18 U8,
19 /// 8-bit a-Law encoded samples.
20 ALaw,
21 /// 8-bit mu-Law encoded samples.
22 ULaw,
23 /// Signed 16-bit little-endian samples.
24 S16LE,
25 /// Signed 16-bit big-endian samples.
26 S16BE,
27 /// Signed 24-bit little-endian samples.
28 S24LE,
29 /// Signed 24-bit big-endian samples.
30 S24BE,
31 /// Signed 24-bit samples in LSB of 32-bit words, little-endian.
32 S24_32LE,
33 /// Signed 24-bit samples in LSB of 32-bit words, big-endian.
34 S24_32BE,
35 /// Signed 32-bit little-endian samples.
36 S32LE,
37 /// Signed 32-bit big-endian samples.
38 S32BE,
39 /// Float 32-bit little-endian samples.
40 F32LE,
41 /// Float 32-bit big-endian samples.
42 F32BE,
43 /// Unknown format.
44 Unknown,
45}
46
47/// Channel map for audio channels
48#[derive(Debug, Clone, PartialEq)]
49pub struct ChannelMap {
50 /// Number of channels
51 pub channels: u8,
52 /// Channel positions
53 pub positions: Vec<ChannelPosition>,
54}
55
56/// Channel position enumeration
57#[derive(Debug, Clone, Copy, PartialEq, Eq)]
58pub enum ChannelPosition {
59 /// Single mono channel.
60 Mono,
61 /// Front left.
62 FrontLeft,
63 /// Front right.
64 FrontRight,
65 /// Front center.
66 FrontCenter,
67 /// Rear left.
68 RearLeft,
69 /// Rear right.
70 RearRight,
71 /// Rear center (Dolby: "Surround Rear Center").
72 RearCenter,
73 /// Low frequency effects (subwoofer).
74 LFE,
75 /// Side left (Dolby: "Surround Left").
76 SideLeft,
77 /// Side right (Dolby: "Surround Right").
78 SideRight,
79 /// Front left of center (Dolby: "Left Center").
80 FrontLeftOfCenter,
81 /// Front right of center (Dolby: "Right Center").
82 FrontRightOfCenter,
83 /// Top center (Apple: "Top Center Surround").
84 TopCenter,
85 /// Top front left (Apple: "Vertical Height Left").
86 TopFrontLeft,
87 /// Top front right (Apple: "Vertical Height Right").
88 TopFrontRight,
89 /// Top front center (Apple: "Vertical Height Center").
90 TopFrontCenter,
91 /// Top rear left (Microsoft/Apple: "Top Back Left").
92 TopRearLeft,
93 /// Top rear right (Microsoft/Apple: "Top Back Right").
94 TopRearRight,
95 /// Top rear center (Microsoft/Apple: "Top Back Center").
96 TopRearCenter,
97 /// Unrecognized position from PulseAudio.
98 Unknown,
99}
100
101/// Audio format information
102#[derive(Debug, Clone, PartialEq)]
103pub struct AudioFormat {
104 /// Encoding type
105 pub encoding: String,
106 /// Properties of the format
107 pub properties: HashMap<String, String>,
108}