http_send.c: Trivial whitespace and spelling cleanups.
[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 #define OV_AUDIO_FORMAT_ARRAY , "ogg"
13 #else
14 #define OV_AUDIO_FORMAT ""
15 #define OV_AUDIO_FORMAT_ARRAY
16 #endif
17
18 #ifdef HAVE_FAAD
19 #define AAC_AUDIO_FORMAT " aac"
20 #define AAC_AUDIO_FORMAT_ARRAY , "aac"
21 #else
22 #define AAC_AUDIO_FORMAT ""
23 #define AAC_AUDIO_FORMAT_ARRAY
24 #endif
25
26 #define SUPPORTED_AUDIO_FORMATS "mp3" OV_AUDIO_FORMAT AAC_AUDIO_FORMAT
27 #define SUPPORTED_AUDIO_FORMATS_ARRAY "mp3" OV_AUDIO_FORMAT_ARRAY \
28 AAC_AUDIO_FORMAT_ARRAY, NULL
29
30 /** \endcond */
31
32 /** size of the audio_file info string */
33 #define AUDIO_FILE_INFO_SIZE 16384
34
35 struct audio_format_info {
36 /** the number of chunks this audio file contains */
37 long unsigned chunks_total;
38 /** the length of the audio file in seconds */
39 long unsigned seconds_total;
40 /** a string that gets filled in by the audio format handler */
41 char info_string[AUDIO_FILE_INFO_SIZE];
42 /**
43 * the table that specifies the offset of the individual pieces in
44 * the current audio file.
45 */
46 size_t *chunk_table;
47 /** period of time between sending data chunks */
48 struct timeval chunk_tv;
49 /** end of file timeout - do not load new audio file until this time */
50 struct timeval eof_tv;
51 /**
52 * The header is needed by senders in case a new client connects in the
53 * middle of the stream. The length of the header defaults to zero
54 * which means that this audio format does not need any special header
55 * treatment. The audio format handler does not need to set this to
56 * zero in this case.
57 */
58 unsigned header_len;
59 /**
60 * The position of the header within the audio file. Ignored if \a
61 * header_len equals zero.
62 */
63 unsigned header_offset;
64 uint8_t channels;
65 uint16_t frequency;
66 uint16_t bitrate;
67 };
68
69 /**
70 * structure for audio format handling
71 *
72 * There's exactly one such struct for each supported audio format. Initially,
73 * only \a name and \a init are defined. During the startup process,
74 * para_server calls the \a init function of each audio format handler which is
75 * expected to fill in all the other function pointers.
76 */
77 struct audio_format_handler {
78 /**
79 * name of the audio format
80 */
81 const char *name;
82 /**
83 * typical file endings for files that can be handled by this afh.
84 */
85 const char **suffixes;
86 /**
87 * pointer to the audio format handler's init function
88 *
89 * Must initialize all function pointers and is assumed to succeed.
90 */
91 void (*init)(struct audio_format_handler*);
92 /**
93 * check if this audio format handler can handle the file
94 *
95 * This is a pointer to a function returning whether a given file is
96 * valid for this audio format. A negative return value indicates that
97 * this audio format handler did not recognize the given file. On
98 * success, the function must return a positive value and fill in the
99 * given struct audio_format_info.
100 *
101 * \sa struct audio_format_info
102 */
103 int (*get_file_info)(char *map, size_t numbytes,
104 struct audio_format_info *afi);
105 };
106