1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
mod atom_info;
mod moov;
mod properties;
mod read;
mod trak;
use crate::error::Result;
use crate::types::file::{AudioFile, FileType, TaggedFile};
use crate::types::properties::FileProperties;
use crate::types::tag::TagType;
use std::io::{Read, Seek};
cfg_if::cfg_if! {
if #[cfg(feature = "mp4_ilst")] {
pub(crate) mod ilst;
pub use atom_info::AtomIdent;
pub use ilst::atom::{Atom, AtomData, AdvisoryRating};
pub use ilst::Ilst;
pub mod constants {
pub use super::ilst::constants::*;
}
}
}
pub use crate::mp4::properties::{Mp4Codec, Mp4Properties};
pub struct Mp4File {
pub(crate) ftyp: String,
#[cfg(feature = "mp4_ilst")]
pub(crate) ilst: Option<Ilst>,
pub(crate) properties: Mp4Properties,
}
impl From<Mp4File> for TaggedFile {
fn from(input: Mp4File) -> Self {
Self {
ty: FileType::MP4,
properties: FileProperties::from(input.properties),
tags: {
#[cfg(feature = "mp4_ilst")]
if let Some(ilst) = input.ilst {
vec![ilst.into()]
} else {
Vec::new()
}
#[cfg(not(feature = "mp4_ilst"))]
Vec::new()
},
}
}
}
impl AudioFile for Mp4File {
type Properties = Mp4Properties;
fn read_from<R>(reader: &mut R, read_properties: bool) -> Result<Self>
where
R: Read + Seek,
{
read::read_from(reader, read_properties)
}
fn properties(&self) -> &Self::Properties {
&self.properties
}
#[allow(unreachable_code)]
fn contains_tag(&self) -> bool {
#[cfg(feature = "mp4_ilst")]
return self.ilst.is_some();
false
}
#[allow(unreachable_code, unused_variables)]
fn contains_tag_type(&self, tag_type: TagType) -> bool {
#[cfg(feature = "mp4_ilst")]
return tag_type == TagType::Mp4Ilst && self.ilst.is_some();
false
}
}
impl Mp4File {
pub fn ftyp(&self) -> &str {
self.ftyp.as_ref()
}
}
impl Mp4File {
crate::macros::tag_methods! {
#[cfg(feature = "mp4_ilst")]
ilst, Ilst
}
}