git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4798 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2007-03-30 00:13:31 +00:00
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;
}
+6 -11
View File
@@ -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 */
+1 -2
View File
@@ -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;
+10 -21
View File
@@ -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) {
+13 -32
View File
@@ -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 */
+1 -2
View File
@@ -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 */
+12 -31
View File
@@ -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;
+1 -2
View File
@@ -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;