Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- **TagExt**: `TagExt::contains`
- **Ilst**: `AtomData::Bool` for the various flag atoms such as `cpil`, `pcst`, etc.

## [0.9.0] - 2022-10-30

Expand Down
7 changes: 6 additions & 1 deletion src/mp4/ilst/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ impl Debug for Atom {
/// to the link above for codes.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum AtomData {
// TODO: Bool variant for the various flag atoms?
/// A UTF-8 encoded string
UTF8(String),
/// A UTF-16 encoded string
Expand All @@ -188,6 +187,12 @@ pub enum AtomData {
///
/// NOTE: See [`AtomData::SignedInteger`]
UnsignedInteger(u32),
/// A boolean value
///
/// NOTE: This isn't an official data type, but multiple flag atoms exist,
/// so this makes them easier to represent. The *real* underlying type
/// is `SignedInteger`.
Bool(bool),
/// Unknown data
///
/// Due to the number of possible types, there are many
Expand Down
17 changes: 17 additions & 0 deletions src/mp4/ilst/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ where

continue;
},
b"cpil" | b"hdvd" | b"pcst" | b"pgap" | b"shwm" => {
if let Some(atom_data) = parse_data_inner(&mut ilst_reader, &atom)? {
if let Some((_, content)) = atom_data.first() {
let data = match content[..] {
[0, ..] => AtomData::Bool(false),
_ => AtomData::Bool(true),
};

tag.atoms.push(Atom {
ident: AtomIdent::Fourcc(*fourcc),
data: AtomDataStorage::Single(data),
})
}
}

continue;
},
_ => {},
}
}
Expand Down
1 change: 1 addition & 0 deletions src/mp4/ilst/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ where
AtomData::Picture(ref pic) => write_picture(pic, writer)?,
AtomData::SignedInteger(int) => write_signed_int(*int, writer)?,
AtomData::UnsignedInteger(uint) => write_unsigned_int(*uint, writer)?,
AtomData::Bool(b) => write_signed_int(i32::from(*b), writer)?,
AtomData::Unknown { code, ref data } => write_data(*code, data, writer)?,
};
}
Expand Down