From 9cbb2664d4518a0dba71fecd8fa8420ce73ac75f Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Fri, 27 Nov 2020 22:47:48 -0800 Subject: [PATCH] axml and iXML access methods --- src/fourcc.rs | 1 - src/wavereader.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/fourcc.rs b/src/fourcc.rs index 3583824..7bdc3b8 100644 --- a/src/fourcc.rs +++ b/src/fourcc.rs @@ -106,7 +106,6 @@ pub const BEXT_SIG: FourCC = FourCC::make(b"bext"); pub const JUNK_SIG: FourCC = FourCC::make(b"JUNK"); pub const FLLR_SIG: FourCC = FourCC::make(b"FLLR"); - #[cfg(test)] mod tests { use super::*; diff --git a/src/wavereader.rs b/src/wavereader.rs index 90298ac..f11f1f6 100644 --- a/src/wavereader.rs +++ b/src/wavereader.rs @@ -163,6 +163,34 @@ impl WaveReader { .collect() ) } + /// Read iXML data. + /// + /// If there are no iXML metadata present in the file, + /// Err(Error::ChunkMissing { "iXML" } will be returned. + pub fn ixml(&mut self, buffer: &mut Vec) -> Result { + let ixml_sig: FourCC = FourCC::make(b"iXML"); + let mut chunk = self.chunk_reader(ixml_sig, 0)?; + + match chunk.read_to_end(buffer) { + Ok(read) => Ok(read), + Err(error) => Err(error.into()) + } + } + + /// Read ADM XML data. + /// + /// If there are no iXML metadata present in the file, + /// Err(Error::ChunkMissing { "axml" } will be returned. + pub fn adm_xml(&mut self, buffer: &mut Vec) -> Result { + let axml_sig: FourCC = FourCC::make(b"axml"); + let mut chunk = self.chunk_reader(axml_sig, 0)?; + + match chunk.read_to_end(buffer) { + Ok(read) => Ok(read), + Err(error) => Err(error.into()) + } + } + /** * Validate file is readable. *