Debian Codegraph @

src/com/drew/imaging/quicktime/QuickTimeTypeChecker.java

raw symbols SCIP
1 /*
2 * Copyright 2002-2019 Drew Noakes and contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * https://drewnoakes.com/code/exif/
19 * https://github.com/drewnoakes/metadata-extractor
20 */
21 package com.drew.imaging.quicktime;
22
23 import com.drew.imaging.FileType;
24 import com.drew.imaging.TypeChecker;
25
26 import java.util.HashMap;
27
28 public class QuickTimeTypeChecker implements TypeChecker
29 {
30 private static final HashMap<String, FileType> _ftypMap;
31
32 static
33 {
34 _ftypMap = new HashMap<String, FileType>();
35
36 // http://www.ftyps.com
37
38 // QuickTime Mov
39 _ftypMap.put("moov", FileType.QuickTime);
40 _ftypMap.put("wide", FileType.QuickTime);
41 _ftypMap.put("mdat", FileType.QuickTime);
42 _ftypMap.put("free", FileType.QuickTime);
43 _ftypMap.put("qt ", FileType.QuickTime);
44 _ftypMap.put("3g2a", FileType.QuickTime);
45
46 // MP4
47 _ftypMap.put("3gp5", FileType.Mp4);
48 _ftypMap.put("avc1", FileType.Mp4);
49 _ftypMap.put("iso2", FileType.Mp4);
50 _ftypMap.put("isom", FileType.Mp4);
51 _ftypMap.put("M4A ", FileType.Mp4);
52 _ftypMap.put("M4B ", FileType.Mp4);
53 _ftypMap.put("M4P ", FileType.Mp4);
54 _ftypMap.put("M4V ", FileType.Mp4);
55 _ftypMap.put("M4VH", FileType.Mp4);
56 _ftypMap.put("M4VP", FileType.Mp4);
57 _ftypMap.put("mmp4", FileType.Mp4);
58 _ftypMap.put("mp41", FileType.Mp4);
59 _ftypMap.put("mp42", FileType.Mp4);
60 _ftypMap.put("mp71", FileType.Mp4);
61 _ftypMap.put("MSNV", FileType.Mp4);
62 _ftypMap.put("NDAS", FileType.Mp4);
63 _ftypMap.put("NDSC", FileType.Mp4);
64 _ftypMap.put("NDSH", FileType.Mp4);
65 _ftypMap.put("NDSM", FileType.Mp4);
66 _ftypMap.put("NDSP", FileType.Mp4);
67 _ftypMap.put("NDSS", FileType.Mp4);
68 _ftypMap.put("NDXC", FileType.Mp4);
69 _ftypMap.put("NDXH", FileType.Mp4);
70 _ftypMap.put("NDXM", FileType.Mp4);
71 _ftypMap.put("NDXP", FileType.Mp4);
72 _ftypMap.put("NDXS", FileType.Mp4);
73 _ftypMap.put("nvr1", FileType.Mp4);
74
75 // HEIF
76 _ftypMap.put("mif1", FileType.Heif);
77 _ftypMap.put("msf1", FileType.Heif);
78 _ftypMap.put("heic", FileType.Heif);
79 _ftypMap.put("heix", FileType.Heif);
80 _ftypMap.put("hevc", FileType.Heif);
81 _ftypMap.put("hevx", FileType.Heif);
82
83 // CRX
84 _ftypMap.put("crx ", FileType.Crx);
85 }
86
87 @Override
88 public int getByteCount()
89 {
90 return 12;
91 }
92
93 @Override
94 public FileType checkType(byte[] bytes)
95 {
96 // Test at offset 4 for Base Media Format (i.e. QuickTime, MP4, etc...) identifier "ftyp"
97 // plus four identifying characters.
98
99 if (bytes[4] == 'f' &&
100 bytes[5] == 't' &&
101 bytes[6] == 'y' &&
102 bytes[7] == 'p') {
103
104 String fourCC = new String(bytes, 8, 4);
105
106 FileType t = _ftypMap.get(fourCC);
107
108 if (t != null)
109 return t;
110
111 return FileType.QuickTime;
112 }
113
114 return FileType.Unknown;
115 }
116 }