Merge branch 'refs/heads/t/opus'
[paraslash.git] / ogg_afh_common.h
1 /*
2  * Copyright (C) 2010 Andre Noll <maan@tuebingen.mpg.de>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /**
8  * \file ogg_afh_common.h Structures and prototypes common to audio format
9  * handlers that use the ogg container format.
10  */
11
12 struct oac_custom_header *oac_custom_header_new(void);
13 void oac_custom_header_init(int serial, struct oac_custom_header *h);
14 int oac_custom_header_append(ogg_packet *op, struct oac_custom_header *h);
15 void oac_custom_header_flush(struct oac_custom_header *h);
16 size_t oac_custom_header_get(char **buf, struct oac_custom_header *h);
17
18 /**
19  * Callback structure provided by audio format handlers.
20  *
21  * All audio formats which utilize the ogg container format define a callback
22  * function whose purpose is to extract the meta information about the audio
23  * file from the first few ogg packets of the bitstream.
24  */
25 struct oac_callback_info {
26         /**
27          * ogg_get_file_info() calls this function for the first three ogg
28          * packets, or until the callback returns a non-positive value. If it
29          * returns negative, the audio file was not recognized by the audio
30          * format handler. If it returns zero, the audio file is considered
31          * valid, and no further processing by the callback is needed. In this
32          * case the header chunk, i.e. chunk number zero, is defined as the
33          * concatenation of all packets that have been processed by the
34          * callback.
35          */
36         int (*packet_callback)(ogg_packet *packet, int packet_num,
37                 int serial, struct afh_info *afhi, void *private_data);
38         /** Data specific to the audio format handler. */
39         void *private_data;
40 };
41
42 int oac_get_file_info(char *map, size_t numbytes, struct afh_info *afhi,
43                 struct oac_callback_info *ci);
44 int oac_rewrite_tags(const char *map, size_t mapsize, int fd,
45                 char *meta_packet, size_t meta_sz);