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 256
36 * Audio format dependent information. Details vary between each audio format
39 struct audio_format_info {
40 /** The number of chunks this audio file contains. */
41 long unsigned chunks_total;
42 /** The length of the audio file in seconds. */
43 long unsigned seconds_total;
44 /** A string that gets filled in by the audio format handler. */
45 char info_string[AUDIO_FILE_INFO_SIZE];
47 * The table that specifies the offset of the individual pieces in
48 * the current audio file.
51 /** Period of time between sending data chunks. */
52 struct timeval chunk_tv;
53 /** End of file timeout - Do not load new audio file until this time. */
54 struct timeval eof_tv;
56 * The header is needed by senders in case a new client connects in the
57 * middle of the stream. The length of the header defaults to zero
58 * which means that this audio format does not need any special header
59 * treatment. The audio format handler does not need to set this to
64 * The position of the header within the audio file. Ignored if \a
65 * header_len equals zero.
67 unsigned header_offset;
68 /** The number of channels. */
70 /** Frquency on Hz. */
72 /** Exact meaning depends on audio format. */
77 * Structure for audio format handling.
79 * There's one such struct for each supported audio format. Initially, only \a
80 * name and \a init are defined. During the startup process, para_server calls
81 * the \a init function of each audio format handler which is expected to fill
82 * in the other part of this struct.
84 struct audio_format_handler {
85 /** Name of the audio format. */
88 * Pointer to the audio format handler's init function.
90 * Must initialize all function pointers and is assumed to succeed.
92 void (*init)(struct audio_format_handler*);
93 /** Typical file endings for files that can be handled by this afh. */
94 const char **suffixes;
96 * Check if this audio format handler can handle the file.
98 * This is a pointer to a function returning whether a given file is
99 * valid for this audio format. A negative return value indicates that
100 * this audio format handler is unable to decode the given file. On
101 * success, the function must return a positive value and fill in the
102 * given struct audio_format_info.
104 * \sa struct audio_format_info
106 int (*get_file_info)(char *map, size_t numbytes,
107 struct audio_format_info *afi);