Get rid of E_WAITPID.
[paraslash.git] / afh.h
1 /*
2  * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** \file afh.h structures for audio format handling (para_server) */
8
9 /** \cond */
10 #ifdef HAVE_OGGVORBIS
11 #define OV_AUDIO_FORMAT " ogg"
12 #else
13 #define OV_AUDIO_FORMAT ""
14 #endif
15
16 #ifdef HAVE_FAAD
17 #define AAC_AUDIO_FORMAT " aac"
18 #else
19 #define AAC_AUDIO_FORMAT ""
20 #endif
21
22 #define SUPPORTED_AUDIO_FORMATS "mp3" OV_AUDIO_FORMAT AAC_AUDIO_FORMAT
23
24 /** \endcond */
25
26 /** size of the  audio_file info string */
27 #define AUDIO_FILE_INFO_SIZE 256
28
29 /**
30  * Audio format dependent information. Details vary between each audio format
31  * handler.
32  */
33 struct audio_format_info {
34         /** The number of chunks this audio file contains. */
35         long unsigned chunks_total;
36         /** The length of the audio file in seconds. */
37         long unsigned seconds_total;
38         /** A string that gets filled in by the audio format handler. */
39         char info_string[AUDIO_FILE_INFO_SIZE];
40         /**
41          * The table that specifies the offset of the individual pieces in
42          * the current audio file.
43          */
44         size_t *chunk_table;
45         /** Period of time between sending data chunks. */
46         struct timeval chunk_tv;
47         /** End of file timeout - Do not load new audio file until this time. */
48         struct timeval eof_tv;
49         /**
50          * The header is needed by senders in case a new client connects in the
51          * middle of the stream. The length of the header defaults to zero
52          * which means that this audio format does not need any special header
53          * treatment. The audio format handler does not need to set this to
54          * zero in this case.
55          */
56         unsigned header_len;
57         /**
58          * The position of the header within the audio file. Ignored if \a
59          * header_len equals zero.
60          */
61         unsigned header_offset;
62         /** The number of channels. */
63         uint8_t channels;
64         /** Frquency on Hz. */
65         uint16_t frequency;
66         /** Exact meaning depends on audio format. */
67         uint16_t bitrate;
68 };
69
70 /**
71  *  Structure for audio format handling.
72  *
73  *  There's one such struct for each supported audio format. Initially, only \a
74  *  name and \a init are defined. During the startup process, para_server calls
75  *  the \a init function of each audio format handler which is expected to fill
76  *  in the other part of this struct.
77  */
78 struct audio_format_handler {
79         /** Name of the audio format. */
80         const char *name;
81         /**
82          * Pointer to the audio format handler's init function.
83          *
84          * Must initialize all function pointers and is assumed to succeed.
85          */
86         void (*init)(struct audio_format_handler*);
87         /** Typical file endings for files that can be handled by this afh. */
88         const char **suffixes;
89         /**
90          * Check if this audio format handler can handle the file.
91          *
92          * This is a  pointer to a function returning whether a given file is
93          * valid for this audio format. A negative return value indicates that
94          * this audio format handler is unable to decode the given file. On
95          * success, the function must return a positive value and fill in the
96          * given struct audio_format_info.
97          *
98          * \sa struct audio_format_info
99          */
100         int (*get_file_info)(char *map, size_t numbytes,
101                 struct audio_format_info *afi);
102 };
103