code analysis, clean up asserts related to switch_core_session_get_channel.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7402 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2008-01-28 07:26:10 +00:00
parent c8dd27cdd1
commit 482badffca
44 changed files with 506 additions and 1661 deletions
@@ -1465,7 +1465,6 @@ SWITCH_STANDARD_API(originate_function)
}
caller_channel = switch_core_session_get_channel(caller_session);
switch_assert(caller_channel != NULL);
switch_channel_clear_state_handler(caller_channel, NULL);
if (*exten == '&' && *(exten + 1)) {
@@ -2016,8 +2015,6 @@ SWITCH_STANDARD_API(uuid_setvar_function)
switch_channel_t *channel;
channel = switch_core_session_get_channel(psession);
switch_assert(channel != NULL);
if (switch_strlen_zero(var_name)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
stream->write_function(stream, "-ERR No variable specified\n");
@@ -2063,8 +2060,6 @@ SWITCH_STANDARD_API(uuid_getvar_function)
if ((psession = switch_core_session_locate(uuid))) {
switch_channel_t *channel;
channel = switch_core_session_get_channel(psession);
switch_assert(channel != NULL);
if (switch_strlen_zero(var_name)) {
stream->write_function(stream, "-ERR No variable name specified!\n");
@@ -2119,7 +2114,6 @@ SWITCH_STANDARD_API(uuid_dump_function)
char *buf;
channel = switch_core_session_get_channel(psession);
switch_assert(channel != NULL);
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_xml_t xml;
@@ -1366,7 +1366,6 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t * thread,
switch_assert(member != NULL);
channel = switch_core_session_get_channel(member->session);
switch_assert(channel != NULL);
read_codec = switch_core_session_get_read_codec(member->session);
switch_assert(read_codec != NULL);
@@ -1550,7 +1549,6 @@ static void conference_loop_output(conference_member_t * member)
uint32_t low_count = 0, bytes = samples * 2;
call_list_t *call_list = NULL, *cp = NULL;
switch_assert(channel != NULL);
switch_assert(member->conference != NULL);
if (switch_core_timer_init(&timer, member->conference->timer_name, interval, tsamples, NULL) == SWITCH_STATUS_SUCCESS) {
@@ -2450,13 +2448,10 @@ static void conference_list_pretty(conference_obj_t * conference, switch_stream_
channel = switch_core_session_get_channel(member->session);
profile = switch_channel_get_caller_profile(channel);
stream->write_function(stream, "%u) %s (%s)\n", member->id, profile->caller_id_name, profile->caller_id_number);
}
switch_mutex_unlock(conference->member_mutex);
}
static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim)
@@ -2486,7 +2481,6 @@ static void conference_list(conference_obj_t * conference, switch_stream_handle_
profile = switch_channel_get_caller_profile(channel);
name = switch_channel_get_name(channel);
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);
@@ -3637,7 +3631,6 @@ static switch_status_t audio_bridge_on_ring(switch_core_session_t *session)
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM RING\n");
@@ -3684,12 +3677,10 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
}
peer_channel = switch_core_session_get_channel(peer_session);
switch_assert(peer_channel != NULL);
rdlock = 1;
goto callup;
}
conference_name = conference->name;
if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
@@ -3699,7 +3690,6 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
if (session != NULL) {
caller_channel = switch_core_session_get_channel(session);
}
if (switch_strlen_zero(cid_name)) {
@@ -3723,7 +3713,6 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
rdlock = 1;
peer_channel = switch_core_session_get_channel(peer_session);
switch_assert(peer_channel != NULL);
/* make sure the conference still exists */
if (!switch_test_flag(conference, CFLAG_RUNNING)) {
@@ -3942,8 +3931,6 @@ SWITCH_STANDARD_APP(conference_auto_function)
switch_channel_t *channel = switch_core_session_get_channel(session);
call_list_t *call_list, *np;
switch_assert(channel != NULL);
call_list = switch_channel_get_private(channel, "_conference_autocall_list_");
if (switch_strlen_zero(data)) {
@@ -3987,8 +3974,6 @@ SWITCH_STANDARD_APP(conference_function)
conf_xml_cfg_t xml_cfg = { 0 };
switch_event_t *params = NULL;
switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n");
return;
+18 -102
View File
@@ -111,10 +111,7 @@ SWITCH_STANDARD_APP(set_user_function)
{
switch_xml_t x_domain, xml = NULL, x_user, x_param, x_params;
char *user, *mailbox, *domain;
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_channel_t *channel = switch_core_session_get_channel(session);
if (switch_strlen_zero(data)) {
goto error;
@@ -164,29 +161,19 @@ SWITCH_STANDARD_APP(set_user_function)
SWITCH_STANDARD_APP(ring_ready_function)
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_channel_ring_ready(channel);
switch_channel_ring_ready(switch_core_session_get_channel(session));
}
SWITCH_STANDARD_APP(break_function)
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_channel_set_flag(channel, CF_BREAK);
switch_channel_set_flag(switch_core_session_get_channel(session), CF_BREAK);
}
SWITCH_STANDARD_APP(queue_dtmf_function)
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_channel_queue_dtmf_string(channel, (const char *) data);
switch_channel_queue_dtmf_string(switch_core_session_get_channel(session), (const char *) data);
}
SWITCH_STANDARD_APP(send_dtmf_function)
{
switch_core_session_send_dtmf_string(session, (const char *) data);
@@ -329,12 +316,8 @@ SWITCH_STANDARD_APP(eval_function)
SWITCH_STANDARD_APP(phrase_function)
{
switch_channel_t *channel;
char *mydata = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
const char *lang;
char *macro = mydata;
@@ -344,7 +327,7 @@ SWITCH_STANDARD_APP(phrase_function)
*mdata++ = '\0';
}
lang = switch_channel_get_variable(channel, "language");
lang = switch_channel_get_variable(switch_core_session_get_channel(session), "language");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, switch_str_nil(mdata), switch_str_nil(lang));
switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
@@ -353,35 +336,23 @@ SWITCH_STANDARD_APP(phrase_function)
SWITCH_STANDARD_APP(hangup_function)
{
switch_channel_t *channel;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!switch_strlen_zero(data)) {
cause = switch_channel_str2cause(data);
}
switch_channel_hangup(channel, cause);
switch_channel_hangup(switch_core_session_get_channel(session), cause);
}
SWITCH_STANDARD_APP(answer_function)
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_channel_answer(channel);
switch_channel_answer(switch_core_session_get_channel(session));
}
SWITCH_STANDARD_APP(pre_answer_function)
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_channel_pre_answer(channel);
switch_channel_pre_answer(switch_core_session_get_channel(session));
}
SWITCH_STANDARD_APP(redirect_function)
@@ -420,12 +391,8 @@ SWITCH_STANDARD_APP(deflect_function)
SWITCH_STANDARD_APP(set_function)
{
switch_channel_t *channel;
char *var, *val = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
} else {
@@ -440,7 +407,7 @@ SWITCH_STANDARD_APP(set_function)
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", var, val ? val : "UNDEF");
switch_channel_set_variable(channel, var, val);
switch_channel_set_variable(switch_core_session_get_channel(session), var, val);
}
}
@@ -470,14 +437,10 @@ SWITCH_STANDARD_APP(set_global_function)
SWITCH_STANDARD_APP(set_profile_var_function)
{
switch_channel_t *channel;
switch_caller_profile_t *caller_profile;
char *name, *val = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -550,14 +513,11 @@ SWITCH_STANDARD_APP(set_profile_var_function)
SWITCH_STANDARD_APP(export_function)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *exports;
char *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL, *var_name = NULL;
int local = 1;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
} else {
@@ -599,27 +559,18 @@ SWITCH_STANDARD_APP(export_function)
SWITCH_STANDARD_APP(unset_function)
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "UNSET [%s]\n", (char *) data);
switch_channel_set_variable(channel, data, NULL);
switch_channel_set_variable(switch_core_session_get_channel(session), data, NULL);
}
}
SWITCH_STANDARD_APP(log_function)
{
switch_channel_t *channel;
char *level, *log_str;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (data && (level = strdup(data))) {
switch_log_level_t ltype = SWITCH_LOG_DEBUG;
@@ -640,15 +591,11 @@ SWITCH_STANDARD_APP(log_function)
SWITCH_STANDARD_APP(info_function)
{
switch_channel_t *channel;
switch_event_t *event;
char *buf;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_channel_event_set_data(switch_core_session_get_channel(session), event);
switch_event_serialize(event, &buf, SWITCH_FALSE);
switch_assert(buf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHANNEL_DATA:\n%s\n", buf);
@@ -659,17 +606,13 @@ SWITCH_STANDARD_APP(info_function)
SWITCH_STANDARD_APP(event_function)
{
switch_channel_t *channel;
switch_event_t *event;
char *argv[25] = { 0 };
int argc = 0;
char *lbuf;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_APPLICATION) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_channel_event_set_data(switch_core_session_get_channel(session), event);
if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
int x = 0;
@@ -700,13 +643,7 @@ SWITCH_STANDARD_APP(event_function)
SWITCH_STANDARD_APP(privacy_function)
{
switch_channel_t *channel;
switch_caller_profile_t *caller_profile;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No privacy mode specified.\n");
@@ -742,15 +679,11 @@ SWITCH_STANDARD_APP(strftime_function)
switch_size_t retsize;
switch_time_exp_t tm;
char date[80] = "";
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), argv[1], &tm);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date);
switch_channel_set_variable(channel, argv[0], date);
switch_channel_set_variable(switch_core_session_get_channel(session), argv[0], date);
}
}
@@ -1025,8 +958,6 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit
const char *terminators;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *p;
switch_assert(channel);
if (!(terminators = switch_channel_get_variable(channel, SWITCH_PLAYBACK_TERMINATORS_VARIABLE))) {
terminators = "*";
@@ -1067,8 +998,6 @@ SWITCH_STANDARD_APP(speak_function)
char *mydata = NULL;
switch_input_args_t args = { 0 };
switch_assert(channel != NULL);
if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
return;
@@ -1122,12 +1051,9 @@ SWITCH_STANDARD_APP(speak_function)
SWITCH_STANDARD_APP(playback_function)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_input_args_t args = { 0 };
switch_assert(channel != NULL);
switch_channel_pre_answer(channel);
switch_channel_pre_answer(switch_core_session_get_channel(session));
args.input_callback = on_dtmf;
switch_ivr_play_file(session, NULL, data, &args);
@@ -1135,7 +1061,6 @@ SWITCH_STANDARD_APP(playback_function)
SWITCH_STANDARD_APP(gentones_function)
{
switch_channel_t *channel;
char *tone_script = NULL;
switch_input_args_t args = { 0 };
char *l;
@@ -1146,12 +1071,7 @@ SWITCH_STANDARD_APP(gentones_function)
return;
}
tone_script = switch_core_session_strdup(session, data);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_channel_pre_answer(channel);
switch_channel_pre_answer(switch_core_session_get_channel(session));
if ((l = strchr(tone_script, '|'))) {
*l++ = '\0';
@@ -1208,8 +1128,6 @@ SWITCH_STANDARD_APP(record_function)
const char *tmp;
int rate;
switch_assert(channel != NULL);
if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
} else {
@@ -1301,8 +1219,6 @@ SWITCH_STANDARD_APP(audio_bridge_function)
uint8_t no_media_bridge = 0;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
assert(caller_channel != NULL);
if (switch_strlen_zero(data)) {
return;
}
-4
View File
@@ -547,8 +547,6 @@ SWITCH_STANDARD_DIALPLAN(enum_dialplan_hunt)
enum_route_t *rtp;
char *dp = (char *) arg;
assert(channel != NULL);
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
@@ -597,8 +595,6 @@ SWITCH_STANDARD_APP(enum_app_function)
uint32_t cnt = 1;
switch_channel_t *channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (!(mydata = switch_core_session_strdup(session, data))) {
return;
}
+1 -6
View File
@@ -56,7 +56,7 @@ typedef enum {
SWITCH_STANDARD_APP(bcast_function)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_socket_t *socket;
switch_sockaddr_t *audio_addr = NULL, *control_packet_addr;
switch_frame_t *read_frame;
@@ -77,11 +77,6 @@ SWITCH_STANDARD_APP(bcast_function)
switch_port_t mcast_control_port = 6061;
char *mcast_port_str = "34567";
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (!switch_strlen_zero((char *) data)) {
mydata = switch_core_session_strdup(session, data);
assert(mydata != NULL);
+14 -37
View File
@@ -40,10 +40,7 @@ SWITCH_MODULE_DEFINITION(mod_fifo, mod_fifo_load, mod_fifo_shutdown, NULL);
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
switch_core_session_t *bleg;
switch_channel_t *channel;
bleg = (switch_core_session_t *) buf;
switch_core_session_t *bleg = (switch_core_session_t *) buf;
switch (itype) {
case SWITCH_INPUT_TYPE_DTMF:
@@ -51,10 +48,8 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
if (dtmf->digit == '*') {
channel = switch_core_session_get_channel(session);
if (switch_channel_test_flag(channel, CF_ORIGINATOR)) {
channel = switch_core_session_get_channel(bleg);
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
if (switch_channel_test_flag(switch_core_session_get_channel(session), CF_ORIGINATOR)) {
switch_channel_hangup(switch_core_session_get_channel(bleg), SWITCH_CAUSE_NORMAL_CLEARING);
return SWITCH_STATUS_BREAK;
}
}
@@ -67,10 +62,8 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit
return SWITCH_STATUS_SUCCESS;
}
#define check_string(s) if (!switch_strlen_zero(s) && !strcasecmp(s, "undef")) { s = NULL; }
static switch_status_t read_frame_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
{
switch_queue_t *fifo = (switch_queue_t *) user_data;
@@ -194,7 +187,7 @@ SWITCH_STANDARD_APP(fifo_function)
int argc;
char *mydata = NULL, *argv[5] = { 0 };
fifo_node_t *node;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
int nowait = 0;
const char *moh = NULL;
const char *announce = NULL;
@@ -208,8 +201,7 @@ SWITCH_STANDARD_APP(fifo_function)
return;
}
if (switch_strlen_zero(data)) {
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Args\n");
return;
}
@@ -221,17 +213,13 @@ SWITCH_STANDARD_APP(fifo_function)
return;
}
channel = switch_core_session_get_channel(session);
switch_mutex_lock(globals.mutex);
switch_mutex_lock(globals.mutex);
if (!(node = switch_core_hash_find(globals.fifo_hash, argv[0]))) {
node = create_node(argv[0]);
}
switch_mutex_unlock(globals.mutex);
moh = switch_channel_get_variable(channel, "fifo_music");
moh = switch_channel_get_variable(channel, "fifo_music");
announce = switch_channel_get_variable(channel, "fifo_announce");
if (argc > 2) {
@@ -254,8 +242,7 @@ SWITCH_STANDARD_APP(fifo_function)
check_string(announce);
check_string(moh);
if (moh) {
if (moh) {
switch_ivr_broadcast(uuid, moh, SMF_LOOP | SMF_ECHO_ALEG);
}
@@ -284,9 +271,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_ivr_park(session, NULL);
if (switch_channel_ready(channel)) {
if (switch_channel_ready(channel)) {
if (announce) {
switch_ivr_play_file(session, NULL, announce, NULL);
}
@@ -345,9 +330,8 @@ SWITCH_STANDARD_APP(fifo_function)
switch_mutex_unlock(node->mutex);
switch_channel_answer(channel);
}
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_start");
@@ -360,9 +344,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_channel_set_variable(channel, "fifo_status", "WAITING");
switch_channel_set_variable(channel, "fifo_timestamp", date);
while(switch_channel_ready(channel)) {
while(switch_channel_ready(channel)) {
if (moh) {
args.read_frame_callback = read_frame_callback;
args.user_data = node->fifo;
@@ -389,8 +371,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_caller_profile_t *cloned_profile;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(other_channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_pop");
@@ -404,9 +385,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_event_fire(&event);
}
if (announce) {
if (announce) {
switch_ivr_play_file(session, NULL, announce, NULL);
} else {
switch_ivr_sleep(session, 500);
@@ -477,8 +456,7 @@ SWITCH_STANDARD_APP(fifo_function)
}
}
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_stop");
@@ -495,7 +473,6 @@ SWITCH_STANDARD_APP(fifo_function)
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
}
}
static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char *tag, int cc_off, int verbose)
+12 -39
View File
@@ -284,18 +284,13 @@ static switch_status_t do_config()
static switch_status_t hanguphook(switch_core_session_t *session)
{
switch_channel_t *channel;
switch_channel_state_t state;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_state_t state = switch_channel_get_state(channel);
const char *realm = NULL;
const char *id = NULL;
char *sql = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
state = switch_channel_get_state(channel);
if (state == CS_HANGUP || state == CS_RING) {
if (state == CS_HANGUP || state == CS_RING) {
id = switch_channel_get_variable(channel, "limit_id");
realm = switch_channel_get_variable(channel, "limit_realm");
sql = switch_mprintf("delete from limit_data where uuid='%q' and hostname='%q' and realm='%q'and id='%q';",
@@ -406,16 +401,12 @@ SWITCH_STANDARD_API(db_api_function)
SWITCH_STANDARD_APP(db_function)
{
switch_channel_t *channel;
int argc = 0;
char *argv[4] = { 0 };
char *mydata = NULL;
char *sql = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (!switch_strlen_zero(data)) {
if (!switch_strlen_zero(data)) {
mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
}
@@ -423,9 +414,8 @@ SWITCH_STANDARD_APP(db_function)
if (argc < 4 || !argv[0]) {
goto error;
}
if (!strcasecmp(argv[0], "insert")) {
if (!strcasecmp(argv[0], "insert")) {
sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
switch_assert(sql);
limit_execute_sql(sql, globals.mutex);
@@ -441,12 +431,8 @@ SWITCH_STANDARD_APP(db_function)
switch_safe_free(sql);
return;
error:
error:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
}
@@ -536,16 +522,12 @@ SWITCH_STANDARD_API(group_api_function)
SWITCH_STANDARD_APP(group_function)
{
switch_channel_t *channel;
int argc = 0;
char *argv[3] = { 0 };
char *mydata = NULL;
char *sql;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (!switch_strlen_zero(data)) {
if (!switch_strlen_zero(data)) {
mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
}
@@ -585,10 +567,7 @@ SWITCH_STANDARD_APP(limit_function)
int max = 0, got = 0;
char buf[80] = "";
callback_t cbt = { 0 };
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_channel_t *channel = switch_core_session_get_channel(session);
if (!switch_strlen_zero(data)) {
mydata = switch_core_session_strdup(session, data);
@@ -600,12 +579,9 @@ SWITCH_STANDARD_APP(limit_function)
return;
}
switch_mutex_lock(globals.mutex);
switch_mutex_lock(globals.mutex);
realm = argv[0];
realm = argv[0];
id = argv[1];
max = atoi(argv[2]);
@@ -639,11 +615,8 @@ SWITCH_STANDARD_APP(limit_function)
limit_execute_sql(sql, NULL);
switch_safe_free(sql);
done:
done:
switch_mutex_unlock(globals.mutex);
}
+2 -6
View File
@@ -155,7 +155,7 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit
SWITCH_STANDARD_APP(rss_function)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status;
const char *err = NULL;
struct dtmf_buffer dtb = { 0 };
@@ -185,16 +185,12 @@ SWITCH_STANDARD_APP(rss_function)
uint32_t matches = 0;
switch_input_args_t args = { 0 };
const char *vcf = NULL;
char *chanvars = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
char *chanvars = switch_channel_build_param_string(channel, NULL, NULL);
if ((vcf = switch_channel_get_variable(channel, "rss_alt_config"))) {
cf = vcf;
}
chanvars = switch_channel_build_param_string(channel, NULL, NULL);
if (!(cxml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return;
@@ -792,13 +792,9 @@ static switch_status_t vm_macro_get(switch_core_session_t *session,
uint32_t timeout)
{
switch_input_args_t args = { 0 }, *ap = NULL;
switch_channel_t *channel;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_size_t bslen;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (buf && buflen) {
memset(buf, 0, buflen);
args.input_callback = cancel_on_dtmf;
@@ -870,7 +866,7 @@ typedef enum {
static switch_status_t create_file(switch_core_session_t *session, vm_profile_t *profile,
char *macro_name, char *file_path, switch_size_t *message_len, switch_bool_t limit)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_file_handle_t fh = { 0 };
switch_input_args_t args = { 0 };
@@ -878,8 +874,6 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t
char input[10] = "" , key_buf[80] = "";
cc_t cc = { 0 };
switch_codec_t *read_codec;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
read_codec = switch_core_session_get_read_codec(session);
@@ -1040,15 +1034,13 @@ static void message_count(vm_profile_t *profile, const char *myid, const char *d
static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t *profile, listen_callback_t *cbt)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_input_args_t args = { 0 };
char term;
char input[10] = "" , key_buf[80] = "";
switch_file_handle_t fh = { 0 };
cc_t cc = { 0 };
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if(switch_channel_ready(channel)) {
@@ -1227,10 +1219,10 @@ end:
static void voicemail_check_main(switch_core_session_t *session, const char *profile_name, const char *domain_name, const char *id, int auth)
{
vm_check_state_t vm_check_state = VM_CHECK_START;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile;
vm_profile_t *profile;
switch_xml_t x_domain, x_domain_root, x_user, x_params, x_param;
switch_xml_t x_domain = NULL, x_domain_root = NULL, x_user = NULL, x_params, x_param;
switch_status_t status;
char pass_buf[80] = "", *mypass = NULL, id_buf[80] = "", *myfolder = NULL;
const char *thepass = NULL, *myid = id;
@@ -1246,16 +1238,11 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro
int heard_auto_saved = 0, heard_auto_new = 0;
char *email_vm = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
return;
}
x_user = x_domain = x_domain_root = NULL;
timeout = profile->digit_timeout;
attempts = profile->max_login_attempts;
@@ -1684,7 +1671,7 @@ end:
static switch_status_t voicemail_leave_main(switch_core_session_t *session, const char *profile_name, const char *domain_name, const char *id)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
char *myfolder = "inbox";
char sql[256];
prefs_callback_t cbt;
@@ -1693,7 +1680,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
char *file_path = NULL;
char *dir_path = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_caller_profile_t *caller_profile;
switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(channel);
switch_file_handle_t fh = { 0 };
switch_input_args_t args = { 0 };
char *email_vm = NULL;
@@ -1719,10 +1706,6 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
return SWITCH_STATUS_FALSE;
}
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
if(switch_strlen_zero(profile->storage_dir)) {
dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir,
SWITCH_PATH_SEPARATOR,
@@ -2059,10 +2042,7 @@ SWITCH_STANDARD_APP(voicemail_function)
const char *id = NULL;
const char *auth_var = NULL;
int x = 0, check = 0, auth = 0;
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_channel_t *channel = switch_core_session_get_channel(session);
if (switch_dir_make_recursive(SWITCH_GLOBAL_dirs.storage_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", SWITCH_GLOBAL_dirs.storage_dir);
@@ -52,13 +52,8 @@ SWITCH_STANDARD_APP(dial_function)
int argc;
char *argv[4] = { 0 };
char *mydata;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (data && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
goto error;
@@ -89,11 +84,7 @@ SWITCH_STANDARD_APP(avoid_function)
{
void *y = NULL;
int x = 0;
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_channel_t *channel = switch_core_session_get_channel(session);
for (x = 0; x < 5; x++) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Avoiding initial deadlock on channel %s.\n", switch_channel_get_name(channel));
@@ -109,11 +100,7 @@ SWITCH_STANDARD_APP(goto_function)
int argc;
char *argv[3] = { 0 };
char *mydata;
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (data && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])))) < 1) {
goto error;
@@ -134,7 +121,7 @@ SWITCH_STANDARD_APP(goto_function)
SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
char *cf = "extensions.conf";
switch_config_t cfg;
char *var, *val;
@@ -144,9 +131,6 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
cf = arg;
}
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
@@ -86,16 +86,13 @@ static void load_config(void)
SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
char *var, *val;
char filter[256];
switch_directory_handle_t dh;
char app[512];
char *data;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
@@ -103,7 +100,6 @@ SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt)
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;
}
@@ -47,14 +47,11 @@ typedef enum {
static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t xexten, switch_caller_extension_t **extension)
{
switch_xml_t xcond, xaction;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
int proceed = 0;
char *expression_expanded = NULL, *field_expanded = NULL;
channel = switch_core_session_get_channel(session);
for (xcond = switch_xml_child(xexten, "condition"); xcond; xcond = xcond->next) {
char *field = NULL;
char *do_break_a = NULL;
@@ -186,11 +183,10 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
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_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_GENERR;
switch_event_t *params = NULL;
channel = switch_core_session_get_channel(session);
switch_event_create(&params, SWITCH_EVENT_MESSAGE);
switch_assert(params);
@@ -204,11 +200,9 @@ static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switc
SWITCH_STANDARD_DIALPLAN(dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten;
char *alt_path = (char *) arg;
channel = switch_core_session_get_channel(session);
if (!caller_profile) {
if (!(caller_profile = switch_channel_get_caller_profile(channel))) {
@@ -906,7 +906,6 @@ static int activate_rtp(struct private_object *tech_pvt)
static int do_candidates(struct private_object *tech_pvt, int force)
{
switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
switch_assert(channel != NULL);
if (switch_test_flag(tech_pvt, TFLAG_DO_CAND)) {
return 1;
@@ -1052,7 +1051,7 @@ static int do_describe(struct private_object *tech_pvt, int force)
static switch_status_t negotiate_media(switch_core_session_t *session)
{
switch_status_t ret = SWITCH_STATUS_FALSE;
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
switch_time_t started;
switch_time_t now;
@@ -1061,9 +1060,6 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_set_flag_locked(tech_pvt, TFLAG_IO);
started = switch_timestamp_now();
@@ -1148,15 +1144,12 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
*/
static switch_status_t channel_on_init(switch_core_session_t *session)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
switch_set_flag(tech_pvt, TFLAG_READY);
@@ -1171,12 +1164,9 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
static switch_status_t channel_on_ring(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -1205,12 +1195,9 @@ static switch_status_t channel_on_execute(switch_core_session_t *session)
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -1258,18 +1245,13 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
{
switch_channel_t *channel = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
if (!(channel = switch_core_session_get_channel(session))) {
return SWITCH_STATUS_SUCCESS;
}
if (!(tech_pvt = switch_core_session_get_private(session))) {
return SWITCH_STATUS_SUCCESS;
}
switch (sig) {
case SWITCH_SIG_KILL:
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
@@ -1351,12 +1333,9 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s
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;
switch_channel_t *channel = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
int payload = 0;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (struct private_object *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -1452,13 +1431,10 @@ 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)
{
struct private_object *tech_pvt;
switch_channel_t *channel = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
int bytes = 0, samples = 0, frames = 0;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (struct private_object *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -1506,10 +1482,6 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
struct private_object *tech_pvt;
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -1524,12 +1496,8 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
switch_channel_t *channel;
struct private_object *tech_pvt;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -1564,13 +1532,9 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
{
switch_channel_t *channel;
struct private_object *tech_pvt;
char *subject, *body;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -2572,7 +2536,6 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using Existing session for %s\n", ldl_session_get_id(dlsession));
+18 -121
View File
@@ -339,8 +339,6 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
}
channel = switch_core_session_get_channel(tech_pvt->session);
switch_assert(channel != NULL);
if (tech_pvt->samprate || *samprate) {
unsigned short samples = iax_build_codec_rates();
@@ -456,26 +454,15 @@ static void tech_init(private_t * tech_pvt, switch_core_session_t *session)
*/
static switch_status_t channel_on_init(switch_core_session_t *session)
{
switch_channel_t *channel;
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
iax_set_private(tech_pvt->iax_session, tech_pvt);
switch_set_flag_locked(tech_pvt, TFLAG_IO);
//switch_thread_cond_create(&tech_pvt->cond, switch_core_session_get_pool(session));
//switch_mutex_lock(tech_pvt->mutex);
/* Move Channel's State Machine to RING */
switch_channel_set_state(channel, CS_RING);
switch_channel_set_state(switch_core_session_get_channel(session), CS_RING);
switch_mutex_lock(globals.mutex);
globals.calls++;
switch_mutex_unlock(globals.mutex);
@@ -485,52 +472,24 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
static switch_status_t channel_on_ring(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_execute(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
private_t *tech_pvt = switch_core_session_get_private(session);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
//switch_thread_cond_signal(tech_pvt->cond);
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
@@ -548,7 +507,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
iax_session_destroy(&tech_pvt->iax_session);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(switch_core_session_get_channel(session)));
switch_mutex_lock(globals.mutex);
globals.calls--;
if (globals.calls < 0) {
@@ -561,21 +520,14 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (sig) {
case SWITCH_SIG_KILL:
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
//switch_thread_cond_signal(tech_pvt->cond);
switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_NORMAL_CLEARING);
break;
case SWITCH_SIG_BREAK:
switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
@@ -601,9 +553,7 @@ static switch_status_t channel_on_transmit(switch_core_session_t *session)
static switch_status_t channel_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
{
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
@@ -611,20 +561,15 @@ static switch_status_t channel_waitfor_read(switch_core_session_t *session, int
static switch_status_t channel_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
{
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (tech_pvt->iax_session) {
iax_send_dtmf(tech_pvt->iax_session, dtmf->digit);
@@ -635,16 +580,11 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s
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;
private_t *tech_pvt = switch_core_session_get_private(session);
switch_time_t started = switch_timestamp_now();
unsigned int elapsed;
switch_byte_t *data;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
tech_pvt->read_frame.flags = SFF_NONE;
*frame = NULL;
@@ -655,7 +595,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
switch_yield(1000);
continue;
}
//switch_thread_cond_wait(tech_pvt->cond, tech_pvt->mutex);
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
switch_clear_flag(tech_pvt, TFLAG_BREAK);
goto cng;
@@ -685,12 +624,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
return SWITCH_STATUS_SUCCESS;
}
}
switch_yield(1000);
}
return SWITCH_STATUS_FALSE;
cng:
@@ -701,19 +637,11 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
tech_pvt->read_frame.flags = SFF_CNG;
*frame = &tech_pvt->read_frame;
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)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
//switch_frame_t *pframe;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
@@ -732,13 +660,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
private_t *tech_pvt;
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
@@ -750,13 +672,7 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
switch_channel_t *channel;
private_t *tech_pvt;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_t *) switch_core_session_get_private(session);
private_t *tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (msg->message_id) {
@@ -824,7 +740,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
if (iax_set_codec(tech_pvt, tech_pvt->iax_session, &req, &cap, &samprate, IAX_QUERY) != SWITCH_STATUS_SUCCESS) {
switch_core_session_destroy(new_session);
return SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL;
@@ -844,23 +759,16 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
}
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
{
switch_channel_t *channel;
struct private_object *tech_pvt;
char *body;
struct private_object *tech_pvt = switch_core_session_get_private(session);
char *body = switch_event_get_body(event);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!(body = switch_event_get_body(event))) {
if (!body) {
body = "";
}
@@ -893,7 +801,6 @@ switch_io_routines_t iax_io_routines = {
SWITCH_MODULE_LOAD_FUNCTION(mod_iax_load)
{
module_pool = pool;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -980,7 +887,6 @@ static switch_status_t tech_media(private_t * tech_pvt, struct iax_event *iaxeve
SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
{
//int refresh;
struct iax_event *iaxevent = NULL;
switch_event_t *s_event;
if (load_config() != SWITCH_STATUS_SUCCESS) {
@@ -1111,7 +1017,6 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
break;
}
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
iaxevent->ies.username,
globals.dialplan,
@@ -1128,7 +1033,6 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
switch_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,
@@ -1163,7 +1067,6 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
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_thread_cond_signal(tech_pvt->cond);
iaxevent->session = NULL;
}
break;
@@ -1177,7 +1080,6 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
int bytes, frames;
if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "audio with no codec yet!\n");
break;
}
@@ -1192,13 +1094,11 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
memcpy(tech_pvt->read_frame.data, iaxevent->data, iaxevent->datalen);
/* wake up the i/o thread */
switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
//switch_thread_cond_signal(tech_pvt->cond);
}
}
break;
case IAX_EVENT_TRANSFER:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call transfer occurred.\n");
//session[0] = iaxevent->session;
break;
case IAX_EVENT_DTMF:
if (channel) {
@@ -1206,7 +1106,6 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
if (globals.debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", dtmf.digit, switch_channel_get_name(channel));
}
switch_channel_queue_dtmf(channel, &dtmf);
}
@@ -1215,10 +1114,8 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n", iaxevent->etype);
break;
}
iax_event_free(iaxevent);
}
}
running = 0;
+13 -153
View File
@@ -165,25 +165,18 @@ static switch_status_t pa_cmd(const char *dest, switch_core_session_t *session,
*/
static switch_status_t channel_on_init(switch_core_session_t *session)
{
switch_channel_t *channel;
private_t *tech_pvt = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_time_t last;
int waitsec = globals.ring_interval * 1000000;
switch_file_handle_t fh = { 0 };
const char *val, *ring_file = NULL, *hold_file = NULL;
int16_t abuf[2048];
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
last = switch_timestamp_now() - waitsec;
if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
hold_file = val;
} else {
@@ -196,12 +189,9 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
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));
if (engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return SWITCH_STATUS_FALSE;
@@ -297,40 +287,17 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
switch_channel_set_state(channel, CS_RING);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_ring(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_execute(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
@@ -429,13 +396,7 @@ static void remove_pvt(private_t * tech_pvt)
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
remove_pvt(tech_pvt);
@@ -450,20 +411,15 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
switch_core_file_close(&tech_pvt->fh);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (sig) {
@@ -476,7 +432,6 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
}
@@ -488,47 +443,24 @@ static switch_status_t channel_on_transmit(switch_core_session_t *session)
static switch_status_t channel_on_loopback(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
{
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
{
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF ON CALL %s [%c]\n", tech_pvt->call_id, dtmf->digit);
@@ -538,15 +470,9 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s
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;
private_t *tech_pvt = switch_core_session_get_private(session);
int samples = 0;
switch_status_t status = SWITCH_STATUS_FALSE;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!globals.audio_stream) {
@@ -590,7 +516,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
return SWITCH_STATUS_SUCCESS;
hold:
{
switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
if (switch_core_timer_next(&globals.timer) != SWITCH_STATUS_SUCCESS) {
@@ -605,7 +530,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
goto cng;
}
tech_pvt->hold_frame.datalen = (uint32_t) (olen * sizeof(int16_t));
tech_pvt->hold_frame.samples = (uint32_t) olen;
*frame = &tech_pvt->hold_frame;
@@ -642,13 +566,8 @@ 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)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!globals.audio_stream) {
@@ -672,35 +591,18 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
}
return status;
}
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
private_t *tech_pvt;
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
switch_channel_t *channel;
private_t *tech_pvt;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_ANSWER:
channel_answer_channel(session);
@@ -743,7 +645,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
switch_caller_profile_t *outbound_profile,
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
{
if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, pool)) != 0) {
private_t *tech_pvt;
switch_channel_t *channel;
@@ -790,7 +691,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
}
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
@@ -817,14 +717,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)
"Input Device: %d, Output Device: %d, Ring Device: %d Sample Rate: %d MS: %d\n", globals.indev,
globals.outdev, globals.ringdev, globals.sample_rate, globals.codec_ms);
switch_core_hash_init(&globals.call_hash, module_pool);
switch_mutex_init(&globals.device_lock, SWITCH_MUTEX_NESTED, module_pool);
switch_mutex_init(&globals.pvt_lock, SWITCH_MUTEX_NESTED, module_pool);
switch_mutex_init(&globals.flag_mutex, SWITCH_MUTEX_NESTED, module_pool);
if (switch_event_reserve_subclass(MY_EVENT_RINGING) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
return SWITCH_STATUS_GENERR;
@@ -1043,8 +940,7 @@ static void PrintSupportedStandardSampleRates(const PaStreamParameters * inputPa
int i, printCount, cr = 7;
PaError err;
static double standardSampleRates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1
};
44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1};
printCount = cr;
for (i = 0; standardSampleRates[i] > 0; i++) {
@@ -1093,8 +989,6 @@ static int dump_info(void)
PaError err;
const char *line = "--------------------------------------------------------------------------------\n";
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
"PortAudio version number = %d\nPortAudio version text = '%s'\n", Pa_GetVersion(), Pa_GetVersionText());
if (globals.audio_stream) {
@@ -1194,8 +1088,6 @@ static int dump_info(void)
return err;
}
static switch_status_t engage_device(int sample_rate, int codec_ms)
{
PaStreamParameters inputParameters, outputParameters;
@@ -1236,13 +1128,9 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
return SWITCH_STATUS_FALSE;
}
globals.read_frame.rate = sample_rate;
globals.read_frame.codec = &globals.read_codec;
switch_mutex_lock(globals.device_lock);
/* LOCKED ************************************************************************************************** */
inputParameters.device = globals.indev;
@@ -1261,7 +1149,6 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
/* UNLOCKED ************************************************************************************************* */
switch_mutex_unlock(globals.device_lock);
if (err != paNoError) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
switch_core_codec_destroy(&globals.read_codec);
@@ -1271,14 +1158,9 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
}
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t engage_ring_device(int sample_rate, int channels)
{
PaStreamParameters outputParameters;
@@ -1301,7 +1183,6 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
/* UNLOCKED ************************************************************************************************* */
switch_mutex_unlock(globals.device_lock);
if (err != paNoError) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open ring device!\n");
return SWITCH_STATUS_FALSE;
@@ -1312,8 +1193,6 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
{
char *dtmf_str = argv[0];
@@ -1382,7 +1261,6 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t
switch_mutex_unlock(globals.pvt_lock);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t *stream)
@@ -1406,7 +1284,6 @@ static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t
switch_mutex_unlock(globals.pvt_lock);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t *stream)
@@ -1446,12 +1323,9 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t
}
done:
switch_mutex_unlock(globals.pvt_lock);
stream->write_function(stream, "Answered %d channels.\n", x);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *stream)
@@ -1676,19 +1550,9 @@ SWITCH_STANDARD_API(pa_cmd)
http = switch_event_get_header(stream->event, "http-host");
}
if (http) {
stream->write_function(stream, "Content-type: text/html\n\n");
#if 0
switch_event_header_t *hp;
stream->write_function(stream, "<pre>");
for (hp = stream->event->headers; hp; hp = hp->next) {
stream->write_function(stream, "[%s]=[%s]\n", hp->name, hp->value);
}
stream->write_function(stream, "</pre>");
#endif
wcmd = switch_str_nil(switch_event_get_header(stream->event, "wcmd"));
action = switch_event_get_header(stream->event, "action");
@@ -1815,13 +1679,10 @@ SWITCH_STANDARD_API(pa_cmd)
}
done:
if (http) {
stream->write_function(stream,
"<br><br><table align=center><tr><td><center><form method=post>\n"
"<input type=text name=wcmd size=40><br><br>\n"
"<input name=action type=submit value=\"call\"> "
"<input name=action type=submit value=\"hangup\"> "
"<input name=action type=submit value=\"list\"> "
@@ -1856,7 +1717,6 @@ SWITCH_STANDARD_API(pa_cmd)
}
switch_safe_free(mycmd);
return status;
}
+26 -119
View File
@@ -73,13 +73,8 @@ static switch_status_t sofia_kill_channel(switch_core_session_t *session, int si
*/
static switch_status_t sofia_on_init(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_object_t *tech_pvt;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
@@ -116,18 +111,12 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
static switch_status_t sofia_on_ring(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RING\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
@@ -135,18 +124,12 @@ static switch_status_t sofia_on_ring(switch_core_session_t *session)
static switch_status_t sofia_on_reset(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
@@ -154,35 +137,23 @@ static switch_status_t sofia_on_reset(switch_core_session_t *session)
static switch_status_t sofia_on_hibernate(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_on_execute(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
@@ -247,16 +218,10 @@ static int hangup_cause_to_sip(switch_call_cause_t cause)
switch_status_t sofia_on_hangup(switch_core_session_t *session)
{
switch_core_session_t *a_session;
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_call_cause_t cause;
int sip_cause;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (tech_pvt->profile->rtpip && tech_pvt->local_sdp_audio_port) {
switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
@@ -364,19 +329,12 @@ static switch_status_t sofia_on_transmit(switch_core_session_t *session)
static switch_status_t sofia_answer_channel(switch_core_session_t *session)
{
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status;
uint32_t session_timeout = 0;
const char *val;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
if (switch_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) {
return SWITCH_STATUS_SUCCESS;
}
@@ -445,14 +403,10 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
static switch_status_t sofia_read_video_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 = NULL;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
int payload = 0;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
@@ -467,10 +421,8 @@ static switch_status_t sofia_read_video_frame(switch_core_session_t *session, sw
}
}
tech_pvt->video_read_frame.datalen = 0;
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
switch_status_t status;
@@ -512,14 +464,10 @@ static switch_status_t sofia_read_video_frame(switch_core_session_t *session, sw
static switch_status_t sofia_write_video_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;
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
while (!(tech_pvt->video_read_codec.implementation && switch_rtp_ready(tech_pvt->video_rtp_session))) {
@@ -552,14 +500,10 @@ static switch_status_t sofia_write_video_frame(switch_core_session_t *session, s
static switch_status_t sofia_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 = NULL;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
int payload = 0;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!(tech_pvt->profile->pflags & PFLAG_RUNNING)) {
@@ -642,15 +586,11 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
static switch_status_t sofia_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;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
int bytes = 0, samples = 0, frames = 0;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) {
@@ -700,16 +640,10 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
static switch_status_t sofia_kill_channel(switch_core_session_t *session, int sig)
{
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = switch_core_session_get_private(session);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (sig) {
case SWITCH_SIG_BREAK:
if (switch_rtp_ready(tech_pvt->rtp_session)) {
@@ -737,29 +671,11 @@ static switch_status_t sofia_kill_channel(switch_core_session_t *session, int si
static switch_status_t sofia_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
{
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
{
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
}
@@ -792,14 +708,10 @@ static switch_status_t sofia_send_dtmf(switch_core_session_t *session, const swi
static switch_status_t sofia_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
switch_channel_t *channel;
private_object_t *tech_pvt;
switch_channel_t *channel = switch_core_session_get_channel(session);
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_status_t status;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {
@@ -1109,15 +1021,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
static switch_status_t sofia_receive_event(switch_core_session_t *session, switch_event_t *event)
{
switch_channel_t *channel;
struct private_object *tech_pvt;
struct private_object *tech_pvt = switch_core_session_get_private(session);
char *body;
nua_handle_t *msg_nh;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!(body = switch_event_get_body(event))) {
+7 -28
View File
@@ -119,12 +119,9 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
sip_t const *sip,
tagi_t tags[])
{
switch_channel_t *channel = NULL;
if (session) {
const char *tmp;
channel = switch_core_session_get_channel(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
if (sip->sip_user_agent && !switch_strlen_zero(sip->sip_user_agent->g_string)){
switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string);
}
@@ -1302,8 +1299,6 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{
if (sip && session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *uuid;
@@ -1437,8 +1432,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (session) {
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_assert(tech_pvt->nh != NULL);
@@ -1821,22 +1814,19 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
sip_from_t const *from;
sip_to_t const *to;
sip_refer_to_t const *refer_to;
private_object_t *tech_pvt = NULL;
private_object_t *tech_pvt = switch_core_session_get_private(session);
char *etmp = NULL, *exten = NULL;
switch_channel_t *channel_a = NULL, *channel_b = NULL;
switch_channel_t *channel_a = switch_core_session_get_channel(session);
switch_channel_t *channel_b = NULL;
su_home_t *home = NULL;
char *full_ref_by = NULL;
char *full_ref_to = NULL;
tech_pvt = switch_core_session_get_private(session);
channel_a = switch_core_session_get_channel(session);
if (!sip->sip_cseq || !(etmp = switch_mprintf("refer;id=%u", sip->sip_cseq->cs_seq))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
goto done;
}
if (switch_channel_test_flag(channel_a, CF_BYPASS_MEDIA)) {
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp), TAG_END());
@@ -2115,8 +2105,6 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
{
struct private_object *tech_pvt = NULL;
switch_channel_t *channel = NULL;
/* placeholder for string searching */
const char *signal_ptr;
const char *rec_header;
@@ -2125,14 +2113,10 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
if (session) {
/* Get the channel */
channel = switch_core_session_get_channel(session);
/* Barf if we didn't get it */
switch_assert(channel != NULL);
switch_channel_t *channel = switch_core_session_get_channel(session);
/* make sure we have our privates */
tech_pvt = switch_core_session_get_private(session);
struct private_object *tech_pvt = switch_core_session_get_private(session);
/* Barf if we didn't get it */
switch_assert(tech_pvt != NULL);
@@ -2219,18 +2203,13 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
}
}
}
return;
}
}
return;
fail:
nua_respond(nh, 488, "Unsupported Request", NUTAG_WITH_THIS(nua), TAG_END());
}
+6 -22
View File
@@ -385,10 +385,8 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
tech_pvt->te = profile->te;
}
tech_pvt->dtmf_type = profile->dtmf_type;
if (tech_pvt->bcng_pt) {
tech_pvt->cng_pt = tech_pvt->bcng_pt;
} else if (!tech_pvt->cng_pt) {
@@ -399,7 +397,6 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
tech_pvt->channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt);
switch_snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
switch_channel_set_name(tech_pvt->channel, name);
}
@@ -651,8 +648,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
char *alert_info = NULL;
const char *max_forwards = NULL;
const char *alertbuf;
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile;
const char *cid_name, *cid_num;
char *e_dest = NULL;
@@ -665,12 +662,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
const char *val;
const char *rep;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SDP);
@@ -897,14 +890,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
void sofia_glue_do_xfer_invite(switch_core_session_t *session)
{
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
@@ -1497,24 +1486,20 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
{
uint8_t match = 0;
switch_payload_t te = 0, cng_pt = 0;
private_object_t *tech_pvt;
private_object_t *tech_pvt = switch_core_session_get_private(session);
sdp_media_t *m;
sdp_attribute_t *attr;
int first = 0, last = 0;
int ptime = 0, dptime = 0;
int sendonly = 0;
int greedy = 0, x = 0, skip = 0, mine = 0;
switch_channel_t *channel = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *val;
const char *crypto = NULL;
int got_crypto = 0;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
greedy = !!(tech_pvt->profile->pflags & PFLAG_GREEDY);
if (!greedy) {
@@ -1962,7 +1947,6 @@ void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp)
if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(val))) {
other_channel = switch_core_session_get_channel(other_session);
switch_assert(other_channel != NULL);
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
+1 -2
View File
@@ -750,8 +750,7 @@ void sofia_reg_handle_sip_r_challenge(int status,
cancel:
if (session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_hangup(channel, SWITCH_CAUSE_MANDATORY_IE_MISSING);
switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_MANDATORY_IE_MISSING);
} else {
nua_cancel(nh, TAG_END());
}
+13 -125
View File
@@ -200,16 +200,12 @@ static int tech_activate(private_object * tech_pvt);
*/
static switch_status_t woomera_on_init(switch_core_session_t *session)
{
switch_channel_t *channel;
struct private_object *tech_pvt = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = switch_core_session_get_private(session);
int rate = 8000;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt->frame.data = tech_pvt->databuf;
if (switch_core_codec_init
@@ -244,53 +240,25 @@ static switch_status_t woomera_on_init(switch_core_session_t *session)
static switch_status_t woomera_on_ring(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
struct private_object *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA RING\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t woomera_on_execute(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
struct private_object *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA EXECUTE\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t woomera_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
struct private_object *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_core_codec_destroy(&tech_pvt->write_codec);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA HANGUP\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA HANGUP\n", switch_channel_get_name(switch_core_session_get_channel(session)));
tech_destroy(tech_pvt);
return SWITCH_STATUS_SUCCESS;
@@ -316,13 +284,7 @@ static void udp_socket_close(struct private_object *tech_pvt)
static switch_status_t woomera_kill_channel(switch_core_session_t *session, int sig)
{
switch_channel_t *channel = NULL;
struct private_object *tech_pvt = NULL;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!tech_pvt->udp_socket) {
@@ -332,7 +294,7 @@ static switch_status_t woomera_kill_channel(switch_core_session_t *session, int
switch (sig) {
case SWITCH_SIG_KILL:
udp_socket_close(tech_pvt);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(switch_core_session_get_channel(session)));
break;
case SWITCH_SIG_BREAK:
{
@@ -345,7 +307,6 @@ static switch_status_t woomera_kill_channel(switch_core_session_t *session, int
break;
}
return SWITCH_STATUS_SUCCESS;
}
@@ -384,15 +345,10 @@ static switch_status_t woomera_waitfor_write(switch_core_session_t *session, int
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;
struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_frame_t *pframe;
switch_size_t len;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
for(;;) {
@@ -406,15 +362,10 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
switch_yield(1000);
}
if (!tech_pvt->udp_socket) {
return SWITCH_STATUS_GENERR;
}
/*
if ((status = woomera_waitfor_read(session, -1)) != SWITCH_STATUS_SUCCESS) {
return status;
}1<
*/
pframe = &tech_pvt->frame;
*frame = pframe;
@@ -430,15 +381,9 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
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;
struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_size_t len;
//switch_frame_t *pframe;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (switch_test_flag(tech_pvt, TFLAG_ABORT) || !tech_pvt->udp_socket) {
@@ -449,7 +394,6 @@ static switch_status_t woomera_write_frame(switch_core_session_t *session, switc
return SWITCH_STATUS_SUCCESS;
}
//pframe = &tech_pvt->frame;
len = frame->datalen;
if (switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, frame->data, &len) == SWITCH_STATUS_SUCCESS) {
frame->datalen = (uint32_t) len;
@@ -953,24 +897,17 @@ static int tech_activate(private_object * tech_pvt)
static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
{
switch_core_session_t *session = obj;
switch_channel_t *channel = NULL;
struct private_object *tech_pvt = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = switch_core_session_get_private(session);
woomera_message wmsg;
int res = 0;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!tech_pvt->udp_socket) {
tech_create_read_socket(tech_pvt);
}
for (;;) {
if (globals.panic) {
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
@@ -1014,18 +951,6 @@ static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
memset(tech_pvt->dtmfbuf, 0, sizeof(tech_pvt->dtmfbuf));
switch_mutex_unlock(tech_pvt->iolock);
}
#if 1==0 /*convert to use switch_time_now */
if (tech_pvt->timeout) {
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));
if (elapsed > tech_pvt->timeout) {
/* call timed out! */
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
}
}
#endif
if (!tech_pvt->command_channel) {
break;
@@ -1038,17 +963,6 @@ static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
continue;
} else if (!strcasecmp(wmsg.command, "DTMF")) {
/*
struct ast_frame dtmf_frame = {AST_FRAME_DTMF};
int x = 0;
for (x = 0; x < strlen(wmsg.command_args); x++) {
dtmf_frame.subclass = wmsg.command_args[x];
ast_queue_frame(tech_pvt->owner, ast_frdup(&dtmf_frame));
if (globals.debug > 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "SEND DTMF [%c] to %s\n", dtmf_frame.subclass, tech_pvt->owner->name);
}
}
*/
} else if (!strcasecmp(wmsg.command, "PROCEED")) {
/* This packet has lots of info so well keep it */
tech_pvt->call_info = wmsg;
@@ -1154,12 +1068,8 @@ static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
return NULL;
}
static void *woomera_thread_run(void *obj)
{
int res = 0;
woomera_message wmsg;
woomera_profile *profile;
@@ -1209,28 +1119,8 @@ static void *woomera_thread_run(void *obj)
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);
globals.panic = 1;
continue;
/* Can't get to the following code --Commented out for now. */
/* if (profile->woomera_socket)
if (switch_test_flag(profile, PFLAG_INBOUND)) {
woomera_printf(profile, profile->woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
if (woomera_message_parse(profile->woomera_socket,
&wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "{%s} HELP! Woomera is broken!\n",
profile->name);
globals.panic = 1;
woomera_socket_close(&profile->woomera_socket);
}
}
if (profile->woomera_socket) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Woomera Thread Up {%s} %s/%d\n", profile->name,
profile->woomera_host, profile->woomera_port);
}
}*/
//continue;
}
if (!strcasecmp(wmsg.command, "INCOMING")) {
@@ -1277,7 +1167,6 @@ static void *woomera_thread_run(void *obj)
switch_yield(100);
}
if (profile->woomera_socket) {
woomera_printf(profile, profile->woomera_socket, "BYE%s", WOOMERA_RECORD_SEPERATOR);
woomera_socket_close(&profile->woomera_socket);
@@ -1290,7 +1179,6 @@ static void *woomera_thread_run(void *obj)
SWITCH_MODULE_RUNTIME_FUNCTION(mod_woomera_runtime)
{
woomera_thread_run(&default_profile);
return SWITCH_STATUS_TERM;
@@ -653,7 +653,6 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
if (listener->session) {
switch_channel_t *channel = switch_core_session_get_channel(listener->session);
switch_assert(channel != NULL);
if (!strncasecmp(cmd, "connect", 7)) {
switch_snprintf(reply, reply_len, "+OK");
@@ -763,8 +762,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
}
if ((session = switch_core_session_locate(uuid))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
if (!switch_channel_test_flag(channel, CF_CONTROLLED)) {
if (!switch_channel_test_flag(switch_core_session_get_channel(session), CF_CONTROLLED)) {
switch_core_session_rwunlock(session);
session = NULL;
}
@@ -1317,14 +1317,9 @@ static switch_status_t js_collect_input_callback(switch_core_session_t *session,
static JSBool session_flush_digits(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
switch_channel_flush_dtmf(channel);
switch_channel_flush_dtmf(switch_core_session_get_channel(jss->session));
*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
return JS_TRUE;
@@ -1334,16 +1329,12 @@ static JSBool session_flush_events(JSContext * cx, JSObject * obj, uintN argc, j
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_event_t *event;
switch_channel_t *channel;
if (!jss || !jss->session) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
return JS_TRUE;
}
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
while (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
switch_event_destroy(&event);
}
@@ -1368,10 +1359,7 @@ static JSBool session_recordfile(JSContext * cx, JSObject * obj, uintN argc, jsv
switch_input_args_t args = { 0 };
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1439,10 +1427,7 @@ static JSBool session_collect_input(JSContext * cx, JSObject * obj, uintN argc,
switch_input_args_t args = { 0 };
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1498,10 +1483,7 @@ static JSBool session_sayphrase(JSContext * cx, JSObject * obj, uintN argc, jsva
switch_input_args_t args = { 0 };
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1575,16 +1557,11 @@ static void check_hangup_hook(struct js_session *jss)
static switch_status_t hanguphook(switch_core_session_t *session)
{
switch_channel_t *channel;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct js_session *jss = NULL;
switch_channel_state_t state;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
state = switch_channel_get_state(channel);
if ((jss = switch_channel_get_private(channel, "jss"))) {
switch_channel_state_t state = switch_channel_get_state(channel);
if (jss->hook_state != state) {
jss->hook_state = state;
check_hangup_hook(jss);
@@ -1604,7 +1581,6 @@ static JSBool session_hanguphook(JSContext * cx, JSObject * obj, uintN argc, jsv
if (argc > 0) {
if ((function = JS_ValueToFunction(cx, argv[0]))) {
switch_channel_t *channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
jss->on_hangup = function;
jss->hook_state = switch_channel_get_state(channel);
switch_channel_set_private(channel, "jss", jss);
@@ -1634,10 +1610,7 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv
char posbuf[35] = "";
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1700,9 +1673,7 @@ static JSBool session_set_variable(JSContext * cx, JSObject * obj, uintN argc, j
switch_channel_t *channel;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
if (argc > 1) {
char *var, *val;
@@ -1729,7 +1700,6 @@ static JSBool session_get_variable(JSContext * cx, JSObject * obj, uintN argc, j
}
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
if (argc > 0) {
const char *var, *val;
@@ -1813,8 +1783,6 @@ static JSBool session_speak(JSContext * cx, JSObject * obj, uintN argc, jsval *
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK();
if (argc < 3) {
@@ -1892,10 +1860,7 @@ static JSBool session_get_digits(JSContext * cx, JSObject * obj, uintN argc, jsv
switch_channel_t *channel;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1958,10 +1923,7 @@ static JSBool session_answer(JSContext * cx, JSObject * obj, uintN argc, jsval *
switch_channel_t *channel;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK_ANSWER();
switch_channel_answer(channel);
@@ -1974,10 +1936,7 @@ static JSBool session_pre_answer(JSContext * cx, JSObject * obj, uintN argc, jsv
switch_channel_t *channel;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK_ANSWER();
switch_channel_pre_answer(channel);
@@ -2009,14 +1968,10 @@ static JSBool session_cdr(JSContext * cx, JSObject * obj, uintN argc, jsval * ar
static JSBool session_ready(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
*rval = BOOLEAN_TO_JSVAL(switch_channel_ready(channel) ? JS_TRUE : JS_FALSE);
*rval = BOOLEAN_TO_JSVAL(switch_channel_ready(switch_core_session_get_channel(jss->session)) ? JS_TRUE : JS_FALSE);
return JS_TRUE;
}
@@ -2033,7 +1988,6 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
started = switch_timestamp_now();
@@ -2072,9 +2026,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
jsrefcount saveDepth;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
started = switch_timestamp_now();
@@ -2111,10 +2063,7 @@ static JSBool session_execute(JSContext * cx, JSObject * obj, uintN argc, jsval
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
/* you can execute some apps before you answer */
/* CHANNEL_SANITY_CHECK(); */
/* you can execute some apps before you answer CHANNEL_SANITY_CHECK(); */
if (argc > 0) {
const switch_application_interface_t *application_interface;
@@ -2203,10 +2152,7 @@ static JSBool session_hangup(JSContext * cx, JSObject * obj, uintN argc, jsval *
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
CHANNEL_SANITY_CHECK();
if (argc > 1) {
@@ -2542,7 +2488,6 @@ static JSBool session_getProperty(JSContext * cx, JSObject * obj, jsval id, jsva
if (jss && jss->session) {
channel = switch_core_session_get_channel(jss->session);
switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
}
-11
View File
@@ -169,17 +169,12 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
static switch_status_t de_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)
{
switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
@@ -420,16 +415,10 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay,
static switch_status_t de_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;
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
-11
View File
@@ -169,17 +169,12 @@ 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)
{
switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
@@ -420,16 +415,10 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
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;
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
-11
View File
@@ -169,17 +169,12 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
static switch_status_t es_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)
{
switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
@@ -420,16 +415,10 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay,
static switch_status_t es_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;
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
-11
View File
@@ -169,17 +169,12 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
static switch_status_t fr_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)
{
switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
@@ -420,16 +415,10 @@ static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay,
static switch_status_t fr_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;
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
-11
View File
@@ -169,17 +169,12 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
static switch_status_t it_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)
{
switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
@@ -420,16 +415,10 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay,
static switch_status_t it_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;
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
-11
View File
@@ -169,17 +169,12 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
static switch_status_t nl_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)
{
switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
@@ -420,16 +415,10 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay,
static switch_status_t nl_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;
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;