33 #include <uuid/uuid.h> 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(1,
"Loading AudioSocket Support module\n");
335 ast_verb(1,
"Unloading AudioSocket Support module\n");
struct sockaddr_storage ss
const int ast_audiosocket_init(const int svc, const char *id)
Send the initial message to an AudioSocket server.
struct ast_frame * ast_audiosocket_receive_frame(const int svc)
Receive an Asterisk frame from an AudioSocket server.
Main Channel structure associated with a channel.
static int unload_module(void)
const int ast_audiosocket_send_frame(const int svc, const struct ast_frame *f)
Send an Asterisk audio frame to an AudioSocket server.
Asterisk main include file. File version handling, generic pbx functions.
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
static int load_module(void)
#define ast_socket_nonblock(domain, type, protocol)
Create a non-blocking socket.
Universally unique identifier support.
static int handle_audiosocket_connection(const char *server, const struct ast_sockaddr addr, const int netsockfd)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
Socket address structure.
#define ast_verb(level,...)
#define ast_strlen_zero(foo)
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
General Asterisk PBX channel definitions.
#define ast_poll(a, b, c)
AudioSocket support functions.
#define ast_malloc(len)
A wrapper for malloc()
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define MAX_CONNECT_TIMEOUT_MSEC
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
struct ast_frame ast_null_frame
const char * ast_channel_name(const struct ast_channel *chan)
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
const int ast_audiosocket_connect(const char *server, struct ast_channel *chan)
Send the initial message to an AudioSocket server.
int ast_connect(int sockfd, const struct ast_sockaddr *addr)
Wrapper around connect(2) that uses struct ast_sockaddr.
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.