1 // This Source Code Form is subject to the terms of the Mozilla Public 2 // License, v. 2.0. If a copy of the MPL was not distributed with this 3 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 #ifndef MP4PARSE_CAPI_H 10 #define MP4PARSE_CAPI_H 11 12 // THIS FILE IS AUTOGENERATED BY mp4parse_capi/build.rs - DO NOT EDIT 13 14 #include <stdint.h> 15 #include <stdlib.h> 16 #include <stdbool.h> 17 18 typedef enum { 19 MP4PARSE_CODEC_UNKNOWN, 20 MP4PARSE_CODEC_AAC, 21 MP4PARSE_CODEC_FLAC, 22 MP4PARSE_CODEC_OPUS, 23 MP4PARSE_CODEC_AVC, 24 MP4PARSE_CODEC_VP9, 25 MP4PARSE_CODEC_MP3, 26 MP4PARSE_CODEC_MP4V, 27 MP4PARSE_CODEC_JPEG, 28 MP4PARSE_CODEC_AC3, 29 MP4PARSE_CODEC_EC3, 30 MP4PARSE_CODEC_ALAC, 31 } Mp4parseCodec; 32 33 typedef enum { 34 MP4PARSE_STATUS_OK = 0, 35 MP4PARSE_STATUS_BAD_ARG = 1, 36 MP4PARSE_STATUS_INVALID = 2, 37 MP4PARSE_STATUS_UNSUPPORTED = 3, 38 MP4PARSE_STATUS_EOF = 4, 39 MP4PARSE_STATUS_IO = 5, 40 MP4PARSE_STATUS_OOM = 6, 41 } Mp4parseStatus; 42 43 typedef enum { 44 MP4PARSE_TRACK_TYPE_VIDEO = 0, 45 MP4PARSE_TRACK_TYPE_AUDIO = 1, 46 } Mp4parseTrackType; 47 48 typedef struct Mp4parseParser Mp4parseParser; 49 50 typedef struct { 51 uint64_t fragment_duration; 52 } Mp4parseFragmentInfo; 53 54 typedef struct { 55 uint64_t start_offset; 56 uint64_t end_offset; 57 int64_t start_composition; 58 int64_t end_composition; 59 int64_t start_decode; 60 bool sync; 61 } Mp4parseIndice; 62 63 typedef struct { 64 uint32_t length; 65 const uint8_t *data; 66 const Mp4parseIndice *indices; 67 } Mp4parseByteData; 68 69 typedef struct { 70 Mp4parseByteData data; 71 } Mp4parsePsshInfo; 72 73 typedef struct { 74 uint32_t is_encrypted; 75 uint8_t iv_size; 76 Mp4parseByteData kid; 77 } Mp4parseSinfInfo; 78 79 typedef struct { 80 uint16_t channels; 81 uint16_t bit_depth; 82 uint32_t sample_rate; 83 uint16_t profile; 84 Mp4parseByteData codec_specific_config; 85 Mp4parseByteData extra_data; 86 Mp4parseSinfInfo protected_data; 87 } Mp4parseTrackAudioInfo; 88 89 typedef struct { 90 Mp4parseTrackType track_type; 91 Mp4parseCodec codec; 92 uint32_t track_id; 93 uint64_t duration; 94 int64_t media_time; 95 } Mp4parseTrackInfo; 96 97 typedef struct { 98 uint32_t display_width; 99 uint32_t display_height; 100 uint16_t image_width; 101 uint16_t image_height; 102 uint16_t rotation; 103 Mp4parseByteData extra_data; 104 Mp4parseSinfInfo protected_data; 105 } Mp4parseTrackVideoInfo; 106 107 typedef struct { 108 intptr_t (*read)(uint8_t*, size_t, void*); 109 void *userdata; 110 } Mp4parseIo; 111 112 // THIS FILE IS AUTOGENERATED BY mp4parse_capi/build.rs - DO NOT EDIT 113 114 /* 115 * Free an `Mp4parseParser*` allocated by `mp4parse_new()`. 116 */ 117 void mp4parse_free(Mp4parseParser *parser); 118 119 /* 120 * Fill the supplied `Mp4parseFragmentInfo` with metadata from fragmented file. 121 */ 122 Mp4parseStatus mp4parse_get_fragment_info(Mp4parseParser *parser, Mp4parseFragmentInfo *info); 123 124 Mp4parseStatus mp4parse_get_indice_table(Mp4parseParser *parser, 125 uint32_t track_id, 126 Mp4parseByteData *indices); 127 128 /* 129 * Get 'pssh' system id and 'pssh' box content for eme playback. 130 * 131 * The data format of the `info` struct passed to gecko is: 132 * 133 * - system id (16 byte uuid) 134 * - pssh box size (32-bit native endian) 135 * - pssh box content (including header) 136 */ 137 Mp4parseStatus mp4parse_get_pssh_info(Mp4parseParser *parser, Mp4parsePsshInfo *info); 138 139 /* 140 * Fill the supplied `Mp4parseTrackAudioInfo` with metadata for `track`. 141 */ 142 Mp4parseStatus mp4parse_get_track_audio_info(Mp4parseParser *parser, 143 uint32_t track_index, 144 Mp4parseTrackAudioInfo *info); 145 146 /* 147 * Return the number of tracks parsed by previous `mp4parse_read()` call. 148 */ 149 Mp4parseStatus mp4parse_get_track_count(const Mp4parseParser *parser, uint32_t *count); 150 151 /* 152 * Fill the supplied `Mp4parseTrackInfo` with metadata for `track`. 153 */ 154 Mp4parseStatus mp4parse_get_track_info(Mp4parseParser *parser, 155 uint32_t track_index, 156 Mp4parseTrackInfo *info); 157 158 /* 159 * Fill the supplied `Mp4parseTrackVideoInfo` with metadata for `track`. 160 */ 161 Mp4parseStatus mp4parse_get_track_video_info(Mp4parseParser *parser, 162 uint32_t track_index, 163 Mp4parseTrackVideoInfo *info); 164 165 /* 166 * A fragmented file needs mvex table and contains no data in stts, stsc, and stco boxes. 167 */ 168 Mp4parseStatus mp4parse_is_fragmented(Mp4parseParser *parser, 169 uint32_t track_id, 170 uint8_t *fragmented); 171 172 /* 173 * Allocate an `Mp4parseParser*` to read from the supplied `Mp4parseIo`. 174 */ 175 Mp4parseParser *mp4parse_new(const Mp4parseIo *io); 176 177 /* 178 * Run the `Mp4parseParser*` allocated by `mp4parse_new()` until EOF or error. 179 */ 180 Mp4parseStatus mp4parse_read(Mp4parseParser *parser); 181 182 // THIS FILE IS AUTOGENERATED BY mp4parse_capi/build.rs - DO NOT EDIT 183 184 #endif /* MP4PARSE_CAPI_H */ 185 186 #ifdef __cplusplus 187 } /* extern "C" */ 188 #endif 189