Makefile.in: Remove special treatment of ortp_send/ortp_recv
[paraslash.git] / recv.h
1 /*
2  * Copyright (C) 2005-2006 Andre Noll <maan@systemlinux.org>
3  *
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  *
9  *     This program is distributed in the hope that it will be useful,
10  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *     GNU General Public License for more details.
13  *
14  *     You should have received a copy of the GNU General Public License
15  *     along with this program; if not, write to the Free Software
16  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17  */
18
19 /** \file recv.h receiver-relates structures and exported symbols of recv_common.c */
20
21 /**
22  * describes one instance of a receiver
23  */
24 struct receiver_node {
25         /** points to the corresponding receiver */
26         struct receiver *receiver;
27         /** the output buffer */
28         char *buf;
29         /** the amount of bytes in \a buf */
30         size_t loaded;
31         /** receiver-specific data */
32         void *private_data;
33         /** set to 1 if end of file is reached */
34         int eof;
35         /** pointer to the configuration data for this instance */
36         void *conf;
37 };
38
39 /**
40  * describes one supported paraslash receiver
41  *
42  * \sa http_recv.c, ortp_recv.c
43  */
44 struct receiver {
45 /**
46  *
47  *
48  * the name of the receiver
49  */
50         const char *name;
51 /**
52  *
53  *
54  * the receiver init function
55  *
56  * It must fill in all other function pointers and is assumed to succeed.
57  *
58  * \sa http_recv_init ortp_recv_init
59  */
60         void (*init)(struct receiver *r);
61 /**
62  *
63  *
64  * the command line parser of the receiver
65  *
66  * It should check whether the command line options given by \a argc and \a
67  * argv are valid.  On success, it should return a pointer to the
68  * receiver-specific configuration data determined by \a argc and \a argv.
69  * Note that this might be called more than once with different values of
70  * \a argc and \a argv.
71  *
72  */
73         void * (*parse_config)(int argc, char **argv);
74 /**
75  *
76  *
77  * open one instance of the receiver
78  *
79  * This should allocate the output buffer of \a rn. and may also perform any
80  * other work necessary for retrieving the stream according to the
81  * configuration stored in the \a conf member of \a rn which is guaranteed to
82  * point to valid configuration data (as previously obtained from the config
83  * parser).
84  *
85  * \sa receiver_node::conf, receiver_node::buf
86  */
87         int (*open)(struct receiver_node *rn);
88 /**
89  *
90  *
91  * close one instance of the receiver
92  *
93  * It should free all resources associated with given receiver node that were
94  * allocated during the corresponding open call.
95  *
96  * \sa receiver_node
97  */
98         void (*close)(struct receiver_node *rn);
99 /**
100  *
101  *
102  * deactivate the receiver
103  *
104  * Clean up what init has allocated.
105  */
106         void (*shutdown)(void);
107 /**
108  *
109  *
110  * add file descriptors to fd_sets and compute timeout for select(2)
111  *
112  * The pre_select function gets called from the driving application before
113  * entering its select loop. The receiver may use this hook to add any file
114  * descriptors to \a rfds and \a wfds in order to check the result later in the
115  * post_select hook.
116  *
117  * \a timeout is a value-result parameter, initially containing the timeout for
118  * select() which was set by the application or by another receiver node. If
119  * the receiver wants its pre_select function to be called at some earlier time
120  * than the time determined by \a timeout, it may set \a timeout to an
121  * appropriate smaller value. However, it must never increase this timeout.
122  *
123  * This function must return the highest-numbered descriptor it wants to being
124  * checked, or -1 if no file descriptors should be checked for this run.
125  *
126  * \sa select(2), receiver_node:private_data, time.c
127  */
128         int (*pre_select)(struct receiver_node *rn, fd_set *rfds,
129                 fd_set *wfds, struct timeval *timeout);
130 /**
131  *
132  *
133  * evaluate the result from select()
134  *
135  * If the call to select() was succesful, this hook gets called. It should
136  * check all file descriptors which were added to any of the the fd sets during
137  * the previous call to pre_select. According to the result, it may then use
138  * any non-blocking I/O to establish a connection or to receive the audio data.
139  *
140  * A negative return value is interpreted as an error.
141  *
142  * \sa select(2), struct receiver
143  */
144         int (*post_select)(struct receiver_node *rn, int select_ret,
145                 fd_set *rfds, fd_set *wfds);
146 };
147
148
149 /** \cond */
150 extern void http_recv_init(struct receiver *r);
151 #define HTTP_RECEIVER {.name = "http", .init = http_recv_init},
152 extern void dccp_recv_init(struct receiver *r);
153 #define DCCP_RECEIVER {.name = "dccp", .init = dccp_recv_init},
154
155 #ifdef HAVE_ORTP
156 extern void ortp_recv_init(struct receiver *r);
157 #define ORTP_RECEIVER {.name = "ortp", .init = ortp_recv_init},
158 #else
159 #define ORTP_RECEIVER
160 #endif
161
162 void *check_receiver_arg(char *ra, int *receiver_num);
163
164
165 extern struct receiver receivers[];
166 extern void (*crypt_function_recv)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
167 extern void (*crypt_function_send)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
168
169 #define DEFINE_RECEIVER_ARRAY struct receiver receivers[] = { \
170         HTTP_RECEIVER \
171         DCCP_RECEIVER \
172         ORTP_RECEIVER \
173         {.name = NULL}};
174
175 /** \endcond */