Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
916a75e9
提交
916a75e9
authored
10月 24, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
device state tweaks
上级
8ab31493
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
106 行增加
和
5 行删除
+106
-5
switch_core.h
src/include/switch_core.h
+22
-0
switch_channel.c
src/switch_channel.c
+84
-5
没有找到文件。
src/include/switch_core.h
浏览文件 @
916a75e9
...
...
@@ -82,18 +82,33 @@ typedef struct device_uuid_node_s {
switch_channel_callstate_t
callstate
;
switch_hold_record_t
*
hold_record
;
switch_caller_profile_t
*
hup_profile
;
switch_call_direction_t
direction
;
struct
switch_device_record_s
*
parent
;
struct
device_uuid_node_s
*
next
;
}
switch_device_node_t
;
typedef
struct
switch_device_stats_s
{
uint32_t
total
;
uint32_t
total_in
;
uint32_t
total_out
;
uint32_t
offhook
;
uint32_t
offhook_in
;
uint32_t
offhook_out
;
uint32_t
active
;
uint32_t
active_in
;
uint32_t
active_out
;
uint32_t
held
;
uint32_t
held_in
;
uint32_t
held_out
;
uint32_t
hup
;
uint32_t
hup_in
;
uint32_t
hup_out
;
uint32_t
ringing
;
uint32_t
ringing_in
;
uint32_t
ringing_out
;
uint32_t
early
;
uint32_t
early_in
;
uint32_t
early_out
;
}
switch_device_stats_t
;
...
...
@@ -102,15 +117,22 @@ typedef struct switch_device_record_s {
char
*
uuid
;
int
refs
;
switch_device_stats_t
stats
;
switch_device_stats_t
last_stats
;
switch_device_state_t
state
;
switch_device_state_t
last_state
;
switch_time_t
active_start
;
switch_time_t
active_stop
;
switch_time_t
last_call_time
;
switch_time_t
ring_start
;
switch_time_t
ring_stop
;
switch_time_t
hold_start
;
switch_time_t
hold_stop
;
switch_time_t
call_start
;
struct
device_uuid_node_s
*
uuid_list
;
struct
device_uuid_node_s
*
uuid_tail
;
switch_mutex_t
*
mutex
;
switch_memory_pool_t
*
pool
;
void
*
user_data
;
}
switch_device_record_t
;
typedef
void
(
*
switch_device_state_function_t
)(
switch_core_session_t
*
session
,
switch_channel_callstate_t
callstate
,
switch_device_record_t
*
drec
);
...
...
src/switch_channel.c
浏览文件 @
916a75e9
...
...
@@ -277,7 +277,11 @@ SWITCH_DECLARE(void) switch_channel_perform_set_callstate(switch_channel_t *chan
switch_channel_callstate2str
(
o_callstate
),
switch_channel_callstate2str
(
callstate
));
switch_channel_check_device_state
(
channel
,
channel
->
callstate
);
if
(
callstate
==
CCS_HANGUP
)
{
process_device_hup
(
channel
);
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CHANNEL_CALLSTATE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Original-Channel-Call-State"
,
switch_channel_callstate2str
(
o_callstate
));
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Call-State-Number"
,
"%d"
,
callstate
);
...
...
@@ -3137,8 +3141,6 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
channel
->
state
=
CS_HANGUP
;
switch_mutex_unlock
(
channel
->
state_mutex
);
process_device_hup
(
channel
);
channel
->
hangup_cause
=
hangup_cause
;
switch_log_printf
(
SWITCH_CHANNEL_ID_LOG
,
file
,
func
,
line
,
switch_channel_get_uuid
(
channel
),
SWITCH_LOG_NOTICE
,
"Hangup %s [%s] [%s]
\n
"
,
channel
->
name
,
state_names
[
last_state
],
switch_channel_cause2str
(
channel
->
hangup_cause
));
...
...
@@ -4664,28 +4666,64 @@ static void fetch_device_stats(switch_device_record_t *drec)
{
switch_device_node_t
*
np
;
memset
(
&
drec
->
stats
,
0
,
sizeof
(
switch_device_stats_t
));
switch_mutex_lock
(
drec
->
mutex
);
for
(
np
=
drec
->
uuid_list
;
np
;
np
=
np
->
next
)
{
drec
->
stats
.
total
++
;
if
(
np
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
drec
->
stats
.
total_in
++
;
}
else
{
drec
->
stats
.
total_out
++
;
}
if
(
!
np
->
hup_profile
)
{
drec
->
stats
.
offhook
++
;
if
(
np
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
drec
->
stats
.
offhook_in
++
;
}
else
{
drec
->
stats
.
offhook_out
++
;
}
if
(
np
->
callstate
==
CCS_HELD
)
{
drec
->
stats
.
held
++
;
if
(
np
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
drec
->
stats
.
held_in
++
;
}
else
{
drec
->
stats
.
held_out
++
;
}
}
else
{
if
(
np
->
callstate
==
CCS_EARLY
)
{
drec
->
stats
.
early
++
;
if
(
np
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
drec
->
stats
.
early_in
++
;
}
else
{
drec
->
stats
.
early_out
++
;
}
}
else
if
(
np
->
callstate
==
CCS_RINGING
)
{
drec
->
stats
.
ringing
++
;
if
(
np
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
drec
->
stats
.
ringing_in
++
;
}
else
{
drec
->
stats
.
ringing_out
++
;
}
}
else
if
(
np
->
callstate
!=
CCS_DOWN
)
{
drec
->
stats
.
active
++
;
if
(
np
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
drec
->
stats
.
active_in
++
;
}
else
{
drec
->
stats
.
active_out
++
;
}
}
}
}
else
{
drec
->
stats
.
hup
++
;
if
(
np
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
drec
->
stats
.
hup_in
++
;
}
else
{
drec
->
stats
.
hup_out
++
;
}
}
}
switch_mutex_unlock
(
drec
->
mutex
);
...
...
@@ -4826,7 +4864,7 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
drec
->
state
=
SDS_HANGUP
;
}
else
{
if
(
drec
->
stats
.
active
==
0
)
{
if
((
drec
->
stats
.
ringing
+
drec
->
stats
.
early
)
>
0
)
{
if
((
drec
->
stats
.
ringing
_out
+
drec
->
stats
.
early_out
)
>
0
)
{
drec
->
state
=
SDS_RINGING
;
}
else
{
if
(
drec
->
stats
.
held
>
0
)
{
...
...
@@ -4848,7 +4886,15 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
return
;
}
if
(
!
drec
->
call_start
)
{
drec
->
call_start
=
switch_micro_time_now
();
}
switch
(
drec
->
state
)
{
case
SDS_RINGING
:
drec
->
ring_start
=
switch_micro_time_now
();
drec
->
ring_stop
=
0
;
break
;
case
SDS_ACTIVE
:
case
SDS_ACTIVE_MULTI
:
if
(
drec
->
last_state
!=
SDS_HELD
&&
drec
->
active_start
)
{
...
...
@@ -4857,6 +4903,9 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
drec
->
active_start
=
switch_micro_time_now
();
}
break
;
case
SDS_HELD
:
drec
->
hold_start
=
switch_micro_time_now
();
drec
->
hold_stop
=
0
;
default
:
if
(
drec
->
last_state
!=
SDS_HELD
)
{
drec
->
active_stop
=
switch_micro_time_now
();
...
...
@@ -4864,6 +4913,15 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
break
;
}
if
(
drec
->
ring_start
&&
!
drec
->
ring_stop
&&
drec
->
state
!=
SDS_RINGING
)
{
drec
->
ring_stop
=
switch_micro_time_now
();
}
if
(
drec
->
hold_start
&&
!
drec
->
hold_stop
&&
drec
->
state
!=
SDS_HELD
)
{
drec
->
hold_stop
=
switch_micro_time_now
();
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_DEVICE_STATE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Device-ID"
,
drec
->
device_id
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Last-Device-State"
,
switch_channel_device_state2str
(
drec
->
last_state
));
...
...
@@ -4884,7 +4942,8 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
}
switch_log_printf
(
SWITCH_CHANNEL_CHANNEL_LOG
(
channel
),
SWITCH_LOG_DEBUG1
,
"%s device: %s
\n
State: %s Dev State: %s/%s Total:%u Offhook:%u Ringing:%u Early:%u Active:%u Held:%u Hungup:%u Dur: %u %s
\n
"
,
"%s device: %s
\n
State: %s Dev State: %s/%s Total:%u Offhook:%u "
"Ringing:%u Early:%u Active:%u Held:%u Hungup:%u Dur: %u Ringtime: %u Holdtime: %u %s
\n
"
,
switch_channel_get_name
(
channel
),
drec
->
device_id
,
switch_channel_callstate2str
(
callstate
),
...
...
@@ -4898,12 +4957,16 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
drec
->
stats
.
held
,
drec
->
stats
.
hup
,
drec
->
active_stop
?
(
uint32_t
)(
drec
->
active_stop
-
drec
->
active_start
)
/
1000
:
0
,
drec
->
ring_stop
?
(
uint32_t
)(
drec
->
ring_stop
-
drec
->
ring_start
)
/
1000
:
0
,
drec
->
hold_stop
?
(
uint32_t
)(
drec
->
hold_stop
-
drec
->
hold_start
)
/
1000
:
0
,
switch_channel_test_flag
(
channel
,
CF_FINAL_DEVICE_LEG
)
?
"FINAL LEG"
:
""
);
for
(
ptr
=
globals
.
device_bindings
;
ptr
;
ptr
=
ptr
->
next
)
{
ptr
->
function
(
channel
->
session
,
callstate
,
drec
);
}
drec
->
last_stats
=
drec
->
stats
;
if
(
drec
->
active_stop
)
{
drec
->
active_start
=
drec
->
active_stop
=
0
;
if
(
drec
->
state
==
SDS_ACTIVE
||
drec
->
state
==
SDS_ACTIVE_MULTI
)
{
...
...
@@ -4911,6 +4974,20 @@ static void switch_channel_check_device_state(switch_channel_t *channel, switch_
}
}
if
(
drec
->
hold_stop
)
{
drec
->
hold_start
=
drec
->
hold_stop
=
0
;
if
(
drec
->
state
==
SDS_HELD
)
{
drec
->
hold_start
=
switch_micro_time_now
();
}
}
if
(
drec
->
ring_stop
)
{
drec
->
ring_start
=
drec
->
ring_stop
=
0
;
if
(
drec
->
state
==
SDS_RINGING
)
{
drec
->
ring_start
=
switch_micro_time_now
();
}
}
drec
->
last_call_time
=
switch_micro_time_now
();
drec
->
last_state
=
drec
->
state
;
...
...
@@ -4938,6 +5015,8 @@ static void add_uuid(switch_device_record_t *drec, switch_channel_t *channel)
node
->
uuid
=
switch_core_strdup
(
drec
->
pool
,
switch_core_session_get_uuid
(
channel
->
session
));
node
->
parent
=
drec
;
node
->
callstate
=
channel
->
callstate
;
node
->
direction
=
channel
->
direction
==
SWITCH_CALL_DIRECTION_INBOUND
?
SWITCH_CALL_DIRECTION_OUTBOUND
:
SWITCH_CALL_DIRECTION_INBOUND
;
channel
->
device_node
=
node
;
if
(
!
drec
->
uuid_list
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论