mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-12 13:42:34 +00:00
EBML: Stub implement remaining Segment elements
This commit is contained in:
parent
a61e084db3
commit
9f1d6325a3
7 changed files with 123 additions and 10 deletions
|
@ -8,6 +8,7 @@ use std::ops::{Deref, DerefMut};
|
||||||
use byteorder::{BigEndian, ReadBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt};
|
||||||
use lofty_attr::ebml_master_elements;
|
use lofty_attr::ebml_master_elements;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
pub struct ElementHeader {
|
pub struct ElementHeader {
|
||||||
pub(crate) id: VInt,
|
pub(crate) id: VInt,
|
||||||
pub(crate) size: VInt,
|
pub(crate) size: VInt,
|
||||||
|
@ -25,7 +26,7 @@ impl ElementHeader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
pub enum ElementDataType {
|
pub enum ElementDataType {
|
||||||
SignedInt,
|
SignedInt,
|
||||||
UnsignedInt,
|
UnsignedInt,
|
||||||
|
@ -37,13 +38,13 @@ pub enum ElementDataType {
|
||||||
Binary,
|
Binary,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
struct MasterElement {
|
struct MasterElement {
|
||||||
id: ElementIdent,
|
id: ElementIdent,
|
||||||
children: &'static [(VInt, ChildElementDescriptor)],
|
children: &'static [(VInt, ChildElementDescriptor)],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub(crate) struct ChildElementDescriptor {
|
pub(crate) struct ChildElementDescriptor {
|
||||||
pub(crate) ident: ElementIdent,
|
pub(crate) ident: ElementIdent,
|
||||||
pub(crate) data_type: ElementDataType,
|
pub(crate) data_type: ElementDataType,
|
||||||
|
@ -124,6 +125,23 @@ ebml_master_elements! {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// segment.tags
|
||||||
|
Tags: {
|
||||||
|
id: 0x1254_C367,
|
||||||
|
children: [
|
||||||
|
Tag: { 0x7373, Master },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
// segment.tags.tag
|
||||||
|
Tag: {
|
||||||
|
id: 0x7373,
|
||||||
|
children: [
|
||||||
|
Targets: { 0x63C0, Master },
|
||||||
|
SimpleTag: { 0x67C8, Master },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
// segment.attachments
|
// segment.attachments
|
||||||
Attachments: {
|
Attachments: {
|
||||||
id: 0x1941_A469,
|
id: 0x1941_A469,
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
mod segment;
|
mod segment;
|
||||||
|
mod segment_attachments;
|
||||||
|
mod segment_chapters;
|
||||||
|
mod segment_cluster;
|
||||||
mod segment_info;
|
mod segment_info;
|
||||||
|
mod segment_tags;
|
||||||
mod segment_tracks;
|
mod segment_tracks;
|
||||||
|
|
||||||
use super::EbmlFile;
|
use super::EbmlFile;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use super::{segment_info, segment_tracks};
|
use super::{
|
||||||
|
segment_attachments, segment_chapters, segment_cluster, segment_info, segment_tags,
|
||||||
|
segment_tracks,
|
||||||
|
};
|
||||||
use crate::config::ParseOptions;
|
use crate::config::ParseOptions;
|
||||||
use crate::ebml::element_reader::{ElementIdent, ElementReader, ElementReaderYield};
|
use crate::ebml::element_reader::{ElementIdent, ElementReader, ElementReaderYield};
|
||||||
use crate::ebml::properties::EbmlProperties;
|
use crate::ebml::properties::EbmlProperties;
|
||||||
|
@ -22,16 +25,36 @@ where
|
||||||
while let Some(child) = children_reader.next()? {
|
while let Some(child) = children_reader.next()? {
|
||||||
match child {
|
match child {
|
||||||
ElementReaderYield::Master((id, size)) => match id {
|
ElementReaderYield::Master((id, size)) => match id {
|
||||||
ElementIdent::Info => {
|
ElementIdent::Info if parse_options.read_properties => {
|
||||||
segment_info::read_from(children_reader.inner(), parse_options, properties)?
|
segment_info::read_from(children_reader.inner(), parse_options, properties)?
|
||||||
},
|
},
|
||||||
ElementIdent::Cluster => todo!("Support segment.Cluster"),
|
ElementIdent::Cluster if parse_options.read_properties => {
|
||||||
ElementIdent::Tracks => {
|
segment_cluster::read_from(children_reader.inner(), parse_options, properties)?
|
||||||
|
},
|
||||||
|
ElementIdent::Tracks if parse_options.read_properties => {
|
||||||
segment_tracks::read_from(children_reader.inner(), parse_options, properties)?
|
segment_tracks::read_from(children_reader.inner(), parse_options, properties)?
|
||||||
},
|
},
|
||||||
ElementIdent::Tags => todo!("Support segment.Tags"),
|
ElementIdent::Tags | ElementIdent::Attachments | ElementIdent::Chapters => {
|
||||||
ElementIdent::Attachments => todo!("Support segment.Attachments"),
|
let mut tag = tags.unwrap_or_default();
|
||||||
ElementIdent::Chapters => todo!("Support segment.Chapters"),
|
|
||||||
|
if id == ElementIdent::Tags {
|
||||||
|
segment_tags::read_from(children_reader.inner(), parse_options, &mut tag)?
|
||||||
|
} else if id == ElementIdent::Attachments {
|
||||||
|
segment_attachments::read_from(
|
||||||
|
children_reader.inner(),
|
||||||
|
parse_options,
|
||||||
|
&mut tag,
|
||||||
|
)?
|
||||||
|
} else {
|
||||||
|
segment_chapters::read_from(
|
||||||
|
children_reader.inner(),
|
||||||
|
parse_options,
|
||||||
|
&mut tag,
|
||||||
|
)?
|
||||||
|
}
|
||||||
|
|
||||||
|
tags = Some(tag);
|
||||||
|
},
|
||||||
_ => {
|
_ => {
|
||||||
// We do not end up using information from all of the segment
|
// We do not end up using information from all of the segment
|
||||||
// elements, so we can just skip any useless ones.
|
// elements, so we can just skip any useless ones.
|
||||||
|
|
17
lofty/src/ebml/read/segment_attachments.rs
Normal file
17
lofty/src/ebml/read/segment_attachments.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use crate::config::ParseOptions;
|
||||||
|
use crate::ebml::element_reader::ElementReader;
|
||||||
|
use crate::ebml::EbmlTag;
|
||||||
|
use crate::error::Result;
|
||||||
|
|
||||||
|
use std::io::{Read, Seek};
|
||||||
|
|
||||||
|
pub(super) fn read_from<R>(
|
||||||
|
_element_reader: &mut ElementReader<R>,
|
||||||
|
_parse_options: ParseOptions,
|
||||||
|
_tag: &mut EbmlTag,
|
||||||
|
) -> Result<()>
|
||||||
|
where
|
||||||
|
R: Read + Seek,
|
||||||
|
{
|
||||||
|
unimplemented!("\\Ebml\\Segment\\Attachments")
|
||||||
|
}
|
17
lofty/src/ebml/read/segment_chapters.rs
Normal file
17
lofty/src/ebml/read/segment_chapters.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use crate::config::ParseOptions;
|
||||||
|
use crate::ebml::element_reader::ElementReader;
|
||||||
|
use crate::ebml::EbmlTag;
|
||||||
|
use crate::error::Result;
|
||||||
|
|
||||||
|
use std::io::{Read, Seek};
|
||||||
|
|
||||||
|
pub(super) fn read_from<R>(
|
||||||
|
_element_reader: &mut ElementReader<R>,
|
||||||
|
_parse_options: ParseOptions,
|
||||||
|
_tag: &mut EbmlTag,
|
||||||
|
) -> Result<()>
|
||||||
|
where
|
||||||
|
R: Read + Seek,
|
||||||
|
{
|
||||||
|
unimplemented!("\\Ebml\\Segment\\Chapters")
|
||||||
|
}
|
17
lofty/src/ebml/read/segment_cluster.rs
Normal file
17
lofty/src/ebml/read/segment_cluster.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use crate::config::ParseOptions;
|
||||||
|
use crate::ebml::element_reader::ElementReader;
|
||||||
|
use crate::ebml::properties::EbmlProperties;
|
||||||
|
use crate::error::Result;
|
||||||
|
|
||||||
|
use std::io::{Read, Seek};
|
||||||
|
|
||||||
|
pub(super) fn read_from<R>(
|
||||||
|
_element_reader: &mut ElementReader<R>,
|
||||||
|
_parse_options: ParseOptions,
|
||||||
|
_properties: &mut EbmlProperties,
|
||||||
|
) -> Result<()>
|
||||||
|
where
|
||||||
|
R: Read + Seek,
|
||||||
|
{
|
||||||
|
unimplemented!("\\Ebml\\Segment\\Cluster")
|
||||||
|
}
|
17
lofty/src/ebml/read/segment_tags.rs
Normal file
17
lofty/src/ebml/read/segment_tags.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use crate::config::ParseOptions;
|
||||||
|
use crate::ebml::element_reader::ElementReader;
|
||||||
|
use crate::ebml::EbmlTag;
|
||||||
|
use crate::error::Result;
|
||||||
|
|
||||||
|
use std::io::{Read, Seek};
|
||||||
|
|
||||||
|
pub(super) fn read_from<R>(
|
||||||
|
_element_reader: &mut ElementReader<R>,
|
||||||
|
_parse_options: ParseOptions,
|
||||||
|
_tag: &mut EbmlTag,
|
||||||
|
) -> Result<()>
|
||||||
|
where
|
||||||
|
R: Read + Seek,
|
||||||
|
{
|
||||||
|
unimplemented!("\\Ebml\\Segment\\Tags")
|
||||||
|
}
|
Loading…
Reference in a new issue