scuffle_mp4/boxes/types/
avcc.rs1use std::io;
2
3use bytes::Bytes;
4use scuffle_h264::AVCDecoderConfigurationRecord;
5
6use crate::boxes::header::BoxHeader;
7use crate::boxes::traits::BoxType;
8
9#[derive(Debug, Clone, PartialEq)]
10pub struct AvcC {
13 pub header: BoxHeader,
14 pub avc_decoder_configuration_record: AVCDecoderConfigurationRecord,
15}
16
17impl AvcC {
18 pub fn new(avc_decoder_configuration_record: AVCDecoderConfigurationRecord) -> Self {
19 Self {
20 header: BoxHeader::new(Self::NAME),
21 avc_decoder_configuration_record,
22 }
23 }
24}
25
26impl BoxType for AvcC {
27 const NAME: [u8; 4] = *b"avcC";
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 avc_decoder_configuration_record: AVCDecoderConfigurationRecord::parse(&mut reader)?,
34 })
35 }
36
37 fn primitive_size(&self) -> u64 {
38 self.avc_decoder_configuration_record.size()
39 }
40
41 fn primitive_mux<T: io::Write>(&self, writer: &mut T) -> io::Result<()> {
42 self.avc_decoder_configuration_record.build(writer)
43 }
44}