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