Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
500be2a4
提交
500be2a4
authored
5月 25, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.openzap.org/svn/openzap/trunk@150
a93c3328-9c30-0410-af19-c9cd2b2d52af
上级
c2fd8a81
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
51 行增加
和
35 行删除
+51
-35
zap_types.h
libs/freetdm/src/include/zap_types.h
+3
-1
testanalog.c
libs/freetdm/src/testanalog.c
+9
-10
zap_analog.c
libs/freetdm/src/zap_analog.c
+3
-10
zap_io.c
libs/freetdm/src/zap_io.c
+18
-12
zap_wanpipe.c
libs/freetdm/src/zap_wanpipe.c
+18
-2
没有找到文件。
libs/freetdm/src/include/zap_types.h
浏览文件 @
500be2a4
...
...
@@ -69,9 +69,11 @@ typedef enum {
ZAP_TRUNK_T1
,
ZAP_TRUNK_J1
,
ZAP_TRUNK_BRI
,
ZAP_TRUNK_FXO
,
ZAP_TRUNK_FXS
,
ZAP_TRUNK_NONE
}
zap_trunk_type_t
;
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "NONE"
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "
FXO", "FXS", "
NONE"
ZAP_STR2ENUM_P
(
zap_str2zap_trunk_type
,
zap_trunk_type2str
,
zap_trunk_type_t
)
typedef
enum
{
...
...
libs/freetdm/src/testanalog.c
浏览文件 @
500be2a4
...
...
@@ -9,9 +9,9 @@ static void *test_call(zap_thread_t *me, void *obj)
zap_size_t
len
;
sleep
(
5
);
sleep
(
10
);
printf
(
"answer call
\n
"
);
zap_log
(
ZAP_LOG_DEBUG
,
"answer call and start echo test
\n
"
);
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_UP
);
...
...
@@ -24,7 +24,7 @@ static void *test_call(zap_thread_t *me, void *obj)
len
=
sizeof
(
frame
);
if
(
flags
&
ZAP_READ
)
{
if
(
zap_channel_read
(
chan
,
frame
,
&
len
)
==
ZAP_SUCCESS
)
{
//
printf(
"WRITE %d\n", len);
//
zap_log(ZAP_LOG_DEBUG,
"WRITE %d\n", len);
zap_channel_write
(
chan
,
frame
,
&
len
);
}
else
{
break
;
...
...
@@ -36,18 +36,18 @@ static void *test_call(zap_thread_t *me, void *obj)
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_BUSY
);
}
printf
(
"call over
\n
"
);
zap_log
(
ZAP_LOG_DEBUG
,
"call over
\n
"
);
}
static
ZIO_SIGNAL_CB_FUNCTION
(
on_signal
)
{
printf
(
"got sig [%s]
\n
"
,
zap_signal_event2str
(
sigmsg
->
event_id
));
zap_log
(
ZAP_LOG_DEBUG
,
"got sig [%s]
\n
"
,
zap_signal_event2str
(
sigmsg
->
event_id
));
switch
(
sigmsg
->
event_id
)
{
case
ZAP_SIGEVENT_START
:
zap_set_state_locked
(
sigmsg
->
channel
,
ZAP_CHANNEL_STATE_RING
);
printf
(
"launching thread and indicating ring
\n
"
);
zap_log
(
ZAP_LOG_DEBUG
,
"launching thread and indicating ring
\n
"
);
zap_thread_create_detached
(
test_call
,
sigmsg
->
channel
);
break
;
default:
...
...
@@ -64,17 +64,16 @@ int main(int argc, char *argv[])
zap_global_set_default_logger
(
ZAP_LOG_LEVEL_DEBUG
);
if
(
zap_global_init
()
!=
ZAP_SUCCESS
)
{
fprintf
(
stderr
,
"Error loading OpenZAP
\n
"
);
zap_log
(
ZAP_LOG_ERROR
,
"Error loading OpenZAP
\n
"
);
exit
(
-
1
);
}
printf
(
"OpenZAP loaded
\n
"
);
zap_log
(
ZAP_LOG_DEBUG
,
"OpenZAP loaded
\n
"
);
if
(
zap_span_find
(
"wanpipe"
,
1
,
&
span
)
!=
ZAP_SUCCESS
)
{
fprintf
(
stderr
,
"Error finding OpenZAP span
\n
"
);
zap_log
(
ZAP_LOG_ERROR
,
"Error finding OpenZAP span
\n
"
);
}
zap_analog_configure_span
(
span
,
"us"
,
2000
,
11
,
on_signal
);
zap_analog_start
(
span
);
...
...
libs/freetdm/src/zap_analog.c
浏览文件 @
500be2a4
...
...
@@ -110,18 +110,10 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
}
zap_set_flag_locked
(
chan
,
ZAP_CHANNEL_INTHREAD
);
teletone_init_session
(
&
ts
,
0
,
teletone_handler
,
dt_buffer
);
#if 0
ts.debug = 1;
ts.debug_stream = stdout;
#endif
ts
.
rate
=
8000
;
zap_channel_command
(
chan
,
ZAP_COMMAND_GET_CODEC
,
&
old_codec
);
zap_channel_command
(
chan
,
ZAP_COMMAND_GET_INTERVAL
,
&
interval
);
zap_buffer_set_loops
(
dt_buffer
,
-
1
);
while
(
zap_test_flag
(
chan
,
ZAP_CHANNEL_INTHREAD
))
{
...
...
@@ -132,7 +124,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
elapsed
+=
interval
;
state_counter
+=
interval
;
XX
printf
(
"WTF %s %s
\n
"
,
zap_channel_state2str
(
chan
->
state
),
zap_channel_state2str
(
chan
->
last_state
));
if
(
!
zap_test_flag
(
chan
,
ZAP_CHANNEL_STATE_CHANGE
))
{
switch
(
chan
->
state
)
{
case
ZAP_CHANNEL_STATE_DIALTONE
:
...
...
@@ -152,7 +144,8 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
case
ZAP_CHANNEL_STATE_UP
:
case
ZAP_CHANNEL_STATE_IDLE
:
{
zap_sleep
(
interval
*
1000
);
zap_sleep
(
interval
);
continue
;
}
break
;
default:
...
...
libs/freetdm/src/zap_io.c
浏览文件 @
500be2a4
...
...
@@ -212,6 +212,7 @@ zap_status_t zap_span_create(zap_io_interface_t *zio, zap_span_t **span)
zap_copy_string
(
new_span
->
tone_map
[
ZAP_TONEMAP_RING
],
"%(2000,4000,440,480)"
,
ZAP_TONEMAP_LEN
);
zap_copy_string
(
new_span
->
tone_map
[
ZAP_TONEMAP_BUSY
],
"%(500,500,480,620)"
,
ZAP_TONEMAP_LEN
);
zap_copy_string
(
new_span
->
tone_map
[
ZAP_TONEMAP_ATTN
],
"%(100,100,1400,2060,2450,2600)"
,
ZAP_TONEMAP_LEN
);
new_span
->
trunk_type
=
ZAP_TRUNK_NONE
;
*
span
=
new_span
;
return
ZAP_SUCCESS
;
}
...
...
@@ -363,9 +364,9 @@ zap_status_t zap_span_next_event(zap_span_t *span, zap_event_t **event)
zap_status_t
zap_channel_set_event_callback
(
zap_channel_t
*
zchan
,
zio_event_cb_t
event_callback
)
{
zap_mutex_lock
(
zchan
->
span
->
mutex
);
zap_mutex_lock
(
zchan
->
mutex
);
zchan
->
event_callback
=
event_callback
;
zap_mutex_unlock
(
zchan
->
span
->
mutex
);
zap_mutex_unlock
(
zchan
->
mutex
);
return
ZAP_SUCCESS
;
}
...
...
@@ -504,15 +505,17 @@ static zap_status_t zap_channel_reset(zap_channel_t *zchan)
zap_status_t
zap_channel_open_chan
(
zap_channel_t
*
zchan
)
{
zap_status_t
status
=
ZAP_FAIL
;
zap_mutex_lock
(
zchan
->
span
->
mutex
);
if
((
status
=
zap_mutex_trylock
(
zchan
->
mutex
))
!=
ZAP_SUCCESS
)
{
return
status
;
}
if
(
zap_test_flag
(
zchan
,
ZAP_CHANNEL_READY
)
&&
!
zap_test_flag
(
zchan
,
ZAP_CHANNEL_OPEN
))
{
status
=
zchan
->
span
->
zio
->
open
(
zchan
);
if
(
status
==
ZAP_SUCCESS
)
{
zap_set_flag
(
zchan
,
ZAP_CHANNEL_OPEN
);
}
}
zap_mutex_unlock
(
zchan
->
span
->
mutex
);
zap_mutex_unlock
(
zchan
->
mutex
);
return
status
;
}
...
...
@@ -528,9 +531,12 @@ zap_status_t zap_channel_open(const char *name, uint32_t span_id, uint32_t chan_
if
(
span_id
<
ZAP_MAX_SPANS_INTERFACE
&&
chan_id
<
ZAP_MAX_CHANNELS_SPAN
&&
zio
)
{
zap_channel_t
*
check
;
zap_mutex_lock
(
zio
->
spans
[
span_id
].
mutex
);
check
=
&
zio
->
spans
[
span_id
].
channels
[
chan_id
];
if
((
status
=
zap_mutex_trylock
(
check
->
mutex
))
!=
ZAP_SUCCESS
)
{
return
status
;
}
if
(
zap_test_flag
(
check
,
ZAP_CHANNEL_READY
)
&&
!
zap_test_flag
(
check
,
ZAP_CHANNEL_OPEN
))
{
status
=
check
->
zio
->
open
(
check
);
if
(
status
==
ZAP_SUCCESS
)
{
...
...
@@ -538,7 +544,7 @@ zap_status_t zap_channel_open(const char *name, uint32_t span_id, uint32_t chan_
*
zchan
=
check
;
}
}
zap_mutex_unlock
(
zio
->
spans
[
span_id
].
mutex
);
zap_mutex_unlock
(
check
->
mutex
);
}
return
status
;
...
...
@@ -554,7 +560,7 @@ zap_status_t zap_channel_close(zap_channel_t **zchan)
assert
(
check
!=
NULL
);
*
zchan
=
NULL
;
zap_mutex_lock
(
check
->
span
->
mutex
);
zap_mutex_lock
(
check
->
mutex
);
if
(
zap_test_flag
(
check
,
ZAP_CHANNEL_OPEN
))
{
status
=
check
->
zio
->
close
(
check
);
if
(
status
==
ZAP_SUCCESS
)
{
...
...
@@ -563,7 +569,7 @@ zap_status_t zap_channel_close(zap_channel_t **zchan)
}
}
zap_mutex_unlock
(
check
->
span
->
mutex
);
zap_mutex_unlock
(
check
->
mutex
);
return
status
;
}
...
...
@@ -613,7 +619,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
return
ZAP_FAIL
;
}
zap_mutex_lock
(
zchan
->
span
->
mutex
);
zap_mutex_lock
(
zchan
->
mutex
);
switch
(
command
)
{
case
ZAP_COMMAND_SET_INTERVAL
:
...
...
@@ -774,7 +780,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
status
=
zchan
->
zio
->
command
(
zchan
,
command
,
obj
);
done:
zap_mutex_unlock
(
zchan
->
span
->
mutex
);
zap_mutex_unlock
(
zchan
->
mutex
);
return
status
;
}
...
...
libs/freetdm/src/zap_wanpipe.c
浏览文件 @
500be2a4
...
...
@@ -228,9 +228,25 @@ static ZIO_CONFIGURE_FUNCTION(wanpipe_configure)
span
->
trunk_type
=
zap_str2zap_trunk_type
(
val
);
zap_log
(
ZAP_LOG_DEBUG
,
"setting trunk type to '%s'
\n
"
,
zap_trunk_type2str
(
span
->
trunk_type
));
}
else
if
(
!
strcasecmp
(
var
,
"fxo-channel"
))
{
configured
+=
wp_configure_channel
(
&
cfg
,
val
,
span
,
ZAP_CHAN_TYPE_FXO
);
if
(
span
->
trunk_type
==
ZAP_TRUNK_NONE
)
{
span
->
trunk_type
=
ZAP_TRUNK_FXO
;
zap_log
(
ZAP_LOG_DEBUG
,
"setting trunk type to '%s'
\n
"
,
zap_trunk_type2str
(
span
->
trunk_type
));
}
if
(
span
->
trunk_type
==
ZAP_TRUNK_FXO
)
{
configured
+=
wp_configure_channel
(
&
cfg
,
val
,
span
,
ZAP_CHAN_TYPE_FXO
);
}
else
{
zap_log
(
ZAP_LOG_WARNING
,
"Cannot add FXO channels to an FXS trunk!
\n
"
);
}
}
else
if
(
!
strcasecmp
(
var
,
"fxs-channel"
))
{
configured
+=
wp_configure_channel
(
&
cfg
,
val
,
span
,
ZAP_CHAN_TYPE_FXS
);
if
(
span
->
trunk_type
==
ZAP_TRUNK_NONE
)
{
span
->
trunk_type
=
ZAP_TRUNK_FXS
;
zap_log
(
ZAP_LOG_DEBUG
,
"setting trunk type to '%s'
\n
"
,
zap_trunk_type2str
(
span
->
trunk_type
));
}
if
(
span
->
trunk_type
==
ZAP_TRUNK_FXS
)
{
configured
+=
wp_configure_channel
(
&
cfg
,
val
,
span
,
ZAP_CHAN_TYPE_FXS
);
}
else
{
zap_log
(
ZAP_LOG_WARNING
,
"Cannot add FXS channels to an FXO trunk!
\n
"
);
}
}
else
if
(
!
strcasecmp
(
var
,
"b-channel"
))
{
configured
+=
wp_configure_channel
(
&
cfg
,
val
,
span
,
ZAP_CHAN_TYPE_B
);
}
else
if
(
!
strcasecmp
(
var
,
"d-channel"
))
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论