Skip to content

Commit bba24de

Browse files
committed
EBML: Add properties test
1 parent 0d54d72 commit bba24de

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

lofty/src/ebml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use lofty_attr::LoftyFile;
99

1010
// Exports
1111

12-
pub use properties::EbmlProperties;
12+
pub use properties::*;
1313
pub use tag::*;
1414
pub use vint::*;
1515

lofty/src/ebml/properties.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::properties::FileProperties;
22

3+
/// Properties from the EBML header
4+
///
5+
/// These are present for all EBML formats.
36
#[derive(Debug, Clone, PartialEq, Default)]
47
pub struct EbmlHeaderProperties {
58
pub(crate) version: u64,
@@ -48,6 +51,7 @@ impl EbmlHeaderProperties {
4851
}
4952
}
5053

54+
/// An EBML DocType extension
5155
#[derive(Debug, Clone, PartialEq, Default)]
5256
pub struct EbmlExtension {
5357
pub(crate) name: String,
@@ -66,6 +70,7 @@ impl EbmlExtension {
6670
}
6771
}
6872

73+
/// Information about a segment
6974
#[derive(Debug, Clone, PartialEq)]
7075
pub struct SegmentInfo {
7176
pub(crate) timestamp_scale: u64,
@@ -107,6 +112,7 @@ impl Default for SegmentInfo {
107112
}
108113
}
109114

115+
/// A full descriptor for an audio track
110116
#[derive(Debug, Clone, PartialEq, Default)]
111117
pub struct AudioTrackDescriptor {
112118
pub(crate) number: u64,
@@ -161,6 +167,7 @@ impl AudioTrackDescriptor {
161167
}
162168
}
163169

170+
/// Settings for an audio track
164171
#[derive(Debug, Clone, PartialEq, Default)]
165172
pub struct AudioTrackSettings {
166173
pub(crate) sampling_frequency: u32,
@@ -199,6 +206,8 @@ impl AudioTrackSettings {
199206
}
200207
}
201208

209+
/// A rarely-used decoder hint that the file must be de-emphasized
210+
#[allow(missing_docs)]
202211
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
203212
pub enum EbmlAudioTrackEmphasis {
204213
None = 0,

lofty/src/properties/tests.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use crate::aac::{AACProperties, AacFile};
22
use crate::ape::{ApeFile, ApeProperties};
33
use crate::config::ParseOptions;
4+
use crate::ebml::{
5+
AudioTrackDescriptor, AudioTrackSettings, EbmlFile, EbmlHeaderProperties, EbmlProperties,
6+
SegmentInfo,
7+
};
48
use crate::file::AudioFile;
59
use crate::flac::{FlacFile, FlacProperties};
610
use crate::iff::aiff::{AiffFile, AiffProperties};
@@ -67,6 +71,42 @@ const FLAC_PROPERTIES: FlacProperties = FlacProperties {
6771
signature: 164_506_065_180_489_231_127_156_351_872_182_799_315,
6872
};
6973

74+
#[allow(non_snake_case)]
75+
fn MKA_PROPERTIES() -> EbmlProperties {
76+
EbmlProperties {
77+
header: EbmlHeaderProperties {
78+
version: 1,
79+
read_version: 1,
80+
max_id_length: 4,
81+
max_size_length: 8,
82+
doc_type: String::from("matroska"),
83+
doc_type_version: 4,
84+
doc_type_read_version: 0,
85+
},
86+
extensions: Vec::new(),
87+
segment_info: SegmentInfo {
88+
timestamp_scale: 1000000,
89+
muxing_app: String::from("Lavf60.3.100"),
90+
writing_app: String::from("Lavf60.3.100"),
91+
},
92+
audio_tracks: vec![AudioTrackDescriptor {
93+
number: 0,
94+
uid: 0,
95+
language: String::new(),
96+
default_duration: 0,
97+
codec_id: String::new(),
98+
codec_private: vec![],
99+
settings: AudioTrackSettings {
100+
sampling_frequency: 0,
101+
output_sampling_frequency: 0,
102+
channels: 0,
103+
bit_depth: None,
104+
emphasis: None,
105+
},
106+
}],
107+
}
108+
}
109+
70110
const MP1_PROPERTIES: MpegProperties = MpegProperties {
71111
version: MpegVersion::V1,
72112
layer: Layer::Layer1,
@@ -325,6 +365,14 @@ fn flac_properties() {
325365
)
326366
}
327367

368+
#[test_log::test]
369+
fn mka_properties() {
370+
assert_eq!(
371+
get_properties::<EbmlFile>("tests/files/assets/minimal/full_test.mka"),
372+
MKA_PROPERTIES()
373+
);
374+
}
375+
328376
#[test_log::test]
329377
fn mp1_properties() {
330378
assert_eq!(

0 commit comments

Comments
 (0)