Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
63359902
提交
63359902
authored
11月 09, 2010
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetdm: minor changes to ftmod_r2
上级
adc26e63
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
53 行增加
和
60 行删除
+53
-60
ftmod_r2.c
libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
+53
-60
没有找到文件。
libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
浏览文件 @
63359902
...
...
@@ -403,6 +403,7 @@ static void ftdm_r2_on_call_init(openr2_chan_t *r2chan)
if
(
ftdm_test_flag
(
ftdmchan
,
FTDM_CHANNEL_INUSE
))
{
ftdm_log_chan
(
ftdmchan
,
FTDM_LOG_CRIT
,
"Cannot start call when channel is in use (state = %s)
\n
"
,
ftdm_channel_state2str
(
ftdmchan
->
state
));
ftdm_mutex_unlock
(
ftdmchan
->
mutex
);
return
;
}
if
(
ftdmchan
->
state
!=
FTDM_CHANNEL_STATE_DOWN
)
{
...
...
@@ -436,9 +437,6 @@ static void ftdm_r2_on_call_init(openr2_chan_t *r2chan)
ftdm_set_state
(
ftdmchan
,
FTDM_CHANNEL_STATE_COLLECT
);
ftdm_mutex_unlock
(
ftdmchan
->
mutex
);
ftdm_log_chan_msg
(
ftdmchan
,
FTDM_LOG_DEBUG
,
"Span is not threaded, not launching thread for this call
\n
"
);
return
;
}
/* only called for incoming calls when the ANI, DNIS etc is complete and the user has to decide either to accept or reject the call */
...
...
@@ -447,9 +445,7 @@ static void ftdm_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, cons
ftdm_channel_t
*
ftdmchan
=
openr2_chan_get_client_data
(
r2chan
);
ftdm_log_chan
(
ftdmchan
,
FTDM_LOG_NOTICE
,
"Call offered with ANI = %s, DNIS = %s, Priority = (%d)
\n
"
,
ani
,
dnis
,
category
);
//ftdmchan->caller_data.priority = category;
ftdm_set_state_locked
(
ftdmchan
,
FTDM_CHANNEL_STATE_RING
);
}
static
void
ftdm_r2_on_call_accepted
(
openr2_chan_t
*
r2chan
,
openr2_call_mode_t
mode
)
...
...
@@ -602,8 +598,8 @@ static void ftdm_r2_on_line_idle(openr2_chan_t *r2chan)
ftdm_log_chan
(
ftdmchan
,
FTDM_LOG_NOTICE
,
"Far end unblocked in state %s
\n
"
,
ftdm_channel_state2str
(
ftdmchan
->
state
));
ftdm_clear_flag
(
ftdmchan
,
FTDM_CHANNEL_SUSPENDED
);
/* XXX when should we set/unset this flag? XXX */
ftdm_set_flag
(
ftdmchan
,
FTDM_CHANNEL_SIG_UP
);
/* XXX when should we set/unset this flag? XXX */
ftdm_set_flag
(
ftdmchan
,
FTDM_CHANNEL_SIG_UP
);
}
static
void
ftdm_r2_write_log
(
openr2_log_level_t
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
message
)
...
...
@@ -1116,7 +1112,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_r2_configure_span)
memset
(
r2call
,
0
,
sizeof
(
*
r2call
));
openr2_chan_set_logging_func
(
r2chan
,
ftdm_r2_on_chan_log
);
openr2_chan_set_client_data
(
r2chan
,
span
->
channels
[
i
]);
r2call
->
r2chan
=
r2chan
;
r2call
->
r2chan
=
r2chan
;
span
->
channels
[
i
]
->
call_data
=
r2call
;
/* value and key are the same so just free one of them */
snprintf
(
r2call
->
name
,
sizeof
(
r2call
->
name
),
"chancall%d"
,
i
);
...
...
@@ -1331,8 +1327,8 @@ static int ftdm_r2_state_advance(ftdm_channel_t *ftdmchan)
static
void
*
ftdm_r2_run
(
ftdm_thread_t
*
me
,
void
*
obj
)
{
openr2_chan_t
*
r2chan
;
ftdm_r2_call_t
*
r2call
=
NULL
;
ftdm_channel_t
*
ftdmchan
=
NULL
;
ftdm_r2_call_t
*
r2call
=
NULL
;
ftdm_channel_t
*
ftdmchan
=
NULL
;
ftdm_status_t
status
;
ftdm_span_t
*
span
=
(
ftdm_span_t
*
)
obj
;
ftdm_r2_data_t
*
r2data
=
span
->
signal_data
;
...
...
@@ -1368,16 +1364,14 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj)
}
#ifndef WIN32
/* figure out what event to poll each channel for. POLLPRI when the channel is down,
* POLLPRI|POLLIN|POLLOUT otherwise.
*/
memset
(
poll_events
,
0
,
sizeof
(
short
)
*
span
->
chan_count
);
for
(
i
=
0
;
i
<
span
->
chan_count
;
i
++
)
{
r2chan
=
R2CALL
(
span
->
channels
[(
i
+
1
)])
->
r2chan
;
ftdmchan
=
openr2_chan_get_client_data
(
r2chan
);
poll_events
[
i
]
=
ftdmchan
->
state
==
FTDM_CHANNEL_STATE_DOWN
?
POLLPRI
:
(
POLLPRI
|
POLLIN
|
POLLOUT
);
}
/* figure out what event to poll each channel for. POLLPRI when the channel is down,
* POLLPRI|POLLIN|POLLOUT otherwise */
memset
(
poll_events
,
0
,
sizeof
(
short
)
*
span
->
chan_count
);
for
(
i
=
0
;
i
<
span
->
chan_count
;
i
++
)
{
r2chan
=
R2CALL
(
span
->
channels
[(
i
+
1
)])
->
r2chan
;
ftdmchan
=
openr2_chan_get_client_data
(
r2chan
);
poll_events
[
i
]
=
ftdmchan
->
state
==
FTDM_CHANNEL_STATE_DOWN
?
POLLPRI
:
(
POLLPRI
|
POLLIN
|
POLLOUT
);
}
status
=
ftdm_span_poll_event
(
span
,
waitms
,
poll_events
);
#else
...
...
@@ -1394,62 +1388,61 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj)
continue
;
}
if
(
FTDM_SUCCESS
==
status
)
{
if
(
FTDM_SUCCESS
==
status
)
{
ftdm_event_t
*
event
;
while
(
ftdm_span_next_event
(
span
,
&
event
)
==
FTDM_SUCCESS
)
{
if
(
event
->
enum_id
==
FTDM_OOB_CAS_BITS_CHANGE
)
{
r2call
=
R2CALL
(
event
->
channel
);
r2chan
=
r2call
->
r2chan
;
r2call
=
R2CALL
(
event
->
channel
);
r2chan
=
r2call
->
r2chan
;
ftdm_log
(
FTDM_LOG_DEBUG
,
"Handling CAS on channel %d.
\n
"
,
openr2_chan_get_number
(
r2chan
));
// we only expect CAS and other OOB events on this thread/loop, once a call is started
// the MF events (in-band signaling) are handled in the call thread
openr2_chan_process_cas_signaling
(
r2chan
);
}
else
{
ftdm_log
(
FTDM_LOG_DEBUG
,
"Ignoring event %d on channel %d.
\n
"
,
event
->
enum_id
,
openr2_chan_get_number
(
r2chan
));
// XXX TODO: handle alarms here XXX
}
}
/* XXX
* when ftdm_span_poll_event() returns FTDM_SUCCESS, means there are events pending on the span.
* is it possible to know on which channels those events are pending, without trasver
ing the span?
* XXX
*/
for
(
i
=
1
;
i
<=
span
->
chan_count
;
i
++
)
{
r2chan
=
R2CALL
(
span
->
channels
[
i
])
->
r2chan
;
ftdmchan
=
openr2_chan_get_client_data
(
r2
chan
);
r2call
=
R2CALL
(
ftdmchan
);
ftdm_mutex_lock
(
ftdmchan
->
mutex
);
ftdm_set_flag
(
r2call
,
FTDM_R2_PROCESSING
);
if
(
ftdm_r2_state_advance
(
ftdmchan
))
{
ftdm_clear_flag
(
r2call
,
FTDM_R2_PROCESSING
);
ftdm_mutex_unlock
(
ftdmchan
->
mutex
)
;
continue
;
}
/* handle timeout events first if any */
openr2_chan_run_schedule
(
r2chan
);
/* process mf tones, if any */
if
(
openr2_chan_get_read_enabled
(
r2chan
))
openr2_chan_process_mf_signaling
(
r2chan
);
if
(
ftdm_r2_state_advance
(
ftdmchan
))
{
ftdm_clear_flag
(
r2call
,
FTDM_R2_PROCESSING
);
ftdm_mutex_unlock
(
ftdmchan
->
mutex
);
continue
;
}
ftdm_clear_flag
(
r2call
,
FTDM_R2_PROCESSING
);
ftdm_mutex_unlock
(
ftdmchan
->
mutex
);
}
/* XXX
* when ftdm_span_poll_event() returns FTDM_SUCCESS, means there are events pending on the span.
* is it possible to know on which channels those events are pending, without travers
ing the span?
* XXX */
for
(
i
=
1
;
i
<=
span
->
chan_count
;
i
++
)
{
r2chan
=
R2CALL
(
span
->
channels
[
i
])
->
r2chan
;
ftdmchan
=
openr2_chan_get_client_data
(
r2chan
)
;
r2call
=
R2CALL
(
ftdm
chan
);
ftdm_mutex_lock
(
ftdmchan
->
mutex
);
ftdm_set_flag
(
r2call
,
FTDM_R2_PROCESSING
);
if
(
ftdm_r2_state_advance
(
ftdmchan
))
{
ftdm_clear_flag
(
r2call
,
FTDM_R2_PROCESSING
);
ftdm_mutex_unlock
(
ftdmchan
->
mutex
);
continue
;
}
/* handle timeout events first if any */
openr2_chan_run_schedule
(
r2chan
);
/* process mf tones, if any */
if
(
openr2_chan_get_read_enabled
(
r2chan
))
{
openr2_chan_process_mf_signaling
(
r2chan
);
}
if
(
ftdm_r2_state_advance
(
ftdmchan
))
{
ftdm_clear_flag
(
r2call
,
FTDM_R2_PROCESSING
);
ftdm_mutex_unlock
(
ftdmchan
->
mutex
);
continue
;
}
ftdm_clear_flag
(
r2call
,
FTDM_R2_PROCESSING
);
ftdm_mutex_unlock
(
ftdmchan
->
mutex
);
}
}
else
if
(
status
!=
FTDM_TIMEOUT
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"ftdm_span_poll_event returned %d.
\n
"
,
status
);
}
}
ftdm_sleep
(
20
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论