1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
//! Typed validation-code catalogue for SMPTE ST 2067-201 (IAB Level 0 Plug-in).
//!
//! The same 21 reason codes apply to both the 2019 and 2021 editions; a
//! `macro_rules!` generates `St2067_201_2019` and `St2067_201_2021` from a
//! single source-of-truth variant list. Each edition enum also exposes
//! `for_code` so that shared helper functions can produce the right
//! `&'static str` without any runtime string building.
use crate::diagnostics::codes::ValidationCode;
use crate::diagnostics::{Category, Severity};
// ─────────────────────────────────────────────────────────────────────────────
// Spec-agnostic reason codes
// ─────────────────────────────────────────────────────────────────────────────
/// Spec-agnostic reason codes for IAB Level 0 Plug-in validation.
///
/// Passed to each edition's `for_code` dispatch function to get the full
/// `&'static str` code without any runtime string building.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum IabCode {
/// IABEssenceDescriptor: Codec item shall not be present (§5.9).
CodecForbidden,
/// IABEssenceDescriptor: ElectrospatialFormulation shall not be present (§5.9).
ElectrospatialFormulationForbidden,
/// IABEssenceDescriptor: QuantizationBits is missing; shall be 24 (§5.9).
QuantizationBitsMissing,
/// IABEssenceDescriptor: QuantizationBits is present but not 24 (§5.9).
QuantizationBitsInvalid,
/// IABEssenceDescriptor: ContainerFormat is missing (§5.3).
ContainerFormatMissing,
/// IABEssenceDescriptor: ContainerFormat is not the required IAB container UL (§5.3).
EssenceContainerInvalid,
/// IABEssenceDescriptor: AudioSampleRate is missing; shall be 48000/1 (§5.9).
AudioSamplingRateMissing,
/// IABEssenceDescriptor: AudioSampleRate is not 48000/1 (§5.9).
AudioSamplingRateInvalid,
/// IABEssenceDescriptor: SoundCompression is missing (§5.9).
SoundCompressionMissing,
/// IABEssenceDescriptor: SoundCompression is not the required IAB compression UL (§5.9).
SoundCompressionInvalid,
/// IABEssenceDescriptor: ChannelCount shall be the distinguished value 0 (§5.9, 2019 only).
ChannelCountNotZero,
/// IABEssenceDescriptor: IABSoundfieldLabelSubDescriptor shall be present (§5.9).
SubDescriptorMissing,
/// IABSoundfieldLabelSubDescriptor: MCATagSymbol shall be "IAB" — missing (§5.9).
MCATagSymbolMissing,
/// IABSoundfieldLabelSubDescriptor: MCATagSymbol shall be "IAB" — wrong value (§5.9).
MCATagSymbolInvalid,
/// IABSoundfieldLabelSubDescriptor: MCATagName shall be "IAB" — missing (§5.9).
MCATagNameMissing,
/// IABSoundfieldLabelSubDescriptor: MCATagName shall be "IAB" — wrong value (§5.9).
MCATagNameInvalid,
/// IABSoundfieldLabelSubDescriptor: MCALabelDictionaryID is missing (§5.9).
MCALabelDictionaryIDMissing,
/// IABSoundfieldLabelSubDescriptor: MCALabelDictionaryID is not the required IAB label UL (§5.9).
MCALabelDictionaryIDInvalid,
/// Segment has IABSequence but no MainAudioSequence (§6.2).
MainAudioMissing,
/// IABSequence shall contain at least one Resource (§6.2).
IABSequenceNoResources,
/// IABSequence Resource.SourceEncoding does not reference an IABEssenceDescriptor (§6.2).
IABSequenceSourceEncodingInvalid,
}
// ─────────────────────────────────────────────────────────────────────────────
// Edition-specific enums (generated by macro)
// ─────────────────────────────────────────────────────────────────────────────
macro_rules! define_iab_enum {
($name:ident, $prefix:literal) => {
/// IAB Level 0 Plug-in validation codes, edition
#[doc = $prefix]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum $name {
/// IABEssenceDescriptor: Codec item shall not be present (§5.9).
CodecForbidden,
/// IABEssenceDescriptor: ElectrospatialFormulation shall not be present (§5.9).
ElectrospatialFormulationForbidden,
/// IABEssenceDescriptor: QuantizationBits is missing; shall be 24 (§5.9).
QuantizationBitsMissing,
/// IABEssenceDescriptor: QuantizationBits is present but not 24 (§5.9).
QuantizationBitsInvalid,
/// IABEssenceDescriptor: ContainerFormat is missing (§5.3).
ContainerFormatMissing,
/// IABEssenceDescriptor: ContainerFormat is not the required IAB container UL (§5.3).
EssenceContainerInvalid,
/// IABEssenceDescriptor: AudioSampleRate is missing; shall be 48000/1 (§5.9).
AudioSamplingRateMissing,
/// IABEssenceDescriptor: AudioSampleRate is not 48000/1 (§5.9).
AudioSamplingRateInvalid,
/// IABEssenceDescriptor: SoundCompression is missing (§5.9).
SoundCompressionMissing,
/// IABEssenceDescriptor: SoundCompression is not the required IAB compression UL (§5.9).
SoundCompressionInvalid,
/// IABEssenceDescriptor: ChannelCount shall be the distinguished value 0 (§5.9, 2019 only).
ChannelCountNotZero,
/// IABEssenceDescriptor: IABSoundfieldLabelSubDescriptor shall be present (§5.9).
SubDescriptorMissing,
/// IABSoundfieldLabelSubDescriptor: MCATagSymbol shall be "IAB" — missing (§5.9).
MCATagSymbolMissing,
/// IABSoundfieldLabelSubDescriptor: MCATagSymbol shall be "IAB" — wrong value (§5.9).
MCATagSymbolInvalid,
/// IABSoundfieldLabelSubDescriptor: MCATagName shall be "IAB" — missing (§5.9).
MCATagNameMissing,
/// IABSoundfieldLabelSubDescriptor: MCATagName shall be "IAB" — wrong value (§5.9).
MCATagNameInvalid,
/// IABSoundfieldLabelSubDescriptor: MCALabelDictionaryID is missing (§5.9).
MCALabelDictionaryIDMissing,
/// IABSoundfieldLabelSubDescriptor: MCALabelDictionaryID is not the required IAB label UL (§5.9).
MCALabelDictionaryIDInvalid,
/// Segment has IABSequence but no MainAudioSequence (§6.2).
MainAudioMissing,
/// IABSequence shall contain at least one Resource (§6.2).
IABSequenceNoResources,
/// IABSequence Resource.SourceEncoding does not reference an IABEssenceDescriptor (§6.2).
IABSequenceSourceEncodingInvalid,
}
impl ValidationCode for $name {
fn code(&self) -> &'static str {
match self {
Self::CodecForbidden => concat!($prefix, ":5.9/CodecForbidden"),
Self::ElectrospatialFormulationForbidden => concat!($prefix, ":5.9/ElectrospatialFormulationForbidden"),
Self::QuantizationBitsMissing => concat!($prefix, ":5.9/QuantizationBitsMissing"),
Self::QuantizationBitsInvalid => concat!($prefix, ":5.9/QuantizationBitsInvalid"),
Self::ContainerFormatMissing => concat!($prefix, ":5.3/ContainerFormatMissing"),
Self::EssenceContainerInvalid => concat!($prefix, ":5.3/EssenceContainerInvalid"),
Self::AudioSamplingRateMissing => concat!($prefix, ":5.9/AudioSamplingRateMissing"),
Self::AudioSamplingRateInvalid => concat!($prefix, ":5.9/AudioSamplingRateInvalid"),
Self::SoundCompressionMissing => concat!($prefix, ":5.9/SoundCompressionMissing"),
Self::SoundCompressionInvalid => concat!($prefix, ":5.9/SoundCompressionInvalid"),
Self::ChannelCountNotZero => concat!($prefix, ":5.9/ChannelCountNotZero"),
Self::SubDescriptorMissing => concat!($prefix, ":5.9/SubDescriptorMissing"),
Self::MCATagSymbolMissing => concat!($prefix, ":5.9/MCATagSymbolMissing"),
Self::MCATagSymbolInvalid => concat!($prefix, ":5.9/MCATagSymbolInvalid"),
Self::MCATagNameMissing => concat!($prefix, ":5.9/MCATagNameMissing"),
Self::MCATagNameInvalid => concat!($prefix, ":5.9/MCATagNameInvalid"),
Self::MCALabelDictionaryIDMissing => concat!($prefix, ":5.9/MCALabelDictionaryIDMissing"),
Self::MCALabelDictionaryIDInvalid => concat!($prefix, ":5.9/MCALabelDictionaryIDInvalid"),
Self::MainAudioMissing => concat!($prefix, ":6.2/MainAudioMissing"),
Self::IABSequenceNoResources => concat!($prefix, ":6.2/IABSequenceNoResources"),
Self::IABSequenceSourceEncodingInvalid => concat!($prefix, ":6.2/IABSequenceSourceEncodingInvalid"),
}
}
fn description(&self) -> &'static str {
match self {
Self::CodecForbidden => "IABEssenceDescriptor: Codec item shall not be present (§5.9).",
Self::ElectrospatialFormulationForbidden => "IABEssenceDescriptor: ElectrospatialFormulation shall not be present (§5.9).",
Self::QuantizationBitsMissing => "IABEssenceDescriptor: QuantizationBits is missing; shall be 24.",
Self::QuantizationBitsInvalid => "IABEssenceDescriptor: QuantizationBits shall be 24.",
Self::ContainerFormatMissing => "IABEssenceDescriptor: ContainerFormat is missing.",
Self::EssenceContainerInvalid => "IABEssenceDescriptor: ContainerFormat is not the required IAB container UL.",
Self::AudioSamplingRateMissing => "IABEssenceDescriptor: AudioSampleRate is missing; shall be 48000/1.",
Self::AudioSamplingRateInvalid => "IABEssenceDescriptor: AudioSampleRate shall be 48000/1.",
Self::SoundCompressionMissing => "IABEssenceDescriptor: SoundCompression is missing.",
Self::SoundCompressionInvalid => "IABEssenceDescriptor: SoundCompression is not the required IAB compression UL.",
Self::ChannelCountNotZero => "IABEssenceDescriptor: ChannelCount shall be the distinguished value 0 (2019 edition).",
Self::SubDescriptorMissing => "IABEssenceDescriptor: IABSoundfieldLabelSubDescriptor shall be present.",
Self::MCATagSymbolMissing => "IABSoundfieldLabelSubDescriptor: MCATagSymbol is missing; shall be \"IAB\".",
Self::MCATagSymbolInvalid => "IABSoundfieldLabelSubDescriptor: MCATagSymbol shall be \"IAB\".",
Self::MCATagNameMissing => "IABSoundfieldLabelSubDescriptor: MCATagName is missing; shall be \"IAB\".",
Self::MCATagNameInvalid => "IABSoundfieldLabelSubDescriptor: MCATagName shall be \"IAB\".",
Self::MCALabelDictionaryIDMissing => "IABSoundfieldLabelSubDescriptor: MCALabelDictionaryID is missing.",
Self::MCALabelDictionaryIDInvalid => "IABSoundfieldLabelSubDescriptor: MCALabelDictionaryID is not the required IAB label UL.",
Self::MainAudioMissing => "Segment has IABSequence but no MainAudioSequence (§6.2).",
Self::IABSequenceNoResources => "IABSequence shall contain at least one Resource (§6.2).",
Self::IABSequenceSourceEncodingInvalid => "IABSequence Resource.SourceEncoding does not reference an IABEssenceDescriptor (§6.2).",
}
}
fn default_severity(&self) -> Severity {
match self {
Self::QuantizationBitsMissing
| Self::ContainerFormatMissing
| Self::AudioSamplingRateMissing
| Self::SoundCompressionMissing => Severity::Warning,
_ => Severity::Error,
}
}
fn category(&self) -> Category {
Category::Audio
}
}
impl $name {
pub const ALL: &'static [Self] = &[
Self::CodecForbidden,
Self::ElectrospatialFormulationForbidden,
Self::QuantizationBitsMissing,
Self::QuantizationBitsInvalid,
Self::ContainerFormatMissing,
Self::EssenceContainerInvalid,
Self::AudioSamplingRateMissing,
Self::AudioSamplingRateInvalid,
Self::SoundCompressionMissing,
Self::SoundCompressionInvalid,
Self::ChannelCountNotZero,
Self::SubDescriptorMissing,
Self::MCATagSymbolMissing,
Self::MCATagSymbolInvalid,
Self::MCATagNameMissing,
Self::MCATagNameInvalid,
Self::MCALabelDictionaryIDMissing,
Self::MCALabelDictionaryIDInvalid,
Self::MainAudioMissing,
Self::IABSequenceNoResources,
Self::IABSequenceSourceEncodingInvalid,
];
/// Dispatch from the spec-agnostic [`IabCode`] to this
/// edition's static code string. Used by the shared validator helpers.
pub fn for_code(r: IabCode) -> &'static str {
match r {
IabCode::CodecForbidden => concat!($prefix, ":5.9/CodecForbidden"),
IabCode::ElectrospatialFormulationForbidden => concat!($prefix, ":5.9/ElectrospatialFormulationForbidden"),
IabCode::QuantizationBitsMissing => concat!($prefix, ":5.9/QuantizationBitsMissing"),
IabCode::QuantizationBitsInvalid => concat!($prefix, ":5.9/QuantizationBitsInvalid"),
IabCode::ContainerFormatMissing => concat!($prefix, ":5.3/ContainerFormatMissing"),
IabCode::EssenceContainerInvalid => concat!($prefix, ":5.3/EssenceContainerInvalid"),
IabCode::AudioSamplingRateMissing => concat!($prefix, ":5.9/AudioSamplingRateMissing"),
IabCode::AudioSamplingRateInvalid => concat!($prefix, ":5.9/AudioSamplingRateInvalid"),
IabCode::SoundCompressionMissing => concat!($prefix, ":5.9/SoundCompressionMissing"),
IabCode::SoundCompressionInvalid => concat!($prefix, ":5.9/SoundCompressionInvalid"),
IabCode::ChannelCountNotZero => concat!($prefix, ":5.9/ChannelCountNotZero"),
IabCode::SubDescriptorMissing => concat!($prefix, ":5.9/SubDescriptorMissing"),
IabCode::MCATagSymbolMissing => concat!($prefix, ":5.9/MCATagSymbolMissing"),
IabCode::MCATagSymbolInvalid => concat!($prefix, ":5.9/MCATagSymbolInvalid"),
IabCode::MCATagNameMissing => concat!($prefix, ":5.9/MCATagNameMissing"),
IabCode::MCATagNameInvalid => concat!($prefix, ":5.9/MCATagNameInvalid"),
IabCode::MCALabelDictionaryIDMissing => concat!($prefix, ":5.9/MCALabelDictionaryIDMissing"),
IabCode::MCALabelDictionaryIDInvalid => concat!($prefix, ":5.9/MCALabelDictionaryIDInvalid"),
IabCode::MainAudioMissing => concat!($prefix, ":6.2/MainAudioMissing"),
IabCode::IABSequenceNoResources => concat!($prefix, ":6.2/IABSequenceNoResources"),
IabCode::IABSequenceSourceEncodingInvalid => concat!($prefix, ":6.2/IABSequenceSourceEncodingInvalid"),
}
}
}
impl From<$name> for String {
fn from(c: $name) -> String {
c.code().to_string()
}
}
};
}
define_iab_enum!(St2067_201_2019, "ST2067-201:2019");
define_iab_enum!(St2067_201_2021, "ST2067-201:2021");