static int inbuf_size;
static unsigned char *inbuf;
static size_t inbuf_len;
-struct audio_format *af;
+struct audio_format_handler *af;
static size_t num_chunks;
static size_t entry;
/**
* the list of supported audio formats
*/
-struct audio_format afl[] = {
+struct audio_format_handler afl[] = {
#if 1
{
.name = "mp3",
return &the_timeout;
}
-static void afs_eof(struct audio_format *af)
+static void afs_eof(struct audio_format_handler *af)
{
struct timeval now;
int i;
*/
struct timeval *afs_preselect(void)
{
- struct audio_format *af = NULL;
+ struct audio_format_handler *af = NULL;
int i, format;
struct timeval *ret;
again:
void afs_send_chunk(void)
{
int i;
- struct audio_format *af;
+ struct audio_format_handler *af;
char *buf;
ssize_t ret;
struct timeval now, due;
* para_server calls the \a init function of each audio format handler which is
* expected to fill in all the other function pointers.
*/
-struct audio_format {
-/**
- *
- *
- * name of the audio format
- */
-const char *name;
-/**
- *
- *
- * pointer to the audio format handler's init function
- *
- * Must initialize all function pointers and is assumed to succeed.
- */
-void (*init)(void*);
-/**
- *
- *
- * 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.
-*/
-int (*get_file_info)(FILE *audio_file, char *info_str,
- long unsigned *chunks, int *seconds);
-/**
- *
- *
- * cleanup function of this audio format handler
- *
- * 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.
-*/
-void (*close_audio_file)(void);
-/**
- *
- *
- * jump to another position in the current audio file
- *
- * This is called if a client issued the ff or jmp command with \a request
- * being the number of the next chunk that should be sent out. Must return a
- * positive value on success and a negative value on errors.
-*/
-int (*reposition_stream)(long unsigned request);
-/**
- *
- *
- * function responsible for reading one data chunk.
- *
- * \a read_chunk() must return a pointer to the next chunk of data that should
- * be sent out, or \p NULL on errors or if the end of the file was encountered.
- *
- * If it returns non-NULL, \a len must contain the length of the returned
- * buffer (which may be zero if nothing has to be sent for some reason).
- * Otherwise, \a len is used to distinguish between the eof and the error case:
- * It must be zero in the eof case, or negative if an error occcured.
-*/
-char * (*read_chunk)(long unsigned chunk_num, ssize_t *len);
+struct audio_format_handler {
+ /**
+ * name of the audio format
+ */
+ const char *name;
+ /**
+ * typical file endings for files that can be handled by this afh.
+ */
+ const char **suffixes;
+ /**
+ * pointer to the audio format handler's init function
+ *
+ * Must initialize all function pointers and is assumed to succeed.
+ */
+ void (*init)(void*);
+ /**
+ * 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.
+ */
+ int (*get_file_info)(FILE *audio_file, char *info_str,
+ long unsigned *chunks, int *seconds);
+ /**
+ * cleanup function of this audio format handler
+ *
+ * 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.
+ */
+ void (*close_audio_file)(void);
+ /**
+ * jump to another position in the current audio file
+ *
+ * This is called if a client issued the ff or jmp command with \a request
+ * being the number of the next chunk that should be sent out. Must return a
+ * positive value on success and a negative value on errors.
+ */
+ int (*reposition_stream)(long unsigned request);
+ /**
+ * function responsible for reading one data chunk.
+ *
+ * \a read_chunk() must return a pointer to the next chunk of data that should
+ * be sent out, or \p NULL on errors or if the end of the file was encountered.
+ *
+ * If it returns non-NULL, \a len must contain the length of the returned
+ * buffer (which may be zero if nothing has to be sent for some reason).
+ * Otherwise, \a len is used to distinguish between the eof and the error case:
+ * It must be zero in the eof case, or negative if an error occcured.
+ */
+ char * (*read_chunk)(long unsigned chunk_num, ssize_t *len);
};
void afs_init(void);
extern struct misc_meta_data *mmd;
extern struct gengetopt_args_info conf;
extern struct audio_file_selector selectors[];
-extern struct audio_format afl[];
+extern struct audio_format_handler afl[];
extern struct sender senders[];
extern char *user_list;
struct sockaddr_in *in_addr;
int header_sent;
};
-static void dccp_pre_select(__a_unused struct audio_format *af, int *max_fileno, fd_set *rfds,
- __a_unused fd_set *wfds)
+static void dccp_pre_select(__a_unused struct audio_format_handler *af,
+ int *max_fileno, fd_set *rfds, __a_unused fd_set *wfds)
{
if (listen_fd < 0)
return;
*max_fileno = PARA_MAX(*max_fileno, listen_fd);
}
-static void dccp_post_select(__a_unused struct audio_format *af, fd_set *rfds,
- __a_unused fd_set *wfds)
+static void dccp_post_select(__a_unused struct audio_format_handler *af,
+ fd_set *rfds, __a_unused fd_set *wfds)
{
struct dccp_client *dc;
int ret;
return -E_DCCP_WRITE;
}
-static void dccp_send(__a_unused struct audio_format *af,
+static void dccp_send(__a_unused struct audio_format_handler *af,
long unsigned current_chunk,
__a_unused long unsigned chunks_sent, const char *buf, size_t len)
{
return 1;
}
-static void http_send(__a_unused struct audio_format *af,
+static void http_send(__a_unused struct audio_format_handler *af,
long unsigned current_chunk,
__a_unused long unsigned chunks_sent, const char *buf, size_t len)
{
return 0;
}
-static void http_post_select(__a_unused struct audio_format *af, fd_set *rfds,
+static void http_post_select(__a_unused struct audio_format_handler *af, fd_set *rfds,
fd_set *wfds)
{
int i = -1, match;
free(hc);
}
-static void http_pre_select(struct audio_format *af, int *max_fileno, fd_set *rfds,
- fd_set *wfds)
+static void http_pre_select(struct audio_format_handler *af, int *max_fileno,
+ fd_set *rfds, fd_set *wfds)
{
struct http_client *hc, *tmp;
static struct mp3info mp3;
static char mp3buf[8192];
static int chunk_size;
-static struct audio_format *af;
+static struct audio_format_handler *af;
static int header_frequency(struct mp3header *h)
{
static int header_len, oggbuf_len, vi_channels;
static char *header, *oggbuf;
static ssize_t *chunk_table, max_chunk_len;
-struct audio_format *af;
+struct audio_format_handler *af;
static long vi_sampling_rate, vi_bitrate, vi_bitrate_nominal,
num_chunks;
}
}
-static int need_extra_header(struct audio_format *af, long unsigned chunks_sent)
+static int need_extra_header(struct audio_format_handler *af,
+ long unsigned chunks_sent)
{
/* FIXME: No need to compute this on every run */
int mod = conf.ortp_header_interval_arg / (tv2ms(&af->chunk_tv) + 1);
return 1;
}
-static void ortp_send(struct audio_format *af, long unsigned current_chunk,
+static void ortp_send(struct audio_format_handler *af, long unsigned current_chunk,
long unsigned chunks_sent, const char *buf, size_t len)
{
struct ortp_target *ot, *tmp;
}
}
-static void ortp_pre_select(__a_unused struct audio_format *af,
+static void ortp_pre_select(__a_unused struct audio_format_handler *af,
__a_unused int *max_fileno, __a_unused fd_set *rfds,
__a_unused fd_set *wfds)
{
* command. Of course, \a buf is a pointer to the chunk of data which
* should be sent, and \a len is the length of this buffer.
*/
- void (*send)(struct audio_format *af, long unsigned current_chunk,
+ void (*send)(struct audio_format_handler *af, long unsigned current_chunk,
long unsigned chunks_sent, const char *buf, size_t len);
/** add file descriptors to fd_sets
*
*
* \sa select(2)
*/
- void (*pre_select)(struct audio_format *af, int *max_fileno, fd_set *rfds,
+ void (*pre_select)(struct audio_format_handler *af, int *max_fileno, fd_set *rfds,
fd_set *wfds);
/**
* handle the file descriptors which are ready for I/O
* set, this is the hook to check the result and do any I/O on those descriptors
* which are ready for reading/writing.
*/
- void (*post_select)(struct audio_format *af, fd_set *rfds, fd_set *wfds);
+ void (*post_select)(struct audio_format_handler *af, fd_set *rfds, fd_set *wfds);
/**
* terminate all connected clients
*
extern void dccp_send_init(struct sender *);
extern void http_send_init(struct sender *);
extern void ortp_send_init(struct sender *);
-extern struct audio_format afl[];
+extern struct audio_format_handler afl[];
/* TODO: This is better handled by autoconf */
/** the list of supported audio file selectors */