X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afh.h;h=e365df86569337ba767cfe9601f81c3ba39c939c;hp=77874108a056c73707f2b39516168558bf1b4e80;hb=a15abef9eee4b8369b3ce8fcaad91a2e0c879df5;hpb=4cfbdce5e460934d4724cac63aa718ea6c7af199 diff --git a/afh.h b/afh.h index 77874108..e365df86 100644 --- a/afh.h +++ b/afh.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2006 Andre Noll + * Copyright (C) 2005-2007 Andre Noll * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,6 +41,42 @@ /** \endcond */ +/** size of the audio_file info string */ +#define AUDIO_FILE_INFO_SIZE 16384 + +struct audio_format_info { + /** the number of chunks this audio file contains */ + long unsigned chunks_total; + /** the length of the audio file in seconds */ + int seconds_total; + /** a string that gets filled in by the audio format handler */ + char info_string[AUDIO_FILE_INFO_SIZE]; + /** + * the table that specifies the offset of the individual pieces in + * the current audio file. + */ + size_t *chunk_table; + /** period of time between sending data chunks */ + struct timeval chunk_tv; + /** end of file timeout - do not load new audio file until this time */ + struct timeval eof_tv; + /** + * optional audio file header + * + * This is read from a sender in case a new client connects in the + * middle of the stream. The audio format handler does not need to set + * this if the audio format does not need any special header treatment. + * If non-NULL, it must point to a buffer holding the current audio + * file header. + */ + char *header; + /** the length of the header, ignored if \a header is \p NULL */ + unsigned header_len; + uint8_t channels; + uint16_t frequency; + uint16_t bitrate; +}; + /** * structure for audio format handling * @@ -64,43 +100,18 @@ struct audio_format_handler { * Must initialize all function pointers and is assumed to succeed. */ void (*init)(struct audio_format_handler*); - /** - * period of time between sending data chunks - */ - struct timeval chunk_tv; /* length of one chunk of data */ - /** - * end of file timeout - do not load new audio file until this time - * - */ - struct timeval eof_tv; /* timeout on eof */ - /** - * Pointer to the optional get-header function. - * - * This is called from a sender in case a new client connects in the middle of - * the stream. The audio format handler may set this to NULL to indicate that - * this audio format does not need any special header treatment. If non-NULL, - * the function it points to must return a pointer to a buffer holding the - * current audio file header, together with the header length. - */ - char *(*get_header_info)(int *header_len); /** * check if this audio format handler can handle the file * - * This is a pointer to a function returning whether a given file is valid for - * this audio format. A negative return value indicates that this audio format - * handler did not recognize the given file. On success, the function is - * expected to return a positive value and to fill in \arg info_str, \arg - * chunks and \arg seconds appropriately and to return the chunk table - * via \a vss_chunk_table. - */ - int (*get_file_info)(FILE *audio_file, char *info_str, - long unsigned *chunks, int *seconds, size_t **vss_chunk_table); - /** - * cleanup function of this audio format handler + * This is a pointer to a function returning whether a given file is + * valid for this audio format. A negative return value indicates that + * this audio format handler did not recognize the given file. On + * success, the function must return a positive value and fill in the + * given struct audio_format_info. * - * This close function should deallocate any resources - * associated with the current audio file. In particular, it is responsible - * for closing the file handle. It is assumed to succeed. + * \sa struct audio_format_info */ - void (*close_audio_file)(void); + int (*get_file_info)(char *map, off_t numbytes, + struct audio_format_info *afi); }; +