7925aee32de83cb33c7ce586649edadd9b89605a
2 * Copyright (C) 2005-2006 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 */
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 * optional audio file header
66 * This is read from a sender in case a new client connects in the
67 * middle of the stream. The audio format handler does not need to set
68 * this if the audio format does not need any special header treatment.
69 * If non-NULL, it must point to a buffer holding the current audio
73 /** the length of the header, ignored if \a header is \p NULL */
78 * structure for audio format handling
80 * There's exactly one such struct for each supported audio format. Initially,
81 * only \a name and \a init are defined. During the startup process,
82 * para_server calls the \a init function of each audio format handler which is
83 * expected to fill in all the other function pointers.
85 struct audio_format_handler
{
87 * name of the audio format
91 * typical file endings for files that can be handled by this afh.
93 const char **suffixes
;
95 * pointer to the audio format handler's init function
97 * Must initialize all function pointers and is assumed to succeed.
99 void (*init
)(struct audio_format_handler
*);
101 * check if this audio format handler can handle the file
103 * This is a pointer to a function returning whether a given file is
104 * valid for this audio format. A negative return value indicates that
105 * this audio format handler did not recognize the given file. On
106 * success, the function must return a positive value and fill in the
107 * given struct audio_format_info.
109 * \sa struct audio_format_info
111 int (*get_file_info
)(FILE *audio_file
, char *map
, off_t numbytes
,
112 struct audio_format_info
*afi
);