2 * Copyright (C) 2005-2010 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) */
10 * The tags used by all audio format handlers.
12 * Paraslash only uses the more common tags. These are recognized
13 * for all supported audio formats.
16 /** TPE1 (id3v2) / ARTIST (vorbis) / ©ART (aac) */
18 /** TIT2/TITLE/©nam */
22 /** TALB/ALBUM/©alb */
24 /** COMM/COMMENT/©cmt */
28 /** Audio format dependent information. */
30 /** The number of chunks this audio file contains. */
31 long unsigned chunks_total;
32 /** The length of the audio file in seconds. */
33 long unsigned seconds_total;
34 /** Audio handler specific info about the file. */
36 /** Id3 tags, vorbis comments, aac tags. */
39 * The table that specifies the offset of the individual pieces in
40 * the current audio file.
42 uint32_t *chunk_table;
43 /** Period of time between sending data chunks. */
44 struct timeval chunk_tv;
46 * The position of the header within the audio file. Ignored if \a
47 * header_len equals zero.
49 uint32_t header_offset;
51 * The header is needed by senders in case a new client connects in the
52 * middle of the stream. The length of the header defaults to zero
53 * which means that this audio format does not need any special header
54 * treatment. The audio format handler does not need to set this to
58 /** The number of channels. */
60 /** Frequency in Hz. */
62 /** Exact meaning depends on audio format. */
67 * Structure for audio format handling.
69 * There's one such struct for each supported audio format. Initially, only \a
70 * name and \a init are defined. During the startup process, para_server calls
71 * the \a init function of each audio format handler which is expected to fill
72 * in the other part of this struct.
74 struct audio_format_handler {
75 /** Name of the audio format. */
78 * Pointer to the audio format handler's init function.
80 * Must initialize all function pointers and is assumed to succeed.
82 void (*init)(struct audio_format_handler*);
83 /** Typical file endings for files that can be handled by this afh. */
84 const char **suffixes;
86 * Check if this audio format handler can handle the file.
88 * This is a pointer to a function returning whether a given file is
89 * valid for this audio format. A negative return value indicates that
90 * this audio format handler is unable to decode the given file. On
91 * success, the function must return a positive value and fill in the
92 * given struct afh_info.
96 int (*get_file_info)(char *map, size_t numbytes, int fd,
97 struct afh_info *afi);
101 int guess_audio_format(const char *name);
102 int compute_afhi(const char *path, char *data, size_t size,
103 int fd, struct afh_info *afhi);
104 const char *audio_format_name(int);
105 void afh_get_chunk(long unsigned chunk_num, struct afh_info *afhi,
106 void *map, const char **buf, size_t *len);
107 uint32_t afh_get_largest_chunk_size(struct afh_info *afhi);
108 void afh_get_header(struct afh_info *afhi, void *map, const char **buf, size_t *len);