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
26 /** Audio format dependent information. */
28 /** The number of chunks this audio file contains. */
29 long unsigned chunks_total
;
30 /** The length of the audio file in seconds. */
31 long unsigned seconds_total
;
32 /** A string that gets filled in by the audio format handler. */
35 * The table that specifies the offset of the individual pieces in
36 * the current audio file.
38 uint32_t *chunk_table
;
39 /** Period of time between sending data chunks. */
40 struct timeval chunk_tv
;
41 /** End of file timeout - Do not load new audio file until this time. */
42 struct timeval eof_tv
;
44 * The position of the header within the audio file. Ignored if \a
45 * header_len equals zero.
47 uint32_t header_offset
;
49 * The header is needed by senders in case a new client connects in the
50 * middle of the stream. The length of the header defaults to zero
51 * which means that this audio format does not need any special header
52 * treatment. The audio format handler does not need to set this to
56 /** The number of channels. */
58 /** Frequency in Hz. */
60 /** Exact meaning depends on audio format. */
65 * Structure for audio format handling.
67 * There's one such struct for each supported audio format. Initially, only \a
68 * name and \a init are defined. During the startup process, para_server calls
69 * the \a init function of each audio format handler which is expected to fill
70 * in the other part of this struct.
72 struct audio_format_handler
{
73 /** Name of the audio format. */
76 * Pointer to the audio format handler's init function.
78 * Must initialize all function pointers and is assumed to succeed.
80 void (*init
)(struct audio_format_handler
*);
81 /** Typical file endings for files that can be handled by this afh. */
82 const char **suffixes
;
84 * Check if this audio format handler can handle the file.
86 * This is a pointer to a function returning whether a given file is
87 * valid for this audio format. A negative return value indicates that
88 * this audio format handler is unable to decode the given file. On
89 * success, the function must return a positive value and fill in the
90 * given struct afh_info.
94 int (*get_file_info
)(char *map
, size_t numbytes
, int fd
,
95 struct afh_info
*afi
);
99 int guess_audio_format(const char *name
);
100 int compute_afhi(const char *path
, char *data
, size_t size
,
101 int fd
, struct afh_info
*afhi
);
102 const char *audio_format_name(int);
103 void afh_get_chunk(long unsigned chunk_num
, struct afh_info
*afhi
,
104 void *map
, const char **buf
, size_t *len
);
105 uint32_t afh_get_largest_chunk_size(struct afh_info
*afhi
);
106 void afh_get_header(struct afh_info
*afhi
, void *map
, const char **buf
, size_t *len
);
107 char *make_taginfo(char *title
, char *artist
, char *album
, char *year
,