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"
13 #define OV_AUDIO_FORMAT ""
17 #define AAC_AUDIO_FORMAT " aac"
19 #define AAC_AUDIO_FORMAT ""
22 #define SUPPORTED_AUDIO_FORMATS "mp3" OV_AUDIO_FORMAT AAC_AUDIO_FORMAT
26 /** Size of the audio_file info string. */
27 #define AUDIO_FILE_INFO_SIZE 256
29 /** Audio format dependent information. */
31 /** The number of chunks this audio file contains. */
32 long unsigned chunks_total;
33 /** The length of the audio file in seconds. */
34 long unsigned seconds_total;
35 /** A string that gets filled in by the audio format handler. */
36 char info_string[AUDIO_FILE_INFO_SIZE];
38 * The table that specifies the offset of the individual pieces in
39 * the current audio file.
41 uint32_t *chunk_table;
42 /** Period of time between sending data chunks. */
43 struct timeval chunk_tv;
44 /** End of file timeout - Do not load new audio file until this time. */
45 struct timeval eof_tv;
47 * The position of the header within the audio file. Ignored if \a
48 * header_len equals zero.
50 uint32_t header_offset;
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
59 /** The number of channels. */
61 /** Frequency in Hz. */
63 /** Exact meaning depends on audio format. */
68 * Structure for audio format handling.
70 * There's one such struct for each supported audio format. Initially, only \a
71 * name and \a init are defined. During the startup process, para_server calls
72 * the \a init function of each audio format handler which is expected to fill
73 * in the other part of this struct.
75 struct audio_format_handler {
76 /** Name of the audio format. */
79 * Pointer to the audio format handler's init function.
81 * Must initialize all function pointers and is assumed to succeed.
83 void (*init)(struct audio_format_handler*);
84 /** Typical file endings for files that can be handled by this afh. */
85 const char **suffixes;
87 * Check if this audio format handler can handle the file.
89 * This is a pointer to a function returning whether a given file is
90 * valid for this audio format. A negative return value indicates that
91 * this audio format handler is unable to decode the given file. On
92 * success, the function must return a positive value and fill in the
93 * given struct afh_info.
97 int (*get_file_info)(char *map, size_t numbytes,
98 struct afh_info *afi);
102 int guess_audio_format(const char *name);
103 int compute_afhi(const char *path, char *data, size_t size,
104 struct afh_info *afhi);
105 const char *audio_format_name(int);