mp4_atom/moov/trak/mdia/minf/dinf/dref/
mod.rs1mod url;
2pub use url::*;
3
4use crate::*;
5
6#[derive(Debug, Clone, PartialEq, Eq, Default)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub struct Dref {
9 pub urls: Vec<Url>,
10}
11
12impl AtomExt for Dref {
13 type Ext = ();
14
15 const KIND_EXT: FourCC = FourCC::new(b"dref");
16
17 fn decode_body_ext<B: Buf>(buf: &mut B, _ext: ()) -> Result<Self> {
18 let entry_count = u32::decode(buf)?;
19 let mut urls = Vec::new();
20
21 for _ in 0..entry_count {
22 let url = Url::decode(buf)?;
23 urls.push(url);
24 }
25
26 Ok(Dref { urls })
27 }
28
29 fn encode_body_ext<B: BufMut>(&self, buf: &mut B) -> Result<()> {
30 (self.urls.len() as u32).encode(buf)?;
31
32 for url in &self.urls {
33 url.encode(buf)?;
34 }
35
36 Ok(())
37 }
38}