2 * Copyright (C) 2005-2009 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
27 * The tags used by all audio format handlers.
29 * Paraslash only uses the more common tags. These are recognized
30 * for all supported audio formats.
33 /** TPE1 (id3v2) / ARTIST (vorbis) / ©ART (aac) */
35 /** TIT2/TITLE/©nam */
39 /** TALB/ALBUM/©alb */
41 /** COMM/COMMENT/©cmt */
45 /** Audio format dependent information. */
47 /** The number of chunks this audio file contains. */
48 long unsigned chunks_total
;
49 /** The length of the audio file in seconds. */
50 long unsigned seconds_total
;
51 /** Audio handler specific info about the file. */
53 /** Id3 tags, vorbis comments, aac tags. */
56 * The table that specifies the offset of the individual pieces in
57 * the current audio file.
59 uint32_t *chunk_table
;
60 /** Period of time between sending data chunks. */
61 struct timeval chunk_tv
;
63 * The position of the header within the audio file. Ignored if \a
64 * header_len equals zero.
66 uint32_t header_offset
;
68 * The header is needed by senders in case a new client connects in the
69 * middle of the stream. The length of the header defaults to zero
70 * which means that this audio format does not need any special header
71 * treatment. The audio format handler does not need to set this to
75 /** The number of channels. */
77 /** Frequency in Hz. */
79 /** Exact meaning depends on audio format. */
84 * Structure for audio format handling.
86 * There's one such struct for each supported audio format. Initially, only \a
87 * name and \a init are defined. During the startup process, para_server calls
88 * the \a init function of each audio format handler which is expected to fill
89 * in the other part of this struct.
91 struct audio_format_handler
{
92 /** Name of the audio format. */
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
*);
100 /** Typical file endings for files that can be handled by this afh. */
101 const char **suffixes
;
103 * Check if this audio format handler can handle the file.
105 * This is a pointer to a function returning whether a given file is
106 * valid for this audio format. A negative return value indicates that
107 * this audio format handler is unable to decode the given file. On
108 * success, the function must return a positive value and fill in the
109 * given struct afh_info.
111 * \sa struct afh_info
113 int (*get_file_info
)(char *map
, size_t numbytes
, int fd
,
114 struct afh_info
*afi
);
118 int guess_audio_format(const char *name
);
119 int compute_afhi(const char *path
, char *data
, size_t size
,
120 int fd
, struct afh_info
*afhi
);
121 const char *audio_format_name(int);
122 void afh_get_chunk(long unsigned chunk_num
, struct afh_info
*afhi
,
123 void *map
, const char **buf
, size_t *len
);
124 uint32_t afh_get_largest_chunk_size(struct afh_info
*afhi
);
125 void afh_get_header(struct afh_info
*afhi
, void *map
, const char **buf
, size_t *len
);