mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-30 07:04:17 +00:00
indent
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4798 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
643ca5c4e7
commit
debdfb1aab
139 files changed
+2075
-3970
No files matched your search
@@ -67,16 +67,13 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
|
||||
&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
|
||||
switch_channel_set_flag(caller_channel, CF_NOMEDIA);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
|
||||
no_media_bridge = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n",
|
||||
switch_channel_cause2str(cause));
|
||||
if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(cause));
|
||||
if (!do_continue && cause != SWITCH_CAUSE_NO_ANSWER) {
|
||||
/* All Causes besides NO_ANSWER terminate the originating session unless continue_on_fail is set.
|
||||
We will pass the fail cause on when we hangup. */
|
||||
@@ -137,8 +134,7 @@ static const switch_loadable_module_interface_t mod_bridgecall_module_interface
|
||||
/*.application_interface */ &bridge_application_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
|
||||
@@ -80,8 +80,7 @@ static switch_status_t status_function(char *cmd, switch_core_session_t *session
|
||||
"UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n",
|
||||
duration.yr, duration.yr == 1 ? "" : "s", duration.day, duration.day == 1 ? "" : "s",
|
||||
duration.hr, duration.hr == 1 ? "" : "s", duration.min, duration.min == 1 ? "" : "s",
|
||||
duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s",
|
||||
duration.mms, duration.mms == 1 ? "" : "s");
|
||||
duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s", duration.mms, duration.mms == 1 ? "" : "s");
|
||||
|
||||
stream->write_function(stream, "%d sessions\n", switch_core_session_count());
|
||||
|
||||
@@ -96,9 +95,7 @@ static switch_status_t status_function(char *cmd, switch_core_session_t *session
|
||||
refresh++;
|
||||
r = atoi(refresh);
|
||||
if (r > 0) {
|
||||
stream->write_function(stream,
|
||||
"<META HTTP-EQUIV=REFRESH CONTENT=\"%d; URL=/api/status?refresh=%d%s\">\n", r, r,
|
||||
html ? "html=1" : "");
|
||||
stream->write_function(stream, "<META HTTP-EQUIV=REFRESH CONTENT=\"%d; URL=/api/status?refresh=%d%s\">\n", r, r, html ? "html=1" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,8 +130,7 @@ static switch_status_t ctl_function(char *data, switch_core_session_t *session,
|
||||
arg = 0;
|
||||
switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
|
||||
} else {
|
||||
stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n",
|
||||
argv[0]);
|
||||
stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n", argv[0]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -161,8 +157,7 @@ static switch_status_t load_function(char *mod, switch_core_session_t *session,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, SWITCH_TRUE) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "ERROR\n");
|
||||
@@ -250,8 +245,7 @@ static switch_status_t transfer_function(char *cmd, switch_core_session_t *isess
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[6] = { 0 };
|
||||
@@ -365,8 +359,7 @@ static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *ise
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
@@ -403,8 +396,7 @@ static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
@@ -500,8 +492,7 @@ static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *is
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t session_record_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
static switch_status_t session_record_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = { 0 };
|
||||
@@ -647,13 +638,11 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
|
||||
timeout = atoi(argv[6]);
|
||||
}
|
||||
|
||||
if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (machine) {
|
||||
stream->write_function(stream, "fail: %s\n", switch_channel_cause2str(cause));
|
||||
} else {
|
||||
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg,
|
||||
switch_channel_cause2str(cause));
|
||||
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg, switch_channel_cause2str(cause));
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -704,14 +693,14 @@ static void sch_api_callback(switch_scheduler_task_t *task)
|
||||
assert(task);
|
||||
|
||||
cmd = (char *) task->cmd_arg;
|
||||
|
||||
|
||||
if ((arg = strchr(cmd, ' '))) {
|
||||
*arg++ = '\0';
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
switch_api_execute(cmd, arg, NULL, &stream);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Command %s(%s):\n%s\n", cmd, arg, switch_str_nil((char *)stream.data));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Command %s(%s):\n%s\n", cmd, arg, switch_str_nil((char *) stream.data));
|
||||
switch_safe_free(stream.data);
|
||||
}
|
||||
|
||||
@@ -723,7 +712,7 @@ static switch_status_t sched_api_function(char *cmd, switch_core_session_t *ises
|
||||
assert(cmd != NULL);
|
||||
tm = strdup(cmd);
|
||||
assert(tm != NULL);
|
||||
|
||||
|
||||
if ((dcmd = strchr(tm, ' '))) {
|
||||
uint32_t id;
|
||||
|
||||
@@ -738,10 +727,10 @@ static switch_status_t sched_api_function(char *cmd, switch_core_session_t *ises
|
||||
stream->write_function(stream, "Added task %u\n", id);
|
||||
} else {
|
||||
stream->write_function(stream, "Invalid syntax\n");
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(tm);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -767,8 +756,7 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
for (x = 0; x < argc; x++) {
|
||||
if (holder->http) {
|
||||
holder->stream->write_function(holder->stream, "<td>");
|
||||
holder->stream->write_function(holder->stream, "<b>%s</b>%s", columnNames[x],
|
||||
x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
holder->stream->write_function(holder->stream, "<b>%s</b>%s", columnNames[x], x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
} else {
|
||||
holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ",");
|
||||
}
|
||||
@@ -782,11 +770,9 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
for (x = 0; x < argc; x++) {
|
||||
if (holder->http) {
|
||||
holder->stream->write_function(holder->stream, "<td>");
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "",
|
||||
x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
} else {
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "",
|
||||
x == (argc - 1) ? "\n" : ",");
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", x == (argc - 1) ? "\n" : ",");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -834,8 +820,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session,
|
||||
holder.print_title = 0;
|
||||
if ((cmdname = strchr(cmd, ' ')) != 0) {
|
||||
*cmdname++ = '\0';
|
||||
snprintf(sql, sizeof(sql) - 1,
|
||||
"select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname);
|
||||
snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname);
|
||||
} else {
|
||||
snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api'");
|
||||
}
|
||||
@@ -1073,8 +1058,7 @@ static const switch_loadable_module_interface_t mod_commands_module_interface =
|
||||
/*.api_interface */ &originate_api_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &mod_commands_module_interface;
|
||||
|
||||
@@ -272,18 +272,16 @@ typedef struct api_command {
|
||||
|
||||
/* Function Prototypes */
|
||||
static uint32_t next_member_id(void);
|
||||
static conference_relationship_t *member_get_relationship(conference_member_t * member,
|
||||
conference_member_t * other_member);
|
||||
static conference_relationship_t *member_get_relationship(conference_member_t * member, conference_member_t * other_member);
|
||||
static conference_member_t *conference_member_get(conference_obj_t * conference, uint32_t id);
|
||||
static conference_relationship_t *member_add_relationship(conference_member_t * member, uint32_t id);
|
||||
static switch_status_t member_del_relationship(conference_member_t * member, uint32_t id);
|
||||
static switch_status_t conference_add_member(conference_obj_t * conference, conference_member_t * member);
|
||||
static switch_status_t conference_del_member(conference_obj_t * conference, conference_member_t * member);
|
||||
static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj);
|
||||
static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread, void *obj);
|
||||
static void conference_loop_output(conference_member_t * member);
|
||||
static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t stop);
|
||||
static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin,
|
||||
switch_channel_t *channel, uint8_t async);
|
||||
static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async);
|
||||
static switch_status_t conference_say(conference_obj_t * conference, const char *text, uint32_t leadin);
|
||||
static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim);
|
||||
static switch_status_t conf_api_main(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
@@ -291,24 +289,19 @@ static switch_status_t audio_bridge_on_ring(switch_core_session_t *session);
|
||||
static switch_status_t conference_outcall(conference_obj_t * conference,
|
||||
char *conference_name,
|
||||
switch_core_session_t *session,
|
||||
char *bridgeto,
|
||||
uint32_t timeout,
|
||||
char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause);
|
||||
char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause);
|
||||
static switch_status_t conference_outcall_bg(conference_obj_t * conference,
|
||||
char *conference_name,
|
||||
switch_core_session_t *session,
|
||||
char *bridgeto,
|
||||
uint32_t timeout, char *flags, char *cid_name, char *cid_num);
|
||||
switch_core_session_t *session, char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num);
|
||||
static void conference_function(switch_core_session_t *session, char *data);
|
||||
static void launch_conference_thread(conference_obj_t * conference);
|
||||
static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj);
|
||||
static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t * thread, void *obj);
|
||||
static switch_status_t conference_local_play_file(conference_obj_t * conference,
|
||||
switch_core_session_t *session, char *path, uint32_t leadin,
|
||||
char *buf, switch_size_t len);
|
||||
switch_core_session_t *session, char *path, uint32_t leadin, char *buf, switch_size_t len);
|
||||
static switch_status_t conference_member_play_file(conference_member_t * member, char *file, uint32_t leadin);
|
||||
static switch_status_t conference_member_say(conference_member_t * member, char *text, uint32_t leadin);
|
||||
static uint32_t conference_member_stop_file(conference_member_t * member, file_stop_t stop);
|
||||
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool);
|
||||
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t * pool);
|
||||
static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint);
|
||||
static void launch_conference_record_thread(conference_obj_t * conference, char *path);
|
||||
|
||||
@@ -316,8 +309,7 @@ typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_strea
|
||||
typedef switch_status_t (*conf_api_member_cmd_t) (conference_member_t *, switch_stream_handle_t *, void *);
|
||||
typedef switch_status_t (*conf_api_text_cmd_t) (conference_obj_t *, switch_stream_handle_t *, const char *);
|
||||
|
||||
static void conference_member_itterator(conference_obj_t * conference,
|
||||
switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data);
|
||||
static void conference_member_itterator(conference_obj_t * conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data);
|
||||
static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data);
|
||||
static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data);
|
||||
static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data);
|
||||
@@ -336,8 +328,7 @@ static uint32_t next_member_id(void)
|
||||
}
|
||||
|
||||
/* if other_member has a relationship with member, produce it */
|
||||
static conference_relationship_t *member_get_relationship(conference_member_t * member,
|
||||
conference_member_t * other_member)
|
||||
static conference_relationship_t *member_get_relationship(conference_member_t * member, conference_member_t * other_member)
|
||||
{
|
||||
conference_relationship_t *rel = NULL;
|
||||
|
||||
@@ -493,15 +484,13 @@ static switch_status_t conference_add_member(conference_obj_t * conference, conf
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count,
|
||||
conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
if (conference->count > 1 && conference->enter_sound) {
|
||||
conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN,
|
||||
switch_core_session_get_channel(member->session), 0);
|
||||
conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
|
||||
}
|
||||
// anounce the total number of members in the conference
|
||||
if (conference->count >= conference->anounce_count && conference->anounce_count > 1) {
|
||||
@@ -509,8 +498,7 @@ static switch_status_t conference_add_member(conference_obj_t * conference, conf
|
||||
conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
|
||||
} else if (conference->count == 1) {
|
||||
if (conference->alone_sound) {
|
||||
conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN,
|
||||
switch_core_session_get_channel(member->session), 0);
|
||||
conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
|
||||
} else {
|
||||
snprintf(msg, sizeof(msg), "You are currently the only person in this conference.");
|
||||
conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
|
||||
@@ -601,8 +589,7 @@ static switch_status_t conference_del_member(conference_obj_t * conference, conf
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count,
|
||||
conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
@@ -612,12 +599,10 @@ static switch_status_t conference_del_member(conference_obj_t * conference, conf
|
||||
switch_set_flag(conference, CFLAG_DESTRUCT);
|
||||
} else {
|
||||
if (conference->exit_sound) {
|
||||
conference_play_file(conference, conference->exit_sound, 0,
|
||||
switch_core_session_get_channel(member->session), 0);
|
||||
conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session), 0);
|
||||
}
|
||||
if (conference->count == 1 && conference->alone_sound) {
|
||||
conference_play_file(conference, conference->alone_sound, 0,
|
||||
switch_core_session_get_channel(member->session), 0);
|
||||
conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,7 +628,7 @@ static switch_status_t conference_del_member(conference_obj_t * conference, conf
|
||||
}
|
||||
|
||||
/* Main monitor thread (1 per distinct conference room) */
|
||||
static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
conference_obj_t *conference = (conference_obj_t *) obj;
|
||||
conference_member_t *imember, *omember;
|
||||
@@ -659,10 +644,8 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
async_file_frame = switch_core_alloc(conference->pool, CONF_BUFFER_SIZE);
|
||||
|
||||
|
||||
if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, conference->pool) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n",
|
||||
conference->interval, samples);
|
||||
if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, conference->pool) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n", conference->interval, samples);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n");
|
||||
return NULL;
|
||||
@@ -700,21 +683,17 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
if (imember->mux_resampler && switch_buffer_inuse(imember->resample_buffer) >= bytes) {
|
||||
imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
|
||||
ready++;
|
||||
} else
|
||||
if ((imember->read =
|
||||
(uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, imember->buflen))) {
|
||||
} else if ((imember->read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, imember->buflen))) {
|
||||
/* If the caller is not at the right sample rate resample him to suit and buffer accordingly */
|
||||
if (imember->mux_resampler) {
|
||||
int16_t *bptr = (int16_t *) imember->frame;
|
||||
int16_t out[1024];
|
||||
int len = (int) imember->read;
|
||||
|
||||
imember->mux_resampler->from_len =
|
||||
switch_short_to_float(bptr, imember->mux_resampler->from, (int) len / 2);
|
||||
imember->mux_resampler->from_len = switch_short_to_float(bptr, imember->mux_resampler->from, (int) len / 2);
|
||||
imember->mux_resampler->to_len =
|
||||
switch_resample_process(imember->mux_resampler, imember->mux_resampler->from,
|
||||
imember->mux_resampler->from_len, imember->mux_resampler->to,
|
||||
imember->mux_resampler->to_size, 0);
|
||||
imember->mux_resampler->from_len, imember->mux_resampler->to, imember->mux_resampler->to_size, 0);
|
||||
switch_float_to_short(imember->mux_resampler->to, out, len);
|
||||
len = imember->mux_resampler->to_len * 2;
|
||||
switch_buffer_write(imember->resample_buffer, out, len);
|
||||
@@ -739,9 +718,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
|
||||
uint32_t rate = conference->rate;
|
||||
|
||||
if (switch_core_speech_read_tts(&conference->fnode->sh,
|
||||
file_frame,
|
||||
&file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_speech_read_tts(&conference->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
|
||||
file_sample_len = file_data_len / 2;
|
||||
} else {
|
||||
file_sample_len = file_data_len = 0;
|
||||
@@ -1278,7 +1255,7 @@ static void conference_loop_fn_hangup(conference_member_t * member, caller_contr
|
||||
}
|
||||
|
||||
/* marshall frames from the call leg to the conference thread for muxing to other call legs */
|
||||
static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
conference_member_t *member = obj;
|
||||
switch_channel_t *channel;
|
||||
@@ -1343,11 +1320,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
|
||||
switch_event_t *event;
|
||||
talking = 1;
|
||||
switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s",
|
||||
member->conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "start-talking");
|
||||
switch_event_fire(&event);
|
||||
@@ -1364,11 +1339,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
|
||||
hangover_hits = hangunder_hits = 0;
|
||||
talking = 0;
|
||||
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s",
|
||||
member->conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "stop-talking");
|
||||
switch_event_fire(&event);
|
||||
@@ -1384,12 +1357,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
|
||||
int16_t *bptr = (int16_t *) read_frame->data;
|
||||
int len = (int) read_frame->datalen;;
|
||||
|
||||
member->read_resampler->from_len =
|
||||
switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2);
|
||||
member->read_resampler->from_len = switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2);
|
||||
member->read_resampler->to_len =
|
||||
switch_resample_process(member->read_resampler, member->read_resampler->from,
|
||||
member->read_resampler->from_len, member->read_resampler->to,
|
||||
member->read_resampler->to_size, 0);
|
||||
member->read_resampler->from_len, member->read_resampler->to, member->read_resampler->to_size, 0);
|
||||
switch_float_to_short(member->read_resampler->to, read_frame->data, len);
|
||||
len = member->read_resampler->to_len * 2;
|
||||
read_frame->datalen = len;
|
||||
@@ -1413,7 +1384,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
|
||||
}
|
||||
|
||||
/* launch an input thread for the call leg */
|
||||
static void launch_conference_loop_input(conference_member_t * member, switch_memory_pool_t *pool)
|
||||
static void launch_conference_loop_input(conference_member_t * member, switch_memory_pool_t * pool)
|
||||
{
|
||||
if (member != NULL) {
|
||||
switch_thread_t *thread;
|
||||
@@ -1486,10 +1457,8 @@ static void conference_loop_output(conference_member_t * member)
|
||||
launch_conference_loop_input(member, switch_core_session_get_pool(member->session));
|
||||
|
||||
/* build a digit stream object */
|
||||
if (member->conference->dtmf_parser != NULL &&
|
||||
switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Warning Will Robinson, there is no digit parser stream object\n");
|
||||
if (member->conference->dtmf_parser != NULL && switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning Will Robinson, there is no digit parser stream object\n");
|
||||
}
|
||||
|
||||
/* Fair WARNING, If you expect the caller to hear anything or for digit handling to be proccessed, */
|
||||
@@ -1514,8 +1483,7 @@ static void conference_loop_output(conference_member_t * member)
|
||||
char *p, *freeme = NULL;
|
||||
|
||||
if ((p = strchr(to, '+')) && strncmp(to, CONF_CHAT_PROTO, strlen(CONF_CHAT_PROTO))) {
|
||||
freeme =
|
||||
switch_mprintf("%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain);
|
||||
freeme = switch_mprintf("%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain);
|
||||
to = freeme;
|
||||
}
|
||||
|
||||
@@ -1527,14 +1495,12 @@ static void conference_loop_output(conference_member_t * member)
|
||||
if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
|
||||
/* test to see if outbound channel has answered */
|
||||
if (switch_channel_test_flag(channel, CF_ANSWERED) && !switch_test_flag(member->conference, CFLAG_ANSWERED)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Outbound conference channel answered, setting CFLAG_ANSWERED\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Outbound conference channel answered, setting CFLAG_ANSWERED\n");
|
||||
switch_set_flag(member->conference, CFLAG_ANSWERED);
|
||||
}
|
||||
} else {
|
||||
if (switch_test_flag(member->conference, CFLAG_ANSWERED) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"CLFAG_ANSWERED set, answering inbound channel\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CLFAG_ANSWERED set, answering inbound channel\n");
|
||||
switch_channel_answer(channel);
|
||||
}
|
||||
}
|
||||
@@ -1547,15 +1513,12 @@ static void conference_loop_output(conference_member_t * member)
|
||||
|
||||
for (digit = dtmf; *digit && caller_action == NULL; digit++) {
|
||||
caller_action = (caller_control_action_t *)
|
||||
switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream,
|
||||
*digit);
|
||||
switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, *digit);
|
||||
}
|
||||
}
|
||||
/* otherwise, clock the parser so that it can handle digit timeout detection */
|
||||
} else if (member->conference->dtmf_parser != NULL) {
|
||||
caller_action =
|
||||
(caller_control_action_t *) switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser,
|
||||
member->digit_stream, '\0');
|
||||
caller_action = (caller_control_action_t *) switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, '\0');
|
||||
}
|
||||
|
||||
/* if a caller action has been detected, handle it */
|
||||
@@ -1572,9 +1535,7 @@ static void conference_loop_output(conference_member_t * member)
|
||||
SWITCH_LOG_INFO,
|
||||
"executing caller control '%s' param '%s' on call '%u, %s, %s, %s'\n",
|
||||
caller_action->fndesc->key,
|
||||
param ? param : "none",
|
||||
member->id,
|
||||
switch_channel_get_name(channel), profile->caller_id_name, profile->caller_id_number);
|
||||
param ? param : "none", member->id, switch_channel_get_name(channel), profile->caller_id_name, profile->caller_id_number);
|
||||
#endif
|
||||
|
||||
caller_action->fndesc->handler(member, caller_action);
|
||||
@@ -1614,9 +1575,7 @@ static void conference_loop_output(conference_member_t * member)
|
||||
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
|
||||
uint32_t rate = member->conference->rate;
|
||||
|
||||
if (switch_core_speech_read_tts(&member->fnode->sh,
|
||||
file_frame,
|
||||
&file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_speech_read_tts(&member->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
|
||||
file_sample_len = file_data_len / 2;
|
||||
} else {
|
||||
file_sample_len = file_data_len = 0;
|
||||
@@ -1732,7 +1691,7 @@ static void conference_loop_output(conference_member_t * member)
|
||||
}
|
||||
|
||||
/* Sub-Routine called by a record entity inside a conference */
|
||||
static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
switch_file_handle_t fh = { 0 };
|
||||
@@ -1772,15 +1731,13 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
|
||||
switch_mutex_init(&member->audio_out_mutex, SWITCH_MUTEX_NESTED, rec->pool);
|
||||
|
||||
/* Setup an audio buffer for the incoming audio */
|
||||
if (switch_buffer_create_dynamic(&member->audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_buffer_create_dynamic(&member->audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Setup an audio buffer for the outgoing audio */
|
||||
if (switch_buffer_create_dynamic(&member->mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_buffer_create_dynamic(&member->mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -1791,19 +1748,14 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
|
||||
}
|
||||
|
||||
if (switch_core_file_open(&fh,
|
||||
rec->path,
|
||||
(uint8_t) 1,
|
||||
conference->rate,
|
||||
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, rec->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
rec->path, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, rec->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, rec->pool) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n",
|
||||
conference->interval, samples);
|
||||
if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, rec->pool) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u samples: %u\n", conference->interval, samples);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n");
|
||||
goto end;
|
||||
@@ -1814,8 +1766,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
|
||||
switch_safe_free(vval);
|
||||
}
|
||||
|
||||
switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_ARTIST,
|
||||
"FreeSWITCH mod_conference Software Conference Module");
|
||||
switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_ARTIST, "FreeSWITCH mod_conference Software Conference Module");
|
||||
|
||||
while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) {
|
||||
mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
|
||||
@@ -1936,8 +1887,7 @@ static uint32_t conference_member_stop_file(conference_member_t * member, file_s
|
||||
}
|
||||
|
||||
/* Play a file in the conference room */
|
||||
static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin,
|
||||
switch_channel_t *channel, uint8_t async)
|
||||
static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
conference_file_node_t *fnode, *nptr = NULL;
|
||||
@@ -2004,11 +1954,7 @@ static switch_status_t conference_play_file(conference_obj_t * conference, char
|
||||
fnode->leadin = leadin;
|
||||
|
||||
/* Open the file */
|
||||
if (switch_core_file_open(&fnode->fh,
|
||||
file,
|
||||
(uint8_t) 1,
|
||||
conference->rate,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_file_open(&fnode->fh, file, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
status = SWITCH_STATUS_NOTFOUND;
|
||||
goto done;
|
||||
@@ -2065,8 +2011,7 @@ static switch_status_t conference_member_play_file(conference_member_t * member,
|
||||
conference_file_node_t *fnode, *nptr;
|
||||
switch_memory_pool_t *pool;
|
||||
|
||||
if ((expanded =
|
||||
switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
|
||||
if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
|
||||
file = expanded;
|
||||
} else {
|
||||
expanded = NULL;
|
||||
@@ -2109,10 +2054,7 @@ static switch_status_t conference_member_play_file(conference_member_t * member,
|
||||
|
||||
/* Open the file */
|
||||
if (switch_core_file_open(&fnode->fh,
|
||||
file,
|
||||
(uint8_t) 1,
|
||||
member->conference->rate,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) {
|
||||
file, (uint8_t) 1, member->conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
status = SWITCH_STATUS_NOTFOUND;
|
||||
goto done;
|
||||
@@ -2178,12 +2120,8 @@ static switch_status_t conference_member_say(conference_member_t * member, char
|
||||
fnode->pool = pool;
|
||||
|
||||
memset(&fnode->sh, 0, sizeof(fnode->sh));
|
||||
if (switch_core_speech_open(&fnode->sh,
|
||||
conference->tts_engine,
|
||||
conference->tts_voice,
|
||||
conference->rate, &flags, fnode->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n",
|
||||
conference->tts_engine);
|
||||
if (switch_core_speech_open(&fnode->sh, conference->tts_engine, conference->tts_voice, conference->rate, &flags, fnode->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@@ -2253,10 +2191,7 @@ static switch_status_t conference_say(conference_obj_t * conference, const char
|
||||
fnode->leadin = leadin;
|
||||
|
||||
memset(&fnode->sh, 0, sizeof(fnode->sh));
|
||||
if (switch_core_speech_open(&fnode->sh,
|
||||
conference->tts_engine,
|
||||
conference->tts_voice,
|
||||
conference->rate, &flags, conference->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_speech_open(&fnode->sh, conference->tts_engine, conference->tts_voice, conference->rate, &flags, conference->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -2284,8 +2219,7 @@ static switch_status_t conference_say(conference_obj_t * conference, const char
|
||||
}
|
||||
|
||||
/* execute a callback for every member of the conference */
|
||||
static void conference_member_itterator(conference_obj_t * conference, switch_stream_handle_t *stream,
|
||||
conf_api_member_cmd_t pfncallback, void *data)
|
||||
static void conference_member_itterator(conference_obj_t * conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data)
|
||||
{
|
||||
conference_member_t *member = NULL;
|
||||
|
||||
@@ -2359,9 +2293,7 @@ static void conference_list(conference_obj_t * conference, switch_stream_handle_
|
||||
|
||||
|
||||
stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s",
|
||||
member->id, delim,
|
||||
name, delim,
|
||||
uuid, delim, profile->caller_id_name, delim, profile->caller_id_number, delim);
|
||||
member->id, delim, name, delim, uuid, delim, profile->caller_id_name, delim, profile->caller_id_number, delim);
|
||||
|
||||
if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
|
||||
stream->write_function(stream, "hear");
|
||||
@@ -2373,9 +2305,7 @@ static void conference_list(conference_obj_t * conference, switch_stream_handle_
|
||||
count++;
|
||||
}
|
||||
|
||||
stream->write_function(stream, "%s%d%s%d%s%d\n",
|
||||
delim,
|
||||
member->volume_in_level, delim, member->volume_out_level, delim, member->energy_level);
|
||||
stream->write_function(stream, "%s%d%s%d%s%d\n", delim, member->volume_in_level, delim, member->volume_out_level, delim, member->energy_level);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(conference->member_mutex);
|
||||
@@ -2692,8 +2622,7 @@ static switch_status_t conf_api_sub_volume_out(conference_member_t * member, swi
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
int ret_status = SWITCH_STATUS_GENERR;
|
||||
|
||||
@@ -2729,9 +2658,7 @@ static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_s
|
||||
|
||||
stream->write_function(stream, "Conference %s (%u member%s%s)\n",
|
||||
conference->name,
|
||||
conference->count,
|
||||
conference->count == 1 ? "" : "s",
|
||||
switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : "");
|
||||
conference->count, conference->count == 1 ? "" : "s", switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : "");
|
||||
if (pretty) {
|
||||
conference_list_pretty(conference, stream);
|
||||
} else {
|
||||
@@ -2751,8 +2678,7 @@ static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_s
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_play(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_play(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
int ret_status = SWITCH_STATUS_GENERR;
|
||||
switch_event_t *event;
|
||||
@@ -2786,8 +2712,7 @@ static switch_status_t conf_api_sub_play(conference_obj_t * conference, switch_s
|
||||
if ((member = conference_member_get(conference, id))) {
|
||||
if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
|
||||
@@ -2833,8 +2758,7 @@ static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_st
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, switch_stream_handle_t *stream,
|
||||
const char *text)
|
||||
static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text)
|
||||
{
|
||||
int ret_status = SWITCH_STATUS_GENERR;
|
||||
char *expanded = NULL;
|
||||
@@ -2870,8 +2794,7 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((expanded =
|
||||
switch_channel_expand_variables(switch_core_session_get_channel(member->session), (char *) text)) != text) {
|
||||
if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), (char *) text)) != text) {
|
||||
text = expanded;
|
||||
} else {
|
||||
expanded = NULL;
|
||||
@@ -2899,8 +2822,7 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
int ret_status = SWITCH_STATUS_GENERR;
|
||||
uint8_t current = 0, all = 0;
|
||||
@@ -2937,8 +2859,7 @@ static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_s
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
int ret_status = SWITCH_STATUS_GENERR;
|
||||
|
||||
@@ -3007,8 +2928,7 @@ static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_lock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_lock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_event_t *event;
|
||||
|
||||
@@ -3030,8 +2950,7 @@ static switch_status_t conf_api_sub_lock(conference_obj_t * conference, switch_s
|
||||
return 0;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_unlock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_unlock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_event_t *event;
|
||||
|
||||
@@ -3054,8 +2973,7 @@ static switch_status_t conf_api_sub_unlock(conference_obj_t * conference, switch
|
||||
return 0;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_dial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_dial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -3080,8 +2998,7 @@ static switch_status_t conf_api_sub_dial(conference_obj_t * conference, switch_s
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -3102,8 +3019,7 @@ static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
|
||||
char *params = NULL;
|
||||
@@ -3225,8 +3141,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, swit
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
|
||||
assert(conference != NULL);
|
||||
@@ -3242,8 +3157,7 @@ static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
static switch_status_t conf_api_sub_norecord(conference_obj_t * conference, switch_stream_handle_t *stream, int argc,
|
||||
char **argv)
|
||||
static switch_status_t conf_api_sub_norecord(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -3330,8 +3244,7 @@ static api_command_t conf_api_sub_commands[] = {
|
||||
|
||||
#define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0]))
|
||||
|
||||
switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv,
|
||||
const char *cmdline, int argn)
|
||||
switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
uint32_t i, found = 0;
|
||||
@@ -3371,9 +3284,7 @@ switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_h
|
||||
}
|
||||
|
||||
if (all) {
|
||||
conference_member_itterator(conference, stream,
|
||||
(conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd,
|
||||
argv[argn + 2]);
|
||||
conference_member_itterator(conference, stream, (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd, argv[argn + 2]);
|
||||
} else if (last) {
|
||||
conference_member_t *member = NULL;
|
||||
conference_member_t *last_member = NULL;
|
||||
@@ -3421,8 +3332,7 @@ switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_h
|
||||
|
||||
if ((start_text = strstr(modified_cmdline, cmd))) {
|
||||
modified_cmdline = start_text + strlen(cmd);
|
||||
while (modified_cmdline && *modified_cmdline
|
||||
&& (*modified_cmdline == ' ' || *modified_cmdline == '\t')) {
|
||||
while (modified_cmdline && *modified_cmdline && (*modified_cmdline == ' ' || *modified_cmdline == '\t')) {
|
||||
modified_cmdline++;
|
||||
}
|
||||
}
|
||||
@@ -3558,9 +3468,7 @@ static const switch_state_handler_table_t audio_bridge_peer_state_handlers = {
|
||||
static switch_status_t conference_outcall(conference_obj_t * conference,
|
||||
char *conference_name,
|
||||
switch_core_session_t *session,
|
||||
char *bridgeto,
|
||||
uint32_t timeout,
|
||||
char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
|
||||
char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
|
||||
{
|
||||
switch_core_session_t *peer_session;
|
||||
switch_channel_t *peer_channel;
|
||||
@@ -3611,13 +3519,8 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
|
||||
|
||||
/* establish an outbound call leg */
|
||||
if (switch_ivr_originate(session,
|
||||
&peer_session,
|
||||
cause,
|
||||
bridgeto,
|
||||
timeout,
|
||||
&audio_bridge_peer_state_handlers, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n",
|
||||
switch_channel_cause2str(*cause));
|
||||
&peer_session, cause, bridgeto, timeout, &audio_bridge_peer_state_handlers, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", switch_channel_cause2str(*cause));
|
||||
if (caller_channel) {
|
||||
switch_channel_hangup(caller_channel, *cause);
|
||||
}
|
||||
@@ -3689,7 +3592,7 @@ struct bg_call {
|
||||
char *conference_name;
|
||||
};
|
||||
|
||||
static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
struct bg_call *call = (struct bg_call *) obj;
|
||||
|
||||
@@ -3697,8 +3600,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,
|
||||
switch_call_cause_t cause;
|
||||
switch_event_t *event;
|
||||
|
||||
conference_outcall(call->conference, NULL, call->session, call->bridgeto, call->timeout, call->flags,
|
||||
call->cid_name, call->cid_num, &cause);
|
||||
conference_outcall(call->conference, NULL, call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause);
|
||||
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", call->conference->name);
|
||||
@@ -3719,9 +3621,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,
|
||||
|
||||
static switch_status_t conference_outcall_bg(conference_obj_t * conference,
|
||||
char *conference_name,
|
||||
switch_core_session_t *session,
|
||||
char *bridgeto,
|
||||
uint32_t timeout, char *flags, char *cid_name, char *cid_num)
|
||||
switch_core_session_t *session, char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num)
|
||||
{
|
||||
struct bg_call *call = NULL;
|
||||
|
||||
@@ -3766,8 +3666,7 @@ static switch_status_t conference_outcall_bg(conference_obj_t * conference,
|
||||
|
||||
/* Play a file */
|
||||
static switch_status_t conference_local_play_file(conference_obj_t * conference,
|
||||
switch_core_session_t *session, char *path, uint32_t leadin,
|
||||
char *buf, switch_size_t len)
|
||||
switch_core_session_t *session, char *path, uint32_t leadin, char *buf, switch_size_t len)
|
||||
{
|
||||
uint32_t x = 0;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
@@ -3977,8 +3876,7 @@ static void conference_function(switch_core_session_t *session, char *data)
|
||||
|
||||
/* be friendly */
|
||||
if (conference->pin_sound) {
|
||||
conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf,
|
||||
sizeof(pin_buf));
|
||||
conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf));
|
||||
}
|
||||
/* wait for them if neccessary */
|
||||
if (strlen(pin_buf) < strlen(conference->pin)) {
|
||||
@@ -3988,8 +3886,7 @@ static void conference_function(switch_core_session_t *session, char *data)
|
||||
status = switch_ivr_collect_digits_count(session,
|
||||
buf,
|
||||
sizeof(pin_buf) - (unsigned int) strlen(pin_buf),
|
||||
(unsigned int) strlen(conference->pin) -
|
||||
(unsigned int) strlen(pin_buf), "#", &term, 10000);
|
||||
(unsigned int) strlen(conference->pin) - (unsigned int) strlen(pin_buf), "#", &term, 10000);
|
||||
}
|
||||
|
||||
pin_valid = (status == SWITCH_STATUS_SUCCESS && strcmp(pin_buf, conference->pin) == 0);
|
||||
@@ -3999,8 +3896,7 @@ static void conference_function(switch_core_session_t *session, char *data)
|
||||
|
||||
/* more friendliness */
|
||||
if (conference->bad_pin_sound) {
|
||||
conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf,
|
||||
sizeof(pin_buf));
|
||||
conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf, sizeof(pin_buf));
|
||||
}
|
||||
}
|
||||
pin_retries--;
|
||||
@@ -4047,8 +3943,7 @@ static void conference_function(switch_core_session_t *session, char *data)
|
||||
/* if we're using "bridge:" make an outbound call and bridge it in */
|
||||
if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
|
||||
switch_call_cause_t cause;
|
||||
if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) != SWITCH_STATUS_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
@@ -4069,17 +3964,13 @@ static void conference_function(switch_core_session_t *session, char *data)
|
||||
NULL,
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_frame / 1000,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
|
||||
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_frame / 1000);
|
||||
read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_frame / 1000);
|
||||
read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
|
||||
flags = 0;
|
||||
goto done;
|
||||
}
|
||||
@@ -4109,31 +4000,25 @@ static void conference_function(switch_core_session_t *session, char *data)
|
||||
NULL,
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_frame / 1000,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
|
||||
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_frame / 1000);
|
||||
read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_frame / 1000);
|
||||
read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
|
||||
flags = 0;
|
||||
goto codec_done2;
|
||||
}
|
||||
|
||||
/* Setup an audio buffer for the incoming audio */
|
||||
if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
|
||||
goto codec_done1;
|
||||
}
|
||||
|
||||
/* Setup an audio buffer for the outgoing audio */
|
||||
if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
|
||||
goto codec_done1;
|
||||
}
|
||||
@@ -4385,8 +4270,7 @@ static switch_status_t conf_default_controls(conference_obj_t * conference)
|
||||
for (i = 0, status = SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i < CCFNTBL_QTY; i++) {
|
||||
if (!switch_strlen_zero(ccfntbl[i].digits)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Installing default caller control action '%s' bound to '%s'.\n", ccfntbl[i].key,
|
||||
ccfntbl[i].digits);
|
||||
"Installing default caller control action '%s' bound to '%s'.\n", ccfntbl[i].key, ccfntbl[i].digits);
|
||||
action = (caller_control_action_t *) switch_core_alloc(conference->pool, sizeof(caller_control_action_t));
|
||||
if (action != NULL) {
|
||||
action->fndesc = &ccfntbl[i];
|
||||
@@ -4394,8 +4278,7 @@ static switch_status_t conf_default_controls(conference_obj_t * conference)
|
||||
status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, ccfntbl[i].digits, action);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key,
|
||||
ccfntbl[i].digits);
|
||||
"unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key, ccfntbl[i].digits);
|
||||
status = SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
}
|
||||
@@ -4405,8 +4288,7 @@ static switch_status_t conf_default_controls(conference_obj_t * conference)
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status_t conference_new_install_caller_controls_custom(conference_obj_t * conference,
|
||||
switch_xml_t xml_controls, switch_xml_t xml_menus)
|
||||
static switch_status_t conference_new_install_caller_controls_custom(conference_obj_t * conference, switch_xml_t xml_controls, switch_xml_t xml_menus)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
switch_xml_t xml_kvp;
|
||||
@@ -4432,11 +4314,8 @@ static switch_status_t conference_new_install_caller_controls_custom(conference_
|
||||
|
||||
caller_control_action_t *action;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Installing caller control action '%s' bound to '%s'.\n", key, val);
|
||||
action =
|
||||
(caller_control_action_t *) switch_core_alloc(conference->pool,
|
||||
sizeof(caller_control_action_t));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing caller control action '%s' bound to '%s'.\n", key, val);
|
||||
action = (caller_control_action_t *) switch_core_alloc(conference->pool, sizeof(caller_control_action_t));
|
||||
if (action != NULL) {
|
||||
action->fndesc = &ccfntbl[i];
|
||||
action->data = (void *) switch_core_strdup(conference->pool, data);
|
||||
@@ -4444,19 +4323,16 @@ static switch_status_t conference_new_install_caller_controls_custom(conference_
|
||||
status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, val, action);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"unable to alloc memory for caller control binding '%s' to '%s'\n",
|
||||
ccfntbl[i].key, ccfntbl[i].digits);
|
||||
"unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key, ccfntbl[i].digits);
|
||||
status = SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status == SWITCH_STATUS_NOOP) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%s'.\n",
|
||||
key);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%s'.\n", key);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"Invalid caller control config entry pair action = '%s' digits = '%s'\n", key, val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control config entry pair action = '%s' digits = '%s'\n", key, val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4464,7 +4340,7 @@ static switch_status_t conference_new_install_caller_controls_custom(conference_
|
||||
}
|
||||
|
||||
/* create a new conferene with a specific profile */
|
||||
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool)
|
||||
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t * pool)
|
||||
{
|
||||
conference_obj_t *conference;
|
||||
switch_xml_t xml_kvp;
|
||||
@@ -4582,8 +4458,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
|
||||
// a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound
|
||||
// stuff is added, see comments above
|
||||
max_members = 0; // set to 0 to disable max counts
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"max-members %s is invalid, not setting a limit\n", val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n", val);
|
||||
}
|
||||
} else if (!strcasecmp(var, "max-members-sound")) {
|
||||
maxmember_sound = val;
|
||||
@@ -4592,8 +4467,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
|
||||
anounce_count = strtol(val, NULL, 0);
|
||||
if (errno == ERANGE || errno == EINVAL) {
|
||||
anounce_count = 0;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"anounce-count is invalid, not anouncing member counts\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "anounce-count is invalid, not anouncing member counts\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4755,8 +4629,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
|
||||
status = conference_new_install_caller_controls_custom(conference, xml_controls, NULL);
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Unable to install caller controls group '%s'\n", caller_controls);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to install caller controls group '%s'\n", caller_controls);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "no caller controls intalled.\n");
|
||||
@@ -4801,8 +4674,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count,
|
||||
conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
@@ -4856,8 +4728,7 @@ static void send_presence(switch_event_types_t id)
|
||||
}
|
||||
|
||||
/* Called by FreeSWITCH when the module loads */
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
uint32_t i;
|
||||
size_t nl, ol = 0;
|
||||
@@ -4910,9 +4781,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
|
||||
|
||||
/* Subscribe to presence request events */
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ static void detect_speech_function(switch_core_session_t *session, char *data)
|
||||
switch_ivr_detect_speech(session, argv[0], argv[1], argv[2], argv[3], NULL);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n",
|
||||
detect_speech_application_interface.syntax);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", detect_speech_application_interface.syntax);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -430,8 +429,7 @@ static void privacy_function(switch_core_session_t *session, char *data)
|
||||
} else if (!strcasecmp(arg, "number")) {
|
||||
switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n");
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", arg, caller_profile->flags);
|
||||
}
|
||||
@@ -552,7 +550,7 @@ static switch_status_t chat_api_function(char *fmt, switch_core_session_t *sessi
|
||||
static char *ivr_cf_name = "ivr.conf";
|
||||
|
||||
#ifdef _TEST_CALLBACK_
|
||||
static switch_ivr_action_t menu_handler(switch_ivr_menu_t *menu, char *param, char *buf, size_t buflen, void *obj)
|
||||
static switch_ivr_action_t menu_handler(switch_ivr_menu_t * menu, char *param, char *buf, size_t buflen, void *obj)
|
||||
{
|
||||
switch_ivr_action_t action = SWITCH_IVR_ACTION_NOOP;
|
||||
|
||||
@@ -585,11 +583,9 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
// build a menu tree and execute it
|
||||
if (switch_ivr_menu_stack_xml_init(&xml_ctx, NULL) == SWITCH_STATUS_SUCCESS
|
||||
#ifdef _TEST_CALLBACK_
|
||||
&& switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom",
|
||||
&menu_handler) == SWITCH_STATUS_SUCCESS
|
||||
&& switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom", &menu_handler) == SWITCH_STATUS_SUCCESS
|
||||
#endif
|
||||
&& switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus,
|
||||
xml_menu) == SWITCH_STATUS_SUCCESS) {
|
||||
&& switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus, xml_menu) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_xml_free(cxml);
|
||||
cxml = NULL;
|
||||
switch_channel_pre_answer(channel);
|
||||
@@ -877,8 +873,7 @@ static const switch_loadable_module_interface_t mod_dptools_module_interface = {
|
||||
/*.api_interface */ &presence_api_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
|
||||
@@ -67,8 +67,7 @@ static switch_loadable_module_interface_t echo_module_interface = {
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &echo_module_interface;
|
||||
|
||||
@@ -329,8 +329,7 @@ static void parse_rr(const struct dns_parse *p, enum_query_t * q, struct dns_rr
|
||||
|
||||
if ((proceed = switch_regex_perform(q->number, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if (strchr(regex, '(')) {
|
||||
switch_perform_substitution(re, proceed, replace, q->number, substituted, sizeof(substituted),
|
||||
ovector);
|
||||
switch_perform_substitution(re, proceed, replace, q->number, substituted, sizeof(substituted), ovector);
|
||||
uri = substituted;
|
||||
} else {
|
||||
uri = replace;
|
||||
@@ -338,8 +337,7 @@ static void parse_rr(const struct dns_parse *p, enum_query_t * q, struct dns_rr
|
||||
|
||||
if ((route = (enum_route_t *) switch_core_hash_find(globals.routes, service))) {
|
||||
switch_regex_safe_free(re);
|
||||
if ((proceed =
|
||||
switch_regex_perform(uri, route->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if ((proceed = switch_regex_perform(uri, route->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if (strchr(route->regex, '(')) {
|
||||
switch_perform_substitution(re, proceed, route->replace, uri, rbuf, sizeof(rbuf), ovector);
|
||||
uri = rbuf;
|
||||
@@ -395,8 +393,7 @@ static void dnscb(struct dns_ctx *ctx, void *result, void *data)
|
||||
if ((qcls == DNS_C_ANY || qcls == rr.dnsrr_cls) && (q->qtyp == DNS_T_ANY || q->qtyp == rr.dnsrr_typ))
|
||||
++nrr;
|
||||
else if (rr.dnsrr_typ == DNS_T_CNAME && !nrr) {
|
||||
if (dns_getdn(pkt, &rr.dnsrr_dptr, end,
|
||||
p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 || rr.dnsrr_dptr != rr.dnsrr_dend) {
|
||||
if (dns_getdn(pkt, &rr.dnsrr_dptr, end, p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 || rr.dnsrr_dptr != rr.dnsrr_dend) {
|
||||
r = DNS_E_PROTOCOL;
|
||||
break;
|
||||
} else {
|
||||
@@ -537,11 +534,8 @@ static switch_caller_extension_t *enum_dialplan_hunt(switch_core_session_t *sess
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ENUM Lookup on %s\n", caller_profile->destination_number);
|
||||
|
||||
if (enum_lookup(switch_strlen_zero(dp) ? globals.root : dp, caller_profile->destination_number, &results) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if ((extension =
|
||||
switch_caller_extension_new(session, caller_profile->destination_number,
|
||||
caller_profile->destination_number)) == 0) {
|
||||
if (enum_lookup(switch_strlen_zero(dp) ? globals.root : dp, caller_profile->destination_number, &results) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
free_results(&results);
|
||||
return NULL;
|
||||
@@ -596,8 +590,7 @@ static void enum_app_function(switch_core_session_t *session, char *data)
|
||||
void *vval;
|
||||
const void *vvar;
|
||||
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &vvar, NULL, &vval);
|
||||
if (vvar && !strncmp(vvar, "enum_", 5)) {
|
||||
switch_channel_set_variable(channel, (char *) vvar, NULL);
|
||||
@@ -658,8 +651,7 @@ static switch_status_t enum_function(char *data, switch_core_session_t *session,
|
||||
|
||||
stream->write_function(stream,
|
||||
"\nOffered Routes:\n"
|
||||
"Order\tPref\tService \tRoute\n"
|
||||
"==============================================================================\n");
|
||||
"Order\tPref\tService \tRoute\n" "==============================================================================\n");
|
||||
|
||||
for (rp = results; rp; rp = rp->next) {
|
||||
stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
|
||||
@@ -668,14 +660,12 @@ static switch_status_t enum_function(char *data, switch_core_session_t *session,
|
||||
|
||||
stream->write_function(stream,
|
||||
"\nSupported Routes:\n"
|
||||
"Order\tPref\tService \tRoute\n"
|
||||
"==============================================================================\n");
|
||||
"Order\tPref\tService \tRoute\n" "==============================================================================\n");
|
||||
|
||||
for (rtp = globals.route_order; rtp; rtp = rtp->next) {
|
||||
for (rp = results; rp; rp = rp->next) {
|
||||
if (!strcmp(rtp->service, rp->service)) {
|
||||
stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service,
|
||||
rp->route);
|
||||
stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -726,8 +716,7 @@ static switch_loadable_module_interface_t enum_module_interface = {
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
if (dns_init(0) < 0) {
|
||||
|
||||
@@ -39,8 +39,7 @@ static const char modname[] = "mod_ivrtest";
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
|
||||
*/
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
switch (itype) {
|
||||
case SWITCH_INPUT_TYPE_DTMF:{
|
||||
@@ -74,8 +73,7 @@ static void xml_function(switch_core_session_t *session, char *data)
|
||||
teamname = switch_xml_attr_soft(team, "name");
|
||||
for (driver = switch_xml_child(team, "driver"); driver; driver = driver->next) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname,
|
||||
switch_xml_child(driver, "points")->txt);
|
||||
"%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname, switch_xml_child(driver, "points")->txt);
|
||||
}
|
||||
}
|
||||
switch_xml_free(f1);
|
||||
@@ -98,16 +96,11 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
NULL,
|
||||
"main",
|
||||
"please enter some numbers so i can figure out if I have any bugs or not",
|
||||
"enter some numbers",
|
||||
NULL, "I have no idea what that is", "cepstral", "david", NULL, 15000, 10, NULL);
|
||||
"enter some numbers", NULL, "I have no idea what that is", "cepstral", "david", NULL, 15000, 10, NULL);
|
||||
|
||||
|
||||
status = switch_ivr_menu_init(&sub_menu,
|
||||
menu,
|
||||
"sub",
|
||||
"/ram/congrats.wav",
|
||||
"/ram/extension.wav",
|
||||
NULL, "/ram/invalid.wav", NULL, NULL, NULL, 15000, 10, NULL);
|
||||
menu, "sub", "/ram/congrats.wav", "/ram/extension.wav", NULL, "/ram/invalid.wav", NULL, NULL, NULL, 15000, 10, NULL);
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
// build the menu
|
||||
@@ -145,10 +138,7 @@ static void dirtest_function(switch_core_session_t *session, char *data)
|
||||
assert(channel != NULL);
|
||||
|
||||
|
||||
if (switch_core_directory_open(&dh,
|
||||
"ldap",
|
||||
"ldap.freeswitch.org",
|
||||
"cn=Manager,dc=freeswitch,dc=org", "test", NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_directory_open(&dh, "ldap", "ldap.freeswitch.org", "cn=Manager,dc=freeswitch,dc=org", "test", NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
|
||||
return;
|
||||
}
|
||||
@@ -166,8 +156,7 @@ static void dirtest_function(switch_core_session_t *session, char *data)
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
|
||||
switch (itype) {
|
||||
@@ -249,8 +238,7 @@ static void bugtest_function(switch_core_session_t *session, char *data)
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_status_t status;
|
||||
|
||||
if ((status = switch_core_media_bug_add(session,
|
||||
bug_callback, NULL, SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = switch_core_media_bug_add(session, bug_callback, NULL, SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return;
|
||||
}
|
||||
@@ -284,9 +272,7 @@ static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
|
||||
|
||||
if (switch_core_asr_open(&ah, "lumenvox",
|
||||
read_codec->implementation->iananame,
|
||||
8000,
|
||||
"127.0.0.1", &flags, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
read_codec->implementation->iananame, 8000, "127.0.0.1", &flags, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
if (strcmp(ah.codec, read_codec->implementation->iananame)) {
|
||||
if (switch_core_codec_init(&codec,
|
||||
ah.codec,
|
||||
@@ -306,16 +292,14 @@ static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->number_of_channels,
|
||||
read_codec->implementation->microseconds_per_frame / 1000);
|
||||
read_codec->implementation->number_of_channels, read_codec->implementation->microseconds_per_frame / 1000);
|
||||
switch_core_session_reset(session);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_asr_load_grammar(&ah, "demo", "/opt/lumenvox/engine_7.0/Lang/BuiltinGrammars/ABNFPhone.gram") !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_asr_load_grammar(&ah, "demo", "/opt/lumenvox/engine_7.0/Lang/BuiltinGrammars/ABNFPhone.gram") != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -393,8 +377,7 @@ static void ivrtest_function(switch_core_session_t *session, char *data)
|
||||
|
||||
while (switch_channel_get_state(channel) == CS_EXECUTE) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
|
||||
"Enter up to 10 digits, press # to terminate, * to hangup\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enter up to 10 digits, press # to terminate, * to hangup\n");
|
||||
|
||||
if (data) {
|
||||
switch_input_args_t args = { 0 };
|
||||
@@ -435,8 +418,7 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "I globally hooked to [%s] on the hangup event\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "I globally hooked to [%s] on the hangup event\n", switch_channel_get_name(channel));
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
@@ -525,8 +507,7 @@ static const switch_loadable_module_interface_t mod_ivrtest_module_interface = {
|
||||
/*.application_interface */ &asrtest_application_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
|
||||
@@ -59,8 +59,7 @@ static switch_loadable_module_interface_t park_module_interface = {
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &park_module_interface;
|
||||
|
||||
@@ -38,8 +38,7 @@ static const char modname[] = "mod_playback";
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
|
||||
*/
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
|
||||
|
||||
@@ -236,8 +235,7 @@ static const switch_loadable_module_interface_t mod_playback_module_interface =
|
||||
/*.application_interface */ &playback_application_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
|
||||
@@ -85,8 +85,7 @@ static uint32_t match_count(char *str, uint32_t max)
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
|
||||
*/
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
switch (itype) {
|
||||
case SWITCH_INPUT_TYPE_DTMF:{
|
||||
@@ -245,9 +244,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
|
||||
memset(&sh, 0, sizeof(sh));
|
||||
if (switch_core_speech_open(&sh,
|
||||
engine,
|
||||
voice, rate, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_speech_open(&sh, engine, voice, rate, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
|
||||
return;
|
||||
}
|
||||
@@ -257,30 +254,24 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
NULL,
|
||||
(int) rate,
|
||||
interval,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
|
||||
rate, interval);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", rate, interval);
|
||||
flags = 0;
|
||||
switch_core_speech_close(&sh, &flags);
|
||||
return;
|
||||
}
|
||||
|
||||
if (timer_name) {
|
||||
if (switch_core_timer_init
|
||||
(&timer, timer_name, interval, (int) (rate / 50),
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_timer_init(&timer, timer_name, interval, (int) (rate / 50), switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
|
||||
switch_core_codec_destroy(&speech_codec);
|
||||
flags = 0;
|
||||
switch_core_speech_close(&sh, &flags);
|
||||
return;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n",
|
||||
(rate / 50) * 2, interval);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", (rate / 50) * 2, interval);
|
||||
|
||||
/* start a thread to absorb incoming audio */
|
||||
for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
|
||||
@@ -311,8 +302,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
#else
|
||||
snprintf(buf + len, sizeof(buf) - len,
|
||||
",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
|
||||
"Select one of the following news sources, followed by the pound key or press 0 to exit. "
|
||||
",<break time=\"600ms\"/>");
|
||||
"Select one of the following news sources, followed by the pound key or press 0 to exit. " ",<break time=\"600ms\"/>");
|
||||
#endif
|
||||
len = (int32_t) strlen(buf);
|
||||
|
||||
@@ -370,10 +360,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
args.input_callback = NULL;
|
||||
args.buf = NULL;
|
||||
args.buflen = 0;
|
||||
status = switch_ivr_speak_text_handle(session,
|
||||
&sh,
|
||||
&speech_codec,
|
||||
timerp, "I'm sorry. That is an Invalid Selection. ", &args);
|
||||
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, "I'm sorry. That is an Invalid Selection. ", &args);
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
goto finished;
|
||||
}
|
||||
@@ -544,8 +531,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
if (switch_test_flag(&dtb, SFLAG_INFO)) {
|
||||
switch_clear_flag(&dtb, SFLAG_INFO);
|
||||
snprintf(buf + len, sizeof(buf) - len,
|
||||
"%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
|
||||
snprintf(buf + len, sizeof(buf) - len, "%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
|
||||
len = (uint32_t) strlen(buf);
|
||||
}
|
||||
|
||||
@@ -569,8 +555,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
|
||||
if (entries[dtb.index].dept_txt) {
|
||||
snprintf(buf + len, sizeof(buf) - len, "From the %s department. ",
|
||||
entries[dtb.index].dept_txt);
|
||||
snprintf(buf + len, sizeof(buf) - len, "From the %s department. ", entries[dtb.index].dept_txt);
|
||||
len = (uint32_t) strlen(buf);
|
||||
}
|
||||
|
||||
@@ -599,10 +584,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
args.input_callback = on_dtmf;
|
||||
args.buf = &dtb;
|
||||
args.buflen = sizeof(dtb);
|
||||
status = switch_ivr_speak_text_handle(session,
|
||||
&sh,
|
||||
&speech_codec,
|
||||
timerp, entries[dtb.index].description_txt, &args);
|
||||
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, entries[dtb.index].description_txt, &args);
|
||||
}
|
||||
if (status == SWITCH_STATUS_BREAK) {
|
||||
continue;
|
||||
@@ -655,8 +637,7 @@ static switch_loadable_module_interface_t rss_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &rss_module_interface;
|
||||
|
||||
@@ -47,8 +47,7 @@ static switch_loadable_module_interface_t skel_module_interface = {
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &skel_module_interface;
|
||||
|
||||
@@ -113,8 +113,7 @@ static swift_result_t write_audio(swift_event * event, swift_event_t type, void
|
||||
return rv;
|
||||
}
|
||||
|
||||
static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate,
|
||||
switch_speech_flag_t *flags)
|
||||
static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate, switch_speech_flag_t *flags)
|
||||
{
|
||||
cepstral_t *cepstral = switch_core_alloc(sh->memory_pool, sizeof(*cepstral));
|
||||
char srate[25];
|
||||
@@ -257,9 +256,7 @@ static void cepstral_speech_flush_tts(switch_speech_handle_t *sh)
|
||||
swift_port_stop(cepstral->port, SWIFT_ASYNC_ANY, SWIFT_EVENT_NOW);
|
||||
}
|
||||
|
||||
static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
|
||||
void *data,
|
||||
size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags)
|
||||
static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags)
|
||||
{
|
||||
cepstral_t *cepstral;
|
||||
size_t desired = *datalen;
|
||||
|
||||
@@ -113,8 +113,7 @@ static struct {
|
||||
|
||||
#endif
|
||||
|
||||
static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
|
||||
#ifdef AMR_PASSTHROUGH
|
||||
@@ -202,8 +201,7 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
||||
context->enc_mode = globals.default_bitrate;
|
||||
}
|
||||
|
||||
snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d",
|
||||
switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
|
||||
snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
|
||||
|
||||
context->enc_mode = AMR_DEFAULT_BITRATE;
|
||||
@@ -245,9 +243,7 @@ static switch_status_t switch_amr_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef AMR_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -259,9 +255,7 @@ static switch_status_t switch_amr_encode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
*encoded_data_len =
|
||||
Encoder_Interface_Encode(context->encoder_state, context->enc_mode, (int16_t *) decoded_data,
|
||||
(switch_byte_t *) encoded_data, 0);
|
||||
*encoded_data_len = Encoder_Interface_Encode(context->encoder_state, context->enc_mode, (int16_t *) decoded_data, (switch_byte_t *) encoded_data, 0);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#endif
|
||||
@@ -271,9 +265,7 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef AMR_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -328,8 +320,7 @@ static switch_loadable_module_interface_t amr_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
#ifndef AMR_PASSTHROUGH
|
||||
char *cf = "amr.conf";
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
static const char modname[] = "mod_g711";
|
||||
|
||||
|
||||
static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -56,9 +55,7 @@ static switch_status_t switch_g711u_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -80,9 +77,7 @@ static switch_status_t switch_g711u_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -111,8 +106,7 @@ static switch_status_t switch_g711u_destroy(switch_codec_t *codec)
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -131,9 +125,7 @@ static switch_status_t switch_g711a_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -155,9 +147,7 @@ static switch_status_t switch_g711a_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -421,8 +411,7 @@ static switch_loadable_module_interface_t g711_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &g711_module_interface;
|
||||
|
||||
@@ -40,8 +40,7 @@ struct g722_context {
|
||||
g722_encode_state_t encoder_object;
|
||||
};
|
||||
|
||||
static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
struct g722_context *context = NULL;
|
||||
@@ -77,9 +76,7 @@ static switch_status_t switch_g722_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct g722_context *context = codec->private_info;
|
||||
|
||||
@@ -87,8 +84,7 @@ static switch_status_t switch_g722_encode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
*encoded_data_len =
|
||||
g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
|
||||
*encoded_data_len = g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -97,9 +93,7 @@ static switch_status_t switch_g722_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct g722_context *context = codec->private_info;
|
||||
|
||||
@@ -107,9 +101,7 @@ static switch_status_t switch_g722_decode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
*decoded_data_len =
|
||||
(2 *
|
||||
g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
|
||||
*decoded_data_len = (2 * g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -178,8 +170,7 @@ static switch_loadable_module_interface_t g722_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &g722_module_interface;
|
||||
|
||||
@@ -60,8 +60,7 @@ struct g723_context {
|
||||
};
|
||||
#endif
|
||||
|
||||
static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
#ifdef G723_PASSTHROUGH
|
||||
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
|
||||
@@ -110,9 +109,7 @@ static switch_status_t switch_g723_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G723_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -142,9 +139,7 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G723_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -205,8 +200,7 @@ static switch_loadable_module_interface_t g723_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &g723_module_interface;
|
||||
|
||||
@@ -52,8 +52,7 @@ typedef struct {
|
||||
switch_byte_t buf[160];
|
||||
} g726_handle_t;
|
||||
|
||||
static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
uint32_t encoding, decoding;
|
||||
g726_handle_t *handle;
|
||||
@@ -88,16 +87,14 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
|
||||
handle->loops = 160;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n",
|
||||
codec->implementation->encoded_bytes_per_frame);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n", codec->implementation->encoded_bytes_per_frame);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
g726_init_state(&handle->context);
|
||||
codec->private_info = handle;
|
||||
handle->bits_per_frame =
|
||||
(switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
|
||||
handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
|
||||
handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
|
||||
? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -117,9 +114,7 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
|
||||
g726_handle_t *handle = codec->private_info;
|
||||
@@ -151,8 +146,7 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -166,9 +160,7 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
|
||||
g726_handle_t *handle = codec->private_info;
|
||||
@@ -434,8 +426,7 @@ static switch_loadable_module_interface_t g726_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &g726_module_interface;
|
||||
|
||||
@@ -45,8 +45,7 @@ struct g729_context {
|
||||
};
|
||||
#endif
|
||||
|
||||
static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
#ifdef G729_PASSTHROUGH
|
||||
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
|
||||
@@ -96,9 +95,7 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G729_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -128,8 +125,7 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -141,9 +137,7 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G729_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -208,8 +202,7 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
|
||||
encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -274,8 +267,7 @@ static switch_loadable_module_interface_t g729_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &g729_module_interface;
|
||||
|
||||
@@ -36,8 +36,7 @@ struct gsm_context {
|
||||
gsm encoder;
|
||||
gsm decoder;
|
||||
};
|
||||
static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
struct gsm_context *context;
|
||||
int encoding, decoding;
|
||||
@@ -90,8 +89,7 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -122,13 +120,11 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
|
||||
if (new_len <= *decoded_data_len) {
|
||||
*decoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len,
|
||||
*decoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len, *decoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n",
|
||||
encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n", encoded_data_len);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -166,8 +162,7 @@ static switch_loadable_module_interface_t gsm_module_interface = {
|
||||
/*.codec_interface */ &gsm_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
|
||||
@@ -44,8 +44,7 @@ struct ilbc_context {
|
||||
uint16_t dbytes;
|
||||
};
|
||||
|
||||
static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
struct ilbc_context *context;
|
||||
int encoding, decoding;
|
||||
@@ -99,9 +98,7 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct ilbc_context *context = codec->private_info;
|
||||
|
||||
@@ -129,8 +126,7 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -141,9 +137,7 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct ilbc_context *context = codec->private_info;
|
||||
|
||||
@@ -176,8 +170,7 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
|
||||
encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -321,8 +314,7 @@ static switch_loadable_module_interface_t ilbc_module_interface = {
|
||||
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
|
||||
@@ -34,8 +34,7 @@
|
||||
static const char modname[] = "mod_l16";
|
||||
|
||||
|
||||
static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -53,13 +52,10 @@ static switch_status_t switch_raw_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
|
||||
if (codec && other_codec
|
||||
&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
memcpy(encoded_data, decoded_data, decoded_data_len);
|
||||
*encoded_data_len = decoded_data_len;
|
||||
return SWITCH_STATUS_RESAMPLE;
|
||||
@@ -71,12 +67,9 @@ static switch_status_t switch_raw_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
if (codec && other_codec
|
||||
&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
memcpy(decoded_data, encoded_data, encoded_data_len);
|
||||
*decoded_data_len = encoded_data_len;
|
||||
return SWITCH_STATUS_RESAMPLE;
|
||||
@@ -429,8 +422,7 @@ static switch_loadable_module_interface_t raw_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &raw_module_interface;
|
||||
|
||||
@@ -51,8 +51,7 @@ struct lpc10_context {
|
||||
struct lpc10_decoder_state decoder_object;
|
||||
};
|
||||
|
||||
static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
uint32_t encoding, decoding;
|
||||
struct lpc10_context *context = NULL;
|
||||
@@ -88,9 +87,7 @@ static switch_status_t switch_lpc10_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct lpc10_context *context = codec->private_info;
|
||||
uint8_t i;
|
||||
@@ -123,9 +120,7 @@ static switch_status_t switch_lpc10_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct lpc10_context *context = codec->private_info;
|
||||
int i;
|
||||
@@ -193,8 +188,7 @@ static switch_loadable_module_interface_t lpc10_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &lpc10_module_interface;
|
||||
|
||||
@@ -72,8 +72,7 @@ struct speex_context {
|
||||
int decoder_mode;
|
||||
};
|
||||
|
||||
static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
struct speex_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
@@ -111,17 +110,14 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_GET_FRAME_SIZE, &context->encoder_frame_size);
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_COMPLEXITY, &codec->codec_settings.complexity);
|
||||
if (codec->codec_settings.preproc) {
|
||||
context->pp =
|
||||
speex_preprocess_state_init(context->encoder_frame_size, codec->implementation->samples_per_second);
|
||||
context->pp = speex_preprocess_state_init(context->encoder_frame_size, codec->implementation->samples_per_second);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_VAD, &codec->codec_settings.pp_vad);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC, &codec->codec_settings.pp_agc);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC_LEVEL, &codec->codec_settings.pp_agc_level);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DENOISE, &codec->codec_settings.pp_denoise);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB, &codec->codec_settings.pp_dereverb);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY,
|
||||
&codec->codec_settings.pp_dereverb_decay);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL,
|
||||
&codec->codec_settings.pp_dereverb_level);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &codec->codec_settings.pp_dereverb_decay);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &codec->codec_settings.pp_dereverb_level);
|
||||
}
|
||||
|
||||
if (!codec->codec_settings.abr && !codec->codec_settings.vbr) {
|
||||
@@ -161,9 +157,7 @@ static switch_status_t switch_speex_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct speex_context *context = codec->private_info;
|
||||
short *buf;
|
||||
@@ -214,9 +208,7 @@ static switch_status_t switch_speex_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct speex_context *context = codec->private_info;
|
||||
short *buf;
|
||||
@@ -343,8 +335,7 @@ static switch_loadable_module_interface_t speex_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &speex_module_interface;
|
||||
|
||||
@@ -99,17 +99,14 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
|
||||
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
|
||||
caller_profile->destination_number);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name, caller_profile->destination_number);
|
||||
|
||||
|
||||
if (!(globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (switch_core_directory_open(&dh,
|
||||
globals.directory_name,
|
||||
globals.host, globals.dn, globals.pass, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_directory_open(&dh, globals.directory_name, globals.host, globals.dn, globals.pass, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -126,8 +123,7 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DIRECTORY VALUE [%s]=[%s]\n", var, val);
|
||||
if (!strcasecmp(var, "callflow")) {
|
||||
if (!extension) {
|
||||
if ((extension = switch_caller_extension_new(session, caller_profile->destination_number,
|
||||
caller_profile->destination_number)) == 0) {
|
||||
if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
goto out;
|
||||
}
|
||||
@@ -168,8 +164,7 @@ static const switch_loadable_module_interface_t directory_dialplan_module_interf
|
||||
/*.application_interface = */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
load_config();
|
||||
|
||||
@@ -114,11 +114,8 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
if (!field_data) {
|
||||
field_data = "";
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field,
|
||||
field_data, expression);
|
||||
if (!
|
||||
(proceed =
|
||||
switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field, field_data, expression);
|
||||
if (!(proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n");
|
||||
|
||||
for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
|
||||
@@ -126,9 +123,7 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
char *data = (char *) switch_xml_attr_soft(xaction, "data");
|
||||
|
||||
if (!*extension) {
|
||||
if ((*extension =
|
||||
switch_caller_extension_new(session, exten_name,
|
||||
caller_profile->destination_number)) == 0) {
|
||||
if ((*extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
proceed = 0;
|
||||
goto done;
|
||||
@@ -170,8 +165,7 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
}
|
||||
|
||||
if (!*extension) {
|
||||
if ((*extension =
|
||||
switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
|
||||
if ((*extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
proceed = 0;
|
||||
goto done;
|
||||
@@ -194,9 +188,7 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
return proceed;
|
||||
}
|
||||
|
||||
static switch_status_t dialplan_xml_locate(switch_core_session_t *session,
|
||||
switch_caller_profile_t *caller_profile,
|
||||
switch_xml_t * root, switch_xml_t * node)
|
||||
static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t * root, switch_xml_t * node)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_GENERR;
|
||||
switch_channel_t *channel;
|
||||
@@ -261,8 +253,7 @@ static switch_status_t dialplan_xml_locate(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
|
||||
void *val;
|
||||
const void *var;
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
@@ -318,8 +309,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name,
|
||||
caller_profile->destination_number);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name, caller_profile->destination_number);
|
||||
|
||||
/* get our handle to the "dialplan" section of the config */
|
||||
|
||||
@@ -330,10 +320,8 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) &&
|
||||
(tag = switch_xml_find_child(conf, "dialplan", NULL, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n",
|
||||
alt_path);
|
||||
if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) && (tag = switch_xml_find_child(conf, "dialplan", NULL, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n", alt_path);
|
||||
xml = alt_root;
|
||||
cfg = tag;
|
||||
} else {
|
||||
@@ -350,8 +338,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
|
||||
/* get a handle to the context tag */
|
||||
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", caller_profile->context))) {
|
||||
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n",
|
||||
caller_profile->context);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n", caller_profile->context);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -402,8 +389,7 @@ static const switch_loadable_module_interface_t dialplan_module_interface = {
|
||||
/*.application_interface = */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
|
||||
@@ -188,8 +188,7 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **
|
||||
context->attr = ldap_next_attribute(context->ld, context->entry, context->ber);
|
||||
}
|
||||
context->vitt++;
|
||||
if (context->entry && context->attr
|
||||
&& (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) {
|
||||
if (context->entry && context->attr && (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) {
|
||||
goto itter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ static switch_memory_pool_t *module_pool = NULL;
|
||||
|
||||
static char sub_sql[] =
|
||||
"CREATE TABLE subscriptions (\n"
|
||||
" sub_from VARCHAR(255),\n"
|
||||
" sub_to VARCHAR(255),\n" " show VARCHAR(255),\n" " status VARCHAR(255)\n" ");\n";
|
||||
" sub_from VARCHAR(255),\n" " sub_to VARCHAR(255),\n" " show VARCHAR(255),\n" " status VARCHAR(255)\n" ");\n";
|
||||
|
||||
|
||||
typedef enum {
|
||||
@@ -171,8 +170,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
|
||||
|
||||
static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session,
|
||||
switch_stream_handle_t *stream);
|
||||
static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
static switch_status_t channel_on_init(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_hangup(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_ring(switch_core_session_t *session);
|
||||
@@ -180,12 +178,9 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
static switch_status_t channel_on_transmit(switch_core_session_t *session);
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session,
|
||||
switch_memory_pool_t **pool);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
||||
|
||||
static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal,
|
||||
@@ -324,8 +319,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||
if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
|
||||
if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) {
|
||||
if (!(db = switch_core_db_open_file(profile->dbname))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n",
|
||||
profile->dbname);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
|
||||
return;
|
||||
}
|
||||
switch_mutex_lock(profile->mutex);
|
||||
@@ -361,12 +355,10 @@ static void pres_event_handler(switch_event_t *event)
|
||||
}
|
||||
|
||||
|
||||
sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from subscriptions where sub_to like '%%%q'",
|
||||
type, rpid, status, proto, from);
|
||||
sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from subscriptions where sub_to like '%%%q'", type, rpid, status, proto, from);
|
||||
|
||||
|
||||
for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||
char *errmsg;
|
||||
switch_hash_this(hi, NULL, NULL, &val);
|
||||
profile = (struct mdl_profile *) val;
|
||||
@@ -465,8 +457,7 @@ static void roster_event_handler(switch_event_t *event)
|
||||
sql = switch_mprintf("select *,'%q' from subscriptions", status ? status : "");
|
||||
}
|
||||
|
||||
for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||
char *errmsg;
|
||||
switch_hash_this(hi, NULL, NULL, &val);
|
||||
profile = (struct mdl_profile *) val;
|
||||
@@ -541,8 +532,7 @@ static void sign_off(void)
|
||||
sql = switch_mprintf("select * from subscriptions");
|
||||
|
||||
|
||||
for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||
char *errmsg;
|
||||
switch_hash_this(hi, NULL, NULL, &val);
|
||||
profile = (struct mdl_profile *) val;
|
||||
@@ -576,10 +566,7 @@ static void sign_on(struct mdl_profile *profile)
|
||||
switch_core_db_t *db;
|
||||
char *errmsg;
|
||||
|
||||
if ((sql =
|
||||
switch_mprintf
|
||||
("select * from subscriptions where sub_to like 'ext+%%' or sub_to like 'user+%%' or sub_to like 'conf+%%'")))
|
||||
{
|
||||
if ((sql = switch_mprintf("select * from subscriptions where sub_to like 'ext+%%' or sub_to like 'user+%%' or sub_to like 'conf+%%'"))) {
|
||||
if (!(db = switch_core_db_open_file(profile->dbname))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
|
||||
return;
|
||||
@@ -599,8 +586,7 @@ static void terminate_session(switch_core_session_t **session, int line, switch_
|
||||
switch_channel_state_t state = switch_channel_get_state(channel);
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Terminate called from line %d state=%s\n", line,
|
||||
switch_channel_state_name(state));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Terminate called from line %d state=%s\n", line, switch_channel_state_name(state));
|
||||
|
||||
tech_pvt = switch_core_session_get_private(*session);
|
||||
|
||||
@@ -650,15 +636,12 @@ static int get_codecs(struct private_object *tech_pvt)
|
||||
if (!tech_pvt->num_codecs) {
|
||||
if (globals.codec_string) {
|
||||
if ((tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs,
|
||||
SWITCH_MAX_CODECS,
|
||||
globals.codec_order,
|
||||
globals.codec_order_last)) <= 0) {
|
||||
SWITCH_MAX_CODECS, globals.codec_order, globals.codec_order_last)) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return 0;
|
||||
}
|
||||
} else if (((tech_pvt->num_codecs =
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session),
|
||||
tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -669,7 +652,7 @@ static int get_codecs(struct private_object *tech_pvt)
|
||||
|
||||
|
||||
|
||||
static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
ldl_handle_t *handle = obj;
|
||||
struct mdl_profile *profile = NULL;
|
||||
@@ -683,8 +666,7 @@ static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t *thread, void
|
||||
switch_clear_flag(profile, TFLAG_IO);
|
||||
globals.handles--;
|
||||
ldl_handle_destroy(&handle);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle %s [%s] Destroyed\n", profile->name,
|
||||
profile->login);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle %s [%s] Destroyed\n", profile->name, profile->login);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -774,10 +756,7 @@ static int activate_rtp(struct private_object *tech_pvt)
|
||||
tech_pvt->codec_num,
|
||||
tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
|
||||
tech_pvt->read_codec.implementation->microseconds_per_frame,
|
||||
flags,
|
||||
NULL,
|
||||
tech_pvt->profile->timer_name,
|
||||
&err, switch_core_session_get_pool(tech_pvt->session)))) {
|
||||
flags, NULL, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session)))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return 0;
|
||||
@@ -787,8 +766,7 @@ static int activate_rtp(struct private_object *tech_pvt)
|
||||
uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
|
||||
switch_rtp_activate_ice(tech_pvt->rtp_session, tech_pvt->remote_user, tech_pvt->local_user);
|
||||
if ((vad_in && inb) || (vad_out && !inb)) {
|
||||
switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec,
|
||||
SWITCH_VAD_FLAG_TALKING);
|
||||
switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_VAD);
|
||||
}
|
||||
switch_rtp_set_cng_pt(tech_pvt->rtp_session, 13);
|
||||
@@ -846,18 +824,15 @@ static int do_candidates(struct private_object *tech_pvt, int force)
|
||||
}
|
||||
|
||||
cand[0].address = tech_pvt->profile->ip;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address,
|
||||
cand[0].port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address, cand[0].port);
|
||||
if (switch_stun_lookup
|
||||
(&cand[0].address, &cand[0].port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &err,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip,
|
||||
SWITCH_STUN_DEFAULT_PORT, err);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return 0;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address,
|
||||
cand[0].port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address, cand[0].port);
|
||||
}
|
||||
cand[0].type = "stun";
|
||||
tech_pvt->stun_ip = switch_core_session_strdup(tech_pvt->session, cand[0].address);
|
||||
@@ -871,8 +846,7 @@ static int do_candidates(struct private_object *tech_pvt, int force)
|
||||
cand[0].password = tech_pvt->local_pass;
|
||||
cand[0].pref = 1;
|
||||
cand[0].protocol = "udp";
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address,
|
||||
cand[0].port, cand[0].username);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
|
||||
tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY);
|
||||
@@ -940,12 +914,10 @@ static int do_describe(struct private_object *tech_pvt, int force)
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Describe [%s@%d]\n", payloads[0].name,
|
||||
payloads[0].rate);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Describe [%s@%d]\n", payloads[0].name, payloads[0].rate);
|
||||
tech_pvt->desc_id =
|
||||
ldl_session_describe(tech_pvt->dlsession, payloads, 1,
|
||||
switch_test_flag(tech_pvt,
|
||||
TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT);
|
||||
switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_CODEC_READY);
|
||||
}
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
|
||||
@@ -985,8 +957,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
|
||||
|
||||
while (!(switch_test_flag(tech_pvt, TFLAG_CODEC_READY) &&
|
||||
switch_test_flag(tech_pvt, TFLAG_RTP_READY) &&
|
||||
switch_test_flag(tech_pvt, TFLAG_ANSWER) &&
|
||||
switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
|
||||
switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
|
||||
now = switch_time_now();
|
||||
elapsed = (unsigned int) ((now - started) / 1000);
|
||||
|
||||
@@ -1242,13 +1213,11 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *d
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF [%s]\n", dtmf);
|
||||
|
||||
return switch_rtp_queue_rfc2833(tech_pvt->rtp_session,
|
||||
dtmf, 100 * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
|
||||
return switch_rtp_queue_rfc2833(tech_pvt->rtp_session, dtmf, 100 * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
struct private_object *tech_pvt = NULL;
|
||||
uint32_t bytes = 0;
|
||||
@@ -1306,9 +1275,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
}
|
||||
|
||||
if (switch_test_flag(&tech_pvt->read_frame, SFF_CNG)) {
|
||||
tech_pvt->read_frame.datalen =
|
||||
tech_pvt->last_read ? tech_pvt->last_read : tech_pvt->read_codec.implementation->
|
||||
encoded_bytes_per_frame;
|
||||
tech_pvt->read_frame.datalen = tech_pvt->last_read ? tech_pvt->last_read : tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
||||
}
|
||||
|
||||
if (tech_pvt->read_frame.datalen > 0) {
|
||||
@@ -1339,8 +1306,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel_t *channel = NULL;
|
||||
@@ -1536,7 +1502,7 @@ static const switch_loadable_module_interface_t channel_module_interface = {
|
||||
*/
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool)
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
|
||||
struct private_object *tech_pvt;
|
||||
@@ -1614,8 +1580,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
|
||||
tech_pvt->flags |= globals.flags;
|
||||
@@ -1662,9 +1627,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
}
|
||||
|
||||
if (!cid_msg) {
|
||||
f_cid_msg =
|
||||
switch_mprintf("Incoming Call From %s %s\n", outbound_profile->caller_id_name,
|
||||
outbound_profile->caller_id_number);
|
||||
f_cid_msg = switch_mprintf("Incoming Call From %s %s\n", outbound_profile->caller_id_name, outbound_profile->caller_id_number);
|
||||
cid_msg = f_cid_msg;
|
||||
}
|
||||
|
||||
@@ -1701,8 +1664,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -1713,14 +1675,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
load_config();
|
||||
|
||||
if (switch_event_reserve_subclass(DL_EVENT_LOGIN_SUCCESS) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!",
|
||||
DL_EVENT_LOGIN_SUCCESS);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_LOGIN_SUCCESS);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_reserve_subclass(DL_EVENT_LOGIN_FAILURE) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!",
|
||||
DL_EVENT_LOGIN_FAILURE);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_LOGIN_FAILURE);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
@@ -1729,23 +1689,17 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -1773,9 +1727,7 @@ static ldl_status handle_loop(ldl_handle_t * handle)
|
||||
|
||||
static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
|
||||
{
|
||||
if (profile &&
|
||||
profile->login &&
|
||||
profile->password && profile->dialplan && profile->message && profile->ip && profile->name && profile->exten) {
|
||||
if (profile && profile->login && profile->password && profile->dialplan && profile->message && profile->ip && profile->name && profile->exten) {
|
||||
ldl_handle_t *handle;
|
||||
|
||||
if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
|
||||
@@ -1787,18 +1739,14 @@ static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
|
||||
profile->login,
|
||||
profile->password,
|
||||
profile->server,
|
||||
profile->user_flags,
|
||||
profile->message,
|
||||
handle_loop, handle_signalling, handle_response, profile) == LDL_STATUS_SUCCESS) {
|
||||
profile->user_flags, profile->message, handle_loop, handle_signalling, handle_response, profile) == LDL_STATUS_SUCCESS) {
|
||||
profile->handle = handle;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Started Thread for %s@%s\n", profile->login,
|
||||
profile->dialplan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Started Thread for %s@%s\n", profile->login, profile->dialplan);
|
||||
switch_core_hash_insert(globals.profile_hash, profile->name, profile);
|
||||
handle_thread_launch(handle);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Profile for %s@%s\n", profile->login,
|
||||
profile->dialplan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Profile for %s@%s\n", profile->login, profile->dialplan);
|
||||
switch_core_hash_insert(globals.profile_hash, profile->name, profile);
|
||||
}
|
||||
} else {
|
||||
@@ -1810,10 +1758,7 @@ static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
|
||||
"message[%s]\n"
|
||||
"rtp-ip[%s]\n"
|
||||
"name[%s]\n"
|
||||
"exten[%s]\n",
|
||||
profile->login,
|
||||
profile->password,
|
||||
profile->dialplan, profile->message, profile->ip, profile->name, profile->exten);
|
||||
"exten[%s]\n", profile->login, profile->password, profile->dialplan, profile->message, profile->ip, profile->name, profile->exten);
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -2014,20 +1959,17 @@ static switch_status_t load_config(void)
|
||||
globals.debug = atoi(val);
|
||||
} else if (!strcasecmp(var, "codec-prefs")) {
|
||||
set_global_codec_string(val);
|
||||
globals.codec_order_last =
|
||||
switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
|
||||
globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
|
||||
} else if (!strcasecmp(var, "codec-rates")) {
|
||||
set_global_codec_rates_string(val);
|
||||
globals.codec_rates_last =
|
||||
switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
|
||||
globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(xmlint = switch_xml_child(cfg, "profile"))) {
|
||||
if ((xmlint = switch_xml_child(cfg, "interface"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"!!!!!!! DEPRICATION WARNING 'interface' is now 'profile' !!!!!!!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "!!!!!!! DEPRICATION WARNING 'interface' is now 'profile' !!!!!!!\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2102,7 +2044,7 @@ static switch_status_t load_config(void)
|
||||
}
|
||||
|
||||
|
||||
static void execute_sql(char *dbname, char *sql, switch_mutex_t *mutex)
|
||||
static void execute_sql(char *dbname, char *sql, switch_mutex_t * mutex)
|
||||
{
|
||||
switch_core_db_t *db;
|
||||
|
||||
@@ -2167,8 +2109,7 @@ static void do_vcard(ldl_handle_t * handle, char *to, char *from, char *id)
|
||||
}
|
||||
|
||||
if (!(vcard = switch_xml_child(user, "vcard"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find <vcard> tag for user [%s@%s]\n", to_user,
|
||||
to_host);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find <vcard> tag for user [%s@%s]\n", to_user, to_host);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -2188,8 +2129,7 @@ static void do_vcard(ldl_handle_t * handle, char *to, char *from, char *id)
|
||||
switch_safe_free(xmlstr);
|
||||
}
|
||||
|
||||
static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal, char *to,
|
||||
char *from, char *subject, char *msg)
|
||||
static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg)
|
||||
{
|
||||
struct mdl_profile *profile = NULL;
|
||||
switch_core_session_t *session = NULL;
|
||||
@@ -2225,8 +2165,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
case LDL_SIGNAL_SUBSCRIBE:
|
||||
|
||||
if ((sql = switch_mprintf("delete from subscriptions where sub_from='%q' and sub_to='%q';\n"
|
||||
"insert into subscriptions values('%q','%q','%q','%q');\n", from, to, from,
|
||||
to, msg, subject))) {
|
||||
"insert into subscriptions values('%q','%q','%q','%q');\n", from, to, from, to, msg, subject))) {
|
||||
execute_sql(profile->dbname, sql, profile->mutex);
|
||||
switch_core_db_free(sql);
|
||||
}
|
||||
@@ -2269,9 +2208,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
break;
|
||||
case LDL_SIGNAL_PRESENCE_IN:
|
||||
|
||||
if ((sql =
|
||||
switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject,
|
||||
from))) {
|
||||
if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
|
||||
execute_sql(profile->dbname, sql, profile->mutex);
|
||||
switch_core_db_free(sql);
|
||||
}
|
||||
@@ -2305,9 +2242,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
case LDL_SIGNAL_PRESENCE_OUT:
|
||||
|
||||
if ((sql =
|
||||
switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject,
|
||||
from))) {
|
||||
if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
|
||||
execute_sql(profile->dbname, sql, profile->mutex);
|
||||
switch_core_db_free(sql);
|
||||
}
|
||||
@@ -2332,9 +2267,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
if (profile->auto_reply) {
|
||||
ldl_handle_send_msg(handle,
|
||||
(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->
|
||||
handle),
|
||||
from, "", profile->auto_reply);
|
||||
(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->handle), from, "", profile->auto_reply);
|
||||
}
|
||||
|
||||
if (strchr(to, '+')) {
|
||||
@@ -2366,10 +2299,8 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
}
|
||||
break;
|
||||
case LDL_SIGNAL_LOGIN_SUCCESS:
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_SUCCESS) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s",
|
||||
ldl_handle_get_login(profile->handle));
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_SUCCESS) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", ldl_handle_get_login(profile->handle));
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
if (profile->user_flags & LDL_FLAG_COMPONENT) {
|
||||
@@ -2378,17 +2309,14 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
break;
|
||||
case LDL_SIGNAL_LOGIN_FAILURE:
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_FAILURE) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s",
|
||||
ldl_handle_get_login(profile->handle));
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_FAILURE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", ldl_handle_get_login(profile->handle));
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
break;
|
||||
case LDL_SIGNAL_CONNECTED:
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_CONNECTED) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s",
|
||||
ldl_handle_get_login(profile->handle));
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", ldl_handle_get_login(profile->handle));
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
break;
|
||||
@@ -2408,12 +2336,10 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using Existing session for %s\n",
|
||||
ldl_session_get_id(dlsession));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using Existing session for %s\n", ldl_session_get_id(dlsession));
|
||||
|
||||
if (switch_channel_get_state(channel) >= CS_HANGUP) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call %s is already over\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call %s is already over\n", switch_channel_get_name(channel));
|
||||
status = LDL_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
@@ -2427,8 +2353,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
tech_pvt->flags |= globals.flags;
|
||||
@@ -2448,8 +2373,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
status = LDL_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n",
|
||||
ldl_session_get_id(dlsession));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
|
||||
ldl_session_set_private(dlsession, session);
|
||||
tech_pvt->dlsession = dlsession;
|
||||
switch_channel_set_name(channel, "DingaLing/new");
|
||||
@@ -2540,8 +2464,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
unsigned int x, y;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u payloads\n", len);
|
||||
for (x = 0; x < len; x++) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Available Payload %s %u\n",
|
||||
payloads[x].name, payloads[x].id);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, payloads[x].id);
|
||||
for (y = 0; y < tech_pvt->num_codecs; y++) {
|
||||
char *name = tech_pvt->codecs[y]->iananame;
|
||||
|
||||
@@ -2559,8 +2482,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
if (match && payloads[x].rate == tech_pvt->codecs[y]->samples_per_second) {
|
||||
tech_pvt->codec_index = y;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n",
|
||||
y, payloads[x].name, payloads[x].id);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, payloads[x].name, payloads[x].id);
|
||||
tech_pvt->codec_name = tech_pvt->codecs[y]->iananame;
|
||||
tech_pvt->codec_num = tech_pvt->codecs[y]->ianacode;
|
||||
tech_pvt->r_codec_num = (switch_payload_t) (payloads[x].id);
|
||||
@@ -2604,8 +2526,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
|
||||
if (tech_pvt->remote_ip) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n",
|
||||
tech_pvt->remote_ip);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->remote_ip);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2617,8 +2538,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address,
|
||||
candidates[x].port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
|
||||
|
||||
if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && ((profile->lanaddr && lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) && strncasecmp(candidates[x].address, "192.168.", 8) && strncasecmp(candidates[x].address, "127.", 4) && strncasecmp(candidates[x].address, "255.", 4) && strncasecmp(candidates[x].address, "0.", 2) && strncasecmp(candidates[x].address, "1.", 2) && strncasecmp(candidates[x].address, "2.", 2) && strncasecmp(candidates[x].address, "172.16.", 7) && strncasecmp(candidates[x].address, "172.17.", 7) && strncasecmp(candidates[x].address, "172.18.", 7) && strncasecmp(candidates[x].address, "172.19.", 7) && strncasecmp(candidates[x].address, "172.2", 5) && strncasecmp(candidates[x].address, "172.30.", 7) && strncasecmp(candidates[x].address, "172.31.", 7) && strncasecmp(candidates[x].address, "192.0.2.", 8) && // 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
|
||||
strncasecmp
|
||||
@@ -2637,8 +2557,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
memset(payloads, 0, sizeof(payloads));
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n",
|
||||
candidates[x].address, candidates[x].port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n", candidates[x].address, candidates[x].port);
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
|
||||
@@ -2704,8 +2623,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
if (!tech_pvt->caller_profile) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Creating an identity for %s %s <%s> %s\n", ldl_session_get_id(dlsession),
|
||||
cid_name, cid_num, exten);
|
||||
"Creating an identity for %s %s <%s> %s\n", ldl_session_get_id(dlsession), cid_name, cid_num, exten);
|
||||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
ldl_handle_get_login(profile->handle),
|
||||
@@ -2718,9 +2636,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
ldl_session_get_value(dlsession,
|
||||
"aniii"),
|
||||
ldl_session_get_value(dlsession,
|
||||
"rdnis"),
|
||||
(char *) modname, context,
|
||||
exten)) != 0) {
|
||||
"rdnis"), (char *) modname, context, exten)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
||||
@@ -103,8 +103,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip)
|
||||
|
||||
|
||||
static char *IAXNAMES[] =
|
||||
{ "IAX_EVENT_CONNECT", "IAX_EVENT_ACCEPT", "IAX_EVENT_HANGUP", "IAX_EVENT_REJECT", "IAX_EVENT_VOICE",
|
||||
static char *IAXNAMES[] = { "IAX_EVENT_CONNECT", "IAX_EVENT_ACCEPT", "IAX_EVENT_HANGUP", "IAX_EVENT_REJECT", "IAX_EVENT_VOICE",
|
||||
"IAX_EVENT_DTMF", "IAX_EVENT_TIMEOUT", "IAX_EVENT_LAGRQ", "IAX_EVENT_LAGRP", "IAX_EVENT_RINGA",
|
||||
"IAX_EVENT_PING", "IAX_EVENT_PONG", "IAX_EVENT_BUSY", "IAX_EVENT_ANSWER", "IAX_EVENT_IMAGE",
|
||||
"IAX_EVENT_AUTHRQ", "IAX_EVENT_AUTHRP", "IAX_EVENT_REGREQ", "IAX_EVENT_REGACK",
|
||||
@@ -210,8 +209,7 @@ typedef enum {
|
||||
} iax_io_t;
|
||||
|
||||
static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *iax_session,
|
||||
unsigned int *format, unsigned int *cababilities, unsigned short *samprate,
|
||||
iax_io_t io)
|
||||
unsigned int *format, unsigned int *cababilities, unsigned short *samprate, iax_io_t io)
|
||||
{
|
||||
char *dname = NULL;
|
||||
//int rate = 8000;
|
||||
@@ -224,17 +222,11 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
|
||||
uint32_t interval = 0;
|
||||
|
||||
if (globals.codec_string) {
|
||||
if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
|
||||
SWITCH_MAX_CODECS,
|
||||
globals.codec_order,
|
||||
globals.codec_order_last)) <= 0) {
|
||||
if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, globals.codec_order, globals.codec_order_last)) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
} else
|
||||
if (((num_codecs =
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs,
|
||||
SWITCH_MAX_CODECS))) <= 0) {
|
||||
} else if (((num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS))) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -425,11 +417,9 @@ static switch_status_t channel_on_loopback(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_transmit(switch_core_session_t *session);
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
||||
|
||||
|
||||
@@ -642,8 +632,7 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *d
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
@@ -714,8 +703,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
@@ -736,8 +724,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
}
|
||||
#endif
|
||||
//printf("Send %ld %d\n", time(NULL), (int) frame->datalen);
|
||||
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int) frame->datalen,
|
||||
tech_pvt->write_codec.implementation->samples_per_frame);
|
||||
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int) frame->datalen, tech_pvt->write_codec.implementation->samples_per_frame);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -803,7 +790,7 @@ that allocate memory or you will have 1 channel with memory allocated from anoth
|
||||
*/
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool)
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
@@ -853,8 +840,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
}
|
||||
|
||||
iax_call(tech_pvt->iax_session,
|
||||
caller_profile->caller_id_number,
|
||||
caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap);
|
||||
caller_profile->caller_id_number, caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap);
|
||||
|
||||
switch_channel_set_flag(channel, CF_OUTBOUND);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
|
||||
@@ -866,8 +852,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -924,12 +909,10 @@ static switch_status_t load_config(void)
|
||||
set_global_dialplan(val);
|
||||
} else if (!strcmp(var, "codec-prefs")) {
|
||||
set_global_codec_string(val);
|
||||
globals.codec_order_last =
|
||||
switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
|
||||
globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
|
||||
} else if (!strcmp(var, "codec-rates")) {
|
||||
set_global_codec_rates_string(val);
|
||||
globals.codec_rates_last =
|
||||
switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
|
||||
globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -954,11 +937,8 @@ static switch_status_t tech_media(private_t * tech_pvt, struct iax_event *iaxeve
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_CODEC) &&
|
||||
(status =
|
||||
iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate,
|
||||
IAX_SET)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format,
|
||||
iaxevent->ies.capability);
|
||||
(status = iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate, IAX_SET)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format, iaxevent->ies.capability);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -1021,8 +1001,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
}
|
||||
|
||||
if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Event %d [%s]!\n",
|
||||
iaxevent->etype, IAXNAMES[iaxevent->etype]);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Event %d [%s]!\n", iaxevent->etype, IAXNAMES[iaxevent->etype]);
|
||||
}
|
||||
|
||||
switch (iaxevent->etype) {
|
||||
@@ -1061,12 +1040,10 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
if (channel) {
|
||||
if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel));
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n", switch_channel_get_name(channel));
|
||||
switch_channel_mark_answered(channel);
|
||||
}
|
||||
} else {
|
||||
@@ -1079,14 +1056,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
|
||||
"Incoming call connected %s, %s, %s %u/%u\n",
|
||||
iaxevent->ies.called_number,
|
||||
iaxevent->ies.calling_number,
|
||||
iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
|
||||
iaxevent->ies.calling_number, iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
|
||||
|
||||
if (iaxevent) {
|
||||
switch_core_session_t *session;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n",
|
||||
iaxevent->ies.calling_name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name);
|
||||
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
@@ -1112,20 +1087,16 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
NULL,
|
||||
NULL,
|
||||
(char *) modname,
|
||||
iaxevent->ies.called_context,
|
||||
iaxevent->ies.called_number)) != 0) {
|
||||
iaxevent->ies.called_context, iaxevent->ies.called_number)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
rand() & 0xffff);
|
||||
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
|
||||
}
|
||||
|
||||
if (iax_set_codec(tech_pvt, iaxevent->session,
|
||||
&iaxevent->ies.format,
|
||||
&iaxevent->ies.capability,
|
||||
&iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
|
||||
&iaxevent->ies.format, &iaxevent->ies.capability, &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
|
||||
iax_reject(iaxevent->session, "Codec Error!");
|
||||
switch_core_session_destroy(&session);
|
||||
} else {
|
||||
@@ -1150,13 +1121,9 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
switch_mutex_unlock(tech_pvt->flag_mutex);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
|
||||
switch_channel_hangup(channel,
|
||||
iaxevent->etype ==
|
||||
IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING :
|
||||
SWITCH_CAUSE_FACILITY_REJECTED);
|
||||
switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED);
|
||||
//switch_thread_cond_signal(tech_pvt->cond);
|
||||
iaxevent->session = NULL;
|
||||
}
|
||||
@@ -1198,16 +1165,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
if (channel) {
|
||||
char str[2] = { (char) iaxevent->subclass };
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str,
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str, switch_channel_get_name(channel));
|
||||
}
|
||||
switch_channel_queue_dtmf(channel, str);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n",
|
||||
iaxevent->etype);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n", iaxevent->etype);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,12 +144,9 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
static switch_status_t channel_on_transmit(switch_core_session_t *session);
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session,
|
||||
switch_memory_pool_t **pool);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
||||
static switch_status_t engage_device(int samplerate, int codec_ms);
|
||||
static switch_status_t engage_ring_device(int sample_rate, int channels);
|
||||
@@ -202,8 +199,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT %d %d\n",
|
||||
switch_channel_get_name(channel), switch_channel_get_state(channel),
|
||||
switch_test_flag(tech_pvt, TFLAG_ANSWER));
|
||||
switch_channel_get_name(channel), switch_channel_get_state(channel), switch_test_flag(tech_pvt, TFLAG_ANSWER));
|
||||
|
||||
|
||||
|
||||
@@ -229,8 +225,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
ring_file,
|
||||
globals.read_codec.implementation->number_of_channels,
|
||||
globals.read_codec.implementation->samples_per_second,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
|
||||
NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
|
||||
if (engage_ring_device(fh.samplerate, fh.channels) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
@@ -239,8 +234,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open %s, disabling ring file!\n",
|
||||
ring_file);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open %s, disabling ring file!\n", ring_file);
|
||||
ring_file = NULL;
|
||||
}
|
||||
}
|
||||
@@ -256,8 +250,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
|
||||
snprintf(buf, sizeof(buf), "BRRRRING! BRRRRING! call %s\n", tech_pvt->call_id);
|
||||
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RINGING) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RINGING) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_info", "%s", buf);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call_id", "%s", tech_pvt->call_id);
|
||||
switch_channel_event_set_data(channel, event);
|
||||
@@ -545,8 +538,7 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *d
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
@@ -584,8 +576,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||
switch_core_codec_destroy(&globals.read_codec);
|
||||
tech_pvt->hold_file = NULL;
|
||||
@@ -647,9 +638,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
switch_mutex_lock(globals.device_lock);
|
||||
|
||||
if ((samples =
|
||||
ReadAudioStream(globals.audio_stream, globals.read_frame.data,
|
||||
globals.read_codec.implementation->samples_per_frame)) != 0) {
|
||||
if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) != 0) {
|
||||
globals.read_frame.datalen = samples * 2;
|
||||
globals.read_frame.samples = samples;
|
||||
|
||||
@@ -668,8 +657,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
@@ -833,7 +821,7 @@ static const switch_loadable_module_interface_t channel_module_interface = {
|
||||
*/
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool)
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool)
|
||||
{
|
||||
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
|
||||
@@ -857,8 +845,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
|
||||
if (outbound_profile) {
|
||||
char name[128];
|
||||
char *id =
|
||||
!switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na";
|
||||
char *id = !switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na";
|
||||
snprintf(name, sizeof(name), "PortAudio/%s", id);
|
||||
|
||||
switch_channel_set_name(channel, name);
|
||||
@@ -883,8 +870,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
switch_status_t status;
|
||||
@@ -1041,8 +1027,7 @@ static switch_status_t load_config(void)
|
||||
|
||||
if (globals.ringdev < 0) {
|
||||
if (globals.outdev > -1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Invalid ring device configured using output device!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ring device configured using output device!\n");
|
||||
globals.ringdev = globals.outdev;
|
||||
}
|
||||
}
|
||||
@@ -1092,8 +1077,7 @@ static int get_dev_by_name(char *name, int in)
|
||||
numDevices = Pa_GetDeviceCount();
|
||||
|
||||
if (numDevices < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "ERROR: Pa_CountDevices returned 0x%x\n",
|
||||
numDevices);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
|
||||
return -2;
|
||||
}
|
||||
|
||||
@@ -1125,8 +1109,7 @@ static int get_dev_by_name(char *name, int in)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
static void PrintSupportedStandardSampleRates(const PaStreamParameters * inputParameters,
|
||||
const PaStreamParameters * outputParameters)
|
||||
static void PrintSupportedStandardSampleRates(const PaStreamParameters * inputParameters, const PaStreamParameters * outputParameters)
|
||||
{
|
||||
int i, printCount, cr = 7;
|
||||
PaError err;
|
||||
@@ -1167,8 +1150,7 @@ static switch_status_t devlist(char **argv, int argc, switch_stream_handle_t *st
|
||||
}
|
||||
for (i = 0; i < numDevices; i++) {
|
||||
deviceInfo = Pa_GetDeviceInfo(i);
|
||||
stream->write_function(stream, "%d;%s;%d;%d\n", i, deviceInfo->name, deviceInfo->maxInputChannels,
|
||||
deviceInfo->maxOutputChannels);
|
||||
stream->write_function(stream, "%d;%s;%d;%d\n", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -1185,18 +1167,15 @@ static int dump_info(void)
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||
"PortAudio version number = %d\nPortAudio version text = '%s'\n", Pa_GetVersion(),
|
||||
Pa_GetVersionText());
|
||||
"PortAudio version number = %d\nPortAudio version text = '%s'\n", Pa_GetVersion(), Pa_GetVersionText());
|
||||
if (globals.audio_stream) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||
"ERROR: Cannot use this command this while a call is in progress\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
numDevices = Pa_GetDeviceCount();
|
||||
if (numDevices < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Pa_CountDevices returned 0x%x\n",
|
||||
numDevices);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
|
||||
err = numDevices;
|
||||
goto error;
|
||||
}
|
||||
@@ -1236,13 +1215,11 @@ static int dump_info(void)
|
||||
}
|
||||
/* print device info fields */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Name: %s\n", deviceInfo->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Host: %s | ",
|
||||
Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Host: %s | ", Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "inputs: %d | ", deviceInfo->maxInputChannels);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "outputs: %d | ", deviceInfo->maxOutputChannels);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Default rate: %8.2f\n",
|
||||
deviceInfo->defaultSampleRate);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Default rate: %8.2f\n", deviceInfo->defaultSampleRate);
|
||||
|
||||
/* poll for standard sample rates */
|
||||
inputParameters.device = i;
|
||||
@@ -1259,22 +1236,19 @@ static int dump_info(void)
|
||||
|
||||
if (inputParameters.channelCount > 0) {
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel input rates:",
|
||||
inputParameters.channelCount);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel input rates:", inputParameters.channelCount);
|
||||
PrintSupportedStandardSampleRates(&inputParameters, NULL);
|
||||
}
|
||||
|
||||
if (outputParameters.channelCount > 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel output rates:",
|
||||
outputParameters.channelCount);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel output rates:", outputParameters.channelCount);
|
||||
PrintSupportedStandardSampleRates(NULL, &outputParameters);
|
||||
}
|
||||
|
||||
if (inputParameters.channelCount > 0 && outputParameters.channelCount > 0) {
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||
"full-duplex 16 bit %d channel input, %d channel output rates:",
|
||||
inputParameters.channelCount, outputParameters.channelCount);
|
||||
"full-duplex 16 bit %d channel input, %d channel output rates:", inputParameters.channelCount, outputParameters.channelCount);
|
||||
PrintSupportedStandardSampleRates(&inputParameters, &outputParameters);
|
||||
}
|
||||
}
|
||||
@@ -1284,8 +1258,7 @@ static int dump_info(void)
|
||||
return 0;
|
||||
|
||||
error:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,
|
||||
"An error occured while using the portaudio stream\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "An error occured while using the portaudio stream\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error number: %d\n", err);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error message: %s\n", Pa_GetErrorText(err));
|
||||
return err;
|
||||
@@ -1308,23 +1281,14 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||
|
||||
if (switch_core_codec_init(&globals.read_codec,
|
||||
"L16",
|
||||
NULL,
|
||||
sample_rate,
|
||||
codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
if (switch_core_codec_init(&globals.write_codec,
|
||||
"L16",
|
||||
NULL,
|
||||
sample_rate,
|
||||
codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||
switch_core_codec_destroy(&globals.read_codec);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -1332,10 +1296,7 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||
}
|
||||
|
||||
if (switch_core_timer_init(&globals.timer,
|
||||
globals.timer_name,
|
||||
codec_ms,
|
||||
globals.read_codec.implementation->samples_per_frame,
|
||||
module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
|
||||
switch_core_codec_destroy(&globals.read_codec);
|
||||
switch_core_codec_destroy(&globals.write_codec);
|
||||
@@ -1415,8 +1376,7 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate,
|
||||
channels);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate, channels);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1714,15 +1674,9 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
||||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL,
|
||||
dialplan,
|
||||
cid_name,
|
||||
cid_num,
|
||||
NULL, NULL, NULL, NULL, (char *) modname, NULL,
|
||||
dest)) != 0) {
|
||||
dialplan, cid_name, cid_num, NULL, NULL, NULL, NULL, (char *) modname, NULL, dest)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "PortAudio/%s",
|
||||
tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->
|
||||
destination_number : modname);
|
||||
snprintf(name, sizeof(name), "PortAudio/%s", tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
@@ -1734,8 +1688,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
switch_core_session_thread_launch(tech_pvt->session);
|
||||
add_pvt(tech_pvt, PA_MASTER);
|
||||
stream->write_function(stream, "SUCCESS:%s:%s\n", tech_pvt->call_id,
|
||||
switch_core_session_get_uuid(tech_pvt->session));
|
||||
stream->write_function(stream, "SUCCESS:%s:%s\n", tech_pvt->call_id, switch_core_session_get_uuid(tech_pvt->session));
|
||||
} else {
|
||||
switch_core_session_destroy(&session);
|
||||
stream->write_function(stream, "FAIL:Device Error!\n");
|
||||
@@ -1773,8 +1726,7 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
|
||||
"pa devlist\n"
|
||||
"pa indev [#<num>|<partial name>\n"
|
||||
"pa outdev [#<num>|<partial name>\n"
|
||||
"pa ringdev [#<num>|<partial name>\n"
|
||||
"--------------------------------------------------------------------------------\n";
|
||||
"pa ringdev [#<num>|<partial name>\n" "--------------------------------------------------------------------------------\n";
|
||||
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "%s", usage_string);
|
||||
|
||||
@@ -164,8 +164,7 @@ void PaUtil_FlushRingBuffer(PaUtilRingBuffer * rbuf)
|
||||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
|
||||
long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
|
||||
{
|
||||
long index;
|
||||
long available = PaUtil_GetRingBufferWriteAvailable(rbuf);
|
||||
@@ -205,8 +204,7 @@ long PaUtil_AdvanceRingBufferWriteIndex(PaUtilRingBuffer * rbuf, long numBytes)
|
||||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
|
||||
long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
|
||||
{
|
||||
long index;
|
||||
long available = PaUtil_GetRingBufferReadAvailable(rbuf);
|
||||
|
||||
@@ -142,8 +142,7 @@ extern "C" {
|
||||
|
||||
@return The room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
|
||||
long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
|
||||
|
||||
/** Advance the write index to the next location to be written.
|
||||
|
||||
@@ -175,8 +174,7 @@ extern "C" {
|
||||
|
||||
@return The number of bytes available for reading.
|
||||
*/
|
||||
long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
|
||||
long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
|
||||
|
||||
/** Advance the read index to the next location to be read.
|
||||
|
||||
|
||||
@@ -60,9 +60,7 @@
|
||||
/************************************************************************/
|
||||
|
||||
static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo * timeInfo,
|
||||
PaStreamCallbackFlags statusFlags, void *userData);
|
||||
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData);
|
||||
static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame);
|
||||
static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf);
|
||||
|
||||
@@ -74,9 +72,7 @@ static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf);
|
||||
* Read and write data only if there is room in FIFOs.
|
||||
*/
|
||||
static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo * timeInfo,
|
||||
PaStreamCallbackFlags statusFlags, void *userData)
|
||||
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
|
||||
{
|
||||
PABLIO_Stream *data = (PABLIO_Stream *) userData;
|
||||
long numBytes = data->bytesPerFrame * framesPerBuffer;
|
||||
@@ -195,8 +191,7 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
||||
*
|
||||
*/
|
||||
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
|
||||
const PaStreamParameters * inputParameters,
|
||||
const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags)
|
||||
const PaStreamParameters * inputParameters, const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags)
|
||||
{
|
||||
long bytesPerSample;
|
||||
PaError err;
|
||||
@@ -250,9 +245,7 @@ PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
|
||||
|
||||
/* Open a PortAudio stream that we will use to communicate with the underlying
|
||||
* audio drivers. */
|
||||
err = Pa_OpenStream(&aStream->stream,
|
||||
inputParameters,
|
||||
outputParameters, sampleRate, FRAMES_PER_BUFFER, streamFlags, blockingIOCallback, aStream);
|
||||
err = Pa_OpenStream(&aStream->stream, inputParameters, outputParameters, sampleRate, FRAMES_PER_BUFFER, streamFlags, blockingIOCallback, aStream);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ extern "C" {
|
||||
*/
|
||||
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
|
||||
const PaStreamParameters * inputParameters,
|
||||
const PaStreamParameters * outputParameters,
|
||||
double sampleRate, PaStreamCallbackFlags statusFlags);
|
||||
const PaStreamParameters * outputParameters, double sampleRate, PaStreamCallbackFlags statusFlags);
|
||||
|
||||
PaError CloseAudioStream(PABLIO_Stream * aStream);
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -69,8 +69,7 @@ extern "C" {
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*//*! \brief Find the bit position of the lowest set bit in a word
|
||||
\param bits The word to be searched
|
||||
\return The bit number of the lowest set bit, or -1 if the word is zero. */
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
\return The bit number of the lowest set bit, or -1 if the word is zero. */ static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n" " bsfl %%eax,%%edx;\n":"=d"(res)
|
||||
@@ -86,8 +85,7 @@ extern "C" {
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
/*- End of function --------------------------------------------------------*/ static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsfq %%rax,%%rdx;\n":"=d"(res)
|
||||
|
||||
@@ -186,8 +186,7 @@ sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan)
|
||||
return CreateFile(fname,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
(LPSECURITY_ATTRIBUTES) NULL,
|
||||
OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, (HANDLE) NULL);
|
||||
(LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, (HANDLE) NULL);
|
||||
#else
|
||||
int fd = -1;
|
||||
|
||||
@@ -498,8 +497,7 @@ int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
|
||||
printf("\trx pkt\t%d\ttx pkt\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_packets, tdm_api->wp_tdm_cmd.stats.tx_packets);
|
||||
printf("\trx err\t%d\ttx err\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_errors, tdm_api->wp_tdm_cmd.stats.tx_errors);
|
||||
#ifndef __WINDOWS__
|
||||
printf("\trx ovr\t%d\ttx idl\t%d\n",
|
||||
tdm_api->wp_tdm_cmd.stats.rx_fifo_errors, tdm_api->wp_tdm_cmd.stats.tx_carrier_errors);
|
||||
printf("\trx ovr\t%d\ttx idl\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_fifo_errors, tdm_api->wp_tdm_cmd.stats.tx_carrier_errors);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -765,8 +763,7 @@ int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
|
||||
if (tdm_api->wp_tdm_event.wp_dtmf_event) {
|
||||
tdm_api->wp_tdm_event.wp_dtmf_event(fd,
|
||||
rx_event->wp_tdm_api_event_dtmf_digit,
|
||||
rx_event->wp_tdm_api_event_dtmf_type,
|
||||
rx_event->wp_tdm_api_event_dtmf_port);
|
||||
rx_event->wp_tdm_api_event_dtmf_type, rx_event->wp_tdm_api_event_dtmf_port);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -138,8 +138,7 @@ static int __pri_sangoma_write(struct pri *pri, void *buf, int buflen)
|
||||
/* FIXME: This might cause problems with other libraries
|
||||
* We must remove 2 bytes from buflen because
|
||||
* libpri sends 2 fake CRC bytes */
|
||||
res = sangoma_sendmsg_socket((sng_fd_t) (pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t), buf, (unsigned short) buflen - 2, 0);
|
||||
res = sangoma_sendmsg_socket((sng_fd_t) (pri->fd), tmpbuf, sizeof(wp_tdm_api_rx_hdr_t), buf, (unsigned short) buflen - 2, 0);
|
||||
if (res > 0) {
|
||||
res = buflen;
|
||||
}
|
||||
@@ -222,8 +221,7 @@ int sangoma_one_loop(struct sangoma_pri *spri)
|
||||
if (event) {
|
||||
event_handler handler;
|
||||
/* 0 is catchall event handler */
|
||||
if ((handler =
|
||||
spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
if ((handler = spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
handler(spri, event->e, event);
|
||||
} else {
|
||||
fprintf(stderr, "No event handler found for event %d.\n", event->e);
|
||||
|
||||
@@ -30,9 +30,7 @@ int tdmv_api_ioctl(HANDLE fd, wanpipe_tdm_api_cmd_t * tdm_api_cmd)
|
||||
|
||||
if (DeviceIoControl(fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) & wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//actual ioctl failed
|
||||
err = 1;
|
||||
prn(1, "Error: tdmv_api_ioctl(): DeviceIoControl failed!!\n");
|
||||
@@ -70,9 +68,7 @@ int wanpipe_api_ioctl(HANDLE fd, wan_cmd_api_t * api_cmd)
|
||||
|
||||
if (DeviceIoControl(fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) & wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
err = 1;
|
||||
prn(1, "Error: wanpipe_api_ioctl(): DeviceIoControl failed!!\n");
|
||||
return err;
|
||||
@@ -95,10 +91,7 @@ static USHORT DoReadCommand(HANDLE drv, RX_DATA_STRUCT * pRx)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlReadCommand,
|
||||
(LPVOID) NULL,
|
||||
0L, (LPVOID) pRx, sizeof(RX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
if (DeviceIoControl(drv, IoctlReadCommand, (LPVOID) NULL, 0L, (LPVOID) pRx, sizeof(RX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoReadCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
@@ -115,9 +108,7 @@ static UCHAR DoWriteCommand(HANDLE drv, TX_DATA_STRUCT * pTx)
|
||||
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlWriteCommand,
|
||||
(LPVOID) pTx,
|
||||
(ULONG) sizeof(TX_DATA_STRUCT),
|
||||
(LPVOID) pTx, sizeof(TX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
(LPVOID) pTx, (ULONG) sizeof(TX_DATA_STRUCT), (LPVOID) pTx, sizeof(TX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoWriteCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
@@ -131,12 +122,7 @@ static USHORT DoApiPollCommand(HANDLE drv, API_POLL_STRUCT * api_poll_ptr)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlApiPoll,
|
||||
(LPVOID) NULL,
|
||||
0L,
|
||||
(LPVOID) api_poll_ptr,
|
||||
sizeof(API_POLL_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
if (DeviceIoControl(drv, IoctlApiPoll, (LPVOID) NULL, 0L, (LPVOID) api_poll_ptr, sizeof(API_POLL_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoApiPollCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
@@ -157,9 +143,7 @@ int DoManagementCommand(HANDLE drv, wan_udp_hdr_t * wan_udp)
|
||||
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
(LPVOID) wan_udp, sizeof(wan_udp_hdr_t), (LPVOID) wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoManagementCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
|
||||
@@ -269,7 +269,7 @@ static void analog_parse_event(analog_channel_t * alc)
|
||||
|
||||
}
|
||||
|
||||
static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
|
||||
for (;;) {
|
||||
@@ -462,18 +462,16 @@ static switch_status_t wanpipe_on_loopback(switch_core_session_t *session);
|
||||
static switch_status_t wanpipe_on_transmit(switch_core_session_t *session);
|
||||
static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool);
|
||||
static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool);
|
||||
static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
|
||||
static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
|
||||
static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
|
||||
static int check_flags(struct sangoma_pri *spri);
|
||||
static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
|
||||
static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
|
||||
static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t *thread, void *obj);
|
||||
static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t * thread, void *obj);
|
||||
static switch_status_t config_wanpipe(int reload);
|
||||
|
||||
|
||||
@@ -499,20 +497,16 @@ static switch_status_t wanpipe_codec_init(private_object_t * tech_pvt)
|
||||
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->read_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
|
||||
switch_channel_get_name(channel));
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->write_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
|
||||
switch_channel_get_name(channel));
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -583,20 +577,16 @@ static switch_status_t wanpipe_on_init(switch_core_session_t *session)
|
||||
switch_mutex_unlock(tech_pvt->ss7boost_handle->mutex);
|
||||
|
||||
switch_copy_string(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index],
|
||||
switch_core_session_get_uuid(session),
|
||||
sizeof(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index]));
|
||||
switch_core_session_get_uuid(session), sizeof(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index]));
|
||||
|
||||
|
||||
ss7boost_client_call_init(&event, tech_pvt->caller_profile->caller_id_number,
|
||||
tech_pvt->caller_profile->destination_number, tech_pvt->setup_index);
|
||||
ss7boost_client_call_init(&event, tech_pvt->caller_profile->caller_id_number, tech_pvt->caller_profile->destination_number, tech_pvt->setup_index);
|
||||
|
||||
if (ss7boost_client_connection_write(&tech_pvt->ss7boost_handle->mcon, &event) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Critical System Error: Failed to tx on ISUP socket [%s]\n", strerror(errno));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Critical System Error: Failed to tx on ISUP socket [%s]\n", strerror(errno));
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Called Event TG=%d\n",
|
||||
tech_pvt->boost_trunk_group);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Called Event TG=%d\n", tech_pvt->boost_trunk_group);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -664,9 +654,7 @@ static switch_status_t wanpipe_on_hangup(switch_core_session_t *session)
|
||||
switch_mutex_unlock(tech_pvt->ss7boost_handle->mutex);
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
isup_exec_command(tech_pvt->ss7boost_handle,
|
||||
tech_pvt->boost_span_number,
|
||||
tech_pvt->boost_chan_number,
|
||||
-1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_NORMAL);
|
||||
tech_pvt->boost_span_number, tech_pvt->boost_chan_number, -1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_NORMAL);
|
||||
}
|
||||
} else if (tech_pvt->spri) {
|
||||
chanmap = tech_pvt->spri->private_info;
|
||||
@@ -731,9 +719,7 @@ static switch_status_t wanpipe_answer_channel(switch_core_session_t *session)
|
||||
pri_answer(tech_pvt->spri->pri, tech_pvt->call, 0, 1);
|
||||
}
|
||||
} else if (tech_pvt->ss7boost_handle) {
|
||||
isup_exec_command(tech_pvt->ss7boost_handle,
|
||||
tech_pvt->boost_span_number,
|
||||
tech_pvt->boost_chan_number, -1, SIGBOOST_EVENT_CALL_ANSWERED, 0);
|
||||
isup_exec_command(tech_pvt->ss7boost_handle, tech_pvt->boost_span_number, tech_pvt->boost_chan_number, -1, SIGBOOST_EVENT_CALL_ANSWERED, 0);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -741,8 +727,7 @@ static switch_status_t wanpipe_answer_channel(switch_core_session_t *session)
|
||||
|
||||
|
||||
|
||||
static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
private_object_t *tech_pvt;
|
||||
switch_channel_t *channel = NULL;
|
||||
@@ -775,9 +760,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch
|
||||
}
|
||||
|
||||
if ((bread = sangoma_readmsg_socket(tech_pvt->wpsock->fd,
|
||||
&tech_pvt->hdrframe,
|
||||
sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes,
|
||||
0)) < 0) {
|
||||
&tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes, 0)) < 0) {
|
||||
if (errno == EBUSY) {
|
||||
continue;
|
||||
} else {
|
||||
@@ -821,8 +804,7 @@ static switch_status_t wanpipe_read_frame(switch_core_session_t *session, switch
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
private_object_t *tech_pvt;
|
||||
uint32_t dtmf_blen;
|
||||
@@ -855,9 +837,7 @@ static switch_status_t wanpipe_write_frame(switch_core_session_t *session, switc
|
||||
write(tech_pvt->fd, data, frame->datalen);
|
||||
#endif
|
||||
|
||||
result =
|
||||
sangoma_sendmsg_socket(tech_pvt->wpsock->fd, &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), data,
|
||||
frame->datalen, 0);
|
||||
result = sangoma_sendmsg_socket(tech_pvt->wpsock->fd, &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), data, frame->datalen, 0);
|
||||
|
||||
if (result < 0 && errno != EBUSY) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
@@ -1005,7 +985,7 @@ static const switch_loadable_module_interface_t wanpipe_module_interface = {
|
||||
|
||||
static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool)
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool)
|
||||
{
|
||||
char *bchan = NULL;
|
||||
char name[128] = "";
|
||||
@@ -1136,8 +1116,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
|
||||
|
||||
if (sangoma_span_chan_fromif(bchan, &span, &chan)) {
|
||||
if (!wp_open(tech_pvt, span, chan)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", span,
|
||||
chan, strerror(errno));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", span, chan, strerror(errno));
|
||||
switch_core_session_destroy(new_session);
|
||||
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
goto error;
|
||||
@@ -1170,8 +1149,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
|
||||
if (autochan > 0) {
|
||||
for (callno = 1; callno < SANGOMA_MAX_CHAN_PER_SPAN; callno++) {
|
||||
if ((SPANS[span]->bchans & (1 << callno)) && !*chanmap->map[callno]) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n",
|
||||
span, callno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, callno);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -1179,8 +1157,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
|
||||
} else if (autochan < 0) {
|
||||
for (callno = SANGOMA_MAX_CHAN_PER_SPAN; callno > 0; callno--) {
|
||||
if ((SPANS[span]->bchans & (1 << callno)) && !*chanmap->map[callno]) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n",
|
||||
span, callno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, callno);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -1209,8 +1186,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
|
||||
if (spri && (tech_pvt->call = pri_new_call(spri->pri))) {
|
||||
struct pri_sr *sr;
|
||||
|
||||
snprintf(name, sizeof(name), "wanpipe/pri/s%dc%d/%s", spri->span, callno,
|
||||
caller_profile->destination_number);
|
||||
snprintf(name, sizeof(name), "wanpipe/pri/s%dc%d/%s", spri->span, callno, caller_profile->destination_number);
|
||||
switch_channel_set_name(channel, name);
|
||||
switch_channel_set_caller_profile(channel, caller_profile);
|
||||
sr = pri_sr_new();
|
||||
@@ -1218,13 +1194,8 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
|
||||
pri_sr_set_bearer(sr, 0, SPANS[span]->l1);
|
||||
pri_sr_set_called(sr, caller_profile->destination_number, SPANS[span]->dp, 1);
|
||||
pri_sr_set_caller(sr,
|
||||
caller_profile->caller_id_number,
|
||||
caller_profile->caller_id_name,
|
||||
SPANS[span]->dp, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
|
||||
pri_sr_set_redirecting(sr,
|
||||
caller_profile->caller_id_number,
|
||||
SPANS[span]->dp,
|
||||
PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, PRI_REDIR_UNCONDITIONAL);
|
||||
caller_profile->caller_id_number, caller_profile->caller_id_name, SPANS[span]->dp, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
|
||||
pri_sr_set_redirecting(sr, caller_profile->caller_id_number, SPANS[span]->dp, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, PRI_REDIR_UNCONDITIONAL);
|
||||
|
||||
if (pri_setup(spri->pri, tech_pvt->call, sr)) {
|
||||
switch_core_session_destroy(new_session);
|
||||
@@ -1241,8 +1212,7 @@ static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *sessi
|
||||
goto error;
|
||||
}
|
||||
pri_sr_free(sr);
|
||||
switch_copy_string(chanmap->map[callno],
|
||||
switch_core_session_get_uuid(*new_session), sizeof(chanmap->map[callno]));
|
||||
switch_copy_string(chanmap->map[callno], switch_core_session_get_uuid(*new_session), sizeof(chanmap->map[callno]));
|
||||
tech_pvt->spri = spri;
|
||||
}
|
||||
} else if (is_boost) {
|
||||
@@ -1304,8 +1274,7 @@ static void s_pri_message(struct pri *pri, char *s)
|
||||
}
|
||||
#endif
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -1379,8 +1348,7 @@ static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, p
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Hanging up channel s%dc%d\n", spri->span,
|
||||
pevent->hangup.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Hanging up channel s%dc%d\n", spri->span, pevent->hangup.channel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1394,15 +1362,13 @@ static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, p
|
||||
chanmap = spri->private_info;
|
||||
|
||||
if ((session = switch_core_session_locate(chanmap->map[pevent->answer.channel]))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d\n", spri->span,
|
||||
pevent->answer.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d\n", spri->span, pevent->answer.channel);
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
switch_channel_mark_answered(channel);
|
||||
switch_core_session_rwunlock(session);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d but it's not in use?\n",
|
||||
spri->span, pevent->answer.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d but it's not in use?\n", spri->span, pevent->answer.channel);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1420,8 +1386,7 @@ static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
||||
if ((session = switch_core_session_locate(chanmap->map[pevent->proceeding.channel]))) {
|
||||
switch_core_session_message_t *msg;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span,
|
||||
pevent->proceeding.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span, pevent->proceeding.channel);
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
@@ -1440,8 +1405,7 @@ static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
||||
switch_core_session_rwunlock(session);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
|
||||
"-- Proceeding on channel s%dc%d but it's not in use?\n", spri->span,
|
||||
pevent->proceeding.channel);
|
||||
"-- Proceeding on channel s%dc%d but it's not in use?\n", spri->span, pevent->proceeding.channel);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1458,8 +1422,7 @@ static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
||||
chanmap = spri->private_info;
|
||||
|
||||
if ((session = switch_core_session_locate(chanmap->map[pevent->ringing.channel]))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d\n", spri->span,
|
||||
pevent->ringing.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d\n", spri->span, pevent->ringing.channel);
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
@@ -1469,8 +1432,7 @@ static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
||||
switch_core_session_rwunlock(session);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, pevent->ringing.channel,
|
||||
chanmap->map[pevent->ringing.channel]);
|
||||
"-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, pevent->ringing.channel, chanmap->map[pevent->ringing.channel]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1489,8 +1451,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
|
||||
|
||||
chanmap = spri->private_info;
|
||||
if (switch_core_session_locate(chanmap->map[pevent->ring.channel])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "--Duplicate Ring on channel s%dc%d (ignored)\n",
|
||||
spri->span, pevent->ring.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "--Duplicate Ring on channel s%dc%d (ignored)\n", spri->span, pevent->ring.channel);
|
||||
switch_core_session_rwunlock(session);
|
||||
ret = 0;
|
||||
goto done;
|
||||
@@ -1529,18 +1490,14 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
|
||||
}
|
||||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL,
|
||||
globals.dialplan,
|
||||
"FreeSWITCH", pevent->ring.callingnum,
|
||||
NULL, globals.dialplan, "FreeSWITCH", pevent->ring.callingnum,
|
||||
#ifdef WIN32
|
||||
NULL,
|
||||
#else
|
||||
pevent->ring.callingani,
|
||||
#endif
|
||||
switch_strlen_zero(ani2str) ? NULL : ani2str,
|
||||
NULL,
|
||||
NULL,
|
||||
(char *) modname, NULL, pevent->ring.callednum))) {
|
||||
NULL, NULL, (char *) modname, NULL, pevent->ring.callednum))) {
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
}
|
||||
|
||||
@@ -1559,8 +1516,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd!\n");
|
||||
}
|
||||
|
||||
switch_copy_string(chanmap->map[pevent->ring.channel], switch_core_session_get_uuid(session),
|
||||
sizeof(chanmap->map[pevent->ring.channel]));
|
||||
switch_copy_string(chanmap->map[pevent->ring.channel], switch_core_session_get_uuid(session), sizeof(chanmap->map[pevent->ring.channel]));
|
||||
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
switch_core_session_thread_launch(session);
|
||||
@@ -1586,8 +1542,7 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
||||
struct channel_map *chanmap;
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Restarting s%dc%d\n", spri->span,
|
||||
pevent->restart.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Restarting s%dc%d\n", spri->span, pevent->restart.channel);
|
||||
|
||||
if (pevent->restart.channel < 1) {
|
||||
return 0;
|
||||
@@ -1599,8 +1554,7 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
||||
if ((session = switch_core_session_locate(chanmap->map[pevent->restart.channel]))) {
|
||||
switch_channel_t *channel;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hanging Up channel %s\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hanging Up channel %s\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
@@ -1635,13 +1589,12 @@ static int on_dchan_down(struct sangoma_pri *spri, sangoma_pri_event_t event_typ
|
||||
static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
|
||||
{
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Caught Event span %d %u (%s)\n", spri->span, event_type,
|
||||
sangoma_pri_event_str(event_type));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Caught Event span %d %u (%s)\n", spri->span, event_type, sangoma_pri_event_str(event_type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
struct sangoma_pri *spri = obj;
|
||||
struct channel_map chanmap;
|
||||
@@ -1787,8 +1740,7 @@ static void handle_call_start(ss7boost_handle_t * ss7boost_handle, ss7boost_clie
|
||||
char name[128];
|
||||
|
||||
if (*ss7boost_handle->span_chanmap[event->span].map[event->chan]) {
|
||||
isup_exec_command(ss7boost_handle,
|
||||
event->span, event->chan, -1, SIGBOOST_EVENT_CALL_START_NACK, SIGBOOST_RELEASE_CAUSE_BUSY);
|
||||
isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_START_NACK, SIGBOOST_RELEASE_CAUSE_BUSY);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1812,20 +1764,13 @@ static void handle_call_start(ss7boost_handle_t * ss7boost_handle, ss7boost_clie
|
||||
|
||||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL,
|
||||
globals.dialplan,
|
||||
"FreeSWITCH(boost)",
|
||||
(char *) event->calling_number_digits,
|
||||
NULL, globals.dialplan, "FreeSWITCH(boost)", (char *) event->calling_number_digits,
|
||||
#ifdef WIN32
|
||||
NULL,
|
||||
#else
|
||||
(char *) event->calling_number_digits,
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(char *) modname,
|
||||
NULL, (char *) event->called_number_digits))) {
|
||||
NULL, NULL, NULL, (char *) modname, NULL, (char *) event->called_number_digits))) {
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
}
|
||||
|
||||
@@ -1839,14 +1784,12 @@ static void handle_call_start(ss7boost_handle_t * ss7boost_handle, ss7boost_clie
|
||||
tech_pvt->boost_pres = event->calling_number_presentation;
|
||||
|
||||
if (!wp_open(tech_pvt, event->span + 1, event->chan + 1)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open channel %d:%d\n", event->span + 1,
|
||||
event->chan + 1);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open channel %d:%d\n", event->span + 1, event->chan + 1);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan],
|
||||
switch_core_session_get_uuid(session),
|
||||
sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
|
||||
switch_core_session_get_uuid(session), sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
|
||||
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_START_ACK, 0);
|
||||
@@ -1862,8 +1805,7 @@ static void handle_call_start(ss7boost_handle_t * ss7boost_handle, ss7boost_clie
|
||||
switch_core_session_destroy(&session);
|
||||
}
|
||||
|
||||
isup_exec_command(ss7boost_handle,
|
||||
event->span, event->chan, -1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_BUSY);
|
||||
isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_BUSY);
|
||||
|
||||
}
|
||||
|
||||
@@ -1899,16 +1841,14 @@ static void handle_call_start_ack(ss7boost_handle_t * ss7boost_handle, ss7boost_
|
||||
tech_pvt->boost_chan_number = event->chan;
|
||||
|
||||
switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan],
|
||||
switch_core_session_get_uuid(session),
|
||||
sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
|
||||
switch_core_session_get_uuid(session), sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
|
||||
|
||||
|
||||
|
||||
if (!tech_pvt->wpsock) {
|
||||
if (!wp_open(tech_pvt, tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n",
|
||||
tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1,
|
||||
strerror(errno));
|
||||
tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1, strerror(errno));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return;
|
||||
}
|
||||
@@ -1951,8 +1891,7 @@ static void handle_call_answer(ss7boost_handle_t * ss7boost_handle, ss7boost_cli
|
||||
if (!tech_pvt->wpsock) {
|
||||
if (!wp_open(tech_pvt, tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n",
|
||||
tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1,
|
||||
strerror(errno));
|
||||
tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1, strerror(errno));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return;
|
||||
}
|
||||
@@ -2003,8 +1942,7 @@ static void handle_call_start_nack(ss7boost_handle_t * ss7boost_handle, ss7boost
|
||||
|
||||
switch_channel_hangup(channel, event->release_cause);
|
||||
|
||||
isup_exec_command(ss7boost_handle,
|
||||
event->span, event->chan, event->call_setup_id, SIGBOOST_EVENT_CALL_START_NACK_ACK, 0);
|
||||
isup_exec_command(ss7boost_handle, event->span, event->chan, event->call_setup_id, SIGBOOST_EVENT_CALL_START_NACK_ACK, 0);
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
} else {
|
||||
@@ -2044,8 +1982,7 @@ static int parse_ss7_event(ss7boost_handle_t * ss7boost_handle, ss7boost_client_
|
||||
event->chan + 1,
|
||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
|
||||
switch_channel_cause2str(event->release_cause),
|
||||
event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
|
||||
switch_channel_cause2str(event->release_cause), event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
|
||||
|
||||
|
||||
switch (event->event_id) {
|
||||
@@ -2075,15 +2012,14 @@ static int parse_ss7_event(ss7boost_handle_t * ss7boost_handle, ss7boost_client_
|
||||
handle_call_stop_ack(ss7boost_handle, event);
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning no handler implemented for [%s]\n",
|
||||
ss7boost_client_event_id_name(event->event_id));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning no handler implemented for [%s]\n", ss7boost_client_event_id_name(event->event_id));
|
||||
break;
|
||||
}
|
||||
switch_mutex_unlock(ss7boost_handle->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *SWITCH_THREAD_FUNC boost_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC boost_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
ss7boost_handle_t *ss7boost_handle = (ss7boost_handle_t *) obj;
|
||||
ss7boost_client_event_t *event;
|
||||
@@ -2091,8 +2027,7 @@ static void *SWITCH_THREAD_FUNC boost_thread_run(switch_thread_t *thread, void *
|
||||
if (ss7boost_client_connection_open(&ss7boost_handle->mcon,
|
||||
ss7boost_handle->local_ip,
|
||||
ss7boost_handle->local_port,
|
||||
ss7boost_handle->remote_ip,
|
||||
ss7boost_handle->remote_port, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
ss7boost_handle->remote_ip, ss7boost_handle->remote_port, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FATAL ERROR CREATING CLIENT CONNECTION\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -2115,13 +2050,11 @@ static void *SWITCH_THREAD_FUNC boost_thread_run(switch_thread_t *thread, void *
|
||||
gettimeofday(¤t, NULL);
|
||||
timersub(¤t, &event->tv, &difftime);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Socket Event [%s] T=%d:%d\n",
|
||||
ss7boost_client_event_id_name(event->event_id),
|
||||
(int) difftime.tv_sec, (int) difftime.tv_usec);
|
||||
ss7boost_client_event_id_name(event->event_id), (int) difftime.tv_sec, (int) difftime.tv_usec);
|
||||
|
||||
parse_ss7_event(ss7boost_handle, event);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: Reading from Boost Socket! %s\n",
|
||||
strerror(errno));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: Reading from Boost Socket! %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2262,8 +2195,7 @@ static switch_status_t config_wanpipe(int reload)
|
||||
}
|
||||
|
||||
if (!(sock = wp_open(NULL, span, chan))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open device '%s' (%s)\n", c_dev,
|
||||
strerror(errno));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open device '%s' (%s)\n", c_dev, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2423,9 +2355,7 @@ static switch_status_t config_wanpipe(int reload)
|
||||
SPANS[current_span]->l1 = PRI_LAYER_1_ULAW;
|
||||
}
|
||||
if (sangoma_init_pri(&SPANS[current_span]->spri,
|
||||
current_span,
|
||||
SPANS[current_span]->dchan,
|
||||
SPANS[current_span]->pswitch, SPANS[current_span]->node, globals.debug)) {
|
||||
current_span, SPANS[current_span]->dchan, SPANS[current_span]->pswitch, SPANS[current_span]->node, globals.debug)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot launch span %d\n", current_span);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -56,14 +56,12 @@ static struct ss7boost_client_map ss7boost_client_table[] = {
|
||||
|
||||
|
||||
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, char *local_ip, int local_port, char *ip,
|
||||
int port)
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, char *local_ip, int local_port, char *ip, int port)
|
||||
{
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
|
||||
if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -79,14 +77,12 @@ static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, ch
|
||||
goto fail;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip,
|
||||
local_port, ip, port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
fail:
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip,
|
||||
local_port, ip, port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@@ -102,9 +98,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip, int port, switch_memory_pool_t *pool)
|
||||
char *local_ip, int local_port, char *ip, int port, switch_memory_pool_t * pool)
|
||||
{
|
||||
memset(mcon, 0, sizeof(*mcon));
|
||||
mcon->pool = pool;
|
||||
@@ -118,24 +112,21 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t ** event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon, ss7boost_client_event_t ** event)
|
||||
{
|
||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||
switch_size_t bytes = 0;
|
||||
|
||||
bytes = sizeof(mcon->event);
|
||||
|
||||
if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *) &mcon->event, &bytes) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *) &mcon->event, &bytes) != SWITCH_STATUS_SUCCESS) {
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event) - sizeof(uint32_t))) {
|
||||
if (rxseq != mcon->event.seqno) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n", rxseq, mcon->event.seqno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n", rxseq, mcon->event.seqno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
}
|
||||
rxseq++;
|
||||
@@ -147,8 +138,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t * event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon, ss7boost_client_event_t * event)
|
||||
{
|
||||
int err;
|
||||
switch_size_t len;
|
||||
@@ -160,8 +150,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
|
||||
if (event->span < 0 || event->chan < 0 || event->span > 7 || event->chan > 30) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Span=%i Chan=%i\n", event->span, event->chan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Critical Error: Invalid Span=%i Chan=%i\n", event->span, event->chan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
}
|
||||
#ifdef WIN32
|
||||
@@ -179,8 +168,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
switch_mutex_unlock(mcon->mutex);
|
||||
|
||||
if (len != sizeof(ss7boost_client_event_t)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno,
|
||||
strerror(errno));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno, strerror(errno));
|
||||
err = -1;
|
||||
}
|
||||
|
||||
@@ -206,15 +194,13 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
event->chan + 1,
|
||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
|
||||
event->release_cause,
|
||||
event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
|
||||
event->release_cause, event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
|
||||
|
||||
|
||||
return err ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
|
||||
int setup_id)
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called, int setup_id)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = SIGBOOST_EVENT_CALL_START;
|
||||
@@ -233,8 +219,7 @@ SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event,
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
|
||||
int chan, int span)
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id, int chan, int span)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = event_id;
|
||||
|
||||
@@ -91,17 +91,11 @@ typedef struct ss7boost_client_connection ss7boost_client_connection_t;
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip, int port, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t ** event);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t * event);
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
|
||||
int chan, int span);
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
|
||||
int setup_id);
|
||||
char *local_ip, int local_port, char *ip, int port, switch_memory_pool_t * pool);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon, ss7boost_client_event_t ** event);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon, ss7boost_client_event_t * event);
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id, int chan, int span);
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called, int setup_id);
|
||||
SWITCH_DECLARE(char *) ss7boost_client_event_id_name(uint32_t event_id);
|
||||
|
||||
#endif
|
||||
@@ -171,24 +171,21 @@ static switch_status_t woomera_on_loopback(switch_core_session_t *session);
|
||||
static switch_status_t woomera_on_transmit(switch_core_session_t *session);
|
||||
static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool);
|
||||
static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool);
|
||||
static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t woomera_kill_channel(switch_core_session_t *session, int sig);
|
||||
static void tech_destroy(private_object * tech_pvt);
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, char *fmt, ...);
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t * socket, char *fmt, ...);
|
||||
static char *woomera_message_header(woomera_message * wmsg, char *key);
|
||||
static int woomera_enqueue_event(woomera_event_queue * event_queue, woomera_message * wmsg);
|
||||
static int woomera_dequeue_event(woomera_event_queue * event_queue, woomera_message * wmsg);
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, int timeout, woomera_profile * profile,
|
||||
woomera_event_queue * event_queue);
|
||||
static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile, int flags);
|
||||
static int woomera_message_parse(switch_socket_t * fd, woomera_message * wmsg, int timeout, woomera_profile * profile, woomera_event_queue * event_queue);
|
||||
static int connect_woomera(switch_socket_t ** new_sock, woomera_profile * profile, int flags);
|
||||
static int woomera_profile_thread_running(woomera_profile * profile, int set, int new);
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **woomera_socket);
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t ** woomera_socket);
|
||||
static int tech_create_read_socket(private_object * tech_pvt);
|
||||
static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj);
|
||||
static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj);
|
||||
static void *woomera_thread_run(void *obj);
|
||||
static int tech_activate(private_object * tech_pvt);
|
||||
|
||||
@@ -214,8 +211,7 @@ static switch_status_t woomera_on_init(switch_core_session_t *session)
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->read_codec, "L16", NULL, rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -223,8 +219,7 @@ static switch_status_t woomera_on_init(switch_core_session_t *session)
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->write_codec, "L16", NULL, rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -297,7 +292,7 @@ static switch_status_t woomera_on_hangup(switch_core_session_t *session)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void woomera_socket_close(switch_socket_t **socket)
|
||||
static void woomera_socket_close(switch_socket_t ** socket)
|
||||
{
|
||||
if (*socket) {
|
||||
switch_socket_close(*socket);
|
||||
@@ -381,8 +376,7 @@ static switch_status_t woomera_waitfor_write(switch_core_session_t *session, int
|
||||
// return switch_socket_waitfor(tech_pvt->write_poll, ms);
|
||||
}
|
||||
|
||||
static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
@@ -407,8 +401,7 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
|
||||
*frame = pframe;
|
||||
|
||||
len = sizeof(tech_pvt->databuf);
|
||||
if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &len) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &len) == SWITCH_STATUS_SUCCESS) {
|
||||
pframe->datalen = (uint32_t) len;
|
||||
pframe->samples = (int) pframe->datalen / 2;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -417,8 +410,7 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
@@ -486,15 +478,14 @@ static const switch_loadable_module_interface_t woomera_module_interface = {
|
||||
*/
|
||||
static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool)
|
||||
switch_core_session_t **new_session, switch_memory_pool_t ** pool)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&woomera_endpoint_interface, pool)) != 0) {
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
|
||||
tech_pvt->profile = &default_profile;
|
||||
@@ -542,12 +533,9 @@ static void tech_destroy(private_object * tech_pvt)
|
||||
}
|
||||
|
||||
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "hangup %s%s", tech_pvt->call_info.callid,
|
||||
WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Already Disconnected\n",
|
||||
tech_pvt->profile->name);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "hangup %s%s", tech_pvt->call_info.callid, WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Already Disconnected\n", tech_pvt->profile->name);
|
||||
}
|
||||
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "bye%s", WOOMERA_RECORD_SEPERATOR);
|
||||
@@ -556,7 +544,7 @@ static void tech_destroy(private_object * tech_pvt)
|
||||
}
|
||||
|
||||
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, char *fmt, ...)
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t * socket, char *fmt, ...)
|
||||
{
|
||||
char *stuff;
|
||||
size_t res = 0, len = 0;
|
||||
@@ -642,8 +630,7 @@ static int woomera_dequeue_event(woomera_event_queue * event_queue, woomera_mess
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, int timeout, woomera_profile * profile,
|
||||
woomera_event_queue * event_queue)
|
||||
static int woomera_message_parse(switch_socket_t * fd, woomera_message * wmsg, int timeout, woomera_profile * profile, woomera_event_queue * event_queue)
|
||||
{
|
||||
char *cur, *cr, *next = NULL;
|
||||
char buf[2048] = "", *ptr;
|
||||
@@ -780,8 +767,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
|
||||
|
||||
if (event_queue && switch_test_flag(wmsg, WFLAG_EVENT)) {
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue Event: {%s} [%s]\n", profile->name,
|
||||
wmsg->command);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue Event: {%s} [%s]\n", profile->name, wmsg->command);
|
||||
}
|
||||
/* we don't want events we want a reply so we will stash them for later */
|
||||
woomera_enqueue_event(event_queue, wmsg);
|
||||
@@ -802,13 +788,12 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
|
||||
}
|
||||
|
||||
|
||||
static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile, int flags)
|
||||
static int connect_woomera(switch_socket_t ** new_sock, woomera_profile * profile, int flags)
|
||||
{
|
||||
|
||||
switch_sockaddr_t *sa;
|
||||
|
||||
if (switch_sockaddr_info_get(&sa, profile->woomera_host, AF_INET, profile->woomera_port, 0, module_pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&sa, profile->woomera_host, AF_INET, profile->woomera_port, 0, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -848,7 +833,7 @@ static int woomera_profile_thread_running(woomera_profile * profile, int set, in
|
||||
|
||||
}
|
||||
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **woomera_socket)
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t ** woomera_socket)
|
||||
{
|
||||
woomera_message wmsg;
|
||||
|
||||
@@ -858,18 +843,15 @@ static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **wo
|
||||
if (!woomera_profile_thread_running(profile, 0, 0)) {
|
||||
break;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n", profile->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n", profile->name);
|
||||
switch_sleep(WOOMERA_RECONNECT_TIME);
|
||||
}
|
||||
|
||||
if (*woomera_socket) {
|
||||
if (switch_test_flag(profile, PFLAG_INBOUND)) {
|
||||
woomera_printf(profile, *woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(*woomera_socket,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
profile->name);
|
||||
if (woomera_message_parse(*woomera_socket, &wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n", profile->name);
|
||||
globals.panic = 1;
|
||||
woomera_profile_thread_running(&default_profile, 1, 0);
|
||||
switch_sleep(WOOMERA_RECONNECT_TIME);
|
||||
@@ -898,8 +880,7 @@ static int tech_create_read_socket(private_object * tech_pvt)
|
||||
tech_pvt->port = globals.next_woomera_port = WOOMERA_MIN_PORT;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d\n", tech_pvt->profile->audio_ip,
|
||||
tech_pvt->port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d\n", tech_pvt->profile->audio_ip, tech_pvt->port);
|
||||
//tech_pvt->udp_socket = create_udp_socket(tech_pvt->profile->audio_ip, tech_pvt->port, &tech_pvt->udpread, 0);
|
||||
|
||||
switch_sockaddr_info_get(&tech_pvt->udpread, tech_pvt->profile->audio_ip, SWITCH_UNSPEC, tech_pvt->port, 0, pool);
|
||||
@@ -936,18 +917,14 @@ static int tech_activate(private_object * tech_pvt)
|
||||
tech_pvt->profile->audio_ip,
|
||||
tech_pvt->port,
|
||||
WOOMERA_LINE_SEPERATOR,
|
||||
tech_pvt->caller_profile->caller_id_name,
|
||||
tech_pvt->caller_profile->caller_id_number, WOOMERA_RECORD_SEPERATOR);
|
||||
tech_pvt->caller_profile->caller_id_name, tech_pvt->caller_profile->caller_id_number, WOOMERA_RECORD_SEPERATOR);
|
||||
|
||||
woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue);
|
||||
woomera_message_parse(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue);
|
||||
} else {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_PARSE_INCOMING);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
if (woomera_message_parse(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
}
|
||||
@@ -961,7 +938,7 @@ static int tech_activate(private_object * tech_pvt)
|
||||
|
||||
|
||||
|
||||
static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
switch_core_session_t *session = obj;
|
||||
switch_channel_t *channel = NULL;
|
||||
@@ -1001,13 +978,9 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
if (switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_ANSWER);
|
||||
#ifdef USE_ANSWER
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "ANSWER %s%s", tech_pvt->call_info.callid,
|
||||
WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
|
||||
&tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "ANSWER %s%s", tech_pvt->call_info.callid, WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
@@ -1019,11 +992,8 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
switch_mutex_lock(tech_pvt->iolock);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "DTMF %s %s%s", tech_pvt->call_info.callid,
|
||||
tech_pvt->dtmfbuf, WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
|
||||
&tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
if (woomera_message_parse(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
@@ -1037,9 +1007,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
struct timeval now;
|
||||
int elapsed;
|
||||
gettimeofday(&now, NULL);
|
||||
elapsed =
|
||||
(((now.tv_sec * 1000) + now.tv_usec / 1000) -
|
||||
((tech_pvt->started.tv_sec * 1000) + tech_pvt->started.tv_usec / 1000));
|
||||
elapsed = (((now.tv_sec * 1000) + now.tv_usec / 1000) - ((tech_pvt->started.tv_sec * 1000) + tech_pvt->started.tv_usec / 1000));
|
||||
if (elapsed > tech_pvt->timeout) {
|
||||
/* call timed out! */
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
@@ -1104,11 +1072,9 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL,
|
||||
tech_pvt->profile->dialplan,
|
||||
cid_name, cid_num, ip, NULL, NULL, NULL,
|
||||
(char *) modname, NULL, exten)) != 0) {
|
||||
cid_name, cid_num, ip, NULL, NULL, NULL, (char *) modname, NULL, exten)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
rand() & 0xffff);
|
||||
snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
|
||||
@@ -1117,15 +1083,10 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel,
|
||||
"%s %s%s"
|
||||
"Raw-Audio: %s/%d%s",
|
||||
MEDIA_ANSWER,
|
||||
wmsg.callid,
|
||||
WOOMERA_LINE_SEPERATOR,
|
||||
tech_pvt->profile->audio_ip, tech_pvt->port, WOOMERA_RECORD_SEPERATOR);
|
||||
MEDIA_ANSWER, wmsg.callid, WOOMERA_LINE_SEPERATOR, tech_pvt->profile->audio_ip, tech_pvt->port, WOOMERA_RECORD_SEPERATOR);
|
||||
|
||||
if (woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
if (woomera_message_parse(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
@@ -1152,16 +1113,10 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
switch_channel_set_state(channel, CS_RING);
|
||||
|
||||
if (switch_sockaddr_info_get(&tech_pvt->udpwrite,
|
||||
ip,
|
||||
SWITCH_UNSPEC,
|
||||
port,
|
||||
0,
|
||||
switch_core_session_get_pool(tech_pvt->session)) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
ip, SWITCH_UNSPEC, port, 0, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n",
|
||||
tech_pvt->profile->name, ip);
|
||||
WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n", tech_pvt->profile->name, ip);
|
||||
}
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NETWORK_OUT_OF_ORDER);
|
||||
}
|
||||
@@ -1169,13 +1124,11 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
}
|
||||
}
|
||||
if (globals.debug > 2) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "CHECK {%s}(%d)\n",
|
||||
tech_pvt->profile->name, res);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "CHECK {%s}(%d)\n", tech_pvt->profile->name, res);
|
||||
}
|
||||
}
|
||||
if (globals.debug > 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "Monitor thread for %s done.\n",
|
||||
tech_pvt->profile->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "Monitor thread for %s done.\n", tech_pvt->profile->name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1229,13 +1182,11 @@ static void *woomera_thread_run(void *obj)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((((res = woomera_dequeue_event(&profile->event_queue, &wmsg)) != 0) ||
|
||||
((res = woomera_message_parse(profile->woomera_socket, &wmsg,
|
||||
/* if we are not stingy with threads we can block forever */
|
||||
0, profile, NULL))) != 0)) {
|
||||
if ((((res = woomera_dequeue_event(&profile->event_queue, &wmsg)) != 0) || ((res = woomera_message_parse(profile->woomera_socket, &wmsg,
|
||||
/* if we are not stingy with threads we can block forever */
|
||||
0, profile, NULL))) != 0)) {
|
||||
if (res < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! I lost my connection to woomera!\n",
|
||||
profile->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! I lost my connection to woomera!\n", profile->name);
|
||||
woomera_socket_close(&profile->woomera_socket);
|
||||
|
||||
//global_set_flag(TFLAG_ABORT);
|
||||
@@ -1277,12 +1228,9 @@ static void *woomera_thread_run(void *obj)
|
||||
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(session,
|
||||
sizeof(struct private_object))) != 0) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED,
|
||||
switch_core_session_get_pool(session));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
tech_pvt->profile = &default_profile;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_core_session_set_private(session, tech_pvt);
|
||||
@@ -1299,8 +1247,7 @@ static void *woomera_thread_run(void *obj)
|
||||
}
|
||||
|
||||
if (globals.debug > 2) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Main Thread {%s} Select Return %d\n",
|
||||
profile->name, res);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Main Thread {%s} Select Return %d\n", profile->name, res);
|
||||
}
|
||||
|
||||
switch_yield(100);
|
||||
@@ -1339,8 +1286,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
struct woomera_profile *profile = &default_profile;
|
||||
|
||||
@@ -54,8 +54,8 @@ extern "C" {
|
||||
class CDRContainer {
|
||||
public:
|
||||
CDRContainer();
|
||||
CDRContainer(switch_memory_pool_t *module_pool);
|
||||
~CDRContainer();
|
||||
CDRContainer(switch_memory_pool_t * module_pool);
|
||||
~CDRContainer();
|
||||
void add_cdr(switch_core_session_t *session);
|
||||
void process_records();
|
||||
#ifdef SWITCH_QUEUE_ENHANCED
|
||||
|
||||
@@ -99,7 +99,7 @@ class MysqlCDR:public BaseCDR {
|
||||
// Now a couple internal methods
|
||||
template < typename T > void add_parameter(T & param, enum_field_types type, bool * is_null = 0);
|
||||
void add_string_parameter(char *param, long unsigned int ¶m_length, enum_field_types type, bool * is_null = 0);
|
||||
void set_mysql_time(switch_time_exp_t ¶m, MYSQL_TIME & destination);
|
||||
void set_mysql_time(switch_time_exp_t & param, MYSQL_TIME & destination);
|
||||
void connect_to_database();
|
||||
};
|
||||
|
||||
|
||||
@@ -146,8 +146,7 @@ static void event_handler(switch_event_t *event)
|
||||
if (globals.event_list[(uint8_t) SWITCH_EVENT_ALL]) {
|
||||
send = 1;
|
||||
} else if ((globals.event_list[(uint8_t) event->event_id])) {
|
||||
if (event->event_id != SWITCH_EVENT_CUSTOM ||
|
||||
(event->subclass && switch_core_hash_find(globals.event_hash, event->subclass->name))) {
|
||||
if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(globals.event_hash, event->subclass->name))) {
|
||||
send = 1;
|
||||
}
|
||||
}
|
||||
@@ -184,8 +183,7 @@ static switch_loadable_module_interface_t event_test_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
@@ -202,8 +200,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
if (switch_sockaddr_info_get(&globals.addr, globals.address, SWITCH_UNSPEC, globals.port, 0, module_pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&globals.addr, globals.address, SWITCH_UNSPEC, globals.port, 0, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find address\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
@@ -237,8 +234,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
*module_interface = &event_test_module_interface;
|
||||
|
||||
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
switch_socket_close(globals.udp_socket);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
@@ -290,8 +286,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
continue;
|
||||
}
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT %d\n--------------------------------\n%s\n", (int) len, packet);
|
||||
if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT) == SWITCH_STATUS_SUCCESS) {
|
||||
char *var, *val, *term = NULL, tmpname[128];
|
||||
switch_event_add_header(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes");
|
||||
var = packet;
|
||||
|
||||
@@ -88,7 +88,7 @@ static struct {
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, prefs.ip)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_pass, prefs.password)
|
||||
|
||||
static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj);
|
||||
static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj);
|
||||
static void launch_listener_thread(listener_t * listener);
|
||||
|
||||
static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_level_t level)
|
||||
@@ -133,8 +133,7 @@ static void event_handler(switch_event_t *event)
|
||||
if (l->event_list[(uint8_t) SWITCH_EVENT_ALL]) {
|
||||
send = 1;
|
||||
} else if ((l->event_list[(uint8_t) event->event_id])) {
|
||||
if (event->event_id != SWITCH_EVENT_CUSTOM
|
||||
|| (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
|
||||
if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
|
||||
send = 1;
|
||||
}
|
||||
}
|
||||
@@ -190,8 +189,7 @@ static void socket_function(switch_core_session_t *session, char *data)
|
||||
port = (switch_port_t) atoi(port_name);
|
||||
}
|
||||
|
||||
if (switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, switch_core_session_get_pool(session)) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
|
||||
return;
|
||||
}
|
||||
@@ -271,7 +269,7 @@ static switch_loadable_module_interface_t event_socket_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
static void close_socket(switch_socket_t **sock)
|
||||
static void close_socket(switch_socket_t ** sock)
|
||||
{
|
||||
switch_mutex_lock(listen_list.sock_mutex);
|
||||
if (*sock) {
|
||||
@@ -303,8 +301,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &event_socket_module_interface;
|
||||
@@ -454,8 +451,7 @@ static switch_status_t read_packet(listener_t * listener, switch_event_t **event
|
||||
|
||||
|
||||
if (data) {
|
||||
snprintf(buf, sizeof(buf),
|
||||
"Content-Type: log/data\nContent-Length: %" SWITCH_SSIZE_T_FMT "\n\n", strlen(data));
|
||||
snprintf(buf, sizeof(buf), "Content-Type: log/data\nContent-Length: %" SWITCH_SSIZE_T_FMT "\n\n", strlen(data));
|
||||
len = strlen(buf);
|
||||
switch_socket_send(listener->sock, buf, &len);
|
||||
len = strlen(data);
|
||||
@@ -492,8 +488,7 @@ static switch_status_t read_packet(listener_t * listener, switch_event_t **event
|
||||
|
||||
len = strlen(listener->ebuf);
|
||||
|
||||
snprintf(hbuf, sizeof(hbuf), "Content-Length: %" SWITCH_SSIZE_T_FMT "\n"
|
||||
"Content-Type: text/event-%s\n" "\n", len, etype);
|
||||
snprintf(hbuf, sizeof(hbuf), "Content-Length: %" SWITCH_SSIZE_T_FMT "\n" "Content-Type: text/event-%s\n" "\n", len, etype);
|
||||
|
||||
len = strlen(hbuf);
|
||||
switch_socket_send(listener->sock, hbuf, &len);
|
||||
@@ -524,7 +519,7 @@ struct api_command_struct {
|
||||
uint8_t bg;
|
||||
};
|
||||
|
||||
static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
|
||||
struct api_command_struct *acs = (struct api_command_struct *) obj;
|
||||
@@ -632,8 +627,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
goto done;
|
||||
} else if (!strncasecmp(cmd, "sendmsg", 4)) {
|
||||
if (switch_test_flag(listener, LFLAG_ASYNC)) {
|
||||
if ((status =
|
||||
switch_core_session_queue_private_event(listener->session, &event)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = switch_core_session_queue_private_event(listener->session, &event)) == SWITCH_STATUS_SUCCESS) {
|
||||
snprintf(reply, reply_len, "+OK");
|
||||
} else {
|
||||
snprintf(reply, reply_len, "-ERR memory error");
|
||||
@@ -901,8 +895,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
switch_set_flag_locked(listener, LFLAG_EVENTS);
|
||||
}
|
||||
|
||||
snprintf(reply, reply_len, "+OK event listener enabled %s",
|
||||
listener->format == EVENT_FORMAT_XML ? "xml" : "plain");
|
||||
snprintf(reply, reply_len, "+OK event listener enabled %s", listener->format == EVENT_FORMAT_XML ? "xml" : "plain");
|
||||
|
||||
} else if (!strncasecmp(cmd, "nixevent", 8)) {
|
||||
char *next, *cur;
|
||||
@@ -991,7 +984,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
return status;
|
||||
}
|
||||
|
||||
static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
listener_t *listener = (listener_t *) obj;
|
||||
char buf[1024];
|
||||
@@ -1045,10 +1038,8 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
|
||||
switch_channel_event_set_data(channel, call_event);
|
||||
switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply");
|
||||
|
||||
switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Socket-Mode",
|
||||
switch_test_flag(listener, LFLAG_ASYNC) ? "async" : "static");
|
||||
switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Control",
|
||||
switch_test_flag(listener, LFLAG_FULL) ? "full" : "single-channel");
|
||||
switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Socket-Mode", switch_test_flag(listener, LFLAG_ASYNC) ? "async" : "static");
|
||||
switch_event_add_header(call_event, SWITCH_STACK_BOTTOM, "Control", switch_test_flag(listener, LFLAG_FULL) ? "full" : "single-channel");
|
||||
|
||||
switch_event_serialize(call_event, &event_str);
|
||||
if (!event_str) {
|
||||
@@ -1221,8 +1212,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_INET, prefs.port, 0, pool);
|
||||
if (rv)
|
||||
goto fail;
|
||||
rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP,
|
||||
pool);
|
||||
rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool);
|
||||
if (rv)
|
||||
goto sock_fail;
|
||||
rv = switch_socket_opt_set(listen_list.sock, SWITCH_SO_REUSEADDR, 1);
|
||||
@@ -1243,8 +1233,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
|
||||
listen_list.ready = 1;
|
||||
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
@@ -53,10 +53,8 @@ static void event_handler(switch_event_t *event)
|
||||
dofree++;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
|
||||
"\nEVENT (text version)\n--------------------------------\n%s", buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
|
||||
"\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (text version)\n--------------------------------\n%s", buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -90,7 +88,7 @@ static switch_loadable_module_interface_t event_test_module_interface = {
|
||||
#define TTHREADS 500
|
||||
static int THREADS = 0;
|
||||
|
||||
static void *torture_thread(switch_thread_t *thread, void *obj)
|
||||
static void *torture_thread(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
@@ -127,8 +125,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
#endif
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &event_test_module_interface;
|
||||
@@ -138,8 +135,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
@@ -134,8 +134,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_jid, globals.jid)
|
||||
|
||||
if (count == 3) {
|
||||
/* TBD use config to pick what events to bind to */
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -305,17 +304,12 @@ static void j_setup_filter(struct session *sess)
|
||||
iks_filter_delete(my_filter);
|
||||
my_filter = iks_filter_new();
|
||||
iks_filter_add_rule(my_filter, on_msg, 0,
|
||||
IKS_RULE_TYPE, IKS_PAK_MESSAGE,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_CHAT, IKS_RULE_FROM, globals.target_jid, IKS_RULE_DONE);
|
||||
IKS_RULE_TYPE, IKS_PAK_MESSAGE, IKS_RULE_SUBTYPE, IKS_TYPE_CHAT, IKS_RULE_FROM, globals.target_jid, IKS_RULE_DONE);
|
||||
iks_filter_add_rule(my_filter, (iksFilterHook *) on_result, sess,
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
|
||||
iks_filter_add_rule(my_filter, on_error, sess,
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_ID, "auth", IKS_RULE_DONE);
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
|
||||
iks_filter_add_rule(my_filter, on_error, sess, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_ID, "auth", IKS_RULE_DONE);
|
||||
|
||||
iks_filter_add_rule(my_filter, on_subscribe, sess,
|
||||
IKS_RULE_TYPE, IKS_PAK_S10N, IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE, IKS_RULE_DONE);
|
||||
iks_filter_add_rule(my_filter, on_subscribe, sess, IKS_RULE_TYPE, IKS_PAK_S10N, IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE, IKS_RULE_DONE);
|
||||
|
||||
}
|
||||
|
||||
@@ -403,8 +397,7 @@ static switch_loadable_module_interface_t xmpp_event_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &xmpp_event_module_interface;
|
||||
|
||||
@@ -50,9 +50,7 @@ static struct {
|
||||
static sw_result HOWL_API my_browser(sw_discovery discovery,
|
||||
sw_discovery_oid oid,
|
||||
sw_discovery_browse_status status,
|
||||
sw_uint32 interface_index,
|
||||
sw_const_string name,
|
||||
sw_const_string type, sw_const_string domain, sw_opaque_t extra)
|
||||
sw_uint32 interface_index, sw_const_string name, sw_const_string type, sw_const_string domain, sw_opaque_t extra)
|
||||
{
|
||||
//sw_discovery_resolve_id rid;
|
||||
|
||||
@@ -90,8 +88,7 @@ static sw_result HOWL_API my_browser(sw_discovery discovery,
|
||||
case SW_DISCOVERY_BROWSE_REMOVE_SERVICE:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Remove Service\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "remove service: 0x%x %s %s %s\n", interface_index,
|
||||
name, type, domain);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "remove service: 0x%x %s %s %s\n", interface_index, name, type, domain);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -108,8 +105,7 @@ static sw_result HOWL_API my_browser(sw_discovery discovery,
|
||||
}
|
||||
|
||||
|
||||
static sw_result HOWL_API my_service_reply(sw_discovery discovery,
|
||||
sw_discovery_oid oid, sw_discovery_publish_status status, sw_opaque extra)
|
||||
static sw_result HOWL_API my_service_reply(sw_discovery discovery, sw_discovery_oid oid, sw_discovery_publish_status status, sw_opaque extra)
|
||||
{
|
||||
static sw_string status_text[] = {
|
||||
"Started",
|
||||
@@ -170,8 +166,7 @@ static void event_handler(switch_event_t *event)
|
||||
NULL,
|
||||
porti,
|
||||
sw_text_record_bytes(text_record),
|
||||
sw_text_record_len(text_record),
|
||||
my_service_reply, NULL, &globals.disc_id)) != SW_OKAY) {
|
||||
sw_text_record_len(text_record), my_service_reply, NULL, &globals.disc_id)) != SW_OKAY) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "publish failed: %u\n", result);
|
||||
sw_text_record_fina(text_record);
|
||||
switch_mutex_unlock(globals.zc_lock);
|
||||
@@ -220,16 +215,12 @@ static switch_status_t load_config(void)
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
} else if (!strcasecmp(var, "publish") && !strcasecmp(val, "yes")) {
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -268,8 +259,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
|
||||
@@ -63,8 +63,7 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
|
||||
flags |= SWITCH_FOPEN_READ;
|
||||
}
|
||||
|
||||
if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -98,8 +97,7 @@ static switch_status_t native_file_file_close(switch_file_handle_t *handle)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples,
|
||||
int whence)
|
||||
static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
|
||||
{
|
||||
native_file_context *context = handle->private_info;
|
||||
|
||||
@@ -123,16 +121,14 @@ static switch_status_t native_file_file_write(switch_file_handle_t *handle, void
|
||||
return switch_file_write(context->fd, data, len);
|
||||
}
|
||||
|
||||
static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col,
|
||||
const char *string)
|
||||
static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
|
||||
{
|
||||
//native_file_context *context = handle->private_info;
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col,
|
||||
const char **string)
|
||||
static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
|
||||
{
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -167,8 +163,7 @@ static switch_loadable_module_interface_t native_file_module_interface = {
|
||||
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
||||
|
||||
@@ -173,10 +173,8 @@ void print_header(struct frame *fr)
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay], freqs[fr->sampling_frequency], modes[fr->mode], fr->mode_ext, fr->framesize + 4);
|
||||
debug_printf("Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n",
|
||||
fr->stereo, fr->copyright ? "Yes" : "No",
|
||||
fr->original ? "Yes" : "No", fr->error_protection ? "Yes" : "No", fr->emphasis);
|
||||
debug_printf("Bitrate: %d Kbits/s, Extension value: %d\n",
|
||||
tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], fr->extension);
|
||||
fr->stereo, fr->copyright ? "Yes" : "No", fr->original ? "Yes" : "No", fr->error_protection ? "Yes" : "No", fr->emphasis);
|
||||
debug_printf("Bitrate: %d Kbits/s, Extension value: %d\n", tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], fr->extension);
|
||||
}
|
||||
|
||||
void print_header_compact(struct frame *fr)
|
||||
@@ -186,8 +184,7 @@ void print_header_compact(struct frame *fr)
|
||||
|
||||
debug_printf("MPEG %s layer %s, %d kbit/s, %ld Hz %s\n",
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay],
|
||||
tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], freqs[fr->sampling_frequency], modes[fr->mode]);
|
||||
layers[fr->lay], tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], freqs[fr->sampling_frequency], modes[fr->mode]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -114,16 +114,13 @@ void init_layer3_const(void)
|
||||
}
|
||||
|
||||
for (i = 0; i < 18; i++) {
|
||||
win[0][i] = win[1][i] =
|
||||
0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 0) + 1)) / cos(M_PI * (double) (2 * (i + 0) + 19) / 72.0);
|
||||
win[0][i + 18] = win[3][i + 18] =
|
||||
0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 18) + 1)) / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0);
|
||||
win[0][i] = win[1][i] = 0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 0) + 1)) / cos(M_PI * (double) (2 * (i + 0) + 19) / 72.0);
|
||||
win[0][i + 18] = win[3][i + 18] = 0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 18) + 1)) / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0);
|
||||
}
|
||||
for (i = 0; i < 6; i++) {
|
||||
win[1][i + 18] = 0.5 / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0);
|
||||
win[3][i + 12] = 0.5 / cos(M_PI * (double) (2 * (i + 12) + 19) / 72.0);
|
||||
win[1][i + 24] =
|
||||
0.5 * sin(M_PI / 24.0 * (double) (2 * i + 13)) / cos(M_PI * (double) (2 * (i + 24) + 19) / 72.0);
|
||||
win[1][i + 24] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 13)) / cos(M_PI * (double) (2 * (i + 24) + 19) / 72.0);
|
||||
win[1][i + 30] = win[3][i] = 0.0;
|
||||
win[3][i + 6] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * (double) (2 * (i + 6) + 19) / 72.0);
|
||||
}
|
||||
@@ -295,8 +292,7 @@ void init_layer3_sample_limits(struct mpstr *mp, int down_sample_sblimit)
|
||||
* read additional side information
|
||||
*/
|
||||
#ifdef MPEG1
|
||||
static int III_get_side_info_1(struct mpstr *mp, struct III_sideinfo *si, int stereo,
|
||||
int ms_stereo, long sfreq, int single)
|
||||
static int III_get_side_info_1(struct mpstr *mp, struct III_sideinfo *si, int stereo, int ms_stereo, long sfreq, int single)
|
||||
{
|
||||
int ch, gr;
|
||||
int powdiff = (single == 3) ? 4 : 0;
|
||||
@@ -372,8 +368,7 @@ static int III_get_side_info_1(struct mpstr *mp, struct III_sideinfo *si, int st
|
||||
/*
|
||||
* Side Info for MPEG 2.0 / LSF
|
||||
*/
|
||||
static int III_get_side_info_2(struct mpstr *mp, struct III_sideinfo *si, int stereo,
|
||||
int ms_stereo, long sfreq, int single)
|
||||
static int III_get_side_info_2(struct mpstr *mp, struct III_sideinfo *si, int stereo, int ms_stereo, long sfreq, int single)
|
||||
{
|
||||
int ch;
|
||||
int powdiff = (single == 3) ? 4 : 0;
|
||||
@@ -602,8 +597,7 @@ static int pretab2[22] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*
|
||||
* don't forget to apply the same changes to III_dequantize_sample_ms() !!!
|
||||
*/
|
||||
static int III_dequantize_sample(struct mpstr *mp, real xr[SBLIMIT][SSLIMIT], int *scf,
|
||||
struct gr_info_s *gr_info, int sfreq, int part2bits)
|
||||
static int III_dequantize_sample(struct mpstr *mp, real xr[SBLIMIT][SSLIMIT], int *scf, struct gr_info_s *gr_info, int sfreq, int part2bits)
|
||||
{
|
||||
int shift = 1 + gr_info->scalefac_scale;
|
||||
real *xrpnt = (real *) xr;
|
||||
@@ -953,8 +947,7 @@ static int III_dequantize_sample(struct mpstr *mp, real xr[SBLIMIT][SSLIMIT], in
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int III_dequantize_sample_ms(real xr[2][SBLIMIT][SSLIMIT], int *scf,
|
||||
struct gr_info_s *gr_info, int sfreq, int part2bits)
|
||||
static int III_dequantize_sample_ms(real xr[2][SBLIMIT][SSLIMIT], int *scf, struct gr_info_s *gr_info, int sfreq, int part2bits)
|
||||
{
|
||||
int shift = 1 + gr_info->scalefac_scale;
|
||||
real *xrpnt = (real *) xr[1];
|
||||
@@ -1345,8 +1338,7 @@ static int III_dequantize_sample_ms(real xr[2][SBLIMIT][SSLIMIT], int *scf,
|
||||
/*
|
||||
* III_stereo: calculate real channel values for Joint-I-Stereo-mode
|
||||
*/
|
||||
static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT], int *scalefac,
|
||||
struct gr_info_s *gr_info, int sfreq, int ms_stereo, int lsf)
|
||||
static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT], int *scalefac, struct gr_info_s *gr_info, int sfreq, int ms_stereo, int lsf)
|
||||
{
|
||||
real(*xr)[SBLIMIT * SSLIMIT] = (real(*)[SBLIMIT * SSLIMIT]) xr_buf;
|
||||
struct bandInfoStruct *bi = &bandInfo[sfreq];
|
||||
@@ -1777,8 +1769,7 @@ static void dct12(real * in, real * rawout1, real * rawout2, register real * wi,
|
||||
/*
|
||||
* III_hybrid
|
||||
*/
|
||||
static void III_hybrid(struct mpstr *mp, real fsIn[SBLIMIT][SSLIMIT], real tsOut[SSLIMIT][SBLIMIT],
|
||||
int ch, struct gr_info_s *gr_info)
|
||||
static void III_hybrid(struct mpstr *mp, real fsIn[SBLIMIT][SSLIMIT], real tsOut[SSLIMIT][SBLIMIT], int ch, struct gr_info_s *gr_info)
|
||||
{
|
||||
real *tspnt = (real *) tsOut;
|
||||
real(*block)[2][SBLIMIT * SSLIMIT] = mp->hybrid_block;
|
||||
|
||||
@@ -422,7 +422,7 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
|
||||
#define MY_BUF_LEN 1024 * 32
|
||||
#define MY_BLOCK_SIZE MY_BUF_LEN
|
||||
static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
CURL *curl_handle = NULL;
|
||||
shout_context_t *context = (shout_context_t *) obj;
|
||||
@@ -458,7 +458,7 @@ static void launch_read_stream_thread(shout_context_t * context)
|
||||
switch_thread_create(&thread, thd_attr, read_stream_thread, context, context->memory_pool);
|
||||
}
|
||||
|
||||
static void *SWITCH_THREAD_FUNC write_stream_thread(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC write_stream_thread(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
shout_context_t *context = (shout_context_t *) obj;
|
||||
|
||||
@@ -484,9 +484,7 @@ static void *SWITCH_THREAD_FUNC write_stream_thread(switch_thread_t *thread, voi
|
||||
memset(audio, 255, sizeof(audio));
|
||||
}
|
||||
|
||||
if ((rlen =
|
||||
lame_encode_buffer(context->gfp, (void *) audio, NULL, audio_read / sizeof(int16_t), mp3buf,
|
||||
sizeof(mp3buf))) < 0) {
|
||||
if ((rlen = lame_encode_buffer(context->gfp, (void *) audio, NULL, audio_read / sizeof(int16_t), mp3buf, sizeof(mp3buf))) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
|
||||
goto error;
|
||||
}
|
||||
@@ -494,8 +492,7 @@ static void *SWITCH_THREAD_FUNC write_stream_thread(switch_thread_t *thread, voi
|
||||
if (rlen) {
|
||||
ret = shout_send(context->shout, mp3buf, rlen);
|
||||
if (ret != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Send error: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Send error: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
@@ -560,9 +557,7 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, char *path)
|
||||
context->stream_url = switch_core_sprintf(context->memory_pool, "http://%s", path);
|
||||
launch_read_stream_thread(context);
|
||||
} else {
|
||||
if (switch_file_open(&context->fd, path, SWITCH_FOPEN_READ,
|
||||
SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE,
|
||||
handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_file_open(&context->fd, path, SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
|
||||
goto error;
|
||||
}
|
||||
@@ -587,8 +582,7 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, char *path)
|
||||
lame_print_config(context->gfp);
|
||||
|
||||
if (handle->handler) {
|
||||
if (switch_buffer_create_dynamic(&context->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_buffer_create_dynamic(&context->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
|
||||
goto error;
|
||||
}
|
||||
@@ -633,62 +627,52 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, char *path)
|
||||
}
|
||||
|
||||
if (shout_set_host(context->shout, host) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting hostname: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting hostname: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_protocol(context->shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting protocol: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting protocol: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_port(context->shout, portno) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting port: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting port: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_password(context->shout, password) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting password: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting password: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_mount(context->shout, file) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting mount: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting mount: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_user(context->shout, username) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_url(context->shout, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_description(context->shout, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_audio_info(context->shout, "bitrate", "64000") != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (shout_set_format(context->shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting user: %s\n", shout_get_error(context->shout));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -728,8 +712,7 @@ static switch_status_t shout_file_close(switch_file_handle_t *handle)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t shout_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples,
|
||||
int whence)
|
||||
static switch_status_t shout_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
|
||||
{
|
||||
shout_context_t *context = handle->private_info;
|
||||
|
||||
@@ -800,8 +783,7 @@ static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data
|
||||
if (context->shout && !context->shout_init) {
|
||||
context->shout_init++;
|
||||
if (shout_open(context->shout) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening stream: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening stream: %s\n", shout_get_error(context->shout));
|
||||
context->err++;
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -844,20 +826,17 @@ static switch_status_t shout_file_set_string(switch_file_handle_t *handle, switc
|
||||
switch (col) {
|
||||
case SWITCH_AUDIO_COL_STR_TITLE:
|
||||
if (shout_set_name(context->shout, string) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
|
||||
}
|
||||
break;
|
||||
case SWITCH_AUDIO_COL_STR_COMMENT:
|
||||
if (shout_set_url(context->shout, string) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
|
||||
}
|
||||
break;
|
||||
case SWITCH_AUDIO_COL_STR_ARTIST:
|
||||
if (shout_set_description(context->shout, string) != SHOUTERR_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n",
|
||||
shout_get_error(context->shout));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -898,8 +877,7 @@ static switch_loadable_module_interface_t shout_module_interface = {
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
supported_formats[0] = "shout";
|
||||
supported_formats[1] = "mp3";
|
||||
|
||||
@@ -137,19 +137,16 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, char *pat
|
||||
}
|
||||
|
||||
if ((mode & SFM_WRITE) && sf_format_check(&context->sfinfo) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error : file format is invalid (0x%08X).\n",
|
||||
context->sfinfo.format);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error : file format is invalid (0x%08X).\n", context->sfinfo.format);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
};
|
||||
|
||||
if ((context->handle = sf_open(path, mode, &context->sfinfo)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s] [%s]\n", path,
|
||||
sf_strerror(context->handle));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s] [%s]\n", path, sf_strerror(context->handle));
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opening File [%s] %dhz\n", path,
|
||||
context->sfinfo.samplerate);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opening File [%s] %dhz\n", path, context->sfinfo.samplerate);
|
||||
handle->samples = (unsigned int) context->sfinfo.frames;
|
||||
handle->samplerate = context->sfinfo.samplerate;
|
||||
handle->channels = (uint8_t) context->sfinfo.channels;
|
||||
@@ -171,8 +168,7 @@ static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples,
|
||||
int whence)
|
||||
static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
|
||||
{
|
||||
sndfile_context *context = handle->private_info;
|
||||
|
||||
@@ -239,8 +235,7 @@ static switch_status_t sndfile_file_set_string(switch_file_handle_t *handle, swi
|
||||
return sf_set_string(context->handle, (int) col, string) ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col,
|
||||
const char **string)
|
||||
static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
|
||||
{
|
||||
sndfile_context *context = handle->private_info;
|
||||
const char *s;
|
||||
@@ -294,15 +289,13 @@ static switch_status_t setup_formats(void)
|
||||
|
||||
sf_command(NULL, SFC_GET_LIB_VERSION, buffer, sizeof(buffer));
|
||||
if (strlen(buffer) < 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Line %d: could not retrieve lib version.\n",
|
||||
__LINE__);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Line %d: could not retrieve lib version.\n", __LINE__);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "\nLibSndFile Version : %s Supported Formats\n", buffer);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||
"================================================================================\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "================================================================================\n");
|
||||
sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof(int));
|
||||
sf_command(NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof(int));
|
||||
|
||||
@@ -315,8 +308,7 @@ static switch_status_t setup_formats(void)
|
||||
skip = 0;
|
||||
info.format = m;
|
||||
sf_command(NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof(info));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s (extension \"%s\")\n", info.name,
|
||||
info.extension);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s (extension \"%s\")\n", info.name, info.extension);
|
||||
for (x = 0; x < len; x++) {
|
||||
if (supported_formats[x] == info.extension) {
|
||||
skip++;
|
||||
@@ -364,14 +356,12 @@ static switch_status_t setup_formats(void)
|
||||
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_NOTICE,
|
||||
"================================================================================\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_NOTICE, "================================================================================\n");
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
||||
@@ -48,8 +48,7 @@ switch_status_t mod_mono_load_modules(const char *module_dir);
|
||||
MonoClass *mod_mono_find_assembly_class(MonoImage * image);
|
||||
|
||||
/* Managed functions */
|
||||
void mod_mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt,
|
||||
char *msg);
|
||||
void mod_mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg);
|
||||
|
||||
static const char modname[] = "mod_mono";
|
||||
static switch_memory_pool_t *mono_pool = NULL;
|
||||
@@ -75,8 +74,7 @@ static switch_loadable_module_interface_t mono_module_interface = {
|
||||
* This function will initialise the memory pool and plugin hash for this module,
|
||||
* it will then initialise a new mono domain.
|
||||
*/
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
|
||||
{
|
||||
*interface = &mono_module_interface;
|
||||
|
||||
@@ -101,8 +99,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
apr_finfo_t *assembly_finfo = (apr_finfo_t *) switch_core_alloc(mono_pool, sizeof(*assembly_finfo));
|
||||
|
||||
snprintf(assembly_dir, assembly_dir_len, "%s/%s", SWITCH_GLOBAL_dirs.base_dir, SWITCH_MONO_LIBDIR);
|
||||
snprintf(assembly_file, assembly_file_len, "%s/%s%s", SWITCH_GLOBAL_dirs.base_dir, SWITCH_MONO_LIBDIR,
|
||||
SWITCH_MONO_ASSEMBLY);
|
||||
snprintf(assembly_file, assembly_file_len, "%s/%s%s", SWITCH_GLOBAL_dirs.base_dir, SWITCH_MONO_LIBDIR, SWITCH_MONO_ASSEMBLY);
|
||||
|
||||
if (apr_stat(assembly_finfo, assembly_file, 0, mono_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not find FreeSwitch.NET assembly\n");
|
||||
@@ -247,8 +244,7 @@ switch_status_t mod_mono_load_modules(const char *module_dir)
|
||||
|
||||
plugin->object = mono_object_new(globals.domain, plugin->class);
|
||||
|
||||
switch_core_hash_insert(globals.plugins, (char *) mono_image_get_name(mono_assembly_get_image(assembly)),
|
||||
plugin);
|
||||
switch_core_hash_insert(globals.plugins, (char *) mono_image_get_name(mono_assembly_get_image(assembly)), plugin);
|
||||
|
||||
plugin = NULL;
|
||||
}
|
||||
@@ -280,8 +276,7 @@ MonoClass *mod_mono_find_assembly_class(MonoImage * image)
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt,
|
||||
char *msg)
|
||||
void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ static void perl_function(switch_core_session_t *session, char *data)
|
||||
char *uuid = switch_core_session_get_uuid(session);
|
||||
char code[1024];
|
||||
PerlInterpreter *my_perl = clone_perl();
|
||||
sprintf(code, "package fs_perl;\n"
|
||||
"$SWITCH_ENV{UUID} = \"%s\";\n" "chdir(\"%s/perl\");\n", uuid, SWITCH_GLOBAL_dirs.base_dir);
|
||||
sprintf(code, "package fs_perl;\n" "$SWITCH_ENV{UUID} = \"%s\";\n" "chdir(\"%s/perl\");\n", uuid, SWITCH_GLOBAL_dirs.base_dir);
|
||||
|
||||
Perl_eval_pv(my_perl, code, TRUE);
|
||||
|
||||
@@ -112,8 +111,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
PerlInterpreter *my_perl;
|
||||
|
||||
@@ -468,8 +468,7 @@ extern "C" {
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s-> next = ty->next;
|
||||
/* Insert s as second element in the list */ s->next = ty->next;
|
||||
if (ty->next)
|
||||
ty->next->prev = s;
|
||||
ty->next = s;
|
||||
@@ -689,14 +688,12 @@ typedef struct {
|
||||
static void _swig_create_magic(SV * sv, char *name, int (*set) (SV *, MAGIC *), int (*get) (SV *, MAGIC *))
|
||||
{
|
||||
#else
|
||||
static void _swig_create_magic(SV * sv, char *name, int (*set) (struct interpreter *, SV *, MAGIC *),
|
||||
int (*get) (struct interpreter *, SV *, MAGIC *))
|
||||
static void _swig_create_magic(SV * sv, char *name, int (*set) (struct interpreter *, SV *, MAGIC *), int (*get) (struct interpreter *, SV *, MAGIC *))
|
||||
{
|
||||
#endif
|
||||
#else
|
||||
# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
|
||||
static void _swig_create_magic(CPerlObj * pPerl, SV * sv, const char *name, int (CPerlObj::*set) (SV *, MAGIC *),
|
||||
int (CPerlObj::*get) (SV *, MAGIC *))
|
||||
static void _swig_create_magic(CPerlObj * pPerl, SV * sv, const char *name, int (CPerlObj::*set) (SV *, MAGIC *), int (CPerlObj::*get) (SV *, MAGIC *))
|
||||
{
|
||||
#endif
|
||||
MAGIC *mg;
|
||||
@@ -821,10 +818,8 @@ SWIGEXPORT(void) SWIG_init(CV * cv, CPerlObj *);
|
||||
switch_input_callback_function_t, void *, unsigned int, unsigned int);
|
||||
extern int fs_switch_ivr_sleep(switch_core_session_t *, uint32_t);
|
||||
extern int fs_ivr_play_file2(switch_core_session_t *, char *);
|
||||
extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *, switch_input_callback_function_t, void *,
|
||||
unsigned int, unsigned int);
|
||||
extern int fs_switch_ivr_collect_digits_count(switch_core_session_t *, char *, unsigned int, unsigned int,
|
||||
char const *, char *, unsigned int);
|
||||
extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *, switch_input_callback_function_t, void *, unsigned int, unsigned int);
|
||||
extern int fs_switch_ivr_collect_digits_count(switch_core_session_t *, char *, unsigned int, unsigned int, char const *, char *, unsigned int);
|
||||
extern int fs_switch_ivr_originate(switch_core_session_t *, switch_core_session_t **, char *, uint32_t);
|
||||
extern int fs_switch_ivr_session_transfer(switch_core_session_t *, char *, char *, char *);
|
||||
extern int fs_switch_ivr_speak_text(switch_core_session_t *, char *, char *, uint32_t, char *);
|
||||
@@ -1157,8 +1152,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(1)))
|
||||
@@ -1192,8 +1186,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(1)))
|
||||
@@ -1291,14 +1284,12 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_ivr_record_file. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_ivr_record_file. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_switch_file_handle_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 2 of fs_switch_ivr_record_file. Expected _p_switch_file_handle_t");
|
||||
SWIG_croak("Type error in argument 2 of fs_switch_ivr_record_file. Expected _p_switch_file_handle_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(2)))
|
||||
@@ -1308,8 +1299,7 @@ extern "C" {
|
||||
{
|
||||
switch_input_callback_function_t *argp;
|
||||
if (SWIG_ConvertPtr(ST(3), (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 4 of fs_switch_ivr_record_file. Expected _p_switch_input_callback_function_t");
|
||||
SWIG_croak("Type error in argument 4 of fs_switch_ivr_record_file. Expected _p_switch_input_callback_function_t");
|
||||
}
|
||||
arg4 = *argp;
|
||||
}
|
||||
@@ -1415,15 +1405,13 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
{
|
||||
switch_input_callback_function_t *argp;
|
||||
if (SWIG_ConvertPtr(ST(1), (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 2 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_input_callback_function_t");
|
||||
SWIG_croak("Type error in argument 2 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_input_callback_function_t");
|
||||
}
|
||||
arg2 = *argp;
|
||||
}
|
||||
@@ -1460,13 +1448,11 @@ extern "C" {
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 7) || (items > 7)) {
|
||||
SWIG_croak
|
||||
("Usage: fs_switch_ivr_collect_digits_count(session,buf,buflen,maxdigits,terminators,terminator,timeout);");
|
||||
SWIG_croak("Usage: fs_switch_ivr_collect_digits_count(session,buf,buflen,maxdigits,terminators,terminator,timeout);");
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_ivr_collect_digits_count. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_count. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(1)))
|
||||
@@ -1511,14 +1497,12 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_ivr_originate. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_ivr_originate. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 2 of fs_switch_ivr_originate. Expected _p_p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 2 of fs_switch_ivr_originate. Expected _p_p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(2)))
|
||||
@@ -1559,8 +1543,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_ivr_session_transfer. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_ivr_session_transfer. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(1)))
|
||||
@@ -1603,8 +1586,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_ivr_speak_text. Expected _p_switch_core_session_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_ivr_speak_text. Expected _p_switch_core_session_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(1)))
|
||||
@@ -1651,8 +1633,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_channel_get_variable. Expected _p_switch_channel_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_channel_get_variable. Expected _p_switch_channel_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(1)))
|
||||
@@ -1689,8 +1670,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t, 0) < 0) {
|
||||
SWIG_croak
|
||||
("Type error in argument 1 of fs_switch_channel_set_variable. Expected _p_switch_channel_t");
|
||||
SWIG_croak("Type error in argument 1 of fs_switch_channel_set_variable. Expected _p_switch_channel_t");
|
||||
}
|
||||
}
|
||||
if (!SvOK((SV *) ST(1)))
|
||||
@@ -1716,17 +1696,14 @@ extern "C" {
|
||||
|
||||
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
|
||||
|
||||
static swig_type_info _swigt__p_switch_channel_t[] =
|
||||
{ {"_p_switch_channel_t", 0, "switch_channel_t *", 0}, {"_p_switch_channel_t"}, {0} };
|
||||
static swig_type_info _swigt__p_switch_file_handle_t[] =
|
||||
{ {"_p_switch_file_handle_t", 0, "switch_file_handle_t *", 0}, {"_p_switch_file_handle_t"}, {0} };
|
||||
static swig_type_info _swigt__p_switch_channel_t[] = { {"_p_switch_channel_t", 0, "switch_channel_t *", 0}, {"_p_switch_channel_t"}, {0} };
|
||||
static swig_type_info _swigt__p_switch_file_handle_t[] = { {"_p_switch_file_handle_t", 0, "switch_file_handle_t *", 0}, {"_p_switch_file_handle_t"}, {0} };
|
||||
static swig_type_info _swigt__p_switch_core_session_t[] =
|
||||
{ {"_p_switch_core_session_t", 0, "switch_core_session_t *", 0}, {"_p_switch_core_session_t"}, {0} };
|
||||
static swig_type_info _swigt__p_p_switch_core_session_t[] =
|
||||
{ {"_p_p_switch_core_session_t", 0, "switch_core_session_t **", 0}, {"_p_p_switch_core_session_t"}, {0} };
|
||||
static swig_type_info _swigt__p_uint32_t[] = { {"_p_uint32_t", 0, "uint32_t *", 0}, {"_p_uint32_t"}, {0} };
|
||||
static swig_type_info _swigt__p_switch_input_callback_function_t[] =
|
||||
{ {"_p_switch_input_callback_function_t", 0, "switch_input_callback_function_t *", 0},
|
||||
static swig_type_info _swigt__p_switch_input_callback_function_t[] = { {"_p_switch_input_callback_function_t", 0, "switch_input_callback_function_t *", 0},
|
||||
{"_p_switch_input_callback_function_t"}, {0}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ extern "C" {
|
||||
#include <switch.h>
|
||||
|
||||
extern void *globalDTMFCallbackFunction;
|
||||
extern switch_status_t PythonDTMFCallback(switch_core_session * session,
|
||||
void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
|
||||
extern switch_status_t PythonDTMFCallback(switch_core_session * session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
|
||||
|
||||
class SessionContainer {
|
||||
private:
|
||||
|
||||
@@ -114,8 +114,7 @@ static switch_loadable_module_interface_t python_module_interface = {
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &python_module_interface;
|
||||
|
||||
@@ -329,8 +329,7 @@ extern "C" {
|
||||
Note: if start == end at the beginning of the function, we go all the way around
|
||||
the circular list.
|
||||
*/
|
||||
SWIGRUNTIME swig_type_info *SWIG_MangledTypeQueryModule(swig_module_info * start,
|
||||
swig_module_info * end, const char *name) {
|
||||
SWIGRUNTIME swig_type_info *SWIG_MangledTypeQueryModule(swig_module_info * start, swig_module_info * end, const char *name) {
|
||||
swig_module_info *iter = start;
|
||||
do {
|
||||
if (iter->size) {
|
||||
@@ -572,7 +571,7 @@ extern "C" {
|
||||
* type checking.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
************************************************************************//* Common SWIG API */
|
||||
************************************************************************//* Common SWIG API */
|
||||
#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags)
|
||||
#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags)
|
||||
#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
|
||||
@@ -584,11 +583,11 @@ extern "C" {
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Pointer declarations
|
||||
* ----------------------------------------------------------------------------- *//*
|
||||
Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
|
||||
C/C++ pointers in the python side. Very useful for debugging, but
|
||||
not always safe.
|
||||
*/
|
||||
* ----------------------------------------------------------------------------- *//*
|
||||
Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
|
||||
C/C++ pointers in the python side. Very useful for debugging, but
|
||||
not always safe.
|
||||
*/
|
||||
#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES)
|
||||
# define SWIG_COBJECT_TYPES
|
||||
#endif
|
||||
@@ -652,8 +651,7 @@ extern "C" {
|
||||
|
||||
SWIGRUNTIME PyObject *PySwigObject_repr(PySwigObject * v) {
|
||||
char result[SWIG_BUFFER_SIZE];
|
||||
return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ?
|
||||
PyString_FromFormat("<Swig Object at %s>", result) : 0;
|
||||
return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? PyString_FromFormat("<Swig Object at %s>", result) : 0;
|
||||
}
|
||||
|
||||
SWIGRUNTIME PyObject *PySwigObject_str(PySwigObject * v) {
|
||||
@@ -1283,8 +1281,7 @@ extern "C" {
|
||||
#ifdef SWIG_LINK_RUNTIME
|
||||
type_pointer = SWIG_ReturnGlobalTypeList((void *) 0);
|
||||
#else
|
||||
type_pointer = PyCObject_Import((char *) "swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||
(char *) "type_pointer" SWIG_TYPE_TABLE_NAME);
|
||||
type_pointer = PyCObject_Import((char *) "swig_runtime_data" SWIG_RUNTIME_VERSION, (char *) "type_pointer" SWIG_TYPE_TABLE_NAME);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
type_pointer = (void *) 0;
|
||||
@@ -1541,8 +1538,7 @@ extern "C" {
|
||||
resultobj = Py_None;
|
||||
return resultobj;
|
||||
fail:return NULL;
|
||||
}
|
||||
static PyObject *_wrap_fs_core_init(PyObject * self, PyObject * args) {
|
||||
} static PyObject *_wrap_fs_core_init(PyObject * self, PyObject * args) {
|
||||
PyObject *resultobj = NULL;
|
||||
char *arg1 = (char *) 0;
|
||||
int result;
|
||||
@@ -1883,8 +1879,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
switch_input_callback_function_t *argp;
|
||||
SWIG_Python_ConvertPtr(obj3, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
|
||||
SWIG_POINTER_EXCEPTION);
|
||||
SWIG_Python_ConvertPtr(obj3, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
|
||||
if (SWIG_arg_fail(4))
|
||||
SWIG_fail;
|
||||
if (argp == NULL) {
|
||||
@@ -1932,8 +1927,7 @@ extern "C" {
|
||||
PyObject *obj4 = 0;
|
||||
PyObject *obj5 = 0;
|
||||
|
||||
if (!PyArg_ParseTuple
|
||||
(args, (char *) "OOOOOO:fs_switch_ivr_record_file", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5))
|
||||
if (!PyArg_ParseTuple(args, (char *) "OOOOOO:fs_switch_ivr_record_file", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5))
|
||||
goto fail;
|
||||
SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
|
||||
if (SWIG_arg_fail(1))
|
||||
@@ -1947,8 +1941,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
switch_input_callback_function_t *argp;
|
||||
SWIG_Python_ConvertPtr(obj3, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
|
||||
SWIG_POINTER_EXCEPTION);
|
||||
SWIG_Python_ConvertPtr(obj3, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
|
||||
if (SWIG_arg_fail(4))
|
||||
SWIG_fail;
|
||||
if (argp == NULL) {
|
||||
@@ -2051,16 +2044,14 @@ extern "C" {
|
||||
PyObject *obj3 = 0;
|
||||
PyObject *obj4 = 0;
|
||||
|
||||
if (!PyArg_ParseTuple
|
||||
(args, (char *) "OOOOO:fs_switch_ivr_collect_digits_callback", &obj0, &obj1, &obj2, &obj3, &obj4))
|
||||
if (!PyArg_ParseTuple(args, (char *) "OOOOO:fs_switch_ivr_collect_digits_callback", &obj0, &obj1, &obj2, &obj3, &obj4))
|
||||
goto fail;
|
||||
SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
|
||||
if (SWIG_arg_fail(1))
|
||||
SWIG_fail;
|
||||
{
|
||||
switch_input_callback_function_t *argp;
|
||||
SWIG_Python_ConvertPtr(obj1, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
|
||||
SWIG_POINTER_EXCEPTION);
|
||||
SWIG_Python_ConvertPtr(obj1, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
|
||||
if (SWIG_arg_fail(2))
|
||||
SWIG_fail;
|
||||
if (argp == NULL) {
|
||||
@@ -2115,9 +2106,7 @@ extern "C" {
|
||||
PyObject *obj5 = 0;
|
||||
PyObject *obj6 = 0;
|
||||
|
||||
if (!PyArg_ParseTuple
|
||||
(args, (char *) "OOOOOOO:fs_switch_ivr_collect_digits_count", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5,
|
||||
&obj6))
|
||||
if (!PyArg_ParseTuple(args, (char *) "OOOOOOO:fs_switch_ivr_collect_digits_count", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6))
|
||||
goto fail;
|
||||
SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
|
||||
if (SWIG_arg_fail(1))
|
||||
@@ -2262,9 +2251,7 @@ extern "C" {
|
||||
PyObject *obj7 = 0;
|
||||
PyObject *obj8 = 0;
|
||||
|
||||
if (!PyArg_ParseTuple
|
||||
(args, (char *) "OOOOOOOOO:fs_switch_ivr_speak_text", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6,
|
||||
&obj7, &obj8))
|
||||
if (!PyArg_ParseTuple(args, (char *) "OOOOOOOOO:fs_switch_ivr_speak_text", &obj0, &obj1, &obj2, &obj3, &obj4, &obj5, &obj6, &obj7, &obj8))
|
||||
goto fail;
|
||||
SWIG_Python_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_switch_core_session_t, SWIG_POINTER_EXCEPTION | 0);
|
||||
if (SWIG_arg_fail(1))
|
||||
@@ -2288,8 +2275,7 @@ extern "C" {
|
||||
}
|
||||
{
|
||||
switch_input_callback_function_t *argp;
|
||||
SWIG_Python_ConvertPtr(obj5, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t,
|
||||
SWIG_POINTER_EXCEPTION);
|
||||
SWIG_Python_ConvertPtr(obj5, (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, SWIG_POINTER_EXCEPTION);
|
||||
if (SWIG_arg_fail(6))
|
||||
SWIG_fail;
|
||||
if (argp == NULL) {
|
||||
@@ -2461,17 +2447,12 @@ extern "C" {
|
||||
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
|
||||
|
||||
static swig_type_info _swigt__p_char = { "_p_char", "char *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_p_switch_core_session_t =
|
||||
{ "_p_p_switch_core_session_t", "switch_core_session_t **", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_channel_state_t =
|
||||
{ "_p_switch_channel_state_t", "enum switch_channel_state_t *|switch_channel_state_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_p_switch_core_session_t = { "_p_p_switch_core_session_t", "switch_core_session_t **", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_channel_state_t = { "_p_switch_channel_state_t", "enum switch_channel_state_t *|switch_channel_state_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_channel_t = { "_p_switch_channel_t", "switch_channel_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_core_session_t =
|
||||
{ "_p_switch_core_session_t", "switch_core_session_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_file_handle_t =
|
||||
{ "_p_switch_file_handle_t", "switch_file_handle_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_input_callback_function_t =
|
||||
{ "_p_switch_input_callback_function_t", "switch_input_callback_function_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_core_session_t = { "_p_switch_core_session_t", "switch_core_session_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_file_handle_t = { "_p_switch_file_handle_t", "switch_file_handle_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__p_switch_input_callback_function_t = { "_p_switch_input_callback_function_t", "switch_input_callback_function_t *", 0, 0, 0 };
|
||||
static swig_type_info _swigt__ptrdiff_t = { "_ptrdiff_t", "ptrdiff_t", 0, 0, 0 };
|
||||
static swig_type_info _swigt__size_t = { "_size_t", "size_t", 0, 0, 0 };
|
||||
|
||||
@@ -2488,17 +2469,12 @@ extern "C" {
|
||||
};
|
||||
|
||||
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_p_switch_core_session_t[] =
|
||||
{ {&_swigt__p_p_switch_core_session_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_channel_state_t[] =
|
||||
{ {&_swigt__p_switch_channel_state_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_p_switch_core_session_t[] = { {&_swigt__p_p_switch_core_session_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_channel_state_t[] = { {&_swigt__p_switch_channel_state_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_channel_t[] = { {&_swigt__p_switch_channel_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_core_session_t[] =
|
||||
{ {&_swigt__p_switch_core_session_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_file_handle_t[] =
|
||||
{ {&_swigt__p_switch_file_handle_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_input_callback_function_t[] =
|
||||
{ {&_swigt__p_switch_input_callback_function_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_core_session_t[] = { {&_swigt__p_switch_core_session_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_file_handle_t[] = { {&_swigt__p_switch_file_handle_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__p_switch_input_callback_function_t[] = { {&_swigt__p_switch_input_callback_function_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__ptrdiff_t[] = { {&_swigt__ptrdiff_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
static swig_cast_info _swigc__size_t[] = { {&_swigt__size_t, 0, 0, 0}, {0, 0, 0, 0} };
|
||||
|
||||
@@ -2704,8 +2680,7 @@ extern "C" {
|
||||
SWIGINTERN PyObject *swig_varlink_repr(swig_varlinkobject * v) {
|
||||
v = v;
|
||||
return PyString_FromString("<Swig global variables>");
|
||||
}
|
||||
SWIGINTERN int swig_varlink_print(swig_varlinkobject * v, FILE * fp, int flags) {
|
||||
} SWIGINTERN int swig_varlink_print(swig_varlinkobject * v, FILE * fp, int flags) {
|
||||
swig_globalvar *var;
|
||||
flags = flags;
|
||||
fprintf(fp, "Swig global variables { ");
|
||||
@@ -2809,9 +2784,7 @@ extern "C" {
|
||||
return ((PyObject *) result);
|
||||
}
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Python_addvarlink(PyObject * p, char *name, PyObject * (*get_attr) (void),
|
||||
int (*set_attr) (PyObject * p)) {
|
||||
SWIGINTERN void SWIG_Python_addvarlink(PyObject * p, char *name, PyObject * (*get_attr) (void), int (*set_attr) (PyObject * p)) {
|
||||
swig_varlinkobject *v = (swig_varlinkobject *) p;
|
||||
swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
|
||||
if (gv) {
|
||||
@@ -2872,10 +2845,7 @@ extern "C" {
|
||||
/* Fix SwigMethods to carry the callback ptrs when needed */
|
||||
/* ----------------------------------------------------------------------------- */
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Python_FixMethods(PyMethodDef * methods,
|
||||
swig_const_info * const_table,
|
||||
swig_type_info ** types, swig_type_info ** types_initial) {
|
||||
SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef * methods, swig_const_info * const_table, swig_type_info ** types, swig_type_info ** types_initial) {
|
||||
size_t i;
|
||||
for (i = 0; methods[i].ml_name; ++i) {
|
||||
char *c = methods[i].ml_doc;
|
||||
|
||||
@@ -614,8 +614,7 @@ JSObject *new_js_event(switch_event_t *event, char *name, JSContext * cx, JSObje
|
||||
eo->event = event;
|
||||
eo->freed = 1;
|
||||
if ((Event = JS_DefineObject(cx, obj, name, &event_class, NULL, 0))) {
|
||||
if ((JS_SetPrivate(cx, Event, eo) &&
|
||||
JS_DefineProperties(cx, Event, event_props) && JS_DefineFunctions(cx, Event, event_methods))) {
|
||||
if ((JS_SetPrivate(cx, Event, eo) && JS_DefineProperties(cx, Event, event_props) && JS_DefineFunctions(cx, Event, event_methods))) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -623,8 +622,7 @@ JSObject *new_js_event(switch_event_t *event, char *name, JSContext * cx, JSObje
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t js_common_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
|
||||
void *buf, unsigned int buflen)
|
||||
static switch_status_t js_common_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
char *dtmf = NULL;
|
||||
switch_event_t *event = NULL;
|
||||
@@ -635,8 +633,7 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
|
||||
JSObject *Event = NULL;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@@ -670,8 +667,7 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t js_stream_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
|
||||
void *buf, unsigned int buflen)
|
||||
static switch_status_t js_stream_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
char *ret;
|
||||
switch_status_t status;
|
||||
@@ -756,8 +752,7 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t js_record_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
|
||||
void *buf, unsigned int buflen)
|
||||
static switch_status_t js_record_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
char *ret;
|
||||
switch_status_t status;
|
||||
@@ -794,8 +789,7 @@ static switch_status_t js_record_input_callback(switch_core_session_t *session,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t js_collect_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype,
|
||||
void *buf, unsigned int buflen)
|
||||
static switch_status_t js_collect_input_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
{
|
||||
char *ret;
|
||||
switch_status_t status;
|
||||
@@ -822,8 +816,7 @@ static JSBool session_flush_digits(JSContext * cx, JSObject * obj, uintN argc, j
|
||||
switch_channel_t *channel;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -878,8 +871,7 @@ static JSBool session_recordfile(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -962,8 +954,7 @@ static JSBool session_collect_input(JSContext * cx, JSObject * obj, uintN argc,
|
||||
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1030,8 +1021,7 @@ static JSBool session_sayphrase(JSContext * cx, JSObject * obj, uintN argc, jsva
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1161,8 +1151,7 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1227,8 +1216,7 @@ static JSBool session_set_variable(JSContext * cx, JSObject * obj, uintN argc, j
|
||||
switch_channel_t *channel;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1298,8 +1286,7 @@ static JSBool session_speak(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1350,10 +1337,7 @@ static JSBool session_speak(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
args.input_callback = dtmf_func;
|
||||
args.buf = bp;
|
||||
args.buflen = len;
|
||||
switch_ivr_speak_text(jss->session,
|
||||
tts_name,
|
||||
voice_name && strlen(voice_name) ? voice_name : NULL,
|
||||
codec->implementation->samples_per_second, text, &args);
|
||||
switch_ivr_speak_text(jss->session, tts_name, voice_name && strlen(voice_name) ? voice_name : NULL, codec->implementation->samples_per_second, text, &args);
|
||||
JS_ResumeRequest(cx, cb_state.saveDepth);
|
||||
*rval = cb_state.ret;
|
||||
|
||||
@@ -1369,8 +1353,7 @@ static JSBool session_get_digits(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
switch_channel_t *channel;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1390,8 +1373,7 @@ static JSBool session_get_digits(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
JS_ValueToInt32(cx, argv[0], &digits);
|
||||
|
||||
if (digits > sizeof(buf) - 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Exceeded max digits of %" SWITCH_SIZE_T_FMT "\n",
|
||||
sizeof(buf) - 1);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Exceeded max digits of %" SWITCH_SIZE_T_FMT "\n", sizeof(buf) - 1);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -1417,8 +1399,7 @@ static JSBool session_autohangup(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1443,8 +1424,7 @@ static JSBool session_answer(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
switch_channel_t *channel;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1473,8 +1453,7 @@ static JSBool session_cdr(JSContext * cx, JSObject * obj, uintN argc, jsval * ar
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -1496,8 +1475,7 @@ static JSBool session_ready(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
switch_channel_t *channel;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1521,8 +1499,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
|
||||
int32 timeout = 60;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1565,8 +1542,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
|
||||
int32 timeout = 60;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1605,8 +1581,7 @@ static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval
|
||||
struct js_session *jss = JS_GetPrivate(cx, obj);
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1629,8 +1604,7 @@ static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval
|
||||
jsrefcount saveDepth;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1655,8 +1629,7 @@ static JSBool session_get_event(JSContext * cx, JSObject * obj, uintN argc, jsva
|
||||
switch_event_t *event;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1670,8 +1643,7 @@ static JSBool session_get_event(JSContext * cx, JSObject * obj, uintN argc, jsva
|
||||
eo->freed = 0;
|
||||
|
||||
if ((Event = JS_DefineObject(cx, obj, "__event__", &event_class, NULL, 0))) {
|
||||
if ((JS_SetPrivate(cx, Event, eo) &&
|
||||
JS_DefineProperties(cx, Event, event_props) && JS_DefineFunctions(cx, Event, event_methods))) {
|
||||
if ((JS_SetPrivate(cx, Event, eo) && JS_DefineProperties(cx, Event, event_props) && JS_DefineFunctions(cx, Event, event_methods))) {
|
||||
*rval = OBJECT_TO_JSVAL(Event);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1691,8 +1663,7 @@ static JSBool session_send_event(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
struct event_obj *eo;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -1724,8 +1695,7 @@ static JSBool session_hangup(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
if (!jss || !jss->session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"You must call the session.originate method before calling this method!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -2043,8 +2013,7 @@ JSClass session_class = {
|
||||
};
|
||||
|
||||
|
||||
static JSObject *new_js_session(JSContext * cx, JSObject * obj, switch_core_session_t *session, struct js_session *jss,
|
||||
char *name, int flags)
|
||||
static JSObject *new_js_session(JSContext * cx, JSObject * obj, switch_core_session_t *session, struct js_session *jss, char *name, int flags)
|
||||
{
|
||||
JSObject *session_obj;
|
||||
if ((session_obj = JS_DefineObject(cx, obj, name, &session_class, NULL, 0))) {
|
||||
@@ -2054,8 +2023,7 @@ static JSObject *new_js_session(JSContext * cx, JSObject * obj, switch_core_sess
|
||||
jss->cx = cx;
|
||||
jss->obj = session_obj;
|
||||
if ((JS_SetPrivate(cx, session_obj, jss) &&
|
||||
JS_DefineProperties(cx, session_obj, session_props) &&
|
||||
JS_DefineFunctions(cx, session_obj, session_methods))) {
|
||||
JS_DefineProperties(cx, session_obj, session_props) && JS_DefineFunctions(cx, session_obj, session_methods))) {
|
||||
return session_obj;
|
||||
}
|
||||
}
|
||||
@@ -2167,15 +2135,9 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
|
||||
}
|
||||
|
||||
caller_profile = switch_caller_profile_new(pool,
|
||||
username,
|
||||
dialplan,
|
||||
cid_name,
|
||||
cid_num,
|
||||
network_addr, ani, aniii, rdnis, (char *) modname, context, dest);
|
||||
username, dialplan, cid_name, cid_num, network_addr, ani, aniii, rdnis, (char *) modname, context, dest);
|
||||
|
||||
if (switch_ivr_originate
|
||||
(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL,
|
||||
caller_profile) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
|
||||
goto done;
|
||||
}
|
||||
@@ -2356,8 +2318,7 @@ static JSBool fileio_write(JSContext * cx, JSObject * obj, uintN argc, jsval * a
|
||||
|
||||
if (data) {
|
||||
wrote = strlen(data);
|
||||
*rval =
|
||||
BOOLEAN_TO_JSVAL((switch_file_write(fio->fd, data, &wrote) == SWITCH_STATUS_SUCCESS) ? JS_TRUE : JS_FALSE);
|
||||
*rval = BOOLEAN_TO_JSVAL((switch_file_write(fio->fd, data, &wrote) == SWITCH_STATUS_SUCCESS) ? JS_TRUE : JS_FALSE);
|
||||
}
|
||||
|
||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||
@@ -2561,8 +2522,7 @@ static JSBool js_bridge(JSContext * cx, JSObject * obj, uintN argc, jsval * argv
|
||||
}
|
||||
|
||||
if (!(jss_a && jss_b)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n",
|
||||
jss_b ? "y" : "n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -2648,18 +2608,11 @@ static int env_init(JSContext * cx, JSObject * javascript_object)
|
||||
|
||||
JS_InitStandardClasses(cx, javascript_object);
|
||||
|
||||
JS_InitClass(cx,
|
||||
javascript_object,
|
||||
NULL,
|
||||
&session_class, session_construct, 3, session_props, session_methods, session_props, session_methods);
|
||||
JS_InitClass(cx, javascript_object, NULL, &session_class, session_construct, 3, session_props, session_methods, session_props, session_methods);
|
||||
|
||||
JS_InitClass(cx,
|
||||
javascript_object,
|
||||
NULL, &fileio_class, fileio_construct, 3, fileio_props, fileio_methods, fileio_props, fileio_methods);
|
||||
JS_InitClass(cx, javascript_object, NULL, &fileio_class, fileio_construct, 3, fileio_props, fileio_methods, fileio_props, fileio_methods);
|
||||
|
||||
JS_InitClass(cx,
|
||||
javascript_object,
|
||||
NULL, &event_class, event_construct, 3, event_props, event_methods, event_props, event_methods);
|
||||
JS_InitClass(cx, javascript_object, NULL, &event_class, event_construct, 3, event_props, event_methods, event_props, event_methods);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -2720,7 +2673,7 @@ static void js_parse_and_execute(switch_core_session_t *session, char *input_cod
|
||||
|
||||
|
||||
|
||||
static void *SWITCH_THREAD_FUNC js_thread_run(switch_thread_t *thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC js_thread_run(switch_thread_t * thread, void *obj)
|
||||
{
|
||||
char *input_code = obj;
|
||||
|
||||
@@ -2801,8 +2754,7 @@ static switch_loadable_module_interface_t spidermonkey_module_interface = {
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
|
||||
@@ -90,8 +90,7 @@ static JSBool js_email(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
|
||||
if (argc > 3 &&
|
||||
(from = JS_GetStringBytes(JS_ValueToString(cx, argv[0]))) &&
|
||||
(to = JS_GetStringBytes(JS_ValueToString(cx, argv[1]))) &&
|
||||
(headers = JS_GetStringBytes(JS_ValueToString(cx, argv[2]))) &&
|
||||
(body = JS_GetStringBytes(JS_ValueToString(cx, argv[3])))
|
||||
(headers = JS_GetStringBytes(JS_ValueToString(cx, argv[2]))) && (body = JS_GetStringBytes(JS_ValueToString(cx, argv[3])))
|
||||
) {
|
||||
if (argc > 4) {
|
||||
file = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
|
||||
@@ -129,8 +128,7 @@ static JSBool js_email(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
|
||||
if (file) {
|
||||
snprintf(buf, B64BUFFLEN, "\n\n--%s\nContent-Type: application/octet-stream\n"
|
||||
"Content-Transfer-Encoding: base64\n"
|
||||
"Content-Description: Sound attachment.\n"
|
||||
"Content-Disposition: attachment; filename=\"%s\"\n\n", bound, file);
|
||||
"Content-Description: Sound attachment.\n" "Content-Disposition: attachment; filename=\"%s\"\n\n", bound, file);
|
||||
if (!write_buf(fd, buf))
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -233,8 +231,7 @@ switch_status_t etpan_load(JSContext * cx, JSObject * obj)
|
||||
{
|
||||
JS_DefineFunctions(cx, obj, etpan_functions);
|
||||
|
||||
JS_InitClass(cx,
|
||||
obj, NULL, &etpan_class, etpan_construct, 3, etpan_props, etpan_methods, etpan_props, etpan_methods);
|
||||
JS_InitClass(cx, obj, NULL, &etpan_class, etpan_construct, 3, etpan_props, etpan_methods, etpan_props, etpan_methods);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -375,9 +372,7 @@ int send_message(char *data, size_t len, char **rcpts)
|
||||
}
|
||||
|
||||
/* first open the stream */
|
||||
if ((ret = mailsmtp_socket_connect(smtp,
|
||||
(smtp_server != NULL ? smtp_server : "localhost"),
|
||||
smtp_port)) != MAILSMTP_NO_ERROR) {
|
||||
if ((ret = mailsmtp_socket_connect(smtp, (smtp_server != NULL ? smtp_server : "localhost"), smtp_port)) != MAILSMTP_NO_ERROR) {
|
||||
fprintf(stderr, "mailsmtp_socket_connect: %s\n", mailsmtp_strerror(ret));
|
||||
goto error;
|
||||
}
|
||||
@@ -397,17 +392,14 @@ int send_message(char *data, size_t len, char **rcpts)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (esmtp && smtp_user != NULL &&
|
||||
(ret = mailsmtp_auth(smtp, smtp_user, (smtp_password != NULL) ? smtp_password : ""))
|
||||
if (esmtp && smtp_user != NULL && (ret = mailsmtp_auth(smtp, smtp_user, (smtp_password != NULL) ? smtp_password : ""))
|
||||
!= MAILSMTP_NO_ERROR) {
|
||||
fprintf(stderr, "mailsmtp_auth: %s: %s\n", smtp_user, mailsmtp_strerror(ret));
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* source */
|
||||
if ((ret = (esmtp ?
|
||||
mailesmtp_mail(smtp, smtp_from, 1, "etPanSMTPTest") :
|
||||
mailsmtp_mail(smtp, smtp_from))) != MAILSMTP_NO_ERROR) {
|
||||
if ((ret = (esmtp ? mailesmtp_mail(smtp, smtp_from, 1, "etPanSMTPTest") : mailsmtp_mail(smtp, smtp_from))) != MAILSMTP_NO_ERROR) {
|
||||
fprintf(stderr, "mailsmtp_mail: %s, %s\n", smtp_from, mailsmtp_strerror(ret));
|
||||
goto error;
|
||||
}
|
||||
@@ -415,9 +407,7 @@ int send_message(char *data, size_t len, char **rcpts)
|
||||
/* recipients */
|
||||
for (r = rcpts; *r != NULL; r++) {
|
||||
if ((ret = (esmtp ?
|
||||
mailesmtp_rcpt(smtp, *r,
|
||||
MAILSMTP_DSN_NOTIFY_FAILURE | MAILSMTP_DSN_NOTIFY_DELAY,
|
||||
NULL) : mailsmtp_rcpt(smtp, *r))) != MAILSMTP_NO_ERROR) {
|
||||
mailesmtp_rcpt(smtp, *r, MAILSMTP_DSN_NOTIFY_FAILURE | MAILSMTP_DSN_NOTIFY_DELAY, NULL) : mailsmtp_rcpt(smtp, *r))) != MAILSMTP_NO_ERROR) {
|
||||
fprintf(stderr, "mailsmtp_rcpt: %s: %s\n", *r, mailsmtp_strerror(ret));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -168,15 +168,12 @@ odbc_status_t odbc_obj_connect(odbc_obj_t * obj)
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connecting %s\n", obj->dsn);
|
||||
|
||||
result = SQLConnect(obj->con,
|
||||
(SQLCHAR *) obj->dsn, SQL_NTS,
|
||||
(SQLCHAR *) obj->username, SQL_NTS, (SQLCHAR *) obj->password, SQL_NTS);
|
||||
result = SQLConnect(obj->con, (SQLCHAR *) obj->dsn, SQL_NTS, (SQLCHAR *) obj->username, SQL_NTS, (SQLCHAR *) obj->password, SQL_NTS);
|
||||
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||
SQLGetDiagRec(SQL_HANDLE_DBC, obj->con, 1, stat, &err, msg, 100, &mlen);
|
||||
SQLFreeHandle(SQL_HANDLE_ENV, obj->env);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error SQLConnect=%d errno=%d %s\n", result, (int) err,
|
||||
msg);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error SQLConnect=%d errno=%d %s\n", result, (int) err, msg);
|
||||
return ODBC_FAIL;
|
||||
} else {
|
||||
|
||||
@@ -445,8 +442,7 @@ static JSBool odbc_get_data(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
SQLCHAR *data = odbc_obj->colbuf;
|
||||
SQLCHAR *esc = NULL;
|
||||
|
||||
SQLDescribeCol(odbc_obj->stmt, x, name, sizeof(name), &NameLength, &DataType, &ColumnSize,
|
||||
&DecimalDigits, &Nullable);
|
||||
SQLDescribeCol(odbc_obj->stmt, x, name, sizeof(name), &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
|
||||
SQLGetData(odbc_obj->stmt, x, SQL_C_CHAR, odbc_obj->colbuf, odbc_obj->cblen, NULL);
|
||||
|
||||
if (strchr((char *) odbc_obj->colbuf, '"')) { /* please don't */
|
||||
@@ -454,8 +450,7 @@ static JSBool odbc_get_data(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
||||
data = esc;
|
||||
}
|
||||
|
||||
snprintf((char *) odbc_obj->code, odbc_obj->codelen, "~_oDbC_dB_RoW_DaTa_[\"%s\"] = \"%s\"", name,
|
||||
data);
|
||||
snprintf((char *) odbc_obj->code, odbc_obj->codelen, "~_oDbC_dB_RoW_DaTa_[\"%s\"] = \"%s\"", name, data);
|
||||
switch_safe_free(esc);
|
||||
|
||||
eval_some_js((char *) odbc_obj->code, cx, obj, rval);
|
||||
|
||||
@@ -116,8 +116,7 @@ static JSBool teletone_construct(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_frame / 1000,
|
||||
read_codec->implementation->number_of_channels,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed\n");
|
||||
@@ -285,9 +284,7 @@ static JSBool teletone_generate(JSContext * cx, JSObject * obj, uintN argc, jsva
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((write_frame.datalen =
|
||||
(uint32_t) switch_buffer_read(tto->audio_buffer, fdata,
|
||||
write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||
if ((write_frame.datalen = (uint32_t) switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||
if (loops) {
|
||||
switch_buffer_t *tmp;
|
||||
|
||||
@@ -298,8 +295,7 @@ static JSBool teletone_generate(JSContext * cx, JSObject * obj, uintN argc, jsva
|
||||
loops--;
|
||||
/* try again */
|
||||
if ((write_frame.datalen =
|
||||
(uint32_t) switch_buffer_read(tto->audio_buffer, fdata,
|
||||
write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||
(uint32_t) switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -363,11 +359,7 @@ JSClass teletone_class = {
|
||||
|
||||
switch_status_t teletone_load(JSContext * cx, JSObject * obj)
|
||||
{
|
||||
JS_InitClass(cx,
|
||||
obj,
|
||||
NULL,
|
||||
&teletone_class,
|
||||
teletone_construct, 3, teletone_props, teletone_methods, teletone_props, teletone_methods);
|
||||
JS_InitClass(cx, obj, NULL, &teletone_class, teletone_construct, 3, teletone_props, teletone_methods, teletone_props, teletone_methods);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ static WORD COLORS[] = { FOREGROUND_RED | FOREGROUND_INTENSITY,
|
||||
FOREGROUND_GREEN | FOREGROUND_INTENSITY
|
||||
};
|
||||
#else
|
||||
static const char *COLORS[] =
|
||||
{ SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN,
|
||||
static const char *COLORS[] = { SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN,
|
||||
SWITCH_SEQ_FGREEN, SWITCH_SEQ_FYELLOW, ""
|
||||
};
|
||||
#endif
|
||||
@@ -130,8 +129,7 @@ static switch_status_t config_logger(void)
|
||||
if (!strcasecmp(var, "colorize") && switch_true(val)) {
|
||||
#ifdef WIN32
|
||||
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (switch_core_get_console() == stdout && hStdout != INVALID_HANDLE_VALUE
|
||||
&& GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) {
|
||||
if (switch_core_get_console() == stdout && hStdout != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) {
|
||||
wOldColorAttrs = csbiInfo.wAttributes;
|
||||
COLORIZE = 1;
|
||||
}
|
||||
@@ -190,8 +188,7 @@ static switch_status_t switch_console_logger(const switch_log_node_t *node, swit
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
|
||||
|
||||
@@ -148,8 +148,7 @@ static switch_status_t load_config(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
|
||||
{
|
||||
switch_status_t status;
|
||||
*interface = &console_module_interface;
|
||||
|
||||
@@ -56,9 +56,7 @@ static const char modname[] = "mod_say_en";
|
||||
}}\
|
||||
|
||||
|
||||
static switch_status_t en_spell(switch_core_session_t *session,
|
||||
char *tosay,
|
||||
switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -78,9 +76,7 @@ static switch_status_t en_spell(switch_core_session_t *session,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t play_group(switch_say_method_t method,
|
||||
int a,
|
||||
int b, int c, char *what, switch_core_session_t *session, switch_input_args_t *args)
|
||||
static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, switch_core_session_t *session, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
if (a) {
|
||||
@@ -156,9 +152,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
}
|
||||
|
||||
static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
char *tosay,
|
||||
switch_say_type_t type,
|
||||
switch_say_method_t method, switch_input_args_t *args)
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
int in;
|
||||
@@ -188,18 +182,13 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
switch (method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
if ((status =
|
||||
play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session,
|
||||
args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status =
|
||||
play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session,
|
||||
args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status =
|
||||
play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@@ -224,8 +213,7 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t en_ip(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
@@ -268,9 +256,7 @@ static switch_status_t en_ip(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t en_say_time(switch_core_session_t *session,
|
||||
char *tosay,
|
||||
switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
@@ -416,9 +402,7 @@ static switch_status_t en_say_time(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t en_say_money(switch_core_session_t *session,
|
||||
char *tosay,
|
||||
switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
|
||||
@@ -484,9 +468,7 @@ static switch_status_t en_say_money(switch_core_session_t *session,
|
||||
|
||||
|
||||
|
||||
static switch_status_t en_say(switch_core_session_t *session,
|
||||
char *tosay,
|
||||
switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
@@ -547,8 +529,7 @@ static switch_loadable_module_interface_t say_en_module_interface = {
|
||||
/*.asr_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &say_en_module_interface;
|
||||
|
||||
@@ -197,8 +197,7 @@ static const switch_loadable_module_interface_t mod_softtimer_module_interface =
|
||||
/*.timer_interface */ &timer_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
||||
@@ -100,8 +100,7 @@ static const switch_loadable_module_interface_t mod_xml_cdr_module_interface = {
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* test global state handlers */
|
||||
switch_core_add_state_handler(&state_handlers);
|
||||
|
||||
@@ -56,9 +56,7 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
}
|
||||
|
||||
|
||||
static switch_xml_t xml_url_fetch(const char *section,
|
||||
const char *tag_name,
|
||||
const char *key_name, const char *key_value, const char *params, void *user_data)
|
||||
static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, const char *key_name, const char *key_value, const char *params, void *user_data)
|
||||
{
|
||||
char filename[512] = "";
|
||||
CURL *curl_handle = NULL;
|
||||
@@ -88,8 +86,7 @@ static switch_xml_t xml_url_fetch(const char *section,
|
||||
section,
|
||||
tag_name ? tag_name : "",
|
||||
key_name ? key_name : "",
|
||||
key_value ? key_value : "",
|
||||
params ? strchr(params, '=') ? "&" : "¶ms=" : "", params ? params : ""))) {
|
||||
key_value ? key_value : "", params ? strchr(params, '=') ? "&" : "¶ms=" : "", params ? params : ""))) {
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
||||
return NULL;
|
||||
@@ -206,8 +203,7 @@ static switch_status_t do_config(void)
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n",
|
||||
switch_strlen_zero(bname) ? "N/A" : bname,
|
||||
binding->url, binding->bindings ? binding->bindings : "all");
|
||||
switch_strlen_zero(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all");
|
||||
switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings), binding);
|
||||
x++;
|
||||
binding = NULL;
|
||||
@@ -219,8 +215,7 @@ static switch_status_t do_config(void)
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &xml_curl_module_interface;
|
||||
|
||||
@@ -112,8 +112,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_realm, globals.realm)
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &xml_rpc_module_interface;
|
||||
@@ -300,8 +299,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
MIMETypeInit();
|
||||
MIMETypeAdd("text/html", "html");
|
||||
|
||||
snprintf(logfile, sizeof(logfile), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR,
|
||||
"freeswitch_http.log");
|
||||
snprintf(logfile, sizeof(logfile), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, "freeswitch_http.log");
|
||||
ServerCreate(&abyssServer, "XmlRpcServer", globals.port, SWITCH_GLOBAL_dirs.htdocs_dir, logfile);
|
||||
|
||||
xmlrpc_server_abyss_set_handler(&env, &abyssServer, "/RPC2", registryP);
|
||||
@@ -309,8 +307,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
ServerInit(&abyssServer);
|
||||
ServerAddHandler(&abyssServer, HandleHook);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting HTTP Port %d, DocRoot [%s]\n", globals.port,
|
||||
SWITCH_GLOBAL_dirs.htdocs_dir);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting HTTP Port %d, DocRoot [%s]\n", globals.port, SWITCH_GLOBAL_dirs.htdocs_dir);
|
||||
while (globals.running) {
|
||||
ServerRunOnce2(&abyssServer, ABYSS_FOREGROUND);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user