Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b10ea3c0
提交
b10ea3c0
authored
7月 02, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fifo tweaks
上级
4e1d5221
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
115 行增加
和
18 行删除
+115
-18
mod_fifo.c
src/mod/applications/mod_fifo/mod_fifo.c
+115
-18
没有找到文件。
src/mod/applications/mod_fifo/mod_fifo.c
浏览文件 @
b10ea3c0
...
@@ -249,6 +249,7 @@ struct fifo_node {
...
@@ -249,6 +249,7 @@ struct fifo_node {
int
busy
;
int
busy
;
int
is_static
;
int
is_static
;
int
outbound_per_cycle
;
int
outbound_per_cycle
;
char
*
outbound_name
;
outbound_strategy_t
outbound_strategy
;
outbound_strategy_t
outbound_strategy
;
};
};
...
@@ -679,7 +680,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -679,7 +680,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
int
timeout
=
0
;
int
timeout
=
0
;
switch_stream_handle_t
stream
=
{
0
};
switch_stream_handle_t
stream
=
{
0
};
fifo_node_t
*
node
=
NULL
;
fifo_node_t
*
node
=
NULL
;
char
*
originate_string
;
char
*
originate_string
=
NULL
;
switch_event_t
*
ovars
=
NULL
;
switch_event_t
*
ovars
=
NULL
;
switch_status_t
status
;
switch_status_t
status
;
switch_core_session_t
*
session
=
NULL
;
switch_core_session_t
*
session
=
NULL
;
...
@@ -691,6 +692,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -691,6 +692,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
switch_event_t
*
pop
=
NULL
;
switch_event_t
*
pop
=
NULL
;
fifo_queue_t
*
q
=
NULL
;
fifo_queue_t
*
q
=
NULL
;
int
x
=
0
;
int
x
=
0
;
switch_event_t
*
event
;
if
(
!
cbh
->
rowcount
)
{
if
(
!
cbh
->
rowcount
)
{
goto
end
;
goto
end
;
...
@@ -737,7 +739,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -737,7 +739,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
if
(
originate_string
)
{
if
(
originate_string
)
{
end_of
(
originate_string
)
=
'\0'
;
end_of
(
originate_string
)
=
'\0'
;
}
}
if
(
!
timeout
)
timeout
=
60
;
if
(
!
timeout
)
timeout
=
60
;
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
...
@@ -774,28 +776,81 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -774,28 +776,81 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
goto
end
;
goto
end
;
}
}
if
((
caller_id_name
=
switch_event_get_header
(
pop
,
"caller-caller-id-name"
)))
{
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"origination_caller_id_name"
,
caller_id_name
);
}
if
((
cid_num
=
switch_event_get_header
(
pop
,
"caller-caller-id-number"
)))
{
if
(
!
switch_event_get_header
(
ovars
,
"origination_caller_id_name"
))
{
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"origination_caller_id_number"
,
cid_num
);
if
((
caller_id_name
=
switch_event_get_header
(
pop
,
"caller-caller-id-name"
)))
{
if
(
node
->
outbound_name
)
{
switch_event_add_header
(
ovars
,
SWITCH_STACK_BOTTOM
,
"origination_caller_id_name"
,
"(%s) %s"
,
node
->
outbound_name
,
caller_id_name
);
}
else
{
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"origination_caller_id_name"
,
caller_id_name
);
}
}
}
}
if
(
!
switch_event_get_header
(
ovars
,
"origination_caller_id_number"
))
{
if
((
cid_num
=
switch_event_get_header
(
pop
,
"caller-caller-id-number"
)))
{
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"origination_caller_id_number"
,
cid_num
);
}
}
if
((
id
=
switch_event_get_header
(
pop
,
"unique-id"
)))
{
if
((
id
=
switch_event_get_header
(
pop
,
"unique-id"
)))
{
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"fifo_bridge_uuid"
,
id
);
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"fifo_bridge_uuid"
,
id
);
}
}
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_core_session_t
*
session
;
if
(
id
&&
(
session
=
switch_core_session_locate
(
id
)))
{
switch_channel_event_set_data
(
switch_core_session_get_channel
(
session
),
event
);
switch_core_session_rwunlock
(
session
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"pre-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"ringall"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"caller-uuid"
,
id
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"originate_string"
,
originate_string
);
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Outbound-UUID"
,
h
->
uuid
);
}
switch_event_fire
(
&
event
);
}
switch_mutex_unlock
(
q
->
mutex
);
switch_mutex_unlock
(
q
->
mutex
);
status
=
switch_ivr_originate
(
NULL
,
&
session
,
&
cause
,
originate_string
,
timeout
,
NULL
,
NULL
,
NULL
,
NULL
,
ovars
,
SOF_NONE
,
NULL
);
status
=
switch_ivr_originate
(
NULL
,
&
session
,
&
cause
,
originate_string
,
timeout
,
NULL
,
NULL
,
NULL
,
NULL
,
ovars
,
SOF_NONE
,
NULL
);
free
(
originate_string
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"post-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"ringall"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"caller-uuid"
,
id
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"result"
,
"failure"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"cause"
,
switch_channel_cause2str
(
cause
));
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"originate_string"
,
originate_string
);
switch_event_fire
(
&
event
);
}
goto
end
;
goto
end
;
}
}
channel
=
switch_core_session_get_channel
(
session
);
channel
=
switch_core_session_get_channel
(
session
);
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"post-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"ringall"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"caller-uuid"
,
id
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Outbound-UUID"
,
switch_channel_get_variable
(
channel
,
"fifo_outbound_uuid"
));
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"result"
,
"success"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"originate_string"
,
originate_string
);
switch_event_fire
(
&
event
);
}
switch_channel_set_variable
(
channel
,
"fifo_pop_order"
,
NULL
);
switch_channel_set_variable
(
channel
,
"fifo_pop_order"
,
NULL
);
app_name
=
"fifo"
;
app_name
=
"fifo"
;
...
@@ -808,6 +863,8 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -808,6 +863,8 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
end:
end:
switch_safe_free
(
originate_string
);
switch_event_destroy
(
&
ovars
);
switch_event_destroy
(
&
ovars
);
if
(
node
)
{
if
(
node
)
{
switch_mutex_lock
(
node
->
mutex
);
switch_mutex_lock
(
node
->
mutex
);
...
@@ -831,11 +888,12 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
...
@@ -831,11 +888,12 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
switch_channel_t
*
channel
;
switch_channel_t
*
channel
;
switch_call_cause_t
cause
=
SWITCH_CAUSE_NONE
;
switch_call_cause_t
cause
=
SWITCH_CAUSE_NONE
;
switch_caller_extension_t
*
extension
=
NULL
;
switch_caller_extension_t
*
extension
=
NULL
;
char
*
app_name
,
*
arg
=
NULL
,
*
originate_string
=
NULL
,
*
p
=
NULL
;
char
*
app_name
,
*
arg
=
NULL
,
*
originate_string
=
NULL
;
const
char
*
member_wait
=
NULL
;
const
char
*
member_wait
=
NULL
;
fifo_node_t
*
node
=
NULL
;
fifo_node_t
*
node
=
NULL
;
switch_event_t
*
ovars
=
NULL
;
switch_event_t
*
ovars
=
NULL
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_event_t
*
event
=
NULL
;
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
h
->
node_name
);
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
h
->
node_name
);
...
@@ -856,28 +914,62 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
...
@@ -856,28 +914,62 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
originate_string
=
switch_mprintf
(
"{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q'}%s"
,
originate_string
=
switch_mprintf
(
"{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q'}%s"
,
node
->
name
,
h
->
originate_string
);
node
->
name
,
h
->
originate_string
);
}
else
{
}
else
{
char
*
name_dup
=
strdup
(
node
->
name
);
if
(
node
->
outbound_name
)
{
if
((
p
=
strchr
(
name_dup
,
'@'
)))
{
originate_string
=
switch_mprintf
(
"{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q',"
*
p
=
'\0'
;
"origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s"
,
node
->
name
,
node
->
outbound_name
,
h
->
originate_string
);
}
else
{
originate_string
=
switch_mprintf
(
"{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q',"
"origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s"
,
node
->
name
,
node
->
name
,
h
->
originate_string
);
}
}
}
originate_string
=
switch_mprintf
(
"{execute_on_answer='unset fifo_hangup_check',fifo_hangup_check='%q',"
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
"origination_caller_id_name=Queue,origination_caller_id_number='fifo+%q'}%s"
,
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
node
->
name
,
name_dup
,
h
->
originate_string
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"pre-dial"
);
free
(
name_dup
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Outbound-UUID"
,
h
->
uuid
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"enterprise"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"originate_string"
,
originate_string
);
switch_event_fire
(
&
event
);
}
}
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
);
free
(
originate_string
);
free
(
originate_string
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"post-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Outbound-UUID"
,
h
->
uuid
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"enterprise"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"result"
,
"failure"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"cause"
,
switch_channel_cause2str
(
cause
));
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"originate_string"
,
originate_string
);
switch_event_fire
(
&
event
);
}
goto
end
;
goto
end
;
}
}
channel
=
switch_core_session_get_channel
(
session
);
channel
=
switch_core_session_get_channel
(
session
);
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"post-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Outbound-UUID"
,
h
->
uuid
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"enterprise"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"result"
,
"success"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"originate_string"
,
originate_string
);
switch_event_fire
(
&
event
);
}
if
((
member_wait
=
switch_channel_get_variable
(
channel
,
"fifo_member_wait"
))
||
(
member_wait
=
switch_channel_get_variable
(
channel
,
"member_wait"
)))
{
if
((
member_wait
=
switch_channel_get_variable
(
channel
,
"fifo_member_wait"
))
||
(
member_wait
=
switch_channel_get_variable
(
channel
,
"member_wait"
)))
{
if
(
strcasecmp
(
member_wait
,
"wait"
)
&&
strcasecmp
(
member_wait
,
"nowait"
))
{
if
(
strcasecmp
(
member_wait
,
"wait"
)
&&
strcasecmp
(
member_wait
,
"nowait"
))
{
member_wait
=
NULL
;
member_wait
=
NULL
;
...
@@ -2761,6 +2853,11 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -2761,6 +2853,11 @@ static switch_status_t load_config(int reload, int del_all)
if
(
!
(
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
name
)))
{
if
(
!
(
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
name
)))
{
node
=
create_node
(
name
,
imp
,
globals
.
sql_mutex
);
node
=
create_node
(
name
,
imp
,
globals
.
sql_mutex
);
}
}
if
((
val
=
switch_xml_attr
(
fifo
,
"outbound_name"
)))
{
node
->
outbound_name
=
switch_core_strdup
(
node
->
pool
,
val
);
}
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
switch_assert
(
node
);
switch_assert
(
node
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论