Initial revision 6759
[qball-mpd.git] / src / mp4ff / mp4ff.h
blob5fb485d77652f3920ce34f36b63be251df4887d1
1 /*
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ** Any non-GPL usage of this software or parts of this software is strictly
20 ** forbidden.
22 ** Commercial non-GPL licensing of this software is possible.
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
25 ** $Id: mp4ff.h,v 1.19 2004/01/11 15:52:18 menno Exp $
26 **/
28 #ifndef MP4FF_H
29 #define MP4FF_H
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
35 #include "mp4ff_int_types.h"
37 /* file callback structure */
38 typedef struct
40 uint32_t (*read)(void *user_data, void *buffer, uint32_t length);
41 uint32_t (*write)(void *udata, void *buffer, uint32_t length);
42 uint32_t (*seek)(void *user_data, uint64_t position);
43 uint32_t (*truncate)(void *user_data);
44 void *user_data;
45 } mp4ff_callback_t;
47 /* mp4 main file structure */
48 typedef void* mp4ff_t;
51 /* API */
53 mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f);
54 void mp4ff_close(mp4ff_t *f);
55 int32_t mp4ff_get_sample_duration(const mp4ff_t *f, const int32_t track, const int32_t sample);
56 int32_t mp4ff_get_sample_duration_use_offsets(const mp4ff_t *f, const int32_t track, const int32_t sample);
57 int64_t mp4ff_get_sample_position(const mp4ff_t *f, const int32_t track, const int32_t sample);
58 int32_t mp4ff_get_sample_offset(const mp4ff_t *f, const int32_t track, const int32_t sample);
59 int32_t mp4ff_find_sample(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip);
60 int32_t mp4ff_find_sample_use_offsets(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip);
62 int32_t mp4ff_read_sample(mp4ff_t *f, const int track, const int sample,
63 unsigned char **audio_buffer, unsigned int *bytes);
65 int32_t mp4ff_read_sample_v2(mp4ff_t *f, const int track, const int sample,unsigned char *buffer);//returns 0 on error, number of bytes read on success, use mp4ff_read_sample_getsize() to check buffer size needed
66 int32_t mp4ff_read_sample_getsize(mp4ff_t *f, const int track, const int sample);//returns 0 on error, buffer size needed for mp4ff_read_sample_v2() on success
70 int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int track,
71 unsigned char** ppBuf, unsigned int* pBufSize);
72 int32_t mp4ff_get_track_type(const mp4ff_t *f, const int track);
73 int32_t mp4ff_total_tracks(const mp4ff_t *f);
74 int32_t mp4ff_num_samples(const mp4ff_t *f, const int track);
75 int32_t mp4ff_time_scale(const mp4ff_t *f, const int track);
77 uint32_t mp4ff_get_avg_bitrate(const mp4ff_t *f, const int32_t track);
78 uint32_t mp4ff_get_max_bitrate(const mp4ff_t *f, const int32_t track);
79 int64_t mp4ff_get_track_duration(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown
80 int64_t mp4ff_get_track_duration_use_offsets(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown
81 uint32_t mp4ff_get_sample_rate(const mp4ff_t *f, const int32_t track);
82 uint32_t mp4ff_get_channel_count(const mp4ff_t * f,const int32_t track);
83 uint32_t mp4ff_get_audio_type(const mp4ff_t * f,const int32_t track);
86 /* metadata */
87 int mp4ff_meta_get_num_items(const mp4ff_t *f);
88 int mp4ff_meta_get_by_index(const mp4ff_t *f, unsigned int index,
89 char **item, char **value);
90 int mp4ff_meta_get_title(const mp4ff_t *f, char **value);
91 int mp4ff_meta_get_artist(const mp4ff_t *f, char **value);
92 int mp4ff_meta_get_writer(const mp4ff_t *f, char **value);
93 int mp4ff_meta_get_album(const mp4ff_t *f, char **value);
94 int mp4ff_meta_get_date(const mp4ff_t *f, char **value);
95 int mp4ff_meta_get_tool(const mp4ff_t *f, char **value);
96 int mp4ff_meta_get_comment(const mp4ff_t *f, char **value);
97 int mp4ff_meta_get_genre(const mp4ff_t *f, char **value);
98 int mp4ff_meta_get_track(const mp4ff_t *f, char **value);
99 int mp4ff_meta_get_disc(const mp4ff_t *f, char **value);
100 int mp4ff_meta_get_compilation(const mp4ff_t *f, char **value);
101 int mp4ff_meta_get_tempo(const mp4ff_t *f, char **value);
102 int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value);
103 #ifdef USE_TAGGING
105 /* metadata tag structure */
106 typedef struct
108 char *item;
109 char *value;
110 } mp4ff_tag_t;
112 /* metadata list structure */
113 typedef struct
115 mp4ff_tag_t *tags;
116 uint32_t count;
117 } mp4ff_metadata_t;
119 int32_t mp4ff_meta_update(mp4ff_callback_t *f,const mp4ff_metadata_t * data);
121 #endif
124 #ifdef __cplusplus
126 #endif /* __cplusplus */
128 #endif