FS-11346: [core] add api to pass pre-parsed values instead of dial strings to switch_ivr_originate

SWITCH_DECLARE(switch_status_t) switch_dial_handle_create(switch_dial_handle_t **handle);
SWITCH_DECLARE(void) switch_dial_handle_destroy(switch_dial_handle_t **handle);
SWITCH_DECLARE(void) switch_dial_handle_add_leg_list(switch_dial_handle_t *handle, switch_dial_leg_list_t **leg_listP);
SWITCH_DECLARE(void) switch_dial_leg_list_add_leg(switch_dial_leg_list_t *parent, const char *dial_string, switch_dial_leg_t **legP);
SWITCH_DECLARE(void) switch_dial_handle_add_global_var(switch_dial_handle_t *handle, const char *var, const char *val);
SWITCH_DECLARE(void) switch_dial_handle_add_global_var_printf(switch_dial_handle_t *handle, const char *var, const char *fmt, ...);
SWITCH_DECLARE(switch_status_t) switch_dial_handle_add_leg_var(switch_dial_leg_t *leg, const char *var, const char *val);
SWITCH_DECLARE(switch_status_t) switch_dial_handle_add_leg_var_printf(switch_dial_leg_t *leg, const char *var, const char *fmt, ...);
SWITCH_DECLARE(int) switch_dial_handle_get_peers(switch_dial_handle_t *handle, int idx, char **array, int max);
SWITCH_DECLARE(int) switch_dial_handle_get_vars(switch_dial_handle_t *handle, int idx, switch_event_t **array, int max);
SWITCH_DECLARE(switch_event_t *) switch_dial_handle_get_global_vars(switch_dial_handle_t *handle);
SWITCH_DECLARE(switch_event_t *) switch_dial_leg_get_vars(switch_dial_leg_t *leg);
SWITCH_DECLARE(int) switch_dial_handle_get_total(switch_dial_handle_t *handle);
SWITCH_DECLARE(void) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh);

add switch_dial_handle_t *dh to end of args for switch_ivr_originate
This commit is contained in:
Anthony Minessale authored and Mike Jerris committed 2018-08-22 18:20:13 +00:00
1 parent b03cde3c57
commit d3e320ef56
16 files changed
+540 -144

No files matched your search

