-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EBML: Stub implement Segment parsing
Signed-off-by: Serial <[email protected]>
- Loading branch information
1 parent
ac4fc48
commit 409d482
Showing
3 changed files
with
81 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::ebml::element_reader::{ElementIdent, ElementReader, ElementReaderYield}; | ||
use crate::ebml::properties::EbmlProperties; | ||
use crate::ebml::tag::EbmlTag; | ||
use crate::error::Result; | ||
use crate::macros::decode_err; | ||
use crate::probe::ParseOptions; | ||
|
||
use std::io::{Read, Seek}; | ||
|
||
pub(super) fn read_from<R>( | ||
element_reader: &mut ElementReader<R>, | ||
_parse_options: ParseOptions, | ||
_properties: &mut EbmlProperties, | ||
) -> Result<Option<EbmlTag>> | ||
where | ||
R: Read + Seek, | ||
{ | ||
element_reader.lock(); | ||
|
||
let mut tags = None; | ||
|
||
loop { | ||
let res = element_reader.next()?; | ||
match res { | ||
ElementReaderYield::Master((id, size)) => match id { | ||
ElementIdent::Info => todo!("Support segment.Info"), | ||
ElementIdent::Cluster => todo!("Support segment.Cluster"), | ||
ElementIdent::Tracks => todo!("Support segment.Tracks"), | ||
ElementIdent::Tags => todo!("Support segment.Tags"), | ||
ElementIdent::Attachments => todo!("Support segment.Attachments"), | ||
ElementIdent::Chapters => todo!("Support segment.Chapters"), | ||
_ => { | ||
// We do not end up using information from all of the segment | ||
// elements, so we can just skip any useless ones. | ||
|
||
log::debug!("Skipping EBML master element: {:?}", id); | ||
element_reader.skip(size)?; | ||
element_reader.goto_previous_master()?; | ||
continue; | ||
}, | ||
}, | ||
ElementReaderYield::Unknown(element) => { | ||
log::debug!("Skipping unknown EBML element: {:X}", element.id.0); | ||
element_reader.skip(element.size.value())?; | ||
continue; | ||
}, | ||
ElementReaderYield::Eof => { | ||
element_reader.unlock(); | ||
break; | ||
}, | ||
_ => { | ||
decode_err!(@BAIL Ebml, "Segment element should only contain master elements") | ||
}, | ||
} | ||
} | ||
|
||
Ok(tags) | ||
} |