[mod_verto] allow vars from dp to pass to verto dialog
This commit is contained in:
parent
6fb9a69fca
commit
2c7f97a606
|
@ -326,7 +326,7 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *c
|
||||||
#define switch_channel_get_variable(_c, _v) switch_channel_get_variable_dup(_c, _v, SWITCH_TRUE, -1)
|
#define switch_channel_get_variable(_c, _v) switch_channel_get_variable_dup(_c, _v, SWITCH_TRUE, -1)
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event);
|
SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event);
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_channel_get_variables_prefix(switch_channel_t *channel, const char *prefix, switch_event_t **event);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel);
|
SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel);
|
||||||
|
|
||||||
static inline int switch_channel_var_false(switch_channel_t *channel, const char *variable) {
|
static inline int switch_channel_var_false(switch_channel_t *channel, const char *variable) {
|
||||||
|
|
|
@ -1194,6 +1194,22 @@ static int attach_wake(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_variables(verto_pvt_t *tech_pvt, cJSON *params)
|
||||||
|
{
|
||||||
|
cJSON *jvariables = NULL;
|
||||||
|
switch_event_header_t *hi;
|
||||||
|
switch_event_t *variables;
|
||||||
|
|
||||||
|
jvariables = cJSON_CreateObject();
|
||||||
|
switch_channel_get_variables_prefix(tech_pvt->channel, "verto_svar_", &variables);
|
||||||
|
for (hi = variables->headers; hi; hi = hi->next) {
|
||||||
|
cJSON_AddItemToObject(jvariables, hi->name, cJSON_CreateString(hi->value));
|
||||||
|
}
|
||||||
|
cJSON_AddItemToObject(params, "variables", jvariables);
|
||||||
|
switch_event_destroy(&variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void tech_reattach(verto_pvt_t *tech_pvt, jsock_t *jsock)
|
static void tech_reattach(verto_pvt_t *tech_pvt, jsock_t *jsock)
|
||||||
{
|
{
|
||||||
cJSON *params = NULL;
|
cJSON *params = NULL;
|
||||||
|
@ -1205,6 +1221,8 @@ static void tech_reattach(verto_pvt_t *tech_pvt, jsock_t *jsock)
|
||||||
switch_set_flag(tech_pvt, TFLAG_ATTACH_REQ);
|
switch_set_flag(tech_pvt, TFLAG_ATTACH_REQ);
|
||||||
msg = jrpc_new_req("verto.attach", tech_pvt->call_id, ¶ms);
|
msg = jrpc_new_req("verto.attach", tech_pvt->call_id, ¶ms);
|
||||||
|
|
||||||
|
add_variables(tech_pvt, params);
|
||||||
|
|
||||||
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
|
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
|
||||||
switch_channel_set_flag(tech_pvt->channel, CF_RECOVERING);
|
switch_channel_set_flag(tech_pvt->channel, CF_RECOVERING);
|
||||||
switch_core_media_gen_local_sdp(tech_pvt->session, SDP_TYPE_REQUEST, NULL, 0, NULL, 0);
|
switch_core_media_gen_local_sdp(tech_pvt->session, SDP_TYPE_REQUEST, NULL, 0, NULL, 0);
|
||||||
|
@ -2214,7 +2232,7 @@ static switch_status_t verto_connect(switch_core_session_t *session, const char
|
||||||
cJSON *msg = NULL;
|
cJSON *msg = NULL;
|
||||||
const char *var = NULL;
|
const char *var = NULL;
|
||||||
switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(tech_pvt->channel);
|
switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(tech_pvt->channel);
|
||||||
switch_event_header_t *hp;
|
switch_event_header_t *hi;
|
||||||
|
|
||||||
//DUMP_EVENT(jsock->params);
|
//DUMP_EVENT(jsock->params);
|
||||||
|
|
||||||
|
@ -2224,8 +2242,8 @@ static switch_status_t verto_connect(switch_core_session_t *session, const char
|
||||||
switch_channel_set_variable(tech_pvt->channel, "chat_proto", VERTO_CHAT_PROTO);
|
switch_channel_set_variable(tech_pvt->channel, "chat_proto", VERTO_CHAT_PROTO);
|
||||||
switch_channel_set_variable(tech_pvt->channel, "verto_host", jsock->domain);
|
switch_channel_set_variable(tech_pvt->channel, "verto_host", jsock->domain);
|
||||||
|
|
||||||
for (hp = jsock->user_vars->headers; hp; hp = hp->next) {
|
for (hi = jsock->user_vars->headers; hi; hi = hi->next) {
|
||||||
switch_channel_set_variable(tech_pvt->channel, hp->name, hp->value);
|
switch_channel_set_variable(tech_pvt->channel, hi->name, hi->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((var = switch_event_get_header(jsock->params, "caller-id-name"))) {
|
if ((var = switch_event_get_header(jsock->params, "caller-id-name"))) {
|
||||||
|
@ -2267,6 +2285,8 @@ static switch_status_t verto_connect(switch_core_session_t *session, const char
|
||||||
|
|
||||||
msg = jrpc_new_req(method, tech_pvt->call_id, ¶ms);
|
msg = jrpc_new_req(method, tech_pvt->call_id, ¶ms);
|
||||||
|
|
||||||
|
add_variables(tech_pvt, params);
|
||||||
|
|
||||||
if (tech_pvt->mparams->local_sdp_str) {
|
if (tech_pvt->mparams->local_sdp_str) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local %s SDP %s:\n%s\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local %s SDP %s:\n%s\n",
|
||||||
method,
|
method,
|
||||||
|
@ -2551,10 +2571,13 @@ static switch_status_t verto_send_media_indication(switch_core_session_t *sessio
|
||||||
} else {
|
} else {
|
||||||
cJSON *params = NULL;
|
cJSON *params = NULL;
|
||||||
cJSON *msg = jrpc_new_req(method, tech_pvt->call_id, ¶ms);
|
cJSON *msg = jrpc_new_req(method, tech_pvt->call_id, ¶ms);
|
||||||
|
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_SENT_MEDIA)) {
|
if (!switch_test_flag(tech_pvt, TFLAG_SENT_MEDIA)) {
|
||||||
cJSON_AddItemToObject(params, "sdp", cJSON_CreateString(tech_pvt->mparams->local_sdp_str));
|
cJSON_AddItemToObject(params, "sdp", cJSON_CreateString(tech_pvt->mparams->local_sdp_str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_variables(tech_pvt, params);
|
||||||
|
|
||||||
switch_set_flag(tech_pvt, TFLAG_SENT_MEDIA);
|
switch_set_flag(tech_pvt, TFLAG_SENT_MEDIA);
|
||||||
|
|
||||||
if (jsock_queue_event(jsock, &msg, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
|
if (jsock_queue_event(jsock, &msg, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
|
|
@ -4457,6 +4457,29 @@ SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *c
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_channel_get_variables_prefix(switch_channel_t *channel, const char *prefix, switch_event_t **event)
|
||||||
|
{
|
||||||
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
switch_event_t *vars;
|
||||||
|
|
||||||
|
switch_event_create(&vars, SWITCH_EVENT_CHANNEL_DATA);
|
||||||
|
|
||||||
|
switch_mutex_lock(channel->profile_mutex);
|
||||||
|
if (channel->variables) {
|
||||||
|
switch_event_header_t *hi;
|
||||||
|
|
||||||
|
for (hi = channel->variables->headers; hi; hi = hi->next) {
|
||||||
|
if (!strncmp(hi->name, prefix, strlen(prefix))) {
|
||||||
|
switch_event_add_header_string(vars, SWITCH_STACK_BOTTOM, hi->name, hi->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch_mutex_unlock(channel->profile_mutex);
|
||||||
|
|
||||||
|
*event = vars;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_core_session_t *) switch_channel_get_session(switch_channel_t *channel)
|
SWITCH_DECLARE(switch_core_session_t *) switch_channel_get_session(switch_channel_t *channel)
|
||||||
{
|
{
|
||||||
switch_assert(channel);
|
switch_assert(channel);
|
||||||
|
|
Loading…
Reference in New Issue