35 #include <uuid/uuid.h>
45 #define AST_MODULE "app_audiosocket"
46 #define AUDIOSOCKET_CONFIG "audiosocket.conf"
47 #define MAX_CONNECT_TIMEOUT_MSEC 2000
70 static const char app[] =
"AudioSocket";
72 static int audiosocket_run(
struct ast_channel *chan,
const char *
id,
const int svc);
90 chanName = ast_channel_name(chan);
95 if (ast_strlen_zero(args.idStr)) {
96 ast_log(LOG_ERROR,
"UUID is required\n");
99 if (uuid_parse(args.idStr, uu)) {
100 ast_log(LOG_ERROR,
"Failed to parse UUID '%s'\n", args.idStr);
108 writeFormat =
ao2_bump(ast_channel_writeformat(chan));
109 readFormat =
ao2_bump(ast_channel_readformat(chan));
112 ast_log(LOG_ERROR,
"Failed to set write format to SLINEAR for channel %s\n", chanName);
119 ast_log(LOG_ERROR,
"Failed to set read format to SLINEAR for channel %s\n", chanName);
125 ast_log(LOG_ERROR,
"Failed to restore write format for channel %s\n", chanName);
133 res = audiosocket_run(chan, args.idStr, s);
138 ast_log(LOG_ERROR,
"Failed to restore write format for channel %s\n", chanName);
141 ast_log(LOG_ERROR,
"Failed to restore read format for channel %s\n", chanName);
151 ast_log(LOG_ERROR,
"Failed to restore write format for channel %s\n", chanName);
154 ast_log(LOG_ERROR,
"Failed to restore read format for channel %s\n", chanName);
162 static int audiosocket_run(
struct ast_channel *chan,
const char *
id,
int svc)
164 const char *chanName;
171 ast_log(LOG_ERROR,
"Channel is %s\n", chan ?
"not answered" :
"missing");
176 ast_log(LOG_ERROR,
"Failed to intialize AudioSocket\n");
180 chanName = ast_channel_name(chan);
194 ast_log(LOG_ERROR,
"Failed to forward channel frame from %s to AudioSocket\n",
206 ast_log(LOG_ERROR,
"Failed to receive frame from AudioSocket message for"
207 "channel %s\n", chanName);
211 ast_log(LOG_WARNING,
"Failed to forward frame to channel %s\n", chanName);
221 static int unload_module(
void)
226 static int load_module(
void)
233 AST_MODFLAG_LOAD_ORDER,
234 "AudioSocket Application",
235 .support_level = AST_MODULE_SUPPORT_EXTENDED,
237 .unload = unload_module,
239 .requires =
"res_audiosocket",
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
ast_channel_state
ast_channel states
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
const int ast_audiosocket_connect(const char *server, struct ast_channel *chan)
Send the initial message to an AudioSocket server.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
const int ast_audiosocket_init(const int svc, const char *id)
Send the initial message to an AudioSocket server.
General Asterisk PBX channel definitions.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
AudioSocket support functions.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
const int ast_audiosocket_send_frame(const int svc, const struct ast_frame *f)
Send an Asterisk audio frame to an AudioSocket server.
union ast_frame::@224 data
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
struct ast_frame * ast_audiosocket_receive_frame(const int svc)
Receive an Asterisk frame from an AudioSocket server.
Data structure associated with a single frame of data.
enum ast_frame_type frametype
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.