1 #ifndef AP_TYPES_H 2 #define AP_TYPES_H 3 4 // Atom version 1byte/ Atom flags 3 bytes; 0x00 00 00 00 5 #define AtomFlags_Data_Binary 0 6 7 // UTF-8, no termination 8 #define AtomFlags_Data_Text 1 9 10 // \x0D 11 #define AtomFlags_Data_JPEGBinary 13 12 13 // \x0E 14 #define AtomFlags_Data_PNGBinary 14 15 16 // \x15 for cpil, tmpo, rtng; iTMS atoms: cnID, atID, plID, geID, sfID, akID 17 #define AtomFlags_Data_UInt 21 18 19 // 0x58 for uuid atoms that contain files 20 #define AtomFlags_Data_uuid_binary 88 21 22 enum { 23 UTF8_iTunesStyle_256glyphLimited = 0, // no NULL termination 24 UTF8_iTunesStyle_Unlimited = 1, // no NULL termination 25 UTF8_iTunesStyle_Binary = 3, // no NULL termination, used in purl & egid 26 UTF8_3GP_Style = 8, // terminated with a NULL uint8_t 27 UTF16_3GP_Style = 16 // terminated with a NULL uint16_t 28 }; 29 30 enum { 31 UNDEFINED_STYLE = 0, 32 ITUNES_STYLE = 100, 33 THIRD_GEN_PARTNER = 300, // 3gpp files prior to 3gp6 34 THIRD_GEN_PARTNER_VER1_REL6 = 35 306, // 3GPP Release6 the first spec to contain the complement of assets 36 THIRD_GEN_PARTNER_VER1_REL7 = 307, // 3GPP Release7 introduces ID32 atoms 37 THIRD_GEN_PARTNER_VER2 = 320, // 3gp2 files 38 THIRD_GEN_PARTNER_VER2_REL_A = 39 321, // 3gp2 files, 3GPP2 C.S0050-A introduces 'gadi' 40 MOTIONJPEG2000 = 400 41 }; 42 43 #include "id3v2types.h" 44 struct AtomicInfo { 45 short AtomicNumber; 46 uint64_t AtomicStart; 47 uint64_t AtomicLength; 48 uint64_t AtomicLengthExtended; 49 char *AtomicName; 50 char *ReverseDNSname; 51 char *ReverseDNSdomain; 52 uint8_t AtomicContainerState; 53 uint8_t AtomicClassification; 54 uint32_t AtomicVerFlags; // used by versioned atoms and derivatives 55 uint16_t AtomicLanguage; // used by 3gp assets & ID32 atoms only 56 uint8_t AtomicLevel; 57 char *AtomicData; 58 int NextAtomNumber; // our first atom is numbered 0; the last points back to 59 // it - so watch it! 60 uint32_t 61 ancillary_data; // just contains a simple number for atoms that contains 62 // some interesting info (like stsd codec used) 63 uint8_t uuid_style; 64 char *uuid_ap_atomname; 65 ID3v2Tag *ID32_TagInfo; 66 }; 67 #include "id3v2.h" 68 69 // currently this is only used on Mac OS X to set type/creator for generic 70 // '.mp4' file extension files. The Finder 4 character code TYPE is what 71 // determines whether a file appears as a video or an audio file in a broad 72 // sense. 73 struct EmployedCodecs { 74 bool has_avc1; 75 bool has_mp4v; 76 bool has_drmi; 77 bool has_alac; 78 bool has_mp4a; 79 bool has_drms; 80 bool has_timed_text; // carries the URL - in the mdat stream at a specific 81 // time - thus it too is timed. 82 bool has_timed_jpeg; // no idea of podcasts support 'png ' or 'tiff' 83 bool has_timed_tx3g; // this IS true timed text stream 84 bool has_mp4s; // MPEG-4 Systems 85 bool has_rtp_hint; //'rtp '; implies hinting 86 }; 87 88 enum { 89 MEDIADATA__PRECEDES__MOOV = 2, 90 ROOT_META__PRECEDES__MOOV = 4, 91 MOOV_META__PRECEDES__TRACKS = 8, 92 MOOV_UDTA__PRECEDES__TRACKS = 16, 93 94 PADDING_AT_EOF = 0x1000000 95 }; 96 97 struct FreeAtomListing { 98 AtomicInfo *free_atom; 99 FreeAtomListing *next_free_listing; 100 }; 101 102 struct DynamicUpdateStat { 103 bool updage_by_padding; 104 bool reorder_moov; 105 bool moov_was_mooved; 106 bool prevent_dynamic_update; 107 108 uint32_t optimization_flags; 109 110 uint64_t padding_bytes; 111 short consolidated_padding_insertion; 112 113 AtomicInfo *last_trak_child_atom; 114 AtomicInfo *moov_atom; 115 AtomicInfo *moov_udta_atom; 116 AtomicInfo *iTunes_list_handler_atom; 117 AtomicInfo *moov_meta_atom; 118 AtomicInfo *file_meta_atom; 119 AtomicInfo *first_mdat_atom; 120 AtomicInfo *first_movielevel_metadata_tagging_atom; 121 AtomicInfo *initial_update_atom; 122 AtomicInfo *first_otiose_freespace_atom; 123 AtomicInfo *padding_store; 124 AtomicInfo *padding_resevoir; 125 FreeAtomListing *first_padding_atom; 126 FreeAtomListing *last_padding_atom; 127 }; 128 129 struct padding_preferences { 130 uint32_t default_padding_size; 131 uint32_t minimum_required_padding_size; 132 uint32_t maximum_present_padding_size; 133 }; 134 135 // Structure that defines the known atoms used by mpeg-4 family of 136 // specifications. 137 typedef struct { 138 const char *known_atom_name; 139 const char *known_parent_atoms[5]; // max known to be tested 140 uint32_t container_state; 141 int presence_requirements; 142 uint32_t box_type; 143 } atomDefinition; 144 145 typedef struct { 146 uint8_t uuid_form; 147 char *binary_uuid; 148 char *uuid_AP_atom_name; 149 } uuid_vitals; 150 151 enum { 152 PARENT_ATOM = 0, // container atom 153 SIMPLE_PARENT_ATOM = 1, 154 DUAL_STATE_ATOM = 155 2, // acts as both parent (contains other atoms) & child (carries data) 156 CHILD_ATOM = 3, // atom that does NOT contain any children 157 UNKNOWN_ATOM_TYPE = 4 158 }; 159 160 enum { 161 REQUIRED_ONCE = 30, // means total of 1 atom per file (or total of 1 if 162 // parent atom is required to be present) 163 REQUIRED_ONE = 31, // means 1 atom per container atom; totalling many per file 164 // (or required present if optional parent atom is present) 165 REQUIRED_VARIABLE = 166 32, // means 1 or more atoms per container atom are required to be present 167 PARENT_SPECIFIC = 168 33, // means (iTunes-style metadata) the atom defines how many are 169 // present; most are MAX 1 'data' atoms; 'covr' is ?unlimited? 170 OPTIONAL_ONCE = 34, // means total of 1 atom per file, but not required 171 OPTIONAL_ONE = 35, // means 1 atom per container atom but not required; many 172 // may be present in a file 173 OPTIONAL_MANY = 36, // means more than 1 occurrence per container atom 174 REQ_FAMILIAL_ONE = 175 OPTIONAL_ONE, // means that one of the family of atoms defined by the spec 176 // is required by the parent atom 177 UKNOWN_REQUIREMENTS = 38 178 }; 179 180 enum { 181 SIMPLE_ATOM = 50, 182 VERSIONED_ATOM = 51, 183 EXTENDED_ATOM = 52, 184 PACKED_LANG_ATOM = 53, 185 UNKNOWN_ATOM = 59 186 }; 187 188 enum { 189 PRINT_DATA = 1, 190 PRINT_FREE_SPACE = 2, 191 PRINT_PADDING_SPACE = 4, 192 PRINT_USER_DATA_SPACE = 8, 193 PRINT_MEDIA_SPACE = 16, 194 EXTRACT_ARTWORK = 20, 195 EXTRACT_ALL_UUID_BINARYS = 21 196 }; 197 198 typedef struct { 199 const char *stik_string; 200 uint8_t stik_number; 201 } stiks; 202 203 typedef struct { 204 const char *storefront_string; 205 uint32_t storefront_number; 206 } sfIDs; 207 208 typedef struct { 209 const char *iso639_2_code; 210 const char *iso639_1_code; 211 const char *language_in_english; 212 } iso639_lang; 213 214 typedef struct { 215 const char *media_rating; 216 const char *media_rating_cli_str; 217 } m_ratings; 218 219 typedef struct { 220 const char *genre_id_movie_string; 221 uint16_t genre_id_movie_value; 222 } geIDMovie; 223 224 typedef struct { 225 const char *genre_id_tv_string; 226 uint16_t genre_id_tv_value; 227 } geIDTV; 228 229 enum { UNIVERSAL_UTF8, WIN32_UTF16 }; 230 231 enum { FORCE_M4B_TYPE = 85, NO_TYPE_FORCING = 90 }; 232 233 enum { FILE_LEVEL_ATOM, MOVIE_LEVEL_ATOM, ALL_TRACKS_ATOM, SINGLE_TRACK_ATOM }; 234 235 enum { 236 UUID_DEPRECATED_FORM, 237 UUID_SHA1_NAMESPACE, 238 UUID_AP_SHA1_NAMESPACE, 239 UUID_OTHER 240 }; 241 242 /* Declarations of functions and data types used for SHA1 sum 243 library functions. 244 Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc. 245 */ 246 247 typedef struct { 248 uint32_t time_low; 249 uint16_t time_mid; 250 uint16_t time_hi_and_version; 251 uint8_t clock_seq_hi_and_reserved; 252 uint8_t clock_seq_low; 253 unsigned char node[6]; 254 } ap_uuid_t; 255 256 typedef uint32_t md5_uint32; 257 258 /* Structure to save state of computation between the single steps. */ 259 struct sha1_ctx { 260 md5_uint32 A; 261 md5_uint32 B; 262 md5_uint32 C; 263 md5_uint32 D; 264 md5_uint32 E; 265 266 md5_uint32 total[2]; 267 md5_uint32 buflen; 268 char buffer[128]; // char buffer[128] __attribute__ ((__aligned__ (__alignof__ 269 // (md5_uint32)))); 270 }; 271 272 typedef struct { // if any of these are unused, they are set to 0xFF 273 uint8_t od_profile_level; 274 uint8_t scene_profile_level; 275 uint8_t audio_profile; 276 uint8_t video_profile_level; 277 uint8_t graphics_profile_level; 278 } iods_OD; 279 280 typedef struct { 281 uint64_t creation_time; 282 uint64_t modified_time; 283 uint64_t duration; 284 bool track_enabled; 285 unsigned char unpacked_lang[4]; 286 char track_hdlr_name[100]; 287 char encoder_name[100]; 288 289 uint32_t track_type; 290 uint32_t track_codec; 291 uint32_t protected_codec; 292 293 bool contains_esds; 294 295 uint64_t section3_length; 296 uint64_t section4_length; 297 uint8_t ObjectTypeIndication; 298 uint32_t max_bitrate; 299 uint32_t avg_bitrate; 300 uint64_t section5_length; 301 uint8_t descriptor_object_typeID; 302 uint16_t channels; 303 uint64_t section6_length; // unused 304 305 // specifics 306 uint8_t m4v_profile; 307 uint8_t avc_version; 308 uint8_t profile; 309 uint8_t level; 310 uint16_t video_height; 311 uint16_t video_width; 312 uint32_t macroblocks; 313 uint64_t sample_aggregate; 314 uint16_t amr_modes; 315 316 uint8_t type_of_track; 317 318 } TrackInfo; 319 320 typedef struct { 321 uint64_t creation_time; 322 uint64_t modified_time; 323 uint32_t timescale; 324 uint32_t duration; 325 uint32_t playback_rate; // fixed point 16.16 326 uint16_t volume; // fixed 8.8 point 327 328 double seconds; 329 double simple_bitrate_calc; 330 331 bool contains_iods; 332 } MovieInfo; 333 334 typedef struct { 335 uint8_t total_tracks; 336 uint8_t track_num; 337 short track_atom; 338 } Trackage; 339 340 typedef struct { 341 uint8_t hours; 342 uint8_t minutes; 343 uint8_t seconds; 344 double rem_millisecs; 345 } ap_time; 346 347 enum { 348 UNKNOWN_TRACK = 0, 349 VIDEO_TRACK = 2, 350 AUDIO_TRACK = 4, 351 DRM_PROTECTED_TRACK = 8, 352 OTHER_TRACK = 16 353 }; 354 355 enum { 356 MP4V_TRACK = 65, 357 AVC1_TRACK = 66, 358 S_AMR_TRACK = 67, 359 S263_TRACK = 68, 360 EVRC_TRACK = 69, 361 QCELP_TRACK = 70, 362 SMV_TRACK = 71 363 }; 364 365 enum { SHOW_TRACK_INFO = 2, SHOW_DATE_INFO = 4 }; 366 367 struct PicPrefs { 368 int max_dimension; 369 int dpi; 370 int max_Kbytes; 371 bool squareUp; 372 bool allJPEG; 373 bool allPNG; 374 bool addBOTHpix; 375 bool removeTempPix; 376 bool force_dimensions; 377 int force_height; 378 int force_width; 379 }; 380 381 #endif 382 383 /* vim:ts=2:sw=2:et: 384 */ 385