]> git.tuebingen.mpg.de Git - paraslash.git/blob - mp4.h
mp4: Simplify and rename mp4ff_read_sample_getsize().
[paraslash.git] / mp4.h
1 typedef struct
2 {
3     uint32_t (*read)(void *user_data, void *buffer, uint32_t length);
4     uint32_t (*write)(void *udata, void *buffer, uint32_t length);
5     uint32_t (*seek)(void *user_data, uint64_t position);
6     uint32_t (*truncate)(void *user_data);
7     void *user_data;
8     uint32_t read_error;
9 } mp4ff_callback_t;
10
11 typedef struct
12 {
13     int32_t type;
14     int32_t channelCount;
15     int32_t sampleSize;
16     uint16_t sampleRate;
17     int32_t audioType;
18
19     /* stsd */
20     int32_t stsd_entry_count;
21
22     /* stsz */
23     int32_t stsz_sample_size;
24     int32_t stsz_sample_count;
25     int32_t *stsz_table;
26
27     /* stts */
28     int32_t stts_entry_count;
29     int32_t *stts_sample_count;
30     int32_t *stts_sample_delta;
31
32     /* stsc */
33     int32_t stsc_entry_count;
34     int32_t *stsc_first_chunk;
35     int32_t *stsc_samples_per_chunk;
36     int32_t *stsc_sample_desc_index;
37
38     /* stsc */
39     int32_t stco_entry_count;
40     int32_t *stco_chunk_offset;
41
42     /* ctts */
43     int32_t ctts_entry_count;
44     int32_t *ctts_sample_count;
45     int32_t *ctts_sample_offset;
46
47     /* esde */
48     uint8_t *decoderConfig;
49     int32_t decoderConfigLen;
50
51     uint32_t maxBitrate;
52     uint32_t avgBitrate;
53
54     uint32_t timeScale;
55     uint64_t duration;
56
57 } mp4ff_track_t;
58
59 #define MAX_TRACKS 1024
60
61 typedef struct
62 {
63     char *item;
64     char *value;
65     uint32_t len;
66 } mp4ff_tag_t;
67
68 typedef struct
69 {
70     mp4ff_tag_t *tags;
71     uint32_t count;
72 } mp4ff_metadata_t;
73
74 /* mp4 main file structure */
75 typedef struct
76 {
77     /* stream to read from */
78     mp4ff_callback_t *stream;
79     int64_t current_position;
80
81     int32_t moov_read;
82     uint64_t moov_offset;
83     uint64_t moov_size;
84     uint8_t last_atom;
85     uint64_t file_size;
86     uint32_t error;
87
88     /* mvhd */
89     int32_t time_scale;
90     int32_t duration;
91
92     /* incremental track index while reading the file */
93     int32_t total_tracks;
94
95     /* track data */
96     mp4ff_track_t *track[MAX_TRACKS];
97
98     /* metadata */
99     mp4ff_metadata_t tags;
100 } mp4ff_t;
101
102 void mp4ff_set_sample_position(mp4ff_t *f, const int32_t track, const int32_t sample);
103 int32_t mp4ff_total_tracks(const mp4ff_t *f);
104 void mp4ff_get_decoder_config(const mp4ff_t *f, const int track,
105                 unsigned char** ppBuf, unsigned int* pBufSize);
106 mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f);
107 void mp4ff_close(mp4ff_t *f);
108 int32_t mp4ff_get_sample_size(const mp4ff_t *f, int track, int sample);
109 uint32_t mp4ff_get_sample_rate(const mp4ff_t *f, const int32_t track);
110 uint32_t mp4ff_get_channel_count(const mp4ff_t * f,const int32_t track);
111 int32_t mp4ff_num_samples(const mp4ff_t *f, const int track);
112 mp4ff_t *mp4ff_open_read_metaonly(mp4ff_callback_t *f);
113
114 int mp4ff_meta_get_by_index(const mp4ff_t *f, unsigned int index,
115                             char **item, char **value);
116 int32_t mp4ff_meta_update(mp4ff_callback_t *f,const mp4ff_metadata_t * data);
117
118 int mp4ff_meta_get_num_items(const mp4ff_t *f);
119 int mp4ff_meta_get_artist(const mp4ff_t *f, char **value);
120 int mp4ff_meta_get_title(const mp4ff_t *f, char **value);
121 int mp4ff_meta_get_date(const mp4ff_t *f, char **value);
122 int mp4ff_meta_get_album(const mp4ff_t *f, char **value);
123 int mp4ff_meta_get_comment(const mp4ff_t *f, char **value);