2022-06-01 03:50:49 +00:00
|
|
|
use serde::Serialize;
|
2024-04-12 16:56:53 +00:00
|
|
|
use std::io::Write;
|
2020-07-28 16:36:17 +00:00
|
|
|
|
2020-08-04 23:56:59 +00:00
|
|
|
use crate::mp4box::elst::ElstBox;
|
|
|
|
use crate::mp4box::*;
|
2020-07-28 16:36:17 +00:00
|
|
|
|
2023-01-06 02:19:47 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
2020-07-28 16:36:17 +00:00
|
|
|
pub struct EdtsBox {
|
|
|
|
pub elst: Option<ElstBox>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl EdtsBox {
|
2020-08-24 05:11:59 +00:00
|
|
|
pub fn get_type(&self) -> BoxType {
|
|
|
|
BoxType::EdtsBox
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_size(&self) -> u64 {
|
|
|
|
let mut size = HEADER_SIZE;
|
|
|
|
if let Some(ref elst) = self.elst {
|
|
|
|
size += elst.box_size();
|
|
|
|
}
|
|
|
|
size
|
|
|
|
}
|
2020-07-28 16:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Mp4Box for EdtsBox {
|
2024-04-12 16:56:53 +00:00
|
|
|
const TYPE: BoxType = BoxType::EdtsBox;
|
2020-07-28 16:36:17 +00:00
|
|
|
|
|
|
|
fn box_size(&self) -> u64 {
|
2022-06-01 03:50:49 +00:00
|
|
|
self.get_size()
|
2020-07-28 16:36:17 +00:00
|
|
|
}
|
2020-09-09 05:24:34 +00:00
|
|
|
|
|
|
|
fn to_json(&self) -> Result<String> {
|
|
|
|
Ok(serde_json::to_string(&self).unwrap())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn summary(&self) -> Result<String> {
|
2022-06-01 03:50:49 +00:00
|
|
|
let s = String::new();
|
2020-09-09 05:24:34 +00:00
|
|
|
Ok(s)
|
|
|
|
}
|
2020-07-28 16:36:17 +00:00
|
|
|
}
|
|
|
|
|
2024-04-12 16:56:53 +00:00
|
|
|
impl BlockReader for EdtsBox {
|
|
|
|
fn read_block<'a>(reader: &mut impl Reader<'a>) -> Result<Self> {
|
|
|
|
Ok(EdtsBox {
|
|
|
|
elst: reader.try_find_box::<ElstBox>()?,
|
|
|
|
})
|
|
|
|
}
|
2020-07-28 16:36:17 +00:00
|
|
|
|
2024-04-12 16:56:53 +00:00
|
|
|
fn size_hint() -> usize {
|
|
|
|
0
|
2020-07-28 16:36:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-31 17:12:26 +00:00
|
|
|
impl<W: Write> WriteBox<&mut W> for EdtsBox {
|
|
|
|
fn write_box(&self, writer: &mut W) -> Result<u64> {
|
2020-07-28 16:36:17 +00:00
|
|
|
let size = self.box_size();
|
2024-04-12 16:56:53 +00:00
|
|
|
BoxHeader::new(Self::TYPE, size).write(writer)?;
|
2020-07-28 16:36:17 +00:00
|
|
|
|
2020-07-31 17:12:26 +00:00
|
|
|
if let Some(ref elst) = self.elst {
|
2020-07-28 16:36:17 +00:00
|
|
|
elst.write_box(writer)?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(size)
|
|
|
|
}
|
|
|
|
}
|