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