Merge pull request #1721 in FS/freeswitch from ~LAZEDO/freeswitch:bug/FS-11838 to master
* commit '9bfa2fc5e47c96b1699299bd336f8de967061f4a': FS-11838 [mod_kazoo] handle intercept
This commit is contained in:
commit
13e40b6951
|
@ -17,7 +17,7 @@
|
||||||
<param name="receive-msg-preallocate" value="8192" />
|
<param name="receive-msg-preallocate" value="8192" />
|
||||||
<param name="node-worker-threads" value="5" />
|
<param name="node-worker-threads" value="5" />
|
||||||
<param name="receive-timeout" value="1" />
|
<param name="receive-timeout" value="1" />
|
||||||
<param name="event-stream-framing" value="2" />
|
<param name="event-stream-framing" value="4" />
|
||||||
|
|
||||||
</settings>
|
</settings>
|
||||||
|
|
||||||
|
@ -35,6 +35,18 @@
|
||||||
</field>
|
</field>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
|
<definition name="originated-legs">
|
||||||
|
<filters>
|
||||||
|
<filter name="variable_originated_legs" type="include" compare="exists" />
|
||||||
|
</filters>
|
||||||
|
<field name="Other-Legs" type="static" serialize-as="object">
|
||||||
|
<fields verbose="false">
|
||||||
|
<field name="variable_originated_legs" as="Callee" />
|
||||||
|
<field name="variable_originate_causes" as="Causes" />
|
||||||
|
</fields>
|
||||||
|
</field>
|
||||||
|
</definition>
|
||||||
|
|
||||||
<definition name="transfer-history">
|
<definition name="transfer-history">
|
||||||
<filters>
|
<filters>
|
||||||
<filter name="variable_transfer_history" type="include" compare="exists" />
|
<filter name="variable_transfer_history" type="include" compare="exists" />
|
||||||
|
@ -54,7 +66,7 @@
|
||||||
<field name="Call-Interaction-Is-Root" type="static" value="true" serialize-as="boolean">
|
<field name="Call-Interaction-Is-Root" type="static" value="true" serialize-as="boolean">
|
||||||
<filters>
|
<filters>
|
||||||
<filter name="variable_Call-Interaction-ID" type="include" compare="field" value="variable_Original-Call-Interaction-ID" />
|
<filter name="variable_Call-Interaction-ID" type="include" compare="field" value="variable_Original-Call-Interaction-ID" />
|
||||||
<field name="${first-of(Event-Subclass|Event-Name|#none)}" type="include" compare="list" value="CHANNEL_DESTROY|KZ_CDR"/>
|
<filter name="${first-of(Event-Subclass|Event-Name|#none)}" type="include" compare="list" value="CHANNEL_DESTROY|KZ_CDR"/>
|
||||||
</filters>
|
</filters>
|
||||||
</field>
|
</field>
|
||||||
</definition>
|
</definition>
|
||||||
|
@ -89,9 +101,13 @@
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="Privacy">
|
<definition name="Privacy">
|
||||||
<field name="Caller-Privacy-Hide-Number" as="Hide-Number" serialize-as="boolean" />
|
<field name="Privacy" type="static" serialize-as="object">
|
||||||
<field name="Caller-Privacy-Hide-Name" as="Hide-Name" serialize-as="boolean" />
|
<fields verbose="false">
|
||||||
<field name="Caller-Screen-Bit" as="Screen-Bit" serialize-as="boolean" />
|
<field name="Caller-Privacy-Hide-Number" as="Hide-Number" serialize-as="boolean" />
|
||||||
|
<field name="Caller-Privacy-Hide-Name" as="Hide-Name" serialize-as="boolean" />
|
||||||
|
<field name="Caller-Screen-Bit" as="Screen-Bit" serialize-as="boolean" />
|
||||||
|
</fields>
|
||||||
|
</field>
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="Custom-Channel-Vars">
|
<definition name="Custom-Channel-Vars">
|
||||||
|
@ -136,6 +152,9 @@
|
||||||
</fields>
|
</fields>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
|
<field name="Caller-Privacy-Hide-Number" as="Privacy-Hide-Number" serialize-as="boolean" />
|
||||||
|
<field name="Caller-Privacy-Hide-Name" as="Privacy-Hide-Name" serialize-as="boolean" />
|
||||||
|
|
||||||
</fields>
|
</fields>
|
||||||
</field>
|
</field>
|
||||||
</definition>
|
</definition>
|
||||||
|
@ -205,14 +224,14 @@
|
||||||
|
|
||||||
<definition name="application">
|
<definition name="application">
|
||||||
<field name="Application-Name" type="first-of"
|
<field name="Application-Name" type="first-of"
|
||||||
value="kazoo_application_name|Application-UUID-Name|Application|Event-Subclass" />
|
value="Application-UUID-Name|kazoo_application_name|Application|Event-Subclass" />
|
||||||
<field name="Application-Response" type="first-of"
|
<field name="Application-Response" type="first-of"
|
||||||
value="kazoo_application_response|Application-Response" />
|
value="kazoo_application_response|Application-Response" />
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="raw-application">
|
<definition name="raw-application">
|
||||||
<field name="Raw-Application-Name" type="first-of"
|
<field name="Raw-Application-Name" type="first-of"
|
||||||
value="Application|kazoo_application_name|Event-Subclass" />
|
value="kazoo_application_name|Application|Event-Subclass" />
|
||||||
<field name="Application-Data" as="Raw-Application-Data" />
|
<field name="Application-Data" as="Raw-Application-Data" />
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
|
@ -342,7 +361,8 @@
|
||||||
<field name="user-agent" type="reference" />
|
<field name="user-agent" type="reference" />
|
||||||
<field name="Custom-Channel-Vars" type="reference" />
|
<field name="Custom-Channel-Vars" type="reference" />
|
||||||
<field name="Custom-Application-Vars" type="reference" />
|
<field name="Custom-Application-Vars" type="reference" />
|
||||||
<field name="Control" type="reference" />
|
<field name="Control" type="reference" />
|
||||||
|
<field name="debug-call" type="reference" />
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
<definition name="fetch-info">
|
<definition name="fetch-info">
|
||||||
|
@ -365,6 +385,7 @@
|
||||||
<field name="freeswitch-url" type="reference" />
|
<field name="freeswitch-url" type="reference" />
|
||||||
<field name="Control" type="reference" />
|
<field name="Control" type="reference" />
|
||||||
<field name="Privacy" type="reference" />
|
<field name="Privacy" type="reference" />
|
||||||
|
<field name="debug-call" type="reference" />
|
||||||
|
|
||||||
</definition>
|
</definition>
|
||||||
|
|
||||||
|
@ -625,33 +646,6 @@
|
||||||
<field name="Event-Name" type="static" value="route_req" />
|
<field name="Event-Name" type="static" value="route_req" />
|
||||||
<field name="Hunt-Context" as="Fetch-Key-Value" />
|
<field name="Hunt-Context" as="Fetch-Key-Value" />
|
||||||
</definition>
|
</definition>
|
||||||
<definition name="metaflow_dialplan">
|
|
||||||
<field name="metaflow" type="group">
|
|
||||||
<filters>
|
|
||||||
<filter name="Hunt-Context" type="include" compare="value"
|
|
||||||
value="metaflow" />
|
|
||||||
</filters>
|
|
||||||
<fields verbose="false">
|
|
||||||
<field name="Hunt-Context" as="Context" />
|
|
||||||
<field name="Resource-Type" type="static" value="metaflow" />
|
|
||||||
<!--
|
|
||||||
<field name="variable_Call-Control-Queue" as="Metaflow-Control-Queue" />
|
|
||||||
<field name="variable_Call-Control-PID" as="Metaflow-Control-PID" />
|
|
||||||
-->
|
|
||||||
<field name="variable_Metaflow-Control-Queue" as="Metaflow-Control-Queue" />
|
|
||||||
<field name="variable_Metaflow-Control-PID" as="Metaflow-Control-PID" />
|
|
||||||
<field name="Custom-Routing-Headers" type="static"
|
|
||||||
serialize-as="object">
|
|
||||||
<fields verbose="false">
|
|
||||||
<field name="Metaflow-Request-Type" type="static" value="in-call" />
|
|
||||||
<field name="Other-Leg-Unique-ID" as="Other-Leg-Call-ID" />
|
|
||||||
<field name="Hunt-Destination-Number" as="Metaflow-Request" />
|
|
||||||
</fields>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
|
|
||||||
</field>
|
|
||||||
</definition>
|
|
||||||
|
|
||||||
</definitions>
|
</definitions>
|
||||||
|
|
||||||
|
@ -687,6 +681,7 @@
|
||||||
<field name="variable_Media-Recordings" as="Media-Recordings" />
|
<field name="variable_Media-Recordings" as="Media-Recordings" />
|
||||||
<field name="debug-call" type="reference" />
|
<field name="debug-call" type="reference" />
|
||||||
<field name="transfer-history" type="reference" />
|
<field name="transfer-history" type="reference" />
|
||||||
|
<field name="originated-legs" type="reference" />
|
||||||
|
|
||||||
</fields>
|
</fields>
|
||||||
<filters>
|
<filters>
|
||||||
|
@ -696,6 +691,14 @@
|
||||||
|
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
<event name="CHANNEL_PROGRESS">
|
||||||
|
<fields verbose="false">
|
||||||
|
<field name="call_event" type="reference" />
|
||||||
|
<field name="from-to" type="reference" />
|
||||||
|
<field name="debug-call" type="reference" />
|
||||||
|
</fields>
|
||||||
|
</event>
|
||||||
|
|
||||||
<event name="CHANNEL_PROGRESS_MEDIA">
|
<event name="CHANNEL_PROGRESS_MEDIA">
|
||||||
<fields verbose="false">
|
<fields verbose="false">
|
||||||
<field name="call_event" type="reference" />
|
<field name="call_event" type="reference" />
|
||||||
|
@ -863,16 +866,22 @@
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
<event name="kazoo::masquerade">
|
<event name="kazoo::masquerade">
|
||||||
|
<!--
|
||||||
<filters>
|
<filters>
|
||||||
<filter type="exclude" name="kazoo_event_name" compare="value"
|
<filter type="exclude" name="kazoo_event_name" compare="value"
|
||||||
value="CHANNEL_EXECUTE_COMPLETE" />
|
value="CHANNEL_EXECUTE_COMPLETE" />
|
||||||
</filters>
|
</filters>
|
||||||
|
-->
|
||||||
<fields verbose="false">
|
<fields verbose="false">
|
||||||
<field name="call_event" type="reference" />
|
<field name="call_event" type="reference" />
|
||||||
|
<field name="application-uuid" type="reference" />
|
||||||
<field name="Application-Response" type="first-of"
|
<field name="Application-Response" type="first-of"
|
||||||
value="variable_originate_disposition|#FAIL" />
|
value="variable_endpoint_disposition|variable_originate_disposition|#FAIL" />
|
||||||
<field name="Disposition" type="first-of"
|
<field name="Disposition" type="first-of"
|
||||||
value="variable_originate_disposition|variable_endpoint_disposition" />
|
value="variable_originate_disposition|variable_endpoint_disposition" />
|
||||||
|
<field name="Bridge-Hangup-Cause" type="first-of" value="variable_bridge_hangup_cause|variable_last_bridge_hangup_cause" />
|
||||||
|
<field name="variable_endpoint_disposition" as="Endpoint-Disposition" />
|
||||||
|
<field name="variable_transfer_disposition" as="Transfer-Disposition" />
|
||||||
</fields>
|
</fields>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
@ -897,6 +906,7 @@
|
||||||
<filter name="Application" value="ring_ready" />
|
<filter name="Application" value="ring_ready" />
|
||||||
<filter name="Application" value="log" />
|
<filter name="Application" value="log" />
|
||||||
<filter name="Application" value="execute_extension" />
|
<filter name="Application" value="execute_extension" />
|
||||||
|
<filter name="Application" value="bridge" />
|
||||||
</filters>
|
</filters>
|
||||||
|
|
||||||
<fields verbose="false">
|
<fields verbose="false">
|
||||||
|
@ -907,6 +917,9 @@
|
||||||
<field name="Disposition" type="first-of"
|
<field name="Disposition" type="first-of"
|
||||||
value="variable_originate_disposition|variable_endpoint_disposition" />
|
value="variable_originate_disposition|variable_endpoint_disposition" />
|
||||||
<field name="Bridge-Hangup-Cause" type="first-of" value="variable_bridge_hangup_cause|variable_last_bridge_hangup_cause" />
|
<field name="Bridge-Hangup-Cause" type="first-of" value="variable_bridge_hangup_cause|variable_last_bridge_hangup_cause" />
|
||||||
|
<field name="variable_endpoint_disposition" as="Endpoint-Disposition" />
|
||||||
|
<field name="variable_transfer_disposition" as="Transfer-Disposition" />
|
||||||
|
|
||||||
<field name="debug-call" type="reference" />
|
<field name="debug-call" type="reference" />
|
||||||
</fields>
|
</fields>
|
||||||
|
|
||||||
|
@ -992,6 +1005,7 @@
|
||||||
<field name="call_event" type="reference" />
|
<field name="call_event" type="reference" />
|
||||||
<field name="Custom-Channel-Vars" type="reference" />
|
<field name="Custom-Channel-Vars" type="reference" />
|
||||||
<field name="Custom-Application-Vars" type="reference" />
|
<field name="Custom-Application-Vars" type="reference" />
|
||||||
|
<field name="debug-call" type="reference" />
|
||||||
</fields>
|
</fields>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
@ -1114,7 +1128,6 @@
|
||||||
|
|
||||||
<fields verbose="false">
|
<fields verbose="false">
|
||||||
<field name="voice_dialplan" type="reference" />
|
<field name="voice_dialplan" type="reference" />
|
||||||
<field name="metaflow_dialplan" type="reference" />
|
|
||||||
<field name="debug-call" type="reference" />
|
<field name="debug-call" type="reference" />
|
||||||
</fields>
|
</fields>
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "mod_kazoo.h"
|
#include "mod_kazoo.h"
|
||||||
|
|
||||||
#define INTERACTION_VARIABLE "Call-Interaction-ID"
|
#define INTERACTION_VARIABLE "Call-Interaction-ID"
|
||||||
|
#define BRIDGE_INTERCEPT_VARIABLE "Bridge-Intercepted"
|
||||||
|
|
||||||
static char *TWEAK_NAMES[] = {
|
static char *TWEAK_NAMES[] = {
|
||||||
"interaction-id",
|
"interaction-id",
|
||||||
|
@ -66,6 +67,9 @@ static switch_status_t kz_tweaks_signal_bridge_on_hangup(switch_core_session_t *
|
||||||
|
|
||||||
const char *peer_uuid = switch_channel_get_variable(channel, "Bridge-B-Unique-ID");
|
const char *peer_uuid = switch_channel_get_variable(channel, "Bridge-B-Unique-ID");
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak signal bridge on hangup: %s , %s\n", switch_core_session_get_uuid(session), peer_uuid);
|
||||||
|
|
||||||
|
|
||||||
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
|
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
|
||||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
|
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
|
||||||
|
@ -100,6 +104,9 @@ static void kz_tweaks_handle_bridge_variables(switch_event_t *event)
|
||||||
|
|
||||||
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_VARIABLES)) return;
|
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_VARIABLES)) return;
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: variables : %s , %s\n", a_leg, b_leg);
|
||||||
|
|
||||||
|
|
||||||
if (a_leg && (a_session = switch_core_session_force_locate(a_leg)) != NULL) {
|
if (a_leg && (a_session = switch_core_session_force_locate(a_leg)) != NULL) {
|
||||||
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
|
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
|
||||||
if(switch_channel_get_variable_dup(a_channel, bridge_variables[0], SWITCH_FALSE, -1) == NULL) {
|
if(switch_channel_get_variable_dup(a_channel, bridge_variables[0], SWITCH_FALSE, -1) == NULL) {
|
||||||
|
@ -130,91 +137,56 @@ static void kz_tweaks_handle_bridge_variables(switch_event_t *event)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kz_tweaks_handle_bridge_replaces_aleg(switch_event_t *event)
|
static void kz_tweaks_handle_bridge_intercepted(switch_event_t *event)
|
||||||
{
|
{
|
||||||
switch_event_t *my_event;
|
switch_event_t *my_event;
|
||||||
|
switch_core_session_t *a_session = NULL;
|
||||||
|
switch_core_session_t *b_session = NULL;
|
||||||
|
|
||||||
const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
|
const char *uuid = switch_event_get_header(event, "Unique-ID");
|
||||||
const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
|
const char *a_leg = switch_event_get_header(event, "Bridge-A-Unique-ID");
|
||||||
const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
|
const char *b_leg = switch_event_get_header(event, "Bridge-B-Unique-ID");
|
||||||
int processed = 0;
|
const char *bridge_intercepted = NULL;
|
||||||
|
|
||||||
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_ALEG)) return;
|
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_ALEG)) return;
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: intercepted : %s , %s, %s\n", uuid, a_leg, b_leg);
|
||||||
|
|
||||||
if(a_leg_call_id && replaced_call_id) {
|
|
||||||
const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
|
|
||||||
switch_core_session_t *session = NULL;
|
|
||||||
if ((session = switch_core_session_locate(peer_uuid)) != NULL) {
|
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
|
||||||
processed = switch_true(switch_channel_get_variable_dup(channel, "Bridge-Event-Processed", SWITCH_FALSE, -1));
|
|
||||||
switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
|
|
||||||
switch_core_session_rwunlock(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(processed) {
|
if ((a_session = switch_core_session_locate(a_leg)) != NULL) {
|
||||||
if(call_id) {
|
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
|
||||||
if((session = switch_core_session_locate(call_id)) != NULL) {
|
bridge_intercepted = switch_channel_get_variable_dup(a_channel, BRIDGE_INTERCEPT_VARIABLE, SWITCH_TRUE, -1);
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_set_variable(a_channel, BRIDGE_INTERCEPT_VARIABLE, NULL);
|
||||||
switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
|
if (bridge_intercepted && switch_true(bridge_intercepted)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(session), peer_uuid);
|
switch_channel_set_variable(a_channel, "Bridge-B-Unique-ID", b_leg);
|
||||||
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
|
switch_channel_add_state_handler(a_channel, &kz_tweaks_signal_bridge_state_handlers);
|
||||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
|
|
||||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
|
if ((b_session = switch_core_session_locate(b_leg)) != NULL) {
|
||||||
switch_channel_event_set_data(channel, my_event);
|
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
|
||||||
switch_event_fire(&my_event);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(b_session), uuid);
|
||||||
}
|
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_channel_set_variable(channel, "Bridge-B-Unique-ID", peer_uuid);
|
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(b_session));
|
||||||
switch_channel_add_state_handler(channel, &kz_tweaks_signal_bridge_state_handlers);
|
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid);
|
||||||
switch_core_session_rwunlock(session);
|
switch_channel_event_set_data(b_channel, my_event);
|
||||||
} else {
|
switch_event_fire(&my_event);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "invalid session : %s\n", call_id);
|
|
||||||
DUMP_EVENT(event);
|
|
||||||
}
|
}
|
||||||
|
switch_core_session_rwunlock(b_session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch_core_session_rwunlock(a_session);
|
||||||
}
|
}
|
||||||
|
switch_safe_strdup(bridge_intercepted);
|
||||||
}
|
|
||||||
|
|
||||||
static void kz_tweaks_handle_bridge_replaces_call_id(switch_event_t *event)
|
|
||||||
{
|
|
||||||
switch_event_t *my_event;
|
|
||||||
|
|
||||||
const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
|
|
||||||
const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
|
|
||||||
const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
|
|
||||||
|
|
||||||
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_CALL_ID)) return;
|
|
||||||
|
|
||||||
if(a_leg_call_id && replaced_call_id) {
|
|
||||||
switch_core_session_t *call_session = NULL;
|
|
||||||
const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
|
|
||||||
if (call_id && (call_session = switch_core_session_force_locate(call_id)) != NULL) {
|
|
||||||
switch_channel_t *call_channel = switch_core_session_get_channel(call_session);
|
|
||||||
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
|
|
||||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(call_session));
|
|
||||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
|
|
||||||
switch_channel_event_set_data(call_channel, my_event);
|
|
||||||
switch_event_fire(&my_event);
|
|
||||||
}
|
|
||||||
switch_channel_set_variable(call_channel, "Bridge-B-Unique-ID", peer_uuid);
|
|
||||||
switch_channel_add_state_handler(call_channel, &kz_tweaks_signal_bridge_state_handlers);
|
|
||||||
switch_core_session_rwunlock(call_session);
|
|
||||||
} else {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "NOT FOUND : %s\n", call_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kz_tweaks_channel_bridge_event_handler(switch_event_t *event)
|
static void kz_tweaks_channel_bridge_event_handler(switch_event_t *event)
|
||||||
{
|
{
|
||||||
|
const char *uuid = switch_event_get_header(event, "Unique-ID");
|
||||||
|
|
||||||
if (!kz_test_tweak(KZ_TWEAK_BRIDGE)) return;
|
if (!kz_test_tweak(KZ_TWEAK_BRIDGE)) return;
|
||||||
|
|
||||||
kz_tweaks_handle_bridge_replaces_call_id(event);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: %s\n", uuid);
|
||||||
kz_tweaks_handle_bridge_replaces_aleg(event);
|
|
||||||
|
kz_tweaks_handle_bridge_intercepted(event);
|
||||||
kz_tweaks_handle_bridge_variables(event);
|
kz_tweaks_handle_bridge_variables(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,12 +204,21 @@ static void kz_tweaks_channel_replaced_event_handler(switch_event_t *event)
|
||||||
|
|
||||||
static void kz_tweaks_channel_intercepted_event_handler(switch_event_t *event)
|
static void kz_tweaks_channel_intercepted_event_handler(switch_event_t *event)
|
||||||
{
|
{
|
||||||
|
switch_core_session_t *uuid_session = NULL;
|
||||||
const char *uuid = switch_event_get_header(event, "Unique-ID");
|
const char *uuid = switch_event_get_header(event, "Unique-ID");
|
||||||
const char *peer_uuid = switch_event_get_header(event, "intercepted_by");
|
const char *peer_uuid = switch_event_get_header(event, "intercepted_by");
|
||||||
|
|
||||||
if (!kz_test_tweak(KZ_TWEAK_TRANSFERS)) return;
|
if (!kz_test_tweak(KZ_TWEAK_TRANSFERS)) return;
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INTERCEPTED : %s => %s\n", uuid, peer_uuid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak intercepted handler : %s was intercepted by %s\n", uuid, peer_uuid);
|
||||||
|
|
||||||
|
if ((uuid_session = switch_core_session_force_locate(peer_uuid)) != NULL) {
|
||||||
|
switch_channel_t *uuid_channel = switch_core_session_get_channel(uuid_session);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "marking %s for channel_bridge handling\n", peer_uuid);
|
||||||
|
switch_channel_set_variable(uuid_channel, BRIDGE_INTERCEPT_VARIABLE, "true");
|
||||||
|
switch_core_session_rwunlock(uuid_session);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kz_tweaks_channel_transferor_event_handler(switch_event_t *event)
|
static void kz_tweaks_channel_transferor_event_handler(switch_event_t *event)
|
||||||
|
|
Loading…
Reference in New Issue