mirror of
https://github.com/alfg/mp4-rust.git
synced 2025-01-03 00:48:40 +00:00
Update mp4dump example and update box_size to method in all boxes.
This commit is contained in:
parent
d51a193272
commit
4df1097948
27 changed files with 144 additions and 117 deletions
|
@ -4,7 +4,7 @@ use std::io::prelude::*;
|
|||
use std::io::{self, BufReader};
|
||||
use std::path::Path;
|
||||
|
||||
use mp4::{Result};
|
||||
use mp4::{Result, Mp4Box};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
@ -21,70 +21,96 @@ fn main() {
|
|||
|
||||
fn dump<P: AsRef<Path>>(filename: &P) -> Result<()> {
|
||||
let f = File::open(filename)?;
|
||||
let size = f.metadata()?.len();
|
||||
let reader = BufReader::new(f);
|
||||
let boxes = get_boxes(f)?;
|
||||
|
||||
let mp4 = mp4::Mp4Reader::read_header(reader, size)?;
|
||||
|
||||
// ftyp
|
||||
println!("[{}] size={} ", mp4.ftyp.get_type(), mp4.ftyp.get_size());
|
||||
|
||||
// moov
|
||||
println!("[{}] size={} ", mp4.moov.get_type(), mp4.moov.get_size());
|
||||
println!(" [{}] size={} ", mp4.moov.mvhd.get_type(), mp4.moov.mvhd.get_size());
|
||||
|
||||
// Tracks.
|
||||
for track in mp4.tracks().iter() {
|
||||
|
||||
// trak
|
||||
println!(" [{}] size={} ", track.trak.get_type(), track.trak.get_size());
|
||||
println!(" [{}] size={} ", track.trak.tkhd.get_type(), track.trak.tkhd.get_size());
|
||||
if let Some(ref edts) = track.trak.edts {
|
||||
println!(" [{}] size={} ", edts.get_type(), edts.get_size());
|
||||
if let Some(ref elst) = edts.elst {
|
||||
println!(" [{}] size={} ", elst.get_type(), elst.get_size());
|
||||
}
|
||||
}
|
||||
|
||||
// trak.mdia.
|
||||
println!(" [{}] size={} ", track.trak.mdia.get_type(), track.trak.mdia.get_size());
|
||||
println!(" [{}] size={} ", track.trak.mdia.mdhd.get_type(), track.trak.mdia.mdhd.get_size());
|
||||
println!(" [{}] size={} ", track.trak.mdia.hdlr.get_type(), track.trak.mdia.hdlr.get_size());
|
||||
println!(" [{}] size={} ", track.trak.mdia.minf.get_type(), track.trak.mdia.minf.get_size());
|
||||
|
||||
// trak.mdia.minf
|
||||
if let Some(ref vmhd) = track.trak.mdia.minf.vmhd {
|
||||
println!(" [{}] size={} ", vmhd.get_type(), vmhd.get_size());
|
||||
}
|
||||
if let Some(ref smhd) = track.trak.mdia.minf.smhd {
|
||||
println!(" [{}] size={} ", smhd.get_type(), smhd.get_size());
|
||||
}
|
||||
|
||||
// trak.mdia.minf.stbl
|
||||
println!(" [{}] size={} ", track.trak.mdia.minf.stbl.get_type(), track.trak.mdia.minf.stbl.get_size());
|
||||
println!(" [{}] size={} ", track.trak.mdia.minf.stbl.stsd.get_type(), track.trak.mdia.minf.stbl.stsd.get_size());
|
||||
if let Some(ref avc1) = track.trak.mdia.minf.stbl.stsd.avc1 {
|
||||
println!(" [{}] size={} ", avc1.get_type(), avc1.get_size());
|
||||
}
|
||||
if let Some(ref mp4a) = track.trak.mdia.minf.stbl.stsd.mp4a {
|
||||
println!(" [{}] size={} ", mp4a.get_type(), mp4a.get_size());
|
||||
}
|
||||
println!(" [{}] size={} ", track.trak.mdia.minf.stbl.stts.get_type(), track.trak.mdia.minf.stbl.stts.get_size());
|
||||
if let Some(ref ctts) = track.trak.mdia.minf.stbl.ctts {
|
||||
println!(" [{}] size={} ", ctts.get_type(), ctts.get_size());
|
||||
}
|
||||
if let Some(ref stss) = track.trak.mdia.minf.stbl.stss {
|
||||
println!(" [{}] size={} ", stss.get_type(), stss.get_size());
|
||||
}
|
||||
println!(" [{}] size={} ", track.trak.mdia.minf.stbl.stsc.get_type(), track.trak.mdia.minf.stbl.stsc.get_size());
|
||||
println!(" [{}] size={} ", track.trak.mdia.minf.stbl.stsz.get_type(), track.trak.mdia.minf.stbl.stsz.get_size());
|
||||
if let Some(ref stco) = track.trak.mdia.minf.stbl.stco {
|
||||
println!(" [{}] size={} ", stco.get_type(), stco.get_size());
|
||||
}
|
||||
if let Some(ref co64) = track.trak.mdia.minf.stbl.co64 {
|
||||
println!(" [{}] size={} ", co64.get_type(), co64.get_size());
|
||||
}
|
||||
// print out boxes
|
||||
for b in boxes.iter() {
|
||||
println!("[{}] size={}", b.name, b.size);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct Box {
|
||||
name: String,
|
||||
size: u64,
|
||||
indent: u32,
|
||||
}
|
||||
|
||||
fn get_boxes(file: File) -> Result<Vec<Box>> {
|
||||
let size = file.metadata()?.len();
|
||||
let reader = BufReader::new(file);
|
||||
let mp4 = mp4::Mp4Reader::read_header(reader, size)?;
|
||||
|
||||
// collect known boxes
|
||||
let mut boxes = Vec::new();
|
||||
|
||||
// ftyp, moov, mvhd
|
||||
boxes.push(build_box(&mp4.ftyp));
|
||||
boxes.push(build_box(&mp4.moov));
|
||||
boxes.push(build_box(&mp4.moov.mvhd));
|
||||
|
||||
// trak.
|
||||
for track in mp4.tracks().iter() {
|
||||
boxes.push(build_box(&track.trak));
|
||||
boxes.push(build_box(&track.trak.tkhd));
|
||||
if let Some(ref edts) = track.trak.edts {
|
||||
boxes.push(build_box(edts));
|
||||
if let Some(ref elst) = edts.elst {
|
||||
boxes.push(build_box(elst));
|
||||
}
|
||||
}
|
||||
|
||||
// trak.mdia
|
||||
let mdia = &track.trak.mdia;
|
||||
boxes.push(build_box(mdia));
|
||||
boxes.push(build_box(&mdia.mdhd));
|
||||
boxes.push(build_box(&mdia.hdlr));
|
||||
boxes.push(build_box(&track.trak.mdia.minf));
|
||||
|
||||
// trak.mdia.minf
|
||||
let minf = &track.trak.mdia.minf;
|
||||
if let Some(ref vmhd) = &minf.vmhd {
|
||||
boxes.push(build_box(vmhd));
|
||||
}
|
||||
if let Some(ref smhd) = &minf.smhd {
|
||||
boxes.push(build_box(smhd));
|
||||
}
|
||||
|
||||
// trak.mdia.minf.stbl
|
||||
let stbl = &track.trak.mdia.minf.stbl;
|
||||
boxes.push(build_box(stbl));
|
||||
boxes.push(build_box(&stbl.stsd));
|
||||
if let Some(ref avc1) = &stbl.stsd.avc1 {
|
||||
boxes.push(build_box(avc1));
|
||||
}
|
||||
if let Some(ref mp4a) = &stbl.stsd.mp4a {
|
||||
boxes.push(build_box(mp4a));
|
||||
}
|
||||
boxes.push(build_box(&stbl.stts));
|
||||
if let Some(ref ctts) = &stbl.ctts {
|
||||
boxes.push(build_box(ctts));
|
||||
}
|
||||
if let Some(ref stss) = &stbl.stss {
|
||||
boxes.push(build_box(stss));
|
||||
}
|
||||
boxes.push(build_box(&stbl.stsc));
|
||||
boxes.push(build_box(&stbl.stsz));
|
||||
if let Some(ref stco) = &stbl.stco {
|
||||
boxes.push(build_box(stco));
|
||||
}
|
||||
if let Some(ref co64) = &stbl.co64 {
|
||||
boxes.push(build_box(co64));
|
||||
}
|
||||
}
|
||||
Ok(boxes)
|
||||
}
|
||||
|
||||
fn build_box<M: Mp4Box + std::fmt::Debug>(ref m: &M) -> Box {
|
||||
return Box{
|
||||
name: m.box_type().to_string(),
|
||||
size: m.box_size(),
|
||||
indent: 0,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ mod types;
|
|||
pub use types::*;
|
||||
|
||||
mod mp4box;
|
||||
pub use mp4box::{Mp4Box};
|
||||
|
||||
mod track;
|
||||
pub use track::{Mp4Track, TrackConfig};
|
||||
|
|
|
@ -54,7 +54,7 @@ impl Avc1Box {
|
|||
}
|
||||
|
||||
impl Mp4Box for Avc1Box {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::Avc1Box
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for Avc1Box {
|
|||
impl<W: Write> WriteBox<&mut W> for Avc1Box {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
writer.write_u32::<BigEndian>(0)?; // reserved
|
||||
writer.write_u16::<BigEndian>(0)?; // reserved
|
||||
|
@ -162,7 +162,7 @@ impl AvcCBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for AvcCBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::AvcCBox
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for AvcCBox {
|
|||
impl<W: Write> WriteBox<&mut W> for AvcCBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
writer.write_u8(self.configuration_version)?;
|
||||
writer.write_u8(self.avc_profile_indication)?;
|
||||
|
|
|
@ -21,7 +21,7 @@ impl Co64Box {
|
|||
}
|
||||
|
||||
impl Mp4Box for Co64Box {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::Co64Box
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for Co64Box {
|
|||
impl<W: Write> WriteBox<&mut W> for Co64Box {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ pub struct CttsEntry {
|
|||
}
|
||||
|
||||
impl Mp4Box for CttsBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::CttsBox
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for CttsBox {
|
|||
impl<W: Write> WriteBox<&mut W> for CttsBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ impl EdtsBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for EdtsBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::EdtsBox
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for EdtsBox {
|
|||
impl<W: Write> WriteBox<&mut W> for EdtsBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
if let Some(ref elst) = self.elst {
|
||||
elst.write_box(writer)?;
|
||||
|
|
|
@ -36,7 +36,7 @@ impl ElstBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for ElstBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::ElstBox
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for ElstBox {
|
|||
impl<W: Write> WriteBox<&mut W> for ElstBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ impl FtypBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for FtypBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::FtypBox
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for FtypBox {
|
|||
impl<W: Write> WriteBox<&mut W> for FtypBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
writer.write_u32::<BigEndian>((&self.major_brand).into())?;
|
||||
writer.write_u32::<BigEndian>(self.minor_version)?;
|
||||
|
|
|
@ -22,7 +22,7 @@ impl HdlrBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for HdlrBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::HdlrBox
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for HdlrBox {
|
|||
impl<W: Write> WriteBox<&mut W> for HdlrBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Default for MdhdBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for MdhdBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::MdhdBox
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MdhdBox {
|
|||
impl<W: Write> WriteBox<&mut W> for MdhdBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ impl MdiaBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for MdiaBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::MdiaBox
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MdiaBox {
|
|||
impl<W: Write> WriteBox<&mut W> for MdiaBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
self.mdhd.write_box(writer)?;
|
||||
self.hdlr.write_box(writer)?;
|
||||
|
|
|
@ -29,7 +29,7 @@ impl MinfBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for MinfBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::MinfBox
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MinfBox {
|
|||
impl<W: Write> WriteBox<&mut W> for MinfBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
if let Some(ref vmhd) = self.vmhd {
|
||||
vmhd.write_box(writer)?;
|
||||
|
|
|
@ -99,7 +99,7 @@ boxtype! {
|
|||
}
|
||||
|
||||
pub trait Mp4Box: Sized {
|
||||
fn box_type() -> BoxType;
|
||||
fn box_type(&self) -> BoxType;
|
||||
fn box_size(&self) -> u64;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ impl MoovBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for MoovBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::MoovBox
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MoovBox {
|
|||
impl<W: Write> WriteBox<&mut W> for MoovBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
self.mvhd.write_box(writer)?;
|
||||
for trak in self.traks.iter() {
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Mp4aBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for Mp4aBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::Mp4aBox
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for Mp4aBox {
|
|||
impl<W: Write> WriteBox<&mut W> for Mp4aBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
writer.write_u32::<BigEndian>(0)?; // reserved
|
||||
writer.write_u16::<BigEndian>(0)?; // reserved
|
||||
|
@ -136,7 +136,7 @@ impl EsdsBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for EsdsBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::EsdsBox
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for EsdsBox {
|
|||
impl<W: Write> WriteBox<&mut W> for EsdsBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ impl Default for MvhdBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for MvhdBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::MvhdBox
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for MvhdBox {
|
|||
impl<W: Write> WriteBox<&mut W> for MvhdBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ impl Default for SmhdBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for SmhdBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::SmhdBox
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for SmhdBox {
|
|||
impl<W: Write> WriteBox<&mut W> for SmhdBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ impl StblBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for StblBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::StblBox
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StblBox {
|
|||
impl<W: Write> WriteBox<&mut W> for StblBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
self.stsd.write_box(writer)?;
|
||||
self.stts.write_box(writer)?;
|
||||
|
|
|
@ -21,7 +21,7 @@ impl StcoBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for StcoBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::StcoBox
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StcoBox {
|
|||
impl<W: Write> WriteBox<&mut W> for StcoBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ pub struct StscEntry {
|
|||
}
|
||||
|
||||
impl Mp4Box for StscBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::StscBox
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StscBox {
|
|||
impl<W: Write> WriteBox<&mut W> for StscBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ impl StsdBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for StsdBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::StsdBox
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StsdBox {
|
|||
impl<W: Write> WriteBox<&mut W> for StsdBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ impl StssBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for StssBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::StssBox
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StssBox {
|
|||
impl<W: Write> WriteBox<&mut W> for StssBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ impl StszBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for StszBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::StszBox
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for StszBox {
|
|||
impl<W: Write> WriteBox<&mut W> for StszBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ pub struct SttsEntry {
|
|||
}
|
||||
|
||||
impl Mp4Box for SttsBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::SttsBox
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for SttsBox {
|
|||
impl<W: Write> WriteBox<&mut W> for SttsBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ impl TkhdBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for TkhdBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::TkhdBox
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for TkhdBox {
|
|||
impl<W: Write> WriteBox<&mut W> for TkhdBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ impl TrakBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for TrakBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::TrakBox
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for TrakBox {
|
|||
impl<W: Write> WriteBox<&mut W> for TrakBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
self.tkhd.write_box(writer)?;
|
||||
if let Some(ref edts) = self.edts {
|
||||
|
|
|
@ -29,7 +29,7 @@ impl VmhdBox {
|
|||
}
|
||||
|
||||
impl Mp4Box for VmhdBox {
|
||||
fn box_type() -> BoxType {
|
||||
fn box_type(&self) -> BoxType {
|
||||
BoxType::VmhdBox
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for VmhdBox {
|
|||
impl<W: Write> WriteBox<&mut W> for VmhdBox {
|
||||
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
||||
let size = self.box_size();
|
||||
BoxHeader::new(Self::box_type(), size).write(writer)?;
|
||||
BoxHeader::new(self.box_type(), size).write(writer)?;
|
||||
|
||||
write_box_header_ext(writer, self.version, self.flags)?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue