2 * Copyright (C) 2005-2011 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 /** Receiver-specific data. */
17 /** Pointer to the configuration data for this instance. */
19 /** The task associated with this instance. */
21 /** The receiver node is always the root of the buffer tree. */
22 struct btr_node
*btrn
;
26 * Describes one supported paraslash receiver.
28 * \sa http_recv.c, udp_recv.c
32 * The name of the receiver.
36 * The receiver init function.
38 * It must fill in all other function pointers and is assumed to succeed.
40 * \sa http_recv_init udp_recv_init.
42 void (*init
)(struct receiver
*r
);
44 * The command line parser of the receiver.
46 * It should check whether the command line options given by \a argc and \a
47 * argv are valid. On success, it should return a pointer to the
48 * receiver-specific configuration data determined by \a argc and \a argv.
49 * Note that this might be called more than once with different values of
50 * \a argc and \a argv.
52 void *(*parse_config
)(int argc
, char **argv
);
54 * Deallocate the configuration structure of a receiver node.
56 * This calls the receiver-specific cleanup function generated by
59 void (*free_config
)(void *conf
);
61 * Open one instance of the receiver.
63 * This should allocate the output buffer of \a rn. and may also
64 * perform any other work necessary for retrieving the stream according
65 * to the configuration stored in the \a conf member of \a rn which is
66 * guaranteed to point to valid configuration data (as previously
67 * obtained from the config parser).
69 * \sa receiver_node::conf, receiver_node::buf.
71 int (*open
)(struct receiver_node
*rn
);
73 * Close this instance of the receiver.
75 * It should free all resources associated with given receiver node
76 * that were allocated during the corresponding open call.
80 void (*close
)(struct receiver_node
*rn
);
82 * Add file descriptors to fd_sets and compute timeout for select(2).
84 * The pre_select function gets called from the driving application
85 * before entering its select loop. The receiver may use this hook to
86 * add any file descriptors to the sets of file descriptors given by \a
89 * \sa select(2), time.c struct task, struct sched.
91 void (*pre_select
)(struct sched
*s
, struct task
*t
);
93 * Evaluate the result from select().
95 * This hook gets called after the call to select(). It should check
96 * all file descriptors which were added to any of the the fd sets
97 * during the previous call to pre_select. According to the result, it
98 * may then use any non-blocking I/O to establish a connection or to
99 * receive the audio data.
101 * \sa select(2), struct receiver.
103 void (*post_select
)(struct sched
*s
, struct task
*t
);
105 /** The two help texts of this receiver. */
106 struct ggo_help help
;
109 /** Define an array of all available receivers. */
110 #define DEFINE_RECEIVER_ARRAY struct receiver receivers[] = { \
116 /** Iterate over all available receivers. */
117 #define FOR_EACH_RECEIVER(i) for (i = 0; receivers[i].name; i++)
119 void recv_init(void);
120 void *check_receiver_arg(char *ra
, int *receiver_num
);
121 void print_receiver_helps(int detailed
);
122 int generic_recv_pre_select(struct sched
*s
, struct task
*t
);
125 extern void http_recv_init(struct receiver
*r
);
126 #define HTTP_RECEIVER {.name = "http", .init = http_recv_init},
127 extern void dccp_recv_init(struct receiver
*r
);
128 #define DCCP_RECEIVER {.name = "dccp", .init = dccp_recv_init},
129 extern void udp_recv_init(struct receiver
*r
);
130 #define UDP_RECEIVER {.name = "udp", .init = udp_recv_init},
132 extern struct receiver receivers
[];