diff options
| author | Felix Kaaman <tmtu@tmtu.ee> | 2021-01-07 20:32:49 +0100 |
|---|---|---|
| committer | Felix Kaaman <tmtu@tmtu.ee> | 2021-01-07 20:32:49 +0100 |
| commit | 9e6e4962f2346a3fbd96ab3e6c331858ef6ec0d1 (patch) | |
| tree | 14b580295f71243def9c8df9c242c33f9f2c66a8 /src/boxes/url.rs | |
| download | fmp4-trunk.tar.gz fmp4-trunk.zip | |
Diffstat (limited to 'src/boxes/url.rs')
| -rw-r--r-- | src/boxes/url.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/boxes/url.rs b/src/boxes/url.rs new file mode 100644 index 0000000..91b471d --- /dev/null +++ b/src/boxes/url.rs @@ -0,0 +1,35 @@ +use four_cc::FourCC; + +use bytes::{BufMut, BytesMut}; + +use crate::Mp4BoxError; +use crate::{FullBoxHeader, Mp4Box}; + +pub struct DataEntryUrlBox { + pub location: String, +} + +impl Mp4Box for DataEntryUrlBox { + const NAME: FourCC = FourCC(*b"url "); + + fn get_full_box_header(&self) -> Option<FullBoxHeader> { + Some(FullBoxHeader::new(0, 0x000001)) + } + + fn content_size(&self) -> u64 { + self.location.as_bytes().len() as u64 + 1 + } + + fn write_box_contents(&self, writer: &mut BytesMut) -> Result<(), Mp4BoxError> { + let mut v = Vec::new(); + + v.extend(self.location.as_bytes()); + v.push(0); + + assert_eq!(v.len() as u64, self.content_size()); + + writer.put_slice(&v); + + Ok(()) + } +} |
