Implented AXML/iXML writing functions

This commit is contained in:
Jamie Hardt
2020-12-29 14:26:34 -08:00
parent 78ad1ae114
commit 84942a4186
3 changed files with 18 additions and 6 deletions

View File

@@ -103,6 +103,8 @@ pub const FMT__SIG: FourCC = FourCC::make(b"fmt ");
pub const BEXT_SIG: FourCC = FourCC::make(b"bext");
//pub const FACT_SIG: FourCC = FourCC::make(b"fact");
pub const IXML_SIG: FourCC = FourCC::make(b"iXML");
pub const AXML_SIG: FourCC = FourCC::make(b"axml");
pub const JUNK_SIG: FourCC = FourCC::make(b"JUNK");
pub const FLLR_SIG: FourCC = FourCC::make(b"FLLR");

View File

@@ -3,7 +3,8 @@ use std::io::SeekFrom;
use std::fs::File;
use super::parser::Parser;
use super::fourcc::{FourCC, ReadFourCC, FMT__SIG,DATA_SIG, BEXT_SIG, LIST_SIG, JUNK_SIG, FLLR_SIG, CUE__SIG, ADTL_SIG};
use super::fourcc::{FourCC, ReadFourCC, FMT__SIG,DATA_SIG, BEXT_SIG, LIST_SIG, JUNK_SIG, FLLR_SIG, CUE__SIG,
ADTL_SIG, AXML_SIG, IXML_SIG};
use super::errors::Error as ParserError;
use super::fmt::{WaveFmt, ChannelDescriptor, ChannelMask};
use super::bext::Bext;
@@ -250,8 +251,7 @@ impl<R: Read + Seek> WaveReader<R> {
/// If there are no iXML metadata present in the file,
/// Ok(0) will be returned.
pub fn read_ixml(&mut self, buffer: &mut Vec<u8>) -> Result<usize, ParserError> {
let ixml_fourcc = FourCC::make(b"iXML");
self.read_chunk(ixml_fourcc, 0, buffer)
self.read_chunk(IXML_SIG, 0, buffer)
}
/// Read AXML data.
@@ -262,8 +262,7 @@ impl<R: Read + Seek> WaveReader<R> {
/// If there are no axml metadata present in the file,
/// Ok(0) will be returned
pub fn read_axml(&mut self, buffer: &mut Vec<u8>) -> Result<usize, ParserError> {
let axml_fourcc = FourCC::make(b"axml");
self.read_chunk(axml_fourcc, 0, buffer)
self.read_chunk(AXML_SIG, 0, buffer)
}

View File

@@ -3,7 +3,8 @@ use std::io::{Write,Seek,SeekFrom,Cursor};
use super::Error;
use super::fourcc::{FourCC, WriteFourCC, RIFF_SIG, RF64_SIG, DS64_SIG,
WAVE_SIG, FMT__SIG, DATA_SIG, ELM1_SIG, JUNK_SIG, BEXT_SIG};
WAVE_SIG, FMT__SIG, DATA_SIG, ELM1_SIG, JUNK_SIG, BEXT_SIG,AXML_SIG,
IXML_SIG};
use super::fmt::WaveFmt;
//use super::common_format::CommonFormat;
use super::chunks::WriteBWaveChunks;
@@ -270,6 +271,16 @@ impl<W> WaveWriter<W> where W: Write + Seek {
Ok(())
}
/// Write iXML metadata
pub fn write_ixml(&mut self, ixml: &[u8]) -> Result<(),Error> {
self.write_chunk(IXML_SIG, &ixml)
}
/// Write axml/ADM metadata
pub fn write_axml(&mut self, axml: &[u8]) -> Result<(), Error> {
self.write_chunk(AXML_SIG, &axml)
}
/// Create an audio frame writer, which takes possession of the callee
/// `WaveWriter`.
///