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