Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
9bfa2fc5
提交
9bfa2fc5
authored
5月 10, 2019
作者:
Luis Azedo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11838 [mod_kazoo] handle intercept
上级
89379c38
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
99 行增加
和
105 行删除
+99
-105
kazoo.conf.xml
src/mod/event_handlers/mod_kazoo/kazoo.conf.xml
+50
-37
kazoo_tweaks.c
src/mod/event_handlers/mod_kazoo/kazoo_tweaks.c
+49
-68
没有找到文件。
src/mod/event_handlers/mod_kazoo/kazoo.conf.xml
浏览文件 @
9bfa2fc5
...
...
@@ -17,7 +17,7 @@
<param
name=
"receive-msg-preallocate"
value=
"8192"
/>
<param
name=
"node-worker-threads"
value=
"5"
/>
<param
name=
"receive-timeout"
value=
"1"
/>
<param
name=
"event-stream-framing"
value=
"
2
"
/>
<param
name=
"event-stream-framing"
value=
"
4
"
/>
</settings>
...
...
@@ -35,6 +35,18 @@
</field>
</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"
>
<filters>
<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"
>
<filters>
<filter
name=
"variable_Call-Interaction-ID"
type=
"include"
compare=
"field"
value=
"variable_Original-Call-Interaction-ID"
/>
<fi
eld
name=
"${first-of(Event-Subclass|Event-Name|#none)}"
type=
"include"
compare=
"list"
value=
"CHANNEL_DESTROY|KZ_CDR"
/>
<fi
lter
name=
"${first-of(Event-Subclass|Event-Name|#none)}"
type=
"include"
compare=
"list"
value=
"CHANNEL_DESTROY|KZ_CDR"
/>
</filters>
</field>
</definition>
...
...
@@ -89,9 +101,13 @@
</definition>
<definition
name=
"Privacy"
>
<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"
/>
<field
name=
"Privacy"
type=
"static"
serialize-as=
"object"
>
<fields
verbose=
"false"
>
<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
name=
"Custom-Channel-Vars"
>
...
...
@@ -136,6 +152,9 @@
</fields>
</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>
</field>
</definition>
...
...
@@ -205,14 +224,14 @@
<definition
name=
"application"
>
<field
name=
"Application-Name"
type=
"first-of"
value=
"
kazoo_application_name|Application-UUID-N
ame|Application|Event-Subclass"
/>
value=
"
Application-UUID-Name|kazoo_application_n
ame|Application|Event-Subclass"
/>
<field
name=
"Application-Response"
type=
"first-of"
value=
"kazoo_application_response|Application-Response"
/>
</definition>
<definition
name=
"raw-application"
>
<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"
/>
</definition>
...
...
@@ -342,7 +361,8 @@
<field
name=
"user-agent"
type=
"reference"
/>
<field
name=
"Custom-Channel-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
name=
"fetch-info"
>
...
...
@@ -365,6 +385,7 @@
<field
name=
"freeswitch-url"
type=
"reference"
/>
<field
name=
"Control"
type=
"reference"
/>
<field
name=
"Privacy"
type=
"reference"
/>
<field
name=
"debug-call"
type=
"reference"
/>
</definition>
...
...
@@ -625,33 +646,6 @@
<field
name=
"Event-Name"
type=
"static"
value=
"route_req"
/>
<field
name=
"Hunt-Context"
as=
"Fetch-Key-Value"
/>
</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>
...
...
@@ -687,6 +681,7 @@
<field
name=
"variable_Media-Recordings"
as=
"Media-Recordings"
/>
<field
name=
"debug-call"
type=
"reference"
/>
<field
name=
"transfer-history"
type=
"reference"
/>
<field
name=
"originated-legs"
type=
"reference"
/>
</fields>
<filters>
...
...
@@ -696,6 +691,14 @@
</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"
>
<fields
verbose=
"false"
>
<field
name=
"call_event"
type=
"reference"
/>
...
...
@@ -863,16 +866,22 @@
</event>
<event
name=
"kazoo::masquerade"
>
<!--
<filters>
<filter type="exclude" name="kazoo_event_name" compare="value"
value="CHANNEL_EXECUTE_COMPLETE" />
</filters>
-->
<fields
verbose=
"false"
>
<field
name=
"call_event"
type=
"reference"
/>
<field
name=
"application-uuid"
type=
"reference"
/>
<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"
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>
</event>
...
...
@@ -897,6 +906,7 @@
<filter
name=
"Application"
value=
"ring_ready"
/>
<filter
name=
"Application"
value=
"log"
/>
<filter
name=
"Application"
value=
"execute_extension"
/>
<filter
name=
"Application"
value=
"bridge"
/>
</filters>
<fields
verbose=
"false"
>
...
...
@@ -907,6 +917,9 @@
<field
name=
"Disposition"
type=
"first-of"
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"
/>
<field
name=
"debug-call"
type=
"reference"
/>
</fields>
...
...
@@ -992,6 +1005,7 @@
<field
name=
"call_event"
type=
"reference"
/>
<field
name=
"Custom-Channel-Vars"
type=
"reference"
/>
<field
name=
"Custom-Application-Vars"
type=
"reference"
/>
<field
name=
"debug-call"
type=
"reference"
/>
</fields>
</event>
...
...
@@ -1114,7 +1128,6 @@
<fields
verbose=
"false"
>
<field
name=
"voice_dialplan"
type=
"reference"
/>
<field
name=
"metaflow_dialplan"
type=
"reference"
/>
<field
name=
"debug-call"
type=
"reference"
/>
</fields>
...
...
src/mod/event_handlers/mod_kazoo/kazoo_tweaks.c
浏览文件 @
9bfa2fc5
...
...
@@ -31,6 +31,7 @@
#include "mod_kazoo.h"
#define INTERACTION_VARIABLE "Call-Interaction-ID"
#define BRIDGE_INTERCEPT_VARIABLE "Bridge-Intercepted"
static
char
*
TWEAK_NAMES
[]
=
{
"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"
);
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
)
{
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
);
...
...
@@ -100,6 +104,9 @@ static void kz_tweaks_handle_bridge_variables(switch_event_t *event)
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
)
{
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
)
{
...
...
@@ -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_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
*
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"
);
int
processed
=
0
;
const
char
*
uuid
=
switch_event_get_header
(
event
,
"Unique-ID
"
);
const
char
*
a_leg
=
switch_event_get_header
(
event
,
"Bridge-A-Unique-ID
"
);
const
char
*
b_leg
=
switch_event_get_header
(
event
,
"Bridge-B-
Unique-ID"
);
const
char
*
bridge_intercepted
=
NULL
;
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
(
call_id
)
{
if
((
session
=
switch_core_session_locate
(
call_id
))
!=
NULL
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_set_variable
(
channel
,
"Bridge-Event-Processed"
,
"true"
);
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
);
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
(
session
));
switch_event_add_header_string
(
my_event
,
SWITCH_STACK_BOTTOM
,
"Bridge-B-Unique-ID"
,
peer_uuid
);
switch_channel_event_set_data
(
channel
,
my_event
);
switch_event_fire
(
&
my_event
);
}
switch_channel_set_variable
(
channel
,
"Bridge-B-Unique-ID"
,
peer_uuid
);
switch_channel_add_state_handler
(
channel
,
&
kz_tweaks_signal_bridge_state_handlers
);
switch_core_session_rwunlock
(
session
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"invalid session : %s
\n
"
,
call_id
);
DUMP_EVENT
(
event
);
}
}
}
}
}
static
void
kz_tweaks_handle_bridge_replaces_call_id
(
switch_event_t
*
event
)
{
switch_event_t
*
my_event
;
if
((
a_session
=
switch_core_session_locate
(
a_leg
))
!=
NULL
)
{
switch_channel_t
*
a_channel
=
switch_core_session_get_channel
(
a_session
);
bridge_intercepted
=
switch_channel_get_variable_dup
(
a_channel
,
BRIDGE_INTERCEPT_VARIABLE
,
SWITCH_TRUE
,
-
1
);
switch_channel_set_variable
(
a_channel
,
BRIDGE_INTERCEPT_VARIABLE
,
NULL
);
if
(
bridge_intercepted
&&
switch_true
(
bridge_intercepted
))
{
switch_channel_set_variable
(
a_channel
,
"Bridge-B-Unique-ID"
,
b_leg
);
switch_channel_add_state_handler
(
a_channel
,
&
kz_tweaks_signal_bridge_state_handlers
);
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
);
if
((
b_session
=
switch_core_session_locate
(
b_leg
))
!=
NULL
)
{
switch_channel_t
*
b_channel
=
switch_core_session_get_channel
(
b_session
);
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_event_add_header_string
(
my_event
,
SWITCH_STACK_BOTTOM
,
"Bridge-A-Unique-ID"
,
switch_core_session_get_uuid
(
b_session
));
switch_event_add_header_string
(
my_event
,
SWITCH_STACK_BOTTOM
,
"Bridge-B-Unique-ID"
,
uuid
);
switch_channel_event_set_data
(
b_channel
,
my_event
);
switch_event_fire
(
&
my_event
);
}
switch_core_session_rwunlock
(
b_session
);
}
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
);
}
switch_core_session_rwunlock
(
a_session
);
}
switch_safe_strdup
(
bridge_intercepted
);
}
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
;
kz_tweaks_handle_bridge_replaces_call_id
(
event
);
kz_tweaks_handle_bridge_replaces_aleg
(
event
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"tweak bridge event handler: %s
\n
"
,
uuid
);
kz_tweaks_handle_bridge_intercepted
(
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
)
{
switch_core_session_t
*
uuid_session
=
NULL
;
const
char
*
uuid
=
switch_event_get_header
(
event
,
"Unique-ID"
);
const
char
*
peer_uuid
=
switch_event_get_header
(
event
,
"intercepted_by"
);
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
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论