scuffle_mp4/boxes/types/
av1c.rs1use std::io;
2
3use bytes::Bytes;
4use scuffle_av1::AV1CodecConfigurationRecord;
5
6use crate::boxes::header::BoxHeader;
7use crate::boxes::traits::BoxType;
8
9#[derive(Debug, Clone, PartialEq)]
10pub struct Av1C {
13 pub header: BoxHeader,
14 pub av1_config: AV1CodecConfigurationRecord,
15}
16
17impl Av1C {
18 pub fn new(av1_config: AV1CodecConfigurationRecord) -> Self {
19 Self {
20 header: BoxHeader::new(Self::NAME),
21 av1_config,
22 }
23 }
24}
25
26impl BoxType for Av1C {
27 const NAME: [u8; 4] = *b"av1C";
28
29 fn demux(header: BoxHeader, data: Bytes) -> io::Result<Self> {
30 let mut reader = io::Cursor::new(data);
31 Ok(Self {
32 header,
33 av1_config: AV1CodecConfigurationRecord::demux(&mut reader)?,
34 })
35 }
36
37 fn primitive_size(&self) -> u64 {
38 self.av1_config.size()
39 }
40
41 fn primitive_mux<T: io::Write>(&self, writer: &mut T) -> io::Result<()> {
42 self.av1_config.mux(writer)
43 }
44}