Skip to main content

mp4_edit/atom/container/
udta.rs

1use crate::{
2    atom::{
3        atom_ref::{unwrap_atom_data, AtomRefMut},
4        chpl::CHPL,
5        container::META,
6        ChapterListAtom,
7    },
8    AtomData, FourCC,
9};
10
11pub const UDTA: FourCC = FourCC::new(b"udta");
12
13pub struct UserDataAtomRefMut<'a>(pub(crate) AtomRefMut<'a>);
14
15impl UserDataAtomRefMut<'_> {
16    /// Finds or inserts CHPL atom
17    pub fn chapter_list(&mut self) -> &'_ mut ChapterListAtom {
18        unwrap_atom_data!(
19            self.0
20                .find_or_insert_child(CHPL)
21                .insert_after(vec![META])
22                .insert_data(AtomData::ChapterList(ChapterListAtom::default()))
23                .call(),
24            AtomData::ChapterList,
25        )
26    }
27}