2 * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file recv.h receiver-related structures and exported symbols of recv_common.c */
10 * describes one instance of a receiver
12 struct receiver_node {
13 /** points to the corresponding receiver */
14 struct receiver *receiver;
15 /** the output buffer */
17 /** the amount of bytes in \a buf */
19 /** receiver-specific data */
21 /** set to 1 if end of file is reached */
23 /** pointer to the eof member of the consumer */
25 /** pointer to the configuration data for this instance */
27 /** the task associated with this instance */
32 * describes one supported paraslash receiver
34 * \sa http_recv.c, ortp_recv.c
38 * the name of the receiver
42 * the receiver init function
44 * It must fill in all other function pointers and is assumed to succeed.
46 * \sa http_recv_init ortp_recv_init
48 void (*init)(struct receiver *r);
50 * the command line parser of the receiver
52 * It should check whether the command line options given by \a argc and \a
53 * argv are valid. On success, it should return a pointer to the
54 * receiver-specific configuration data determined by \a argc and \a argv.
55 * Note that this might be called more than once with different values of
56 * \a argc and \a argv.
58 void * (*parse_config)(int argc, char **argv);
60 * open one instance of the receiver
62 * This should allocate the output buffer of \a rn. and may also perform any
63 * other work necessary for retrieving the stream according to the
64 * configuration stored in the \a conf member of \a rn which is guaranteed to
65 * point to valid configuration data (as previously obtained from the config
68 * \sa receiver_node::conf, receiver_node::buf
70 int (*open)(struct receiver_node *rn);
72 * close this instance of the receiver
74 * It should free all resources associated with given receiver node that were
75 * allocated during the corresponding open call.
79 void (*close)(struct receiver_node *rn);
81 * deactivate the receiver
83 * Clean up what init has allocated.
85 void (*shutdown)(void);
87 * add file descriptors to fd_sets and compute timeout for select(2)
89 * The pre_select function gets called from the driving application before
90 * entering its select loop. The receiver may use this hook to add any file
91 * descriptors to the sets of file descriptors given by \a s.
93 * \sa select(2), time.c struct task, struct sched
95 void (*pre_select)(struct sched *s, struct task *t);
97 * evaluate the result from select()
99 * This hook gets called after the call to select(). It should check all file
100 * descriptors which were added to any of the the fd sets during the previous
101 * call to pre_select. According to the result, it may then use any
102 * non-blocking I/O to establish a connection or to receive the audio data.
104 * \sa select(2), struct receiver
106 void (*post_select)(struct sched *s, struct task *t);
111 extern void http_recv_init(struct receiver *r);
112 #define HTTP_RECEIVER {.name = "http", .init = http_recv_init},
113 extern void dccp_recv_init(struct receiver *r);
114 #define DCCP_RECEIVER {.name = "dccp", .init = dccp_recv_init},
117 extern void ortp_recv_init(struct receiver *r);
118 #define ORTP_RECEIVER {.name = "ortp", .init = ortp_recv_init},
120 #define ORTP_RECEIVER
123 extern struct receiver receivers[];
126 /** define an array of all available receivers */
127 #define DEFINE_RECEIVER_ARRAY struct receiver receivers[] = { \
133 void *check_receiver_arg(char *ra, int *receiver_num);