@@ -1707,7 +1707,7 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa
dialstr = switch_channel_expand_variables(member_channel, h->originate_string);
switch_channel_set_app_flag_key(CC_APP_KEY, member_channel, CC_APP_AGENT_CONNECTING);
status = switch_ivr_originate(NULL, &agent_session, &cause, dialstr, 60, NULL, cid_name ? cid_name : h->member_cid_name, cid_number ? cid_number : h->member_cid_number, NULL, ovars, SOF_NONE, NULL);
status = switch_ivr_originate(NULL, &agent_session, &cause, dialstr, 60, NULL, cid_name ? cid_name : h->member_cid_name, cid_number ? cid_number : h->member_cid_number, NULL, ovars, SOF_NONE, NULL, NULL);
/* Search for loopback agent */
if (status == SWITCH_STATUS_SUCCESS) {
@@ -5042,7 +5042,7 @@ SWITCH_STANDARD_API(originate_function)
timeout = atoi(argv[6]);
}
if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS
if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL, NULL) != SWITCH_STATUS_SUCCESS
|| !caller_session) {
stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause));
goto done;
@@ -1520,7 +1520,7 @@ switch_status_t conference_outcall(conference_obj_t *conference,
if (conference == NULL) {
char *dialstr = switch_mprintf("{ignore_early_media=true}%s", bridgeto);
status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, var_event, SOF_NO_LIMITS, NULL);
status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, var_event, SOF_NO_LIMITS, NULL, NULL);
switch_safe_free(dialstr);
if (status != SWITCH_STATUS_SUCCESS) {
@@ -1562,7 +1562,7 @@ switch_status_t conference_outcall(conference_obj_t *conference,
}
status = switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, var_event, SOF_NO_LIMITS, cancel_cause);
status = switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, var_event, SOF_NO_LIMITS, cancel_cause, NULL);
switch_mutex_lock(conference->mutex);
conference->originating--;
switch_mutex_unlock(conference->mutex);
@@ -2565,7 +2565,7 @@ void *SWITCH_THREAD_FUNC att_thread_run(switch_thread_t *thread, void *obj)
switch_core_session_rwunlock(b_session);
}
if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)
if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL)
!= SWITCH_STATUS_SUCCESS || !peer_session) {
switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);
goto end;
@@ -3480,7 +3480,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
status = switch_ivr_originate(NULL, &peer_session,
&cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE,
switch_channel_get_cause_ptr(caller_channel));
switch_channel_get_cause_ptr(caller_channel), NULL);
} while (camping && switch_channel_ready(caller_channel));
@@ -3509,7 +3509,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
} else {
if ((status =
switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)) != SWITCH_STATUS_SUCCESS) {
switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL)) != SWITCH_STATUS_SUCCESS) {
fail = 1;
}
}
@@ -4166,7 +4166,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session
if (switch_ivr_originate(session, new_session, &cause, dest, timelimit, NULL,
cid_name_override, cid_num_override, NULL, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) {
cid_name_override, cid_num_override, NULL, var_event, myflags, cancel_cause, NULL) == SWITCH_STATUS_SUCCESS) {
const char *context;
switch_caller_profile_t *cp;
@@ -4364,7 +4364,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
} else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL,
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
cancel_cause) == SWITCH_STATUS_SUCCESS) {
cancel_cause, NULL) == SWITCH_STATUS_SUCCESS) {
const char *context;
switch_caller_profile_t *cp;
@@ -5627,7 +5627,7 @@ void *SWITCH_THREAD_FUNC page_thread(switch_thread_t *thread, void *obj)
switch_memory_pool_t *pool = pd->pool;
if (switch_ivr_originate(NULL, &session, &cause, pd->dial_str, SWITCH_DEFAULT_TIMEOUT, NULL, NULL, NULL, NULL, pd->var_event, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS) {
if (switch_ivr_originate(NULL, &session, &cause, pd->dial_str, SWITCH_DEFAULT_TIMEOUT, NULL, NULL, NULL, NULL, pd->var_event, SOF_NONE, NULL, NULL) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_set_variable(channel, "page_file", pd->path);
+3 -3
View File
@@ -1643,7 +1643,7 @@ static void *SWITCH_THREAD_FUNC outbound_ringall_thread_run(switch_thread_t *thr
if (globals.debug) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s dialing: %s\n", node->name, originate_string);
status = switch_ivr_originate(NULL, &session, &cause, originate_string, timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, &cancel_cause);
status = switch_ivr_originate(NULL, &session, &cause, originate_string, timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, &cancel_cause, NULL);
del_caller_outbound_call(id);
@@ -1847,7 +1847,7 @@ static void *SWITCH_THREAD_FUNC outbound_enterprise_thread_run(switch_thread_t *
sql = switch_mprintf("update fifo_outbound set ring_count=ring_count+1 where uuid='%q'", h->uuid);
fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE);
status = switch_ivr_originate(NULL, &session, &cause, originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL);
status = switch_ivr_originate(NULL, &session, &cause, originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL, NULL);
if (status != SWITCH_STATUS_SUCCESS) {
sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1, "
@@ -3185,7 +3185,7 @@ SWITCH_STANDARD_APP(fifo_function)
}
}
if (switch_ivr_originate(session, &other_session, &cause, url, 120, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) {
if (switch_ivr_originate(session, &other_session, &cause, url, 120, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
other_session = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Originate to [%s] failed, cause: %s\n", url,
switch_channel_cause2str(cause));
+1 -1
View File
@@ -1511,7 +1511,7 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session,
}
}
if (switch_ivr_originate(session, new_session, &cause, cur_route->dialstring, timelimit, NULL,
cid_name_override, cid_num_override, NULL, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) {
cid_name_override, cid_num_override, NULL, var_event, myflags, cancel_cause, NULL) == SWITCH_STATUS_SUCCESS) {
const char *context;
switch_caller_profile_t *cp;
+90 -82
View File
@@ -117,100 +117,108 @@ static switch_status_t do_config(switch_bool_t reload)
//#define _switch_stun_packet_next_attribute(attribute, end) (attribute && (attribute = (switch_stun_packet_attribute_t *) (attribute->value + _switch_stun_attribute_padded_length(attribute))) && ((void *)attribute < end) && ((void *)(attribute + _switch_stun_attribute_padded_length(attribute)) < end))
#define MAX_PEERS 128
SWITCH_STANDARD_API(skel_function)
{
switch_event_t *event;
unsigned char frame_buffer[8192] = {0};
uint8_t buf[256] = { 0 };
switch_stun_packet_t *packet;
char user_name[] = "0000000000000000:1111111111111111";
//char user_name[] = "0000000000000000";
void *end_buf;
switch_stun_packet_attribute_t *attr;
int xlen = 0;
packet = switch_stun_packet_build_header(SWITCH_STUN_BINDING_REQUEST, NULL, buf);
printf("1len %d %d\n", ntohs(packet->header.length), xlen);
switch_stun_packet_attribute_add_username(packet, user_name, strlen(user_name));
printf("2len %d %d\n", ntohs(packet->header.length), xlen);
switch_stun_packet_attribute_add_controlled(packet);
//switch_stun_packet_attribute_add_password(packet, user_name, strlen(user_name));
//printf("3len %d %d\n", ntohs(packet->header.length), xlen);
//switch_stun_packet_attribute_add_use_candidate(packet);
switch_stun_packet_attribute_add_integrity(packet, "FUCK");
switch_stun_packet_attribute_add_fingerprint(packet);
switch_dial_handle_t *dh;
switch_dial_leg_list_t *ll;
switch_dial_leg_t *leg = NULL;
int timeout = 0;
char *peer_names[MAX_PEERS] = { 0 };
switch_event_t *peer_vars[MAX_PEERS] = { 0 };
int i;
switch_core_session_t *peer_session = NULL;
switch_call_cause_t cause;
switch_dial_handle_create(&dh);
end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf));
switch_dial_handle_add_global_var(dh, "ignore_early_media", "true");
switch_dial_handle_add_global_var_printf(dh, "coolness_count", "%d", 12);
//// SET TO 1 FOR AND LIST example or to 0 for OR LIST example
#if 0
switch_dial_handle_add_leg_list(dh, &ll);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/foo1@bar1.com");
timeout += 10;
switch_dial_handle_add_leg_var_printf(leg, "leg_timeout", "%d", timeout);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/foo2@bar2.com");
timeout += 10;
switch_dial_handle_add_leg_var_printf(leg, "leg_timeout", "%d", timeout);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/foo3@bar3.com");
timeout += 10;
switch_dial_handle_add_leg_var_printf(leg, "leg_timeout", "%d", timeout);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/3000@cantina.freeswitch.org");
#else
switch_dial_handle_add_leg_list(dh, &ll);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/foo1@bar1.com");
timeout += 10;
switch_dial_handle_add_leg_var_printf(leg, "leg_timeout", "%d", timeout);
switch_dial_handle_add_leg_list(dh, &ll);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/foo2@bar2.com");
timeout += 10;
switch_dial_handle_add_leg_var_printf(leg, "leg_timeout", "%d", timeout);
switch_dial_handle_add_leg_list(dh, &ll);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/foo3@bar3.com");
timeout += 10;
switch_dial_handle_add_leg_var_printf(leg, "leg_timeout", "%d", timeout);
switch_dial_handle_add_leg_list(dh, &ll);
switch_dial_leg_list_add_leg(ll, &leg, "sofia/internal/3000@cantina.freeswitch.org");
#endif
/////// JUST DUMP SOME OF IT TO SEE FIRST
switch_dial_handle_get_peers(dh, 0, peer_names, MAX_PEERS);
switch_dial_handle_get_vars(dh, 0, peer_vars, MAX_PEERS);
switch_stun_packet_first_attribute(packet, attr);
for(i = 0; i < MAX_PEERS; i++) {
if (peer_names[i]) {
char *foo;
printf("peer: [%s]\n", peer_names[i]);
xlen = sizeof(switch_stun_packet_header_t);
printf("len %d %d\n", ntohs(packet->header.length), xlen);
do {
printf("WTF %p %d %d:(%d)\n", (void *)attr, ntohs(attr->type), ntohs(attr->length), switch_stun_attribute_padded_length_hbo(attr));
if (!switch_stun_packet_next_attribute_hbo(attr, end_buf)) {
break;
if (peer_vars[i]) {
if (switch_event_serialize(peer_vars[i], &foo, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
printf("%s\n", foo);
}
}
printf("\n\n");
}
xlen += 4+switch_stun_attribute_padded_length_hbo(attr);
} while (xlen <= ntohs(packet->header.length));
return SWITCH_STATUS_SUCCESS;
do_config(SWITCH_TRUE);
if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
switch_size_t len = 0;
int x = 0;
/* populate the event with some headers */
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "testing", "true");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "foo", "bar");
for (x = 0; x < 10; x++) {
char name[128];
switch_snprintf(name, sizeof(name), "test-header-%d", x);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, name, "value-%d", x);
}
/* Nothing up my sleeve, here is the event */
DUMP_EVENT(event);
/* ok, serialize it into frame_buffer and destroy the event *poof* */
len = sizeof(frame_buffer);
switch_event_binary_serialize(event, (void *)frame_buffer, &len);
switch_event_destroy(&event);
/* wave the magic wand and feed frame_buffer to deserialize */
switch_event_binary_deserialize(&event, (void *)frame_buffer, len, SWITCH_FALSE);
/* TA DA */
DUMP_EVENT(event);
switch_event_destroy(&event);
}
switch_ivr_originate(NULL, &peer_session, &cause, NULL, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, dh);
if (peer_session) {
switch_ivr_session_transfer(peer_session, "3500", "XML", NULL);
switch_core_session_rwunlock(peer_session);
}
switch_dial_handle_destroy(&dh);
return SWITCH_STATUS_SUCCESS;
}
+1 -1
View File
@@ -8541,7 +8541,7 @@ void *SWITCH_THREAD_FUNC nightmare_xfer_thread_run(switch_thread_t *thread, void
switch_channel_t *channel_a = switch_core_session_get_channel(session);
if ((status = switch_ivr_originate(NULL, &tsession, &cause, nhelper->exten_with_params, timeout, NULL, NULL, NULL,
switch_channel_get_caller_profile(channel_a), nhelper->vars, SOF_NONE, NULL)) == SWITCH_STATUS_SUCCESS) {
switch_channel_get_caller_profile(channel_a), nhelper->vars, SOF_NONE, NULL, NULL)) == SWITCH_STATUS_SUCCESS) {
if (switch_channel_up(channel_a)) {
if (switch_true(switch_channel_get_variable(channel_a, "recording_follow_transfer"))) {
+1 -1
View File
@@ -5480,7 +5480,7 @@ static switch_call_cause_t verto_outgoing_channel(switch_core_session_t *session
}
if (switch_ivr_originate(session, new_session, &cause, dial_str, 0, NULL,
NULL, NULL, outbound_profile, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) {
NULL, NULL, outbound_profile, var_event, myflags, cancel_cause, NULL) == SWITCH_STATUS_SUCCESS) {
switch_core_session_rwunlock(*new_session);
}
+1 -1
View File
@@ -2801,7 +2801,7 @@ static void *SWITCH_THREAD_FUNC rayo_dial_thread(switch_thread_t *thread, void *
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rayo_call_get_uuid(call)), SWITCH_LOG_DEBUG, "dial: Using dialstring: %s\n", dialstring);
/* <iq><ref> response will be sent when originate event is received- otherwise error is returned */
if (switch_ivr_originate(NULL, &called_session, &cause, dialstring, dial_timeout_sec, NULL, NULL, NULL, NULL, originate_vars, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS && called_session) {
if (switch_ivr_originate(NULL, &called_session, &cause, dialstring, dial_timeout_sec, NULL, NULL, NULL, NULL, originate_vars, SOF_NONE, NULL, NULL) == SWITCH_STATUS_SUCCESS && called_session) {
/* start APP */
switch_caller_extension_t *extension = NULL;
switch_channel_t *called_channel = switch_core_session_get_channel(called_session);
+4 -2
View File
@@ -1603,7 +1603,8 @@ void *FSSession::Construct(const v8::FunctionCallbackInfo<Value>& info)
old_obj = JSBase::GetInstance<FSSession>(Handle<Object>::Cast(info[1]));
}
if (switch_ivr_originate(old_obj ? old_obj->_session : NULL,
&session_obj->_session, &session_obj->_cause, uuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS) {
&session_obj->_session, &session_obj->_cause, uuid, 60,
NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL) == SWITCH_STATUS_SUCCESS) {
switch_set_flag(session_obj, S_HUP);
} else {
/* This will return the Session object, but with no C++ instance related to it */
@@ -1765,7 +1766,8 @@ JS_SESSION_FUNCTION_IMPL(Originate)
caller_profile = switch_caller_profile_new(pool, username, dialplan, cid_name, cid_num, network_addr, ani, aniii, rdnis, "mod_v8", context, dest.c_str());
status =
switch_ivr_originate(session, &peer_session, &this->_cause, dest.c_str(), to.length() > 0 ? atoi(to.c_str()) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE, NULL);
switch_ivr_originate(session, &peer_session, &this->_cause,
dest.c_str(), to.length() > 0 ? atoi(to.c_str()) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE, NULL, NULL);
if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest.c_str());