mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-03-04 14:57:17 +00:00
EBML: Stub implement EbmlFile
and EbmlTag
This commit is contained in:
parent
dd4e926db4
commit
15876582cd
7 changed files with 150 additions and 3 deletions
|
@ -119,6 +119,7 @@ mod util;
|
|||
|
||||
pub mod aac;
|
||||
pub mod ape;
|
||||
pub mod ebml;
|
||||
pub mod flac;
|
||||
pub mod id3;
|
||||
pub mod iff;
|
||||
|
|
|
@ -19,6 +19,7 @@ use crate::ogg::vorbis::VorbisFile;
|
|||
use crate::resolve::custom_resolvers;
|
||||
use crate::wavpack::WavPackFile;
|
||||
|
||||
use crate::ebml::EbmlFile;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Cursor, Read, Seek, SeekFrom};
|
||||
use std::path::Path;
|
||||
|
@ -468,6 +469,7 @@ impl<R: Read + Seek> Probe<R> {
|
|||
FileType::Aac => AacFile::read_from(reader, options)?.into(),
|
||||
FileType::Aiff => AiffFile::read_from(reader, options)?.into(),
|
||||
FileType::Ape => ApeFile::read_from(reader, options)?.into(),
|
||||
FileType::Ebml => EbmlFile::read_from(reader, options)?.into(),
|
||||
FileType::Flac => FlacFile::read_from(reader, options)?.into(),
|
||||
FileType::Mpeg => MpegFile::read_from(reader, options)?.into(),
|
||||
FileType::Opus => OpusFile::read_from(reader, options)?.into(),
|
||||
|
|
|
@ -9,9 +9,9 @@ use quote::quote;
|
|||
pub(crate) fn opt_internal_file_type(
|
||||
struct_name: String,
|
||||
) -> Option<(proc_macro2::TokenStream, bool)> {
|
||||
const LOFTY_FILE_TYPES: [&str; 12] = [
|
||||
"Aac", "Aiff", "Ape", "Flac", "Mpeg", "Mp4", "Mpc", "Opus", "Vorbis", "Speex", "Wav",
|
||||
"WavPack",
|
||||
const LOFTY_FILE_TYPES: [&str; 13] = [
|
||||
"Aac", "Aiff", "Ape", "Ebml", "Flac", "Mpeg", "Mp4", "Mpc", "Opus", "Vorbis", "Speex",
|
||||
"Wav", "WavPack",
|
||||
];
|
||||
|
||||
const ID3V2_STRIPPABLE: [&str; 2] = ["Flac", "Ape"];
|
||||
|
|
22
src/ebml/mod.rs
Normal file
22
src/ebml/mod.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! EBML specific items
|
||||
mod properties;
|
||||
mod read;
|
||||
mod tag;
|
||||
|
||||
use lofty_attr::LoftyFile;
|
||||
|
||||
// Exports
|
||||
|
||||
pub use properties::EbmlProperties;
|
||||
pub use tag::EbmlTag;
|
||||
|
||||
/// An EBML file
|
||||
#[derive(LoftyFile, Default)]
|
||||
#[lofty(read_fn = "read::read_from")]
|
||||
pub struct EbmlFile {
|
||||
/// An ID3v2 tag
|
||||
#[lofty(tag_type = "Id3v2")]
|
||||
pub(crate) ebml_tag: Option<EbmlTag>,
|
||||
/// The file's audio properties
|
||||
pub(crate) properties: EbmlProperties,
|
||||
}
|
11
src/ebml/properties.rs
Normal file
11
src/ebml/properties.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use crate::properties::FileProperties;
|
||||
|
||||
/// EBML audio properties
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct EbmlProperties {}
|
||||
|
||||
impl From<EbmlProperties> for FileProperties {
|
||||
fn from(input: EbmlProperties) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
12
src/ebml/read.rs
Normal file
12
src/ebml/read.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use super::EbmlFile;
|
||||
use crate::error::Result;
|
||||
use crate::probe::ParseOptions;
|
||||
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
pub(super) fn read_from<R>(reader: &mut R, parse_options: ParseOptions) -> Result<EbmlFile>
|
||||
where
|
||||
R: Read + Seek,
|
||||
{
|
||||
todo!()
|
||||
}
|
99
src/ebml/tag/mod.rs
Normal file
99
src/ebml/tag/mod.rs
Normal file
|
@ -0,0 +1,99 @@
|
|||
use crate::error::LoftyError;
|
||||
use crate::tag::Tag;
|
||||
use crate::traits::{Accessor, MergeTag, SplitTag, TagExt};
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::ops::Deref;
|
||||
use std::path::Path;
|
||||
|
||||
use lofty_attr::tag;
|
||||
|
||||
/// TODO
|
||||
#[derive(Default, Debug, PartialEq, Eq, Clone)]
|
||||
#[tag(description = "An `EBML` tag", supported_formats(Ebml))]
|
||||
pub struct EbmlTag {}
|
||||
|
||||
impl Accessor for EbmlTag {}
|
||||
|
||||
impl TagExt for EbmlTag {
|
||||
type Err = LoftyError;
|
||||
type RefKey<'a> = &'a str;
|
||||
|
||||
fn len(&self) -> usize {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn save_to(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn dump_to<W: Write>(&self, writer: &mut W) -> std::result::Result<(), Self::Err> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct SplitTagRemainder(EbmlTag);
|
||||
|
||||
impl From<SplitTagRemainder> for EbmlTag {
|
||||
fn from(from: SplitTagRemainder) -> Self {
|
||||
from.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for SplitTagRemainder {
|
||||
type Target = EbmlTag;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl SplitTag for EbmlTag {
|
||||
type Remainder = SplitTagRemainder;
|
||||
|
||||
fn split_tag(mut self) -> (Self::Remainder, Tag) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl MergeTag for SplitTagRemainder {
|
||||
type Merged = EbmlTag;
|
||||
|
||||
fn merge_tag(self, tag: Tag) -> Self::Merged {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EbmlTag> for Tag {
|
||||
fn from(input: EbmlTag) -> Self {
|
||||
input.split_tag().1
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Tag> for EbmlTag {
|
||||
fn from(input: Tag) -> Self {
|
||||
SplitTagRemainder::default().merge_tag(input)
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue