paraslash 0.3.0
[paraslash.git] / send.h
1 /** \file send.h sender-related defines and structures */
2 /** the sender subcommands */
3 enum {SENDER_ADD, SENDER_DELETE, SENDER_ALLOW, SENDER_DENY, SENDER_ON, SENDER_OFF};
4
5 /** the number of sender subcommands */
6 #define NUM_SENDER_CMDS (SENDER_OFF + 1)
7
8 /**
9 * describes one supported sender of para_server
10 *
11 * \sa http_send.c ortp_send.c
12 */
13 struct sender {
14 /** the name of the sender */
15 const char *name;
16 /**
17 * the init function of this sender
18 *
19 * It must fill in all function pointers of \a s as well as the \a client_cmds
20 * array, see below. It should also do all necessary preparations to init
21 * this sending facility, for example it could open a tcp port.
22 */
23 void (*init)(struct sender *s);
24 /** \p SENDER_ON or \p SENDER_OFF */
25 int status;
26 /**
27 * return the help text of this sender
28 *
29 * The result must be dynamically allocated and is freed by the caller.
30 */
31 char* (*help)(void);
32 /**
33 * return current status info about this sender
34 *
35 * The result must be dynamically allocated and is freed by the caller.
36 */
37 char* (*info)(void);
38 /**
39 * the send-hook
40 *
41 * It gets called whenever para_server is playing and the current
42 * audio format handler indicates that another chunk of data should
43 * be sent now. The two parameters \a current_chunk and \a chunks_sent
44 * only differ if the stream was repositioned by the \a ff or \a jmp
45 * command. Of course, \a buf is a pointer to the chunk of data which
46 * should be sent, and \a len is the length of this buffer.
47 */
48 void (*send)(long unsigned current_chunk, long unsigned chunks_sent,
49 const char *buf, size_t len);
50 /** add file descriptors to fd_sets
51 *
52 * The pre_select function of each supported sender is called just before
53 * para_server enters its main select loop. Each sender may add its own
54 * file descriptors to the \a rfds or the \a wfds set.
55 *
56 * If a file descriptor was added, \a max_fileno must be increased by
57 * this function, if necessary.
58 *
59 * \sa select(2)
60 */
61 void (*pre_select)(int *max_fileno, fd_set *rfds, fd_set *wfds);
62 /**
63 * handle the file descriptors which are ready for I/O
64 *
65 * If the pre_select hook added one ore more file descriptors to the read or write
66 * set, this is the hook to check the result and do any I/O on those descriptors
67 * which are ready for reading/writing.
68 */
69 void (*post_select)(fd_set *rfds, fd_set *wfds);
70 /**
71 * terminate all connected clients
72 *
73 * This is called e.g. if the stop command was executed. It should make the clients
74 * aware of the end-of-file condition.
75 */
76 void (*shutdown_clients)(void);
77 /**
78 * array of function pointers for the sender subcommands
79 *
80 * Each sender may implement any subset of the sender commands by filling in
81 * the appropriate function pointer in the array. A \p NULL pointer means this
82 * command is not implemented by this sender.
83 */
84 int (*client_cmds[NUM_SENDER_CMDS])(struct sender_command_data*);
85 };
86