42#define MODULE_DESCRIPTION "AudioSocket support functions for Asterisk"
44#define MAX_CONNECT_TIMEOUT_MSEC 2000
60 struct pollfd pfds[1];
64 reslen =
sizeof(conresult);
66 pfds[0].fd = netsockfd;
67 pfds[0].events = POLLOUT;
73 "out after MAX_CONNECT_TIMEOUT_MSEC (%d) milliseconds.\n",
84 if (getsockopt(pfds[0].fd, SOL_SOCKET, SO_ERROR, &conresult, &reslen) < 0) {
103 int num_addrs = 0, i = 0;
119 "requires a valid hostname and port\n", server);
124 for (i = 0; i < num_addrs; i++) {
171 if (i == num_addrs) {
191 if (uuid_parse(
id, uu)) {
199 memcpy(
buf + 3, uu, 16);
201 if (write(svc,
buf, 3 + 16) != 3 + 16) {
234 int i = 0, n = 0, ret = 0, not_audio = 0;
238 .src =
"AudioSocket",
247 n = read(svc, &kind, 1);
248 if (n < 0 &&
errno == EAGAIN) {
268 n = read(svc, &len_high, 1);
273 len += len_high * 256;
274 n = read(svc, &len_low, 1);
295 n = read(svc,
data + i,
len - i);
329 ast_verb(5,
"Loading AudioSocket Support module\n");
335 ast_verb(5,
"Unloading AudioSocket Support module\n");
Asterisk main include file. File version handling, generic pbx functions.
#define ast_malloc(len)
A wrapper for malloc()
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Generic File Format Support. Should be included by clients of the file handling routines....
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
struct ast_frame ast_null_frame
#define ast_verb(level,...)
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DEPEND
@ AST_MODULE_SUPPORT_EXTENDED
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
int ast_connect(int sockfd, const struct ast_sockaddr *addr)
Wrapper around connect(2) that uses struct ast_sockaddr.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family)
Parses a string with an IPv4 or IPv6 address and place results into an array.
#define ast_poll(a, b, c)
const int ast_audiosocket_init(const int svc, const char *id)
Send the initial message to an AudioSocket server.
const int ast_audiosocket_send_frame(const int svc, const struct ast_frame *f)
Send an Asterisk audio frame to an AudioSocket server.
struct ast_frame * ast_audiosocket_receive_frame(const int svc)
Receive an Asterisk frame from an AudioSocket server.
const int ast_audiosocket_connect(const char *server, struct ast_channel *chan)
Send the initial message to an AudioSocket server.
#define MAX_CONNECT_TIMEOUT_MSEC
static int load_module(void)
static int unload_module(void)
static int handle_audiosocket_connection(const char *server, const struct ast_sockaddr addr, const int netsockfd)
AudioSocket support functions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Main Channel structure associated with a channel.
Data structure associated with a single frame of data.
union ast_frame::@226 data
enum ast_frame_type frametype
Socket address structure.
struct sockaddr_storage ss
#define ast_socket_nonblock(domain, type, protocol)
Create a non-blocking socket.
Universally unique identifier support.