webm_iterable/matroska_spec/
mod.rs

1//!
2//! Provides the [`MatroskaSpec`] enum, which implements [`EbmlSpecification`] and [`EbmlTag`].
3//!
4//! This is used in conjuction with the [ebml_iterable](https://crates.io/crates/ebml_iterable) library to be able to read and write Matroska formatted files based on raw tag data. Additionally, this module provides the [`Block`] and [`SimpleBlock`] structs, which provide an easy way to work with block data.  These can easily be converted to and from the regular enum variants using `into()` and `try_from()` to make working with the iterator stream easier.
5//!
6
7mod blocks;
8
9pub use blocks::block::{Block, BlockLacing, Frame};
10pub use blocks::simple_block::SimpleBlock;
11
12pub use ebml_iterable::specs::{EbmlSpecification, EbmlTag, Master, TagDataType};
13use ebml_iterable::specs::easy_ebml;
14
15
16easy_ebml! {
17    ///
18    /// The Matroska specification
19    ///
20    /// Variants are all of the different tag types defined by the Matroska spec.
21    ///
22    #[derive(Clone, PartialEq, Debug)]
23    pub enum MatroskaSpec {
24
25        // EBML Header
26        Ebml:                                           Master      = 0x1a45dfa3,
27        Ebml/EbmlVersion:                               UnsignedInt = 0x4286,
28        Ebml/EbmlReadVersion:                           UnsignedInt = 0x42f7,
29        Ebml/EbmlMaxIdLength:                           UnsignedInt = 0x42f2,
30        Ebml/EbmlMaxSizeLength:                         UnsignedInt = 0x42f3,
31        Ebml/DocType:                                   Utf8        = 0x4282,
32        Ebml/DocTypeVersion:                            UnsignedInt = 0x4287,
33        Ebml/DocTypeReadVersion:                        UnsignedInt = 0x4285,
34        Ebml/DocTypeExtension:                          Master      = 0x4281,
35        Ebml/DocTypeExtension/DocTypeExtensionName:     Utf8        = 0x4283,
36        Ebml/DocTypeExtension/DocTypeExtensionVersion:  UnsignedInt = 0x4284,
37
38        // MKV of spec
39        Segment : Master = 0x18538067,
40
41        Segment/Attachments : Master = 0x1941A469,
42        Segment/Attachments/AttachedFile : Master = 0x61A7,
43        Segment/Attachments/AttachedFile/FileData : Binary = 0x465C,
44        Segment/Attachments/AttachedFile/FileDescription : Utf8 = 0x467E,
45        Segment/Attachments/AttachedFile/FileMimeType : Utf8 = 0x4660,
46        Segment/Attachments/AttachedFile/FileName : Utf8 = 0x466E,
47        Segment/Attachments/AttachedFile/FileReferral : Binary = 0x4675,
48        Segment/Attachments/AttachedFile/FileUID : UnsignedInt = 0x46AE,
49        Segment/Attachments/AttachedFile/FileUsedEndTime : UnsignedInt = 0x4662,
50        Segment/Attachments/AttachedFile/FileUsedStartTime : UnsignedInt = 0x4661,
51
52        Segment/Chapters : Master = 0x1043A770,
53        Segment/Chapters/EditionEntry : Master = 0x45B9,
54        Segment/Chapters/EditionEntry/ChapterAtom : Master = 0xB6,
55        Segment/Chapters/EditionEntry/ChapterAtom/ChapProcess : Master = 0x6944,
56        Segment/Chapters/EditionEntry/ChapterAtom/ChapProcess/ChapProcessCodecID : UnsignedInt = 0x6955,
57        Segment/Chapters/EditionEntry/ChapterAtom/ChapProcess/ChapProcessCommand : Master = 0x6911,
58        Segment/Chapters/EditionEntry/ChapterAtom/ChapProcess/ChapProcessCommand/ChapProcessData : Binary = 0x6933,
59        Segment/Chapters/EditionEntry/ChapterAtom/ChapProcess/ChapProcessCommand/ChapProcessTime : UnsignedInt = 0x6922,
60        Segment/Chapters/EditionEntry/ChapterAtom/ChapProcess/ChapProcessPrivate : Binary = 0x450D,
61        Segment/Chapters/EditionEntry/ChapterAtom/ChapterDisplay : Master = 0x80,
62        Segment/Chapters/EditionEntry/ChapterAtom/ChapterDisplay/ChapCountry : Utf8 = 0x437E,
63        Segment/Chapters/EditionEntry/ChapterAtom/ChapterDisplay/ChapLanguage : Utf8 = 0x437C,
64        Segment/Chapters/EditionEntry/ChapterAtom/ChapterDisplay/ChapLanguageIETF : Utf8 = 0x437D,
65        Segment/Chapters/EditionEntry/ChapterAtom/ChapterDisplay/ChapString : Utf8 = 0x85,
66        Segment/Chapters/EditionEntry/ChapterAtom/ChapterFlagEnabled : UnsignedInt = 0x4598,
67        Segment/Chapters/EditionEntry/ChapterAtom/ChapterFlagHidden : UnsignedInt = 0x98,
68        Segment/Chapters/EditionEntry/ChapterAtom/ChapterPhysicalEquiv : UnsignedInt = 0x63C3,
69        Segment/Chapters/EditionEntry/ChapterAtom/ChapterSegmentEditionUID : UnsignedInt = 0x6EBC,
70        Segment/Chapters/EditionEntry/ChapterAtom/ChapterSegmentUID : Binary = 0x6E67,
71        Segment/Chapters/EditionEntry/ChapterAtom/ChapterStringUID : Utf8 = 0x5654,
72        Segment/Chapters/EditionEntry/ChapterAtom/ChapterTimeEnd : UnsignedInt = 0x92,
73        Segment/Chapters/EditionEntry/ChapterAtom/ChapterTimeStart : UnsignedInt = 0x91,
74        Segment/Chapters/EditionEntry/ChapterAtom/ChapterTrack : Master = 0x8F,
75        Segment/Chapters/EditionEntry/ChapterAtom/ChapterTrack/ChapterTrackUID : UnsignedInt = 0x89,
76        Segment/Chapters/EditionEntry/ChapterAtom/ChapterUID : UnsignedInt = 0x73C4,
77        Segment/Chapters/EditionEntry/EditionFlagDefault : UnsignedInt = 0x45DB,
78        Segment/Chapters/EditionEntry/EditionFlagHidden : UnsignedInt = 0x45BD,
79        Segment/Chapters/EditionEntry/EditionFlagOrdered : UnsignedInt = 0x45DD,
80        Segment/Chapters/EditionEntry/EditionUID : UnsignedInt = 0x45BC,
81
82        Segment/Cluster : Master = 0x1F43B675,
83        Segment/Cluster/BlockGroup : Master = 0xA0,
84        Segment/Cluster/BlockGroup/Block : Binary = 0xA1,
85        Segment/Cluster/BlockGroup/BlockAdditions : Master = 0x75A1,
86        Segment/Cluster/BlockGroup/BlockAdditions/BlockMore : Master = 0xA6,
87        Segment/Cluster/BlockGroup/BlockAdditions/BlockMore/BlockAddID : UnsignedInt = 0xEE,
88        Segment/Cluster/BlockGroup/BlockAdditions/BlockMore/BlockAdditional : Binary = 0xA5,
89        Segment/Cluster/BlockGroup/BlockDuration : UnsignedInt = 0x9B,
90        Segment/Cluster/BlockGroup/BlockVirtual : Binary = 0xA2,
91        Segment/Cluster/BlockGroup/CodecState : Binary = 0xA4,
92        Segment/Cluster/BlockGroup/DiscardPadding : Integer = 0x75A2,
93        Segment/Cluster/BlockGroup/ReferenceBlock : Integer = 0xFB,
94        Segment/Cluster/BlockGroup/ReferenceFrame : Master = 0xC8,
95        Segment/Cluster/BlockGroup/ReferenceFrame/ReferenceOffset : UnsignedInt = 0xC9,
96        Segment/Cluster/BlockGroup/ReferenceFrame/ReferenceTimestamp : UnsignedInt = 0xCA,
97        Segment/Cluster/BlockGroup/ReferencePriority : UnsignedInt = 0xFA,
98        Segment/Cluster/BlockGroup/ReferenceVirtual : Integer = 0xFD,
99        Segment/Cluster/BlockGroup/Slices : Master = 0x8E,
100        Segment/Cluster/BlockGroup/Slices/TimeSlice : Master = 0xE8,
101        Segment/Cluster/BlockGroup/Slices/TimeSlice/BlockAdditionID : UnsignedInt = 0xCB,
102        Segment/Cluster/BlockGroup/Slices/TimeSlice/Delay : UnsignedInt = 0xCE,
103        Segment/Cluster/BlockGroup/Slices/TimeSlice/FrameNumber : UnsignedInt = 0xCD,
104        Segment/Cluster/BlockGroup/Slices/TimeSlice/LaceNumber : UnsignedInt = 0xCC,
105        Segment/Cluster/BlockGroup/Slices/TimeSlice/SliceDuration : UnsignedInt = 0xCF,
106        Segment/Cluster/EncryptedBlock : Binary = 0xAF,
107        Segment/Cluster/Position : UnsignedInt = 0xA7,
108        Segment/Cluster/PrevSize : UnsignedInt = 0xAB,
109        Segment/Cluster/SilentTracks : Master = 0x5854,
110        Segment/Cluster/SilentTracks/SilentTrackNumber : UnsignedInt = 0x58D7,
111        Segment/Cluster/SimpleBlock : Binary = 0xA3,
112        Segment/Cluster/Timestamp : UnsignedInt = 0xE7,
113
114        Segment/Cues : Master = 0x1C53BB6B,
115        Segment/Cues/CuePoint : Master = 0xBB,
116        Segment/Cues/CuePoint/CueTime : UnsignedInt = 0xB3,
117        Segment/Cues/CuePoint/CueTrackPositions : Master = 0xB7,
118        Segment/Cues/CuePoint/CueTrackPositions/CueBlockNumber : UnsignedInt = 0x5378,
119        Segment/Cues/CuePoint/CueTrackPositions/CueClusterPosition : UnsignedInt = 0xF1,
120        Segment/Cues/CuePoint/CueTrackPositions/CueCodecState : UnsignedInt = 0xEA,
121        Segment/Cues/CuePoint/CueTrackPositions/CueDuration : UnsignedInt = 0xB2,
122        Segment/Cues/CuePoint/CueTrackPositions/CueReference : Master = 0xDB,
123        Segment/Cues/CuePoint/CueTrackPositions/CueReference/CueRefCluster : UnsignedInt = 0x97,
124        Segment/Cues/CuePoint/CueTrackPositions/CueReference/CueRefCodecState : UnsignedInt = 0xEB,
125        Segment/Cues/CuePoint/CueTrackPositions/CueReference/CueRefNumber : UnsignedInt = 0x535F,
126        Segment/Cues/CuePoint/CueTrackPositions/CueReference/CueRefTime : UnsignedInt = 0x96,
127        Segment/Cues/CuePoint/CueTrackPositions/CueRelativePosition : UnsignedInt = 0xF0,
128        Segment/Cues/CuePoint/CueTrackPositions/CueTrack : UnsignedInt = 0xF7,
129
130        Segment/Info : Master = 0x1549A966,
131        Segment/Info/ChapterTranslate : Master = 0x6924,
132        Segment/Info/ChapterTranslate/ChapterTranslateCodec : UnsignedInt = 0x69BF,
133        Segment/Info/ChapterTranslate/ChapterTranslateEditionUID : UnsignedInt = 0x69FC,
134        Segment/Info/ChapterTranslate/ChapterTranslateID : Binary = 0x69A5,
135        Segment/Info/DateUTC : Integer = 0x4461,
136        Segment/Info/Duration : Float = 0x4489,
137        Segment/Info/MuxingApp : Utf8 = 0x4D80,
138        Segment/Info/NextFilename : Utf8 = 0x3E83BB,
139        Segment/Info/NextUID : Binary = 0x3EB923,
140        Segment/Info/PrevFilename : Utf8 = 0x3C83AB,
141        Segment/Info/PrevUID : Binary = 0x3CB923,
142        Segment/Info/SegmentFamily : Binary = 0x4444,
143        Segment/Info/SegmentFilename : Utf8 = 0x7384,
144        Segment/Info/SegmentUID : Binary = 0x73A4,
145        Segment/Info/TimestampScale : UnsignedInt = 0x2AD7B1,
146        Segment/Info/Title : Utf8 = 0x7BA9,
147        Segment/Info/WritingApp : Utf8 = 0x5741,
148
149        Segment/SeekHead : Master = 0x114D9B74,
150        Segment/SeekHead/Seek : Master = 0x4DBB,
151        Segment/SeekHead/Seek/SeekID : Binary = 0x53AB,
152        Segment/SeekHead/Seek/SeekPosition : UnsignedInt = 0x53AC,
153
154        Segment/Tags : Master = 0x1254C367,
155        Segment/Tags/Tag : Master = 0x7373,
156        Segment/Tags/Tag/SimpleTag : Master = 0x67C8,
157        Segment/Tags/Tag/SimpleTag/TagBinary : Binary = 0x4485,
158        Segment/Tags/Tag/SimpleTag/TagDefault : UnsignedInt = 0x4484,
159        Segment/Tags/Tag/SimpleTag/TagDefaultBogus : UnsignedInt = 0x44B4,
160        Segment/Tags/Tag/SimpleTag/TagLanguage : Utf8 = 0x447A,
161        Segment/Tags/Tag/SimpleTag/TagLanguageIETF : Utf8 = 0x447B,
162        Segment/Tags/Tag/SimpleTag/TagName : Utf8 = 0x45A3,
163        Segment/Tags/Tag/SimpleTag/TagString : Utf8 = 0x4487,
164        Segment/Tags/Tag/Targets : Master = 0x63C0,
165        Segment/Tags/Tag/Targets/TagAttachmentUID : UnsignedInt = 0x63C6,
166        Segment/Tags/Tag/Targets/TagChapterUID : UnsignedInt = 0x63C4,
167        Segment/Tags/Tag/Targets/TagEditionUID : UnsignedInt = 0x63C9,
168        Segment/Tags/Tag/Targets/TagTrackUID : UnsignedInt = 0x63C5,
169        Segment/Tags/Tag/Targets/TargetType : Utf8 = 0x63CA,
170        Segment/Tags/Tag/Targets/TargetTypeValue : UnsignedInt = 0x68CA,
171
172        Segment/Tracks : Master = 0x1654AE6B,
173        Segment/Tracks/TrackEntry : Master = 0xAE,
174        Segment/Tracks/TrackEntry/AttachmentLink : UnsignedInt = 0x7446,
175        Segment/Tracks/TrackEntry/Audio : Master = 0xE1,
176        Segment/Tracks/TrackEntry/Audio/BitDepth : UnsignedInt = 0x6264,
177        Segment/Tracks/TrackEntry/Audio/ChannelPositions : Binary = 0x7D7B,
178        Segment/Tracks/TrackEntry/Audio/Channels : UnsignedInt = 0x9F,
179        Segment/Tracks/TrackEntry/Audio/OutputSamplingFrequency : Float = 0x78B5,
180        Segment/Tracks/TrackEntry/Audio/SamplingFrequency : Float = 0xB5,
181        Segment/Tracks/TrackEntry/BlockAdditionMapping : Master = 0x41E4,
182        Segment/Tracks/TrackEntry/BlockAdditionMapping/BlockAddIDExtraData : Binary = 0x41ED,
183        Segment/Tracks/TrackEntry/BlockAdditionMapping/BlockAddIDName : Utf8 = 0x41A4,
184        Segment/Tracks/TrackEntry/BlockAdditionMapping/BlockAddIDType : UnsignedInt = 0x41E7,
185        Segment/Tracks/TrackEntry/BlockAdditionMapping/BlockAddIDValue : UnsignedInt = 0x41F0,
186        Segment/Tracks/TrackEntry/CodecDecodeAll : UnsignedInt = 0xAA,
187        Segment/Tracks/TrackEntry/CodecDelay : UnsignedInt = 0x56AA,
188        Segment/Tracks/TrackEntry/CodecDownloadURL : Utf8 = 0x26B240,
189        Segment/Tracks/TrackEntry/CodecID : Utf8 = 0x86,
190        Segment/Tracks/TrackEntry/CodecInfoURL : Utf8 = 0x3B4040,
191        Segment/Tracks/TrackEntry/CodecName : Utf8 = 0x258688,
192        Segment/Tracks/TrackEntry/CodecPrivate : Binary = 0x63A2,
193        Segment/Tracks/TrackEntry/CodecSettings : Utf8 = 0x3A9697,
194        Segment/Tracks/TrackEntry/ContentEncodings : Master = 0x6D80,
195        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding : Master = 0x6240,
196        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentCompression : Master = 0x5034,
197        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentCompression/ContentCompAlgo : UnsignedInt = 0x4254,
198        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentCompression/ContentCompSettings : Binary = 0x4255,
199        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncodingOrder : UnsignedInt = 0x5031,
200        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncodingScope : UnsignedInt = 0x5032,
201        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncodingType : UnsignedInt = 0x5033,
202        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption : Master = 0x5035,
203        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentEncAESSettings : Master = 0x47E7,
204        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentEncAESSettings/AESSettingsCipherMode : UnsignedInt = 0x47E8,
205        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentEncAlgo : UnsignedInt = 0x47E1,
206        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentEncKeyID : Binary = 0x47E2,
207        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentSigAlgo : UnsignedInt = 0x47E5,
208        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentSigHashAlgo : UnsignedInt = 0x47E6,
209        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentSigKeyID : Binary = 0x47E4,
210        Segment/Tracks/TrackEntry/ContentEncodings/ContentEncoding/ContentEncryption/ContentSignature : Binary = 0x47E3,
211        Segment/Tracks/TrackEntry/DefaultDecodedFieldDuration : UnsignedInt = 0x234E7A,
212        Segment/Tracks/TrackEntry/DefaultDuration : UnsignedInt = 0x23E383,
213        Segment/Tracks/TrackEntry/FlagCommentary : UnsignedInt = 0x55AF,
214        Segment/Tracks/TrackEntry/FlagDefault : UnsignedInt = 0x88,
215        Segment/Tracks/TrackEntry/FlagEnabled : UnsignedInt = 0xB9,
216        Segment/Tracks/TrackEntry/FlagForced : UnsignedInt = 0x55AA,
217        Segment/Tracks/TrackEntry/FlagHearingImpaired : UnsignedInt = 0x55AB,
218        Segment/Tracks/TrackEntry/FlagLacing : UnsignedInt = 0x9C,
219        Segment/Tracks/TrackEntry/FlagOriginal : UnsignedInt = 0x55AE,
220        Segment/Tracks/TrackEntry/FlagTextDescriptions : UnsignedInt = 0x55AD,
221        Segment/Tracks/TrackEntry/FlagVisualImpaired : UnsignedInt = 0x55AC,
222        Segment/Tracks/TrackEntry/Language : Utf8 = 0x22B59C,
223        Segment/Tracks/TrackEntry/LanguageIETF : Utf8 = 0x22B59D,
224        Segment/Tracks/TrackEntry/MaxBlockAdditionID : UnsignedInt = 0x55EE,
225        Segment/Tracks/TrackEntry/MaxCache : UnsignedInt = 0x6DF8,
226        Segment/Tracks/TrackEntry/MinCache : UnsignedInt = 0x6DE7,
227        Segment/Tracks/TrackEntry/Name : Utf8 = 0x536E,
228        Segment/Tracks/TrackEntry/SeekPreRoll : UnsignedInt = 0x56BB,
229        Segment/Tracks/TrackEntry/TrackNumber : UnsignedInt = 0xD7,
230        Segment/Tracks/TrackEntry/TrackOffset : Integer = 0x537F,
231        Segment/Tracks/TrackEntry/TrackOperation : Master = 0xE2,
232        Segment/Tracks/TrackEntry/TrackOperation/TrackCombinePlanes : Master = 0xE3,
233        Segment/Tracks/TrackEntry/TrackOperation/TrackCombinePlanes/TrackPlane : Master = 0xE4,
234        Segment/Tracks/TrackEntry/TrackOperation/TrackCombinePlanes/TrackPlane/TrackPlaneType : UnsignedInt = 0xE6,
235        Segment/Tracks/TrackEntry/TrackOperation/TrackCombinePlanes/TrackPlane/TrackPlaneUID : UnsignedInt = 0xE5,
236        Segment/Tracks/TrackEntry/TrackOperation/TrackJoinBlocks : Master = 0xE9,
237        Segment/Tracks/TrackEntry/TrackOperation/TrackJoinBlocks/TrackJoinUID : UnsignedInt = 0xED,
238        Segment/Tracks/TrackEntry/TrackOverlay : UnsignedInt = 0x6FAB,
239        Segment/Tracks/TrackEntry/TrackTimestampScale : Float = 0x23314F,
240        Segment/Tracks/TrackEntry/TrackTranslate : Master = 0x6624,
241        Segment/Tracks/TrackEntry/TrackTranslate/TrackTranslateCodec : UnsignedInt = 0x66BF,
242        Segment/Tracks/TrackEntry/TrackTranslate/TrackTranslateEditionUID : UnsignedInt = 0x66FC,
243        Segment/Tracks/TrackEntry/TrackTranslate/TrackTranslateTrackID : Binary = 0x66A5,
244        Segment/Tracks/TrackEntry/TrackType : UnsignedInt = 0x83,
245        Segment/Tracks/TrackEntry/TrackUID : UnsignedInt = 0x73C5,
246        Segment/Tracks/TrackEntry/TrickMasterTrackSegmentUID : Binary = 0xC4,
247        Segment/Tracks/TrackEntry/TrickMasterTrackUID : UnsignedInt = 0xC7,
248        Segment/Tracks/TrackEntry/TrickTrackFlag : UnsignedInt = 0xC6,
249        Segment/Tracks/TrackEntry/TrickTrackSegmentUID : Binary = 0xC1,
250        Segment/Tracks/TrackEntry/TrickTrackUID : UnsignedInt = 0xC0,
251        Segment/Tracks/TrackEntry/Video : Master = 0xE0,
252        Segment/Tracks/TrackEntry/Video/AlphaMode : UnsignedInt = 0x53C0,
253        Segment/Tracks/TrackEntry/Video/AspectRatioType : UnsignedInt = 0x54B3,
254        Segment/Tracks/TrackEntry/Video/Colour : Master = 0x55B0,
255        Segment/Tracks/TrackEntry/Video/Colour/BitsPerChannel : UnsignedInt = 0x55B2,
256        Segment/Tracks/TrackEntry/Video/Colour/CbSubsamplingHorz : UnsignedInt = 0x55B5,
257        Segment/Tracks/TrackEntry/Video/Colour/CbSubsamplingVert : UnsignedInt = 0x55B6,
258        Segment/Tracks/TrackEntry/Video/Colour/ChromaSitingHorz : UnsignedInt = 0x55B7,
259        Segment/Tracks/TrackEntry/Video/Colour/ChromaSitingVert : UnsignedInt = 0x55B8,
260        Segment/Tracks/TrackEntry/Video/Colour/ChromaSubsamplingHorz : UnsignedInt = 0x55B3,
261        Segment/Tracks/TrackEntry/Video/Colour/ChromaSubsamplingVert : UnsignedInt = 0x55B4,
262        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata : Master = 0x55D0,
263        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/LuminanceMax : Float = 0x55D9,
264        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/LuminanceMin : Float = 0x55DA,
265        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/PrimaryBChromaticityX : Float = 0x55D5,
266        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/PrimaryBChromaticityY : Float = 0x55D6,
267        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/PrimaryGChromaticityX : Float = 0x55D3,
268        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/PrimaryGChromaticityY : Float = 0x55D4,
269        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/PrimaryRChromaticityX : Float = 0x55D1,
270        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/PrimaryRChromaticityY : Float = 0x55D2,
271        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/WhitePointChromaticityX : Float = 0x55D7,
272        Segment/Tracks/TrackEntry/Video/Colour/MasteringMetadata/WhitePointChromaticityY : Float = 0x55D8,
273        Segment/Tracks/TrackEntry/Video/Colour/MatrixCoefficients : UnsignedInt = 0x55B1,
274        Segment/Tracks/TrackEntry/Video/Colour/MaxCLL : UnsignedInt = 0x55BC,
275        Segment/Tracks/TrackEntry/Video/Colour/MaxFALL : UnsignedInt = 0x55BD,
276        Segment/Tracks/TrackEntry/Video/Colour/Primaries : UnsignedInt = 0x55BB,
277        Segment/Tracks/TrackEntry/Video/Colour/Range : UnsignedInt = 0x55B9,
278        Segment/Tracks/TrackEntry/Video/Colour/TransferCharacteristics : UnsignedInt = 0x55BA,
279        Segment/Tracks/TrackEntry/Video/DisplayHeight : UnsignedInt = 0x54BA,
280        Segment/Tracks/TrackEntry/Video/DisplayUnit : UnsignedInt = 0x54B2,
281        Segment/Tracks/TrackEntry/Video/DisplayWidth : UnsignedInt = 0x54B0,
282        Segment/Tracks/TrackEntry/Video/FieldOrder : UnsignedInt = 0x9D,
283        Segment/Tracks/TrackEntry/Video/FlagInterlaced : UnsignedInt = 0x9A,
284        Segment/Tracks/TrackEntry/Video/FrameRate : Float = 0x2383E3,
285        Segment/Tracks/TrackEntry/Video/GammaValue : Float = 0x2FB523,
286        Segment/Tracks/TrackEntry/Video/OldStereoMode : UnsignedInt = 0x53B9,
287        Segment/Tracks/TrackEntry/Video/PixelCropBottom : UnsignedInt = 0x54AA,
288        Segment/Tracks/TrackEntry/Video/PixelCropLeft : UnsignedInt = 0x54CC,
289        Segment/Tracks/TrackEntry/Video/PixelCropRight : UnsignedInt = 0x54DD,
290        Segment/Tracks/TrackEntry/Video/PixelCropTop : UnsignedInt = 0x54BB,
291        Segment/Tracks/TrackEntry/Video/PixelHeight : UnsignedInt = 0xBA,
292        Segment/Tracks/TrackEntry/Video/PixelWidth : UnsignedInt = 0xB0,
293        Segment/Tracks/TrackEntry/Video/Projection : Master = 0x7670,
294        Segment/Tracks/TrackEntry/Video/Projection/ProjectionPosePitch : Float = 0x7674,
295        Segment/Tracks/TrackEntry/Video/Projection/ProjectionPoseRoll : Float = 0x7675,
296        Segment/Tracks/TrackEntry/Video/Projection/ProjectionPoseYaw : Float = 0x7673,
297        Segment/Tracks/TrackEntry/Video/Projection/ProjectionPrivate : Binary = 0x7672,
298        Segment/Tracks/TrackEntry/Video/Projection/ProjectionType : UnsignedInt = 0x7671,
299        Segment/Tracks/TrackEntry/Video/StereoMode : UnsignedInt = 0x53B8,
300        Segment/Tracks/TrackEntry/Video/UncompressedFourCC : Binary = 0x2EB524,
301    }
302}
303
304#[cfg(test)]
305mod test {
306    use std::str::from_utf8;
307    use hyper::Client;
308    use hyper_tls::HttpsConnector;
309    use serde::{Deserialize, Serialize};
310
311    #[derive(Clone, Debug, Serialize, Deserialize)]
312    pub struct EBMLSpec {
313        #[serde(rename = "$value")]
314        elements: Vec<EBMLElement>
315    }
316
317    #[derive(Clone, Debug, Serialize, Deserialize)]
318    pub struct EBMLElement {
319        path: String,
320        id: String,
321        r#type: String,
322    }
323
324    #[ignore]
325    #[tokio::test]
326    async fn print_spec() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
327        let url = "https://raw.githubusercontent.com/ietf-wg-cellar/matroska-specification/master/ebml_matroska.xml";
328        let client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new());
329        let resp = client.get(url.parse()?).await?;
330        let bytes = hyper::body::to_bytes(resp.into_body()).await?;
331        let str = from_utf8(&bytes)?;
332        let spec: EBMLSpec = serde_xml_rs::from_str(str)?;
333
334        let mut lines = vec![];
335        for EBMLElement {  path, id, r#type } in spec.elements {
336            let ty = match r#type.as_str() {
337                "master" => "Master",
338                "uinteger" => "UnsignedInt",
339                "integer" | "date" => "Integer",
340                "utf-8" | "string" => "Utf8",
341                "binary" => "Binary",
342                "float" => "Float",
343                _ => unreachable!("unknown type: {}", r#type)
344            };
345            let path = path.trim_start_matches("\\").replace("\\", "/").replace("+", "");
346            lines.push(format!("{} : {} = {},", path, ty, id));
347        }
348        lines.sort();
349        for line in lines {
350            println!("{}", line);
351        }
352        Ok(())
353    }
354}