cosmetics
[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 int *output_eof;
36 /** pointer to the configuration data for this instance */
37 void *conf;
38 /** the task associated with this instance */
39 struct task task;
40 };
41
42 /**
43 * describes one supported paraslash receiver
44 *
45 * \sa http_recv.c, ortp_recv.c
46 */
47 struct receiver {
48 /**
49 *
50 *
51 * the name of the receiver
52 */
53 const char *name;
54 /**
55 *
56 *
57 * the receiver init function
58 *
59 * It must fill in all other function pointers and is assumed to succeed.
60 *
61 * \sa http_recv_init ortp_recv_init
62 */
63 void (*init)(struct receiver *r);
64 /**
65 *
66 *
67 * the command line parser of the receiver
68 *
69 * It should check whether the command line options given by \a argc and \a
70 * argv are valid. On success, it should return a pointer to the
71 * receiver-specific configuration data determined by \a argc and \a argv.
72 * Note that this might be called more than once with different values of
73 * \a argc and \a argv.
74 *
75 */
76 void * (*parse_config)(int argc, char **argv);
77 /**
78 *
79 *
80 * open one instance of the receiver
81 *
82 * This should allocate the output buffer of \a rn. and may also perform any
83 * other work necessary for retrieving the stream according to the
84 * configuration stored in the \a conf member of \a rn which is guaranteed to
85 * point to valid configuration data (as previously obtained from the config
86 * parser).
87 *
88 * \sa receiver_node::conf, receiver_node::buf
89 */
90 int (*open)(struct receiver_node *rn);
91 /**
92 *
93 *
94 * close one instance of the receiver
95 *
96 * It should free all resources associated with given receiver node that were
97 * allocated during the corresponding open call.
98 *
99 * \sa receiver_node
100 */
101 void (*close)(struct receiver_node *rn);
102 /**
103 *
104 *
105 * deactivate the receiver
106 *
107 * Clean up what init has allocated.
108 */
109 void (*shutdown)(void);
110 /**
111 *
112 *
113 * add file descriptors to fd_sets and compute timeout for select(2)
114 *
115 * The pre_select function gets called from the driving application before
116 * entering its select loop. The receiver may use this hook to add any file
117 * descriptors to the sets of file descriptors given by \a s.
118 *
119 *
120 * \sa select(2), time.c struct task, struct sched
121 */
122 void (*pre_select)(struct sched *s, struct task *t);
123 /**
124 *
125 *
126 * evaluate the result from select()
127 *
128 * This hook gets called after the call to select(). It should check all file
129 * descriptors which were added to any of the the fd sets during the previous
130 * call to pre_select. According to the result, it may then use any
131 * non-blocking I/O to establish a connection or to receive the audio data.
132 *
133 *
134 * \sa select(2), struct receiver
135 */
136 void (*post_select)(struct sched *s, struct task *t);
137 };
138
139
140 /** \cond */
141 extern void http_recv_init(struct receiver *r);
142 #define HTTP_RECEIVER {.name = "http", .init = http_recv_init},
143 extern void dccp_recv_init(struct receiver *r);
144 #define DCCP_RECEIVER {.name = "dccp", .init = dccp_recv_init},
145
146 #ifdef HAVE_ORTP
147 extern void ortp_recv_init(struct receiver *r);
148 #define ORTP_RECEIVER {.name = "ortp", .init = ortp_recv_init},
149 #else
150 #define ORTP_RECEIVER
151 #endif
152
153 void *check_receiver_arg(char *ra, int *receiver_num);
154
155
156 extern struct receiver receivers[];
157 extern void (*crypt_function_recv)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
158 extern void (*crypt_function_send)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
159
160 #define DEFINE_RECEIVER_ARRAY struct receiver receivers[] = { \
161 HTTP_RECEIVER \
162 DCCP_RECEIVER \
163 ORTP_RECEIVER \
164 {.name = NULL}};
165
166 /** \endcond */