2 * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
19 /** \file afh.h structures for audio format handling (para_server) */
23 #define OV_AUDIO_FORMAT " ogg"
24 #define OV_AUDIO_FORMAT_ARRAY , "ogg"
26 #define OV_AUDIO_FORMAT ""
27 #define OV_AUDIO_FORMAT_ARRAY
31 #define AAC_AUDIO_FORMAT " aac"
32 #define AAC_AUDIO_FORMAT_ARRAY , "aac"
34 #define AAC_AUDIO_FORMAT ""
35 #define AAC_AUDIO_FORMAT_ARRAY
38 #define SUPPORTED_AUDIO_FORMATS "mp3" OV_AUDIO_FORMAT AAC_AUDIO_FORMAT
39 #define SUPPORTED_AUDIO_FORMATS_ARRAY "mp3" OV_AUDIO_FORMAT_ARRAY \
40 AAC_AUDIO_FORMAT_ARRAY, NULL
44 /** size of the audio_file info string */
45 #define AUDIO_FILE_INFO_SIZE 16384
47 struct audio_format_info {
48 /** the number of chunks this audio file contains */
49 long unsigned chunks_total;
50 /** the length of the audio file in seconds */
51 long unsigned seconds_total;
52 /** a string that gets filled in by the audio format handler */
53 char info_string[AUDIO_FILE_INFO_SIZE];
55 * the table that specifies the offset of the individual pieces in
56 * the current audio file.
59 /** period of time between sending data chunks */
60 struct timeval chunk_tv;
61 /** end of file timeout - do not load new audio file until this time */
62 struct timeval eof_tv;
64 * The header is needed by senders in case a new client connects in the
65 * middle of the stream. The length of the header defaults to zero
66 * which means that this audio format does not need any special header
67 * treatment. The audio format handler does not need to set this to
72 * The position of the header within the audio file. Ignored if \a
73 * header_len equals zero.
75 unsigned header_offset;
82 * structure for audio format handling
84 * There's exactly one such struct for each supported audio format. Initially,
85 * only \a name and \a init are defined. During the startup process,
86 * para_server calls the \a init function of each audio format handler which is
87 * expected to fill in all the other function pointers.
89 struct audio_format_handler {
91 * name of the audio format
95 * typical file endings for files that can be handled by this afh.
97 const char **suffixes;
99 * pointer to the audio format handler's init function
101 * Must initialize all function pointers and is assumed to succeed.
103 void (*init)(struct audio_format_handler*);
105 * check if this audio format handler can handle the file
107 * This is a pointer to a function returning whether a given file is
108 * valid for this audio format. A negative return value indicates that
109 * this audio format handler did not recognize the given file. On
110 * success, the function must return a positive value and fill in the
111 * given struct audio_format_info.
113 * \sa struct audio_format_info
115 int (*get_file_info)(char *map, size_t numbytes,
116 struct audio_format_info *afi);