2 * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file afh.h structures for audio format handling (para_server) */
11 #define OV_AUDIO_FORMAT " ogg"
12 #define OV_AUDIO_FORMAT_ARRAY , "ogg"
14 #define OV_AUDIO_FORMAT ""
15 #define OV_AUDIO_FORMAT_ARRAY
19 #define AAC_AUDIO_FORMAT " aac"
20 #define AAC_AUDIO_FORMAT_ARRAY , "aac"
22 #define AAC_AUDIO_FORMAT ""
23 #define AAC_AUDIO_FORMAT_ARRAY
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
32 /** size of the audio_file info string */
33 #define AUDIO_FILE_INFO_SIZE 16384
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];
43 * the table that specifies the offset of the individual pieces in
44 * the current audio file.
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;
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
60 * The position of the header within the audio file. Ignored if \a
61 * header_len equals zero.
63 unsigned header_offset;
70 * structure for audio format handling
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.
77 struct audio_format_handler {
79 * name of the audio format
83 * typical file endings for files that can be handled by this afh.
85 const char **suffixes;
87 * pointer to the audio format handler's init function
89 * Must initialize all function pointers and is assumed to succeed.
91 void (*init)(struct audio_format_handler*);
93 * check if this audio format handler can handle the file
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.
101 * \sa struct audio_format_info
103 int (*get_file_info)(char *map, size_t numbytes,
104 struct audio_format_info *afi);