Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
85d2395d
提交
85d2395d
authored
12月 01, 2010
作者:
Arnaldo Pereira
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetdm: ftmod_r2 - now clearing FTDM_CHANNEL_STATE_CHANGE flag when needed
上级
3934682e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
41 行增加
和
13 行删除
+41
-13
ftmod_r2.c
libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
+41
-13
没有找到文件。
libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
浏览文件 @
85d2395d
...
...
@@ -56,15 +56,10 @@ typedef enum {
FTDM_R2_RUNNING
=
(
1
<<
0
),
}
ftdm_r2_flag_t
;
typedef
enum
{
FTDM_R2_WAITING_ACK
=
(
1
<<
0
),
}
ftdm_r2_call_flag_t
;
/* private call information stored in ftdmchan->call_data void* ptr */
#define R2CALL(ftdmchan) ((ftdm_r2_call_t*)((ftdmchan)->call_data))
typedef
struct
ftdm_r2_call_t
{
openr2_chan_t
*
r2chan
;
ftdm_r2_call_flag_t
flags
;
int
accepted
:
1
;
int
answer_pending
:
1
;
int
disconnect_rcvd
:
1
;
...
...
@@ -154,6 +149,12 @@ static ftdm_io_interface_t g_ftdm_r2_interface;
static
int
ftdm_r2_state_advance
(
ftdm_channel_t
*
ftdmchan
);
static
void
ftdm_r2_state_advance_all
(
ftdm_channel_t
*
ftdmchan
);
/* whether R2 call accept process is pending */
#define IS_ACCEPTING_PENDING(ftdmchan) \
( (!ftdm_test_flag((ftdmchan), FTDM_CHANNEL_OUTBOUND)) && !R2CALL((ftdmchan))->accepted && \
((ftdmchan)->state == FTDM_CHANNEL_STATE_PROGRESS || \
(ftdmchan)->state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA || \
(ftdmchan)->state == FTDM_CHANNEL_STATE_UP) )
/* functions not available on windows */
#ifdef WIN32
...
...
@@ -374,7 +375,6 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(r2_outgoing_call)
if
(
ftdmchan
->
state
!=
FTDM_CHANNEL_STATE_DIALING
)
{
ftdm_log_chan
(
ftdmchan
,
FTDM_LOG_WARNING
,
"Collision after call attempt, try another channel, new state = %s
\n
"
,
ftdm_channel_state2str
(
ftdmchan
->
state
));
ftdm_clear_flag
(
R2CALL
(
ftdmchan
),
FTDM_R2_WAITING_ACK
);
return
FTDM_BREAK
;
}
...
...
@@ -451,16 +451,43 @@ static void ftdm_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, cons
ftdm_set_state_locked
(
ftdmchan
,
FTDM_CHANNEL_STATE_RING
);
}
/*
* Accepting a call in R2 is a lengthy process due to MF tones,
* when the user sends PROGRESS indication (implicitly moving the
* ftdm channel to PROGRESS state) the R2 processing loop
* does not clear FTDM_CHANNEL_STATE_CHANGE immediately as it does
* for all the other states, instead has to wait for on_call_accepted
* callback from openr2, which means the MF has ended and the progress
* indication is done, in order to clear the flag. However, if
* a protocol error or call disconnection (which is indicated using CAS bits)
* occurrs while accepting, we must clear the pending flag, this function
* takes care of that
* */
static
void
clear_accept_pending
(
ftdm_channel_t
*
fchan
)
{
if
(
IS_ACCEPTING_PENDING
(
fchan
))
{
ftdm_clear_flag
(
fchan
,
FTDM_CHANNEL_STATE_CHANGE
);
ftdm_channel_complete_state
(
fchan
);
}
else
if
(
ftdm_test_flag
(
fchan
,
FTDM_CHANNEL_STATE_CHANGE
))
{
ftdm_log_chan
(
fchan
,
FTDM_LOG_CRIT
,
"State change flag set in state %s, last state = %s
\n
"
,
ftdm_channel_state2str
(
fchan
->
state
),
ftdm_channel_state2str
(
fchan
->
last_state
));
ftdm_clear_flag
(
fchan
,
FTDM_CHANNEL_STATE_CHANGE
);
ftdm_channel_complete_state
(
fchan
);
}
}
static
void
ftdm_r2_on_call_accepted
(
openr2_chan_t
*
r2chan
,
openr2_call_mode_t
mode
)
{
ftdm_channel_t
*
ftdmchan
=
openr2_chan_get_client_data
(
r2chan
);
ftdm_log_chan_msg
(
ftdmchan
,
FTDM_LOG_NOTICE
,
"Call accepted
\n
"
);
clear_accept_pending
(
ftdmchan
);
/* at this point the MF signaling has ended and there is no point on keep reading */
openr2_chan_disable_read
(
r2chan
);
R2CALL
(
ftdmchan
)
->
accepted
=
1
;
if
(
OR2_DIR_BACKWARD
==
openr2_chan_get_direction
(
r2chan
))
{
ftdm_clear_flag
(
ftdmchan
,
FTDM_CHANNEL_STATE_CHANGE
);
ftdm_channel_complete_state
(
ftdmchan
);
if
(
R2CALL
(
ftdmchan
)
->
answer_pending
)
{
ftdm_log_chan_msg
(
ftdmchan
,
FTDM_LOG_DEBUG
,
"Answer was pending, answering now.
\n
"
);
ft_r2_answer_call
(
ftdmchan
);
...
...
@@ -493,6 +520,8 @@ static void ftdm_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_discon
ftdm_log_chan_msg
(
ftdmchan
,
FTDM_LOG_DEBUG
,
"Got openr2 disconnection, clearing call
\n
"
);
clear_accept_pending
(
ftdmchan
);
R2CALL
(
ftdmchan
)
->
disconnect_rcvd
=
1
;
if
(
ftdmchan
->
state
==
FTDM_CHANNEL_STATE_HANGUP
)
{
...
...
@@ -564,6 +593,8 @@ static void ftdm_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_err
ftdm_log_chan_msg
(
ftdmchan
,
FTDM_LOG_ERROR
,
"Protocol error
\n
"
);
clear_accept_pending
(
ftdmchan
);
R2CALL
(
ftdmchan
)
->
disconnect_rcvd
=
1
;
R2CALL
(
ftdmchan
)
->
protocol_error
=
1
;
...
...
@@ -1204,12 +1235,9 @@ static int ftdm_r2_state_advance(ftdm_channel_t *ftdmchan)
ftdm_log_chan
(
ftdmchan
,
FTDM_LOG_DEBUG
,
"Executing state handler for %s
\n
"
,
ftdm_channel_state2str
(
ftdmchan
->
state
));
R2CALL
(
ftdmchan
)
->
chanstate
=
ftdmchan
->
state
;
if
(
!
ftdm_test_flag
(
ftdmchan
,
FTDM_CHANNEL_OUTBOUND
)
&&
!
R2CALL
(
ftdmchan
)
->
accepted
&&
(
ftdmchan
->
state
==
FTDM_CHANNEL_STATE_PROGRESS
||
ftdmchan
->
state
==
FTDM_CHANNEL_STATE_PROGRESS_MEDIA
||
ftdmchan
->
state
==
FTDM_CHANNEL_STATE_UP
)
)
{
if
(
IS_ACCEPTING_PENDING
(
ftdmchan
))
{
/*
Moving to PROGRESS, PROGRESS_MEDIA or UP means that we must accept the call, and accepting
Moving to PROGRESS, PROGRESS_MEDIA or UP means that we must accept the call
first
, and accepting
the call in R2 means sending a tone, then waiting for the acknowledge from the other end,
since all of that requires sending and detecting tones, it takes a few milliseconds (I'd say around 100)
which means during that time the user should not try to perform any operations like answer, hangup or anything
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论