@@ -66,7 +66,7 @@ impl EbmlExtension {
6666 }
6767}
6868
69- #[ derive( Debug , Clone , PartialEq , Default ) ]
69+ #[ derive( Debug , Clone , PartialEq ) ]
7070pub struct SegmentInfo {
7171 pub ( crate ) timestamp_scale : u64 ,
7272 pub ( crate ) muxing_app : String ,
@@ -96,6 +96,17 @@ impl SegmentInfo {
9696 }
9797}
9898
99+ impl Default for SegmentInfo {
100+ fn default ( ) -> Self {
101+ Self {
102+ // https://matroska.org/technical/elements.html
103+ timestamp_scale : 1_000_000 ,
104+ muxing_app : String :: new ( ) ,
105+ writing_app : String :: new ( ) ,
106+ }
107+ }
108+ }
109+
99110#[ derive( Debug , Clone , PartialEq , Default ) ]
100111pub struct AudioTrackDescriptor {
101112 pub ( crate ) number : u64 ,
@@ -211,7 +222,7 @@ pub struct EbmlProperties {
211222 pub ( crate ) header : EbmlHeaderProperties ,
212223 pub ( crate ) extensions : Vec < EbmlExtension > ,
213224 pub ( crate ) segment_info : SegmentInfo ,
214- pub ( crate ) default_audio_track : AudioTrackDescriptor ,
225+ pub ( crate ) audio_tracks : Vec < AudioTrackDescriptor > ,
215226}
216227
217228impl EbmlProperties {
@@ -228,29 +239,44 @@ impl EbmlProperties {
228239 & self . extensions
229240 }
230241
231- /// Information from the Matroska `\EBML\Segment\Info` element
242+ /// Information from the `\EBML\Segment\Info` element
232243 pub fn segment_info ( & self ) -> & SegmentInfo {
233244 & self . segment_info
234245 }
235246
247+ /// All audio tracks in the file
248+ ///
249+ /// This includes all audio tracks in the Matroska `\EBML\Segment\Tracks` element.
250+ ///
251+ /// NOTE: The first audio track is **always** the default audio track.
252+ pub fn audio_tracks ( & self ) -> & [ AudioTrackDescriptor ] {
253+ & self . audio_tracks
254+ }
255+
236256 /// Information about the default audio track
237257 ///
238258 /// The information is extracted from the first audio track with its default flag set
239- /// in the Matroska `\EBML\Segment\Tracks` element.
240- pub fn default_audio_track ( & self ) -> & AudioTrackDescriptor {
241- & self . default_audio_track
259+ /// in the `\EBML\Segment\Tracks` element.
260+ ///
261+ /// NOTE: This will always return `Some` unless [`ParseOptions::read_properties`](crate::config::ParseOptions::read_properties) is set to `false`.
262+ pub fn default_audio_track ( & self ) -> Option < & AudioTrackDescriptor > {
263+ self . audio_tracks . first ( )
242264 }
243265}
244266
245267impl From < EbmlProperties > for FileProperties {
246268 fn from ( input : EbmlProperties ) -> Self {
269+ let Some ( default_audio_track) = input. default_audio_track ( ) else {
270+ return FileProperties :: default ( ) ;
271+ } ;
272+
247273 Self {
248274 duration : todo ! ( "Support duration" ) ,
249275 overall_bitrate : todo ! ( "Support bitrate" ) ,
250276 audio_bitrate : todo ! ( "Support bitrate" ) ,
251- sample_rate : Some ( input . default_audio_track . settings . sampling_frequency ) ,
252- bit_depth : input . default_audio_track . settings . bit_depth ,
253- channels : Some ( input . default_audio_track . settings . channels ) ,
277+ sample_rate : Some ( default_audio_track. settings . sampling_frequency ) ,
278+ bit_depth : default_audio_track. settings . bit_depth ,
279+ channels : Some ( default_audio_track. settings . channels ) ,
254280 channel_mask : todo ! ( "Channel mask" ) ,
255281 }
256282 }
0 commit comments