bunch of tweaks to make ivr more fun

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2350 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-08-21 19:14:51 +00:00
parent 9955db7959
commit 4f17ab7714
10 changed files with 104 additions and 83 deletions

View File

@ -107,6 +107,7 @@ struct ldl_handle {
apr_hash_t *sessions; apr_hash_t *sessions;
apr_hash_t *retry_hash; apr_hash_t *retry_hash;
apr_hash_t *probe_hash; apr_hash_t *probe_hash;
apr_hash_t *sub_hash;
apr_thread_mutex_t *lock; apr_thread_mutex_t *lock;
apr_thread_mutex_t *flag_mutex; apr_thread_mutex_t *flag_mutex;
ldl_loop_callback_t loop_callback; ldl_loop_callback_t loop_callback;
@ -438,6 +439,7 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
return LDL_STATUS_SUCCESS; return LDL_STATUS_SUCCESS;
} }
const char *marker = "TRUE";
static int on_presence(void *user_data, ikspak *pak) static int on_presence(void *user_data, ikspak *pak)
{ {
@ -447,10 +449,12 @@ static int on_presence(void *user_data, ikspak *pak)
char *resource; char *resource;
struct ldl_buffer *buffer; struct ldl_buffer *buffer;
size_t x; size_t x;
//iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling...."); if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) {
//apr_queue_push(handle->queue, msg); apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker);
iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling....");
apr_queue_push(handle->queue, msg);
}
apr_cpystrn(id, from, sizeof(id)); apr_cpystrn(id, from, sizeof(id));
if ((resource = strchr(id, '/'))) { if ((resource = strchr(id, '/'))) {
@ -517,42 +521,21 @@ static int on_commands(void *user_data, ikspak *pak)
if (!strcasecmp(iks_name(tag), "bind")) { if (!strcasecmp(iks_name(tag), "bind")) {
char *jid = iks_find_cdata(tag, "jid"); char *jid = iks_find_cdata(tag, "jid");
char *resource = strchr(jid, '/'); char *resource = strchr(jid, '/');
iks *iq, *usersetting, *x; iks *iq, *x;
handle->acc->resource = apr_pstrdup(handle->pool, resource); handle->acc->resource = apr_pstrdup(handle->pool, resource);
handle->login = apr_pstrdup(handle->pool, jid); handle->login = apr_pstrdup(handle->pool, jid);
if ((iq = iks_new("iq"))) { if ((iq = iks_new("iq"))) {
char *njid = strdup(handle->login); iks_insert_attrib(iq, "type", "get");
if ((resource = strchr(njid, '/'))) { iks_insert_attrib(iq, "id", "roster");
*resource++ = '\0'; x = iks_insert(iq, "query");
} iks_insert_attrib(x, "xmlns", "jabber:iq:roster");
iks_insert_attrib(iq, "type", "set"); iks_insert_attrib(x, "xmlns:gr", "google:roster");
iks_insert_attrib(iq, "to", njid); iks_insert_attrib(x, "gr:ext", "2");
iks_insert_attrib(iq, "id", "params"); iks_insert_attrib(x, "gr:include", "all");
usersetting = iks_insert(iq, "usersetting");
iks_insert_attrib(usersetting, "xmlns", "google:setting");
x = iks_insert(usersetting, "autoacceptrequests");
iks_insert_attrib(x, "value", "true");
x = iks_insert(usersetting, "mailnotifications");
iks_insert_attrib(x, "value", "false");
free(njid);
iks_send(handle->parser, iq); iks_send(handle->parser, iq);
iks_delete(iq); iks_delete(iq);
if ((iq = iks_new("iq"))) { break;
iks_insert_attrib(iq, "type", "get");
iks_insert_attrib(iq, "id", "roster");
x = iks_insert(iq, "query");
iks_insert_attrib(x, "xmlns", "jabber:iq:roster");
iks_insert_attrib(x, "xmlns:gr", "google:roster");
iks_insert_attrib(x, "gr:ext", "2");
iks_insert_attrib(x, "gr:include", "all");
iks_send(handle->parser, iq);
iks_delete(iq);
}
} }
break;
} }
tag = iks_next_tag(tag); tag = iks_next_tag(tag);
} }
@ -1488,6 +1471,7 @@ ldl_status ldl_handle_init(ldl_handle_t **handle,
new_handle->sessions = apr_hash_make(new_handle->pool); new_handle->sessions = apr_hash_make(new_handle->pool);
new_handle->retry_hash = apr_hash_make(new_handle->pool); new_handle->retry_hash = apr_hash_make(new_handle->pool);
new_handle->probe_hash = apr_hash_make(new_handle->pool); new_handle->probe_hash = apr_hash_make(new_handle->pool);
new_handle->sub_hash = apr_hash_make(new_handle->pool);
apr_thread_mutex_create(&new_handle->lock, APR_THREAD_MUTEX_NESTED, new_handle->pool); apr_thread_mutex_create(&new_handle->lock, APR_THREAD_MUTEX_NESTED, new_handle->pool);
apr_thread_mutex_create(&new_handle->flag_mutex, APR_THREAD_MUTEX_NESTED, new_handle->pool); apr_thread_mutex_create(&new_handle->flag_mutex, APR_THREAD_MUTEX_NESTED, new_handle->pool);

View File

@ -173,6 +173,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
\param table optional state handler table to install on the channel \param table optional state handler table to install on the channel
\param cid_name_override override the caller id name \param cid_name_override override the caller id name
\param cid_num_override override the caller id number \param cid_num_override override the caller id number
\param caller_profile_override override the entire calling caller profile
\return SWITCH_STATUS_SUCCESS if bleg is a running session. \return SWITCH_STATUS_SUCCESS if bleg is a running session.
*/ */
SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session, SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
@ -181,7 +182,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
uint32_t timelimit_sec, uint32_t timelimit_sec,
const switch_state_handler_table_t *table, const switch_state_handler_table_t *table,
char *cid_name_override, char *cid_name_override,
char *cid_num_override); char *cid_num_override,
switch_caller_profile_t *caller_profile_override);
/*! /*!
\brief Bridge Audio from one session to another \brief Bridge Audio from one session to another

View File

@ -50,7 +50,7 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
timelimit = atoi(var); timelimit = atoi(var);
} }
if (switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) { if (switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL); switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
return; return;

View File

@ -260,7 +260,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (switch_ivr_originate(NULL, &caller_session, aleg, timeout, NULL, cid_name, cid_num) != SWITCH_STATUS_SUCCESS) { if (switch_ivr_originate(NULL, &caller_session, aleg, timeout, NULL, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s]\n", aleg); stream->write_function(stream, "Cannot Create Outgoing Channel! [%s]\n", aleg);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }

View File

@ -1989,7 +1989,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
switch_channel_t *caller_channel = NULL; switch_channel_t *caller_channel = NULL;
if (switch_ivr_originate(session, &peer_session, bridgeto, timeout, &audio_bridge_peer_state_handlers, cid_name, cid_num) != SWITCH_STATUS_SUCCESS) { if (switch_ivr_originate(session, &peer_session, bridgeto, timeout, &audio_bridge_peer_state_handlers, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
if (session) { if (session) {
caller_channel = switch_core_session_get_channel(session); caller_channel = switch_core_session_get_channel(session);

View File

@ -1,7 +1,7 @@
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
depends: depends:
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install speex-1.1.12.tar.gz --prefix=$(PREFIX) MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install speex-1.1.12.tar.gz --prefix=$(PREFIX) --disable-shared --with-pic
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o $(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o

View File

@ -1500,22 +1500,34 @@ static void destroy_call_by_event(eXosip_event_t *event)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy %s\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy %s\n", switch_channel_get_name(channel));
exosip_kill_channel(tech_pvt->session, SWITCH_SIG_KILL); exosip_kill_channel(tech_pvt->session, SWITCH_SIG_KILL);
switch (event->type) { switch (event->type) {
case EXOSIP_CALL_RELEASED: case EXOSIP_CALL_RELEASED:
switch_channel_set_variable(channel, "exosip_disposition", "RELEASED");
cause = SWITCH_CAUSE_NORMAL_CLEARING;
break;
case EXOSIP_CALL_CLOSED: case EXOSIP_CALL_CLOSED:
switch_channel_set_variable(channel, "exosip_disposition", "CLOSED");
cause = SWITCH_CAUSE_NORMAL_CLEARING; cause = SWITCH_CAUSE_NORMAL_CLEARING;
break; break;
case EXOSIP_CALL_NOANSWER: case EXOSIP_CALL_NOANSWER:
switch_channel_set_variable(channel, "exosip_disposition", "NO ANSWER");
cause = SWITCH_CAUSE_NO_ANSWER; cause = SWITCH_CAUSE_NO_ANSWER;
break; break;
case EXOSIP_CALL_REQUESTFAILURE: case EXOSIP_CALL_REQUESTFAILURE:
switch_channel_set_variable(channel, "exosip_disposition", "REQUEST FAILURE");
cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL; cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL;
break; break;
case EXOSIP_CALL_SERVERFAILURE: case EXOSIP_CALL_SERVERFAILURE:
switch_channel_set_variable(channel, "exosip_disposition", "SERVER FAILURE");
cause = SWITCH_CAUSE_CALL_REJECTED;
break;
case EXOSIP_CALL_GLOBALFAILURE: case EXOSIP_CALL_GLOBALFAILURE:
switch_channel_set_variable(channel, "exosip_disposition", "GLOBAL FAILURE");
cause = SWITCH_CAUSE_CALL_REJECTED; cause = SWITCH_CAUSE_CALL_REJECTED;
break; break;
default: default:
switch_channel_set_variable(channel, "exosip_disposition", "UNKNOWN");
cause = SWITCH_CAUSE_SWITCH_CONGESTION; cause = SWITCH_CAUSE_SWITCH_CONGESTION;
break; break;
} }

View File

@ -1337,12 +1337,11 @@ static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map
static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{ {
switch_memory_pool_t *pool = NULL; switch_memory_pool_t *pool = NULL;
if (argc > 2) { if (argc > 1) {
struct js_session *jss = NULL; struct js_session *jss = NULL;
JSObject *session_obj; JSObject *session_obj;
switch_core_session_t *session = NULL, *peer_session = NULL; switch_core_session_t *session = NULL, *peer_session = NULL;
switch_caller_profile_t *caller_profile = NULL; switch_caller_profile_t *caller_profile = NULL;
char *channel_type = NULL;
char *dest = NULL; char *dest = NULL;
char *dialplan = NULL; char *dialplan = NULL;
char *cid_name = ""; char *cid_name = "";
@ -1353,6 +1352,7 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
char *rdnis = ""; char *rdnis = "";
char *context = ""; char *context = "";
char *username = NULL; char *username = NULL;
char *to = NULL;
*rval = BOOLEAN_TO_JSVAL( JS_FALSE ); *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
if (JS_ValueToObject(cx, argv[0], &session_obj)) { if (JS_ValueToObject(cx, argv[0], &session_obj)) {
@ -1362,35 +1362,37 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
} }
} }
channel_type = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); dest = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
dest = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
if (argc > 2) {
dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
}
if (argc > 3) { if (argc > 3) {
dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[3])); context = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
} }
if (argc > 4) { if (argc > 4) {
context = JS_GetStringBytes(JS_ValueToString(cx, argv[4])); cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
} }
if (argc > 5) { if (argc > 5) {
cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[5])); cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
} }
if (argc > 6) { if (argc > 6) {
cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[6])); network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
} }
if (argc > 7) { if (argc > 7) {
network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[7])); ani = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
} }
if (argc > 8) { if (argc > 8) {
ani = JS_GetStringBytes(JS_ValueToString(cx, argv[8])); ani2 = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
} }
if (argc > 9) { if (argc > 9) {
ani2 = JS_GetStringBytes(JS_ValueToString(cx, argv[9])); rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
} }
if (argc > 10) { if (argc > 10) {
rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[10])); username = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
} }
if (argc > 11) { if (argc > 11) {
username = JS_GetStringBytes(JS_ValueToString(cx, argv[11])); to = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
} }
@ -1399,20 +1401,34 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
return JS_FALSE; return JS_FALSE;
} }
caller_profile = switch_caller_profile_new(pool, username, dialplan, cid_name, cid_num, network_addr, ani, ani2, rdnis, (char *)modname, context, dest); caller_profile = switch_caller_profile_new(pool,
if (switch_core_session_outgoing_channel(session, channel_type, caller_profile, &peer_session, pool) == SWITCH_STATUS_SUCCESS) { username,
jss = switch_core_session_alloc(peer_session, sizeof(*jss)); dialplan,
jss->session = peer_session; cid_name,
jss->flags = 0; cid_num,
jss->cx = cx; network_addr,
jss->obj = obj; ani,
JS_SetPrivate(cx, obj, jss); ani2,
switch_core_session_thread_launch(peer_session); rdnis,
switch_set_flag(jss, S_HUP); (char *)modname,
context,
dest);
if (switch_ivr_originate(NULL, &peer_session, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
return JS_TRUE; return JS_TRUE;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Channel\n");
} }
switch_core_session_rwunlock(peer_session);
jss = switch_core_session_alloc(peer_session, sizeof(*jss));
jss->session = peer_session;
jss->flags = 0;
jss->cx = cx;
jss->obj = obj;
JS_SetPrivate(cx, obj, jss);
switch_set_flag(jss, S_HUP);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing Args\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing Args\n");
} }
@ -1494,6 +1510,9 @@ static void fileio_destroy(JSContext *cx, JSObject *obj)
struct fileio_obj *fio = JS_GetPrivate(cx, obj); struct fileio_obj *fio = JS_GetPrivate(cx, obj);
if (fio) { if (fio) {
if (fio->fd) {
switch_file_close(fio->fd);
}
switch_memory_pool_t *pool = fio->pool; switch_memory_pool_t *pool = fio->pool;
switch_core_destroy_memory_pool(&pool); switch_core_destroy_memory_pool(&pool);
pool = NULL; pool = NULL;
@ -2214,7 +2233,6 @@ static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
{ {
struct js_session *jss_a = NULL, *jss_b = NULL; struct js_session *jss_a = NULL, *jss_b = NULL;
JSObject *session_obj_a = NULL, *session_obj_b = NULL; JSObject *session_obj_a = NULL, *session_obj_b = NULL;
int32 timelimit = 60;
if (argc > 1) { if (argc > 1) {
if (JS_ValueToObject(cx, argv[0], &session_obj_a)) { if (JS_ValueToObject(cx, argv[0], &session_obj_a)) {
@ -2231,12 +2249,6 @@ static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
} }
} }
if (argc > 3) {
if (!JS_ValueToInt32(cx, argv[3], &timelimit)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Convert to INT\n");
return JS_FALSE;
}
}
if (!(jss_a && jss_b)) { if (!(jss_a && jss_b)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n");
return JS_FALSE; return JS_FALSE;

View File

@ -247,11 +247,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio
{ {
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
if (!switch_channel_test_flag(session->channel, CF_LOCK_THREAD)) {
if ((status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock)) == SWITCH_STATUS_SUCCESS) { status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
switch_channel_set_flag(session->channel, CF_LOCK_THREAD);
}
}
return status; return status;
} }
@ -263,8 +260,9 @@ SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *sessi
SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session) SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session)
{ {
switch_channel_clear_flag(session->channel, CF_LOCK_THREAD);
switch_thread_rwlock_unlock(session->rwlock); switch_thread_rwlock_unlock(session->rwlock);
} }
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_str) SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_str)

View File

@ -1280,7 +1280,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
uint32_t timelimit_sec, uint32_t timelimit_sec,
const switch_state_handler_table_t *table, const switch_state_handler_table_t *table,
char *cid_name_override, char *cid_name_override,
char *cid_num_override) char *cid_num_override,
switch_caller_profile_t *caller_profile_override
)
{ {
char *peer_names[MAX_PEERS]; char *peer_names[MAX_PEERS];
@ -1361,8 +1363,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
goto done; goto done;
} }
caller_caller_profile = switch_channel_get_caller_profile(caller_channel); caller_caller_profile = caller_profile_override ? caller_profile_override : switch_channel_get_caller_profile(caller_channel);
if (!cid_name_override) { if (!cid_name_override) {
cid_name_override = caller_caller_profile->caller_id_name; cid_name_override = caller_caller_profile->caller_id_name;
} }
@ -1515,14 +1517,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
} }
switch_core_session_reset(session); if (session) {
switch_core_session_reset(session);
}
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (!peer_channels[i]) { if (!peer_channels[i]) {
continue; continue;
} }
if (i != idx) { if (i != idx) {
switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE); if (caller_channel) {
switch_channel_set_variable(caller_channel, "originate_disposition", "lost race");
switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
}
} }
} }
@ -1542,9 +1549,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) { if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
switch_core_session_read_lock(peer_session); switch_core_session_read_lock(peer_session);
*bleg = peer_session; *bleg = peer_session;
if (caller_channel) {
switch_channel_set_variable(caller_channel, "originate_disposition", "call accepted");
}
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
} else { } else {
switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER); if (caller_channel) {
switch_channel_set_variable(caller_channel, "originate_disposition", "no answer");
switch_channel_hangup(caller_channel, SWITCH_CAUSE_NO_ANSWER);
}
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;
} }