Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
43b18e4e
提交
43b18e4e
authored
6月 01, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.openzap.org/svn/openzap/trunk@192
a93c3328-9c30-0410-af19-c9cd2b2d52af
上级
943586b1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
77 行增加
和
57 行删除
+77
-57
openzap.h
libs/freetdm/src/include/openzap.h
+6
-3
zap_types.h
libs/freetdm/src/include/zap_types.h
+4
-1
zap_analog.c
libs/freetdm/src/zap_analog.c
+29
-35
zap_io.c
libs/freetdm/src/zap_io.c
+38
-18
没有找到文件。
libs/freetdm/src/include/openzap.h
浏览文件 @
43b18e4e
...
...
@@ -261,12 +261,13 @@ struct zap_channel {
teletone_generation_session_t
tone_session
;
zap_time_t
last_event_time
;
char
tokens
[
ZAP_MAX_TOKENS
+
1
][
ZAP_TOKEN_STRLEN
];
uint8_t
need_tone
[
ZAP_TONEMAP_INVALID
+
1
];
uint8_t
needed_tones
[
ZAP_TONEMAP_INVALID
];
uint8_t
detected_tones
[
ZAP_TONEMAP_INVALID
];
zap_tonemap_t
last_detected_tone
;
uint32_t
token_count
;
char
chan_name
[
128
];
char
chan_number
[
32
];
zap_tonemap_t
detected_tone
;
zap_tonemap_t
last_detected_tone
;
struct
zap_caller_data
caller_data
;
struct
zap_span
*
span
;
struct
zap_io_interface
*
zio
;
...
...
@@ -341,6 +342,8 @@ struct zap_io_interface {
zap_status_t
zap_channel_outgoing_call
(
zap_channel_t
*
zchan
);
void
zap_channel_rotate_tokens
(
zap_channel_t
*
zchan
);
void
zap_channel_clear_detected_tones
(
zap_channel_t
*
zchan
);
void
zap_channel_clear_needed_tones
(
zap_channel_t
*
zchan
);
zap_status_t
zap_channel_clear_token
(
zap_channel_t
*
zchan
,
int32_t
token_id
);
zap_status_t
zap_channel_add_token
(
zap_channel_t
*
zchan
,
char
*
token
);
zap_status_t
zap_channel_set_state
(
zap_channel_t
*
zchan
,
zap_channel_state_t
state
);
...
...
libs/freetdm/src/include/zap_types.h
浏览文件 @
43b18e4e
...
...
@@ -61,10 +61,13 @@ typedef enum {
ZAP_TONEMAP_DIAL
,
ZAP_TONEMAP_RING
,
ZAP_TONEMAP_BUSY
,
ZAP_TONEMAP_FAIL1
,
ZAP_TONEMAP_FAIL2
,
ZAP_TONEMAP_FAIL3
,
ZAP_TONEMAP_ATTN
,
ZAP_TONEMAP_INVALID
}
zap_tonemap_t
;
#define TONEMAP_STRINGS "NONE", "DIAL", "RING", "BUSY", "ATTN", "INVALID"
#define TONEMAP_STRINGS "NONE", "DIAL", "RING", "BUSY", "
FAIL1", "FAIL2", "FAIL3", "
ATTN", "INVALID"
ZAP_STR2ENUM_P
(
zap_str2zap_tonemap
,
zap_tonemap2str
,
zap_tonemap_t
)
typedef
enum
{
...
...
libs/freetdm/src/zap_analog.c
浏览文件 @
43b18e4e
...
...
@@ -41,7 +41,7 @@ static ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(analog_fxo_outgoing_call)
if
(
!
zap_test_flag
(
zchan
,
ZAP_CHANNEL_OFFHOOK
)
&&
!
zap_test_flag
(
zchan
,
ZAP_CHANNEL_INTHREAD
))
{
zap_channel_command
(
zchan
,
ZAP_COMMAND_OFFHOOK
,
NULL
);
zap_channel_command
(
zchan
,
ZAP_COMMAND_ENABLE_PROGRESS_DETECT
,
NULL
);
zchan
->
need
_tone
[
ZAP_TONEMAP_DIAL
]
=
1
;
zchan
->
need
ed_tones
[
ZAP_TONEMAP_DIAL
]
=
1
;
zap_set_state_locked
(
zchan
,
ZAP_CHANNEL_STATE_DIALING
);
zap_thread_create_detached
(
zap_analog_channel_run
,
zchan
);
return
ZAP_SUCCESS
;
...
...
@@ -118,10 +118,9 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
zap_size_t
dtmf_offset
=
0
;
zap_analog_data_t
*
data
=
chan
->
span
->
analog_data
;
zap_channel_t
*
closed_chan
;
uint32_t
state_counter
=
0
,
elapsed
=
0
,
interval
=
0
,
last_digit
=
0
,
indicate
=
0
;
uint32_t
state_counter
=
0
,
elapsed
=
0
,
interval
=
0
,
last_digit
=
0
,
indicate
=
0
,
dial_timeout
=
30000
;
zap_sigmsg_t
sig
;
zap_status_t
status
;
zap_log
(
ZAP_LOG_DEBUG
,
"ANALOG CHANNEL thread starting.
\n
"
);
...
...
@@ -167,8 +166,8 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
switch
(
chan
->
state
)
{
case
ZAP_CHANNEL_STATE_DIALING
:
{
if
(
state_counter
>
5000
)
{
if
(
chan
->
need
_tone
[
ZAP_TONEMAP_DIAL
])
{
if
(
state_counter
>
dial_timeout
)
{
if
(
chan
->
need
ed_tones
[
ZAP_TONEMAP_DIAL
])
{
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_BUSY
);
}
else
{
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_UP
);
...
...
@@ -235,6 +234,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
case
ZAP_CHANNEL_STATE_UP
:
{
zap_channel_use
(
chan
);
zap_channel_clear_needed_tones
(
chan
);
if
(
chan
->
type
==
ZAP_CHAN_TYPE_FXO
&&
!
zap_test_flag
(
chan
,
ZAP_CHANNEL_OFFHOOK
))
{
zap_channel_command
(
chan
,
ZAP_COMMAND_OFFHOOK
,
NULL
);
...
...
@@ -352,45 +352,39 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
goto
done
;
}
if
(
chan
->
detected_tone
)
{
if
(
chan
->
type
==
ZAP_CHAN_TYPE_FXO
&&
chan
->
detected_tones
[
0
]
)
{
zap_sigmsg_t
sig
;
int
i
;
memset
(
&
sig
,
0
,
sizeof
(
sig
));
sig
.
chan_id
=
chan
->
chan_id
;
sig
.
span_id
=
chan
->
span_id
;
sig
.
channel
=
chan
;
sig
.
event_id
=
ZAP_SIGEVENT_TONE_DETECTED
;
zap_log
(
ZAP_LOG_DEBUG
,
"Detected tone %s
\n
"
,
zap_tonemap2str
(
chan
->
detected_tone
));
data
->
sig_cb
(
&
sig
);
if
(
chan
->
type
==
ZAP_CHAN_TYPE_FXO
)
{
if
(
chan
->
need_tone
[
chan
->
detected_tone
])
{
switch
(
chan
->
detected_tone
)
{
case
ZAP_TONEMAP_DIAL
:
{
zap_channel_command
(
chan
,
ZAP_COMMAND_SEND_DTMF
,
chan
->
caller_data
.
ani
);
state_counter
=
0
;
chan
->
need_tone
[
ZAP_TONEMAP_RING
]
=
1
;
chan
->
need_tone
[
ZAP_TONEMAP_BUSY
]
=
1
;
}
break
;
case
ZAP_TONEMAP_RING
:
{
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_UP
);
}
break
;
case
ZAP_TONEMAP_BUSY
:
{
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_BUSY
);
}
break
;
default:
break
;
}
chan
->
need_tone
[
chan
->
detected_tone
]
=
0
;
for
(
i
=
1
;
i
<
ZAP_TONEMAP_INVALID
;
i
++
)
{
if
(
chan
->
detected_tones
[
i
])
{
zap_log
(
ZAP_LOG_DEBUG
,
"Detected tone %s
\n
"
,
zap_tonemap2str
(
chan
->
detected_tones
[
i
]));
sig
.
raw_data
=
&
i
;
data
->
sig_cb
(
&
sig
);
}
}
chan
->
detected_tone
=
0
;
if
(
chan
->
detected_tones
[
ZAP_TONEMAP_DIAL
])
{
zap_channel_command
(
chan
,
ZAP_COMMAND_SEND_DTMF
,
chan
->
caller_data
.
ani
);
state_counter
=
0
;
chan
->
needed_tones
[
ZAP_TONEMAP_RING
]
=
1
;
chan
->
needed_tones
[
ZAP_TONEMAP_BUSY
]
=
1
;
chan
->
needed_tones
[
ZAP_TONEMAP_FAIL1
]
=
1
;
chan
->
needed_tones
[
ZAP_TONEMAP_FAIL2
]
=
1
;
chan
->
needed_tones
[
ZAP_TONEMAP_FAIL3
]
=
1
;
dial_timeout
=
(
chan
->
dtmf_on
+
chan
->
dtmf_off
)
*
strlen
(
chan
->
caller_data
.
ani
)
+
50
;
}
else
if
(
chan
->
detected_tones
[
ZAP_TONEMAP_RING
])
{
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_UP
);
}
else
if
(
chan
->
detected_tones
[
ZAP_TONEMAP_BUSY
])
{
zap_set_state_locked
(
chan
,
ZAP_CHANNEL_STATE_BUSY
);
}
zap_channel_clear_detected_tones
(
chan
);
}
if
(
chan
->
dtmf_buffer
&&
zap_buffer_inuse
(
chan
->
dtmf_buffer
))
{
...
...
libs/freetdm/src/zap_io.c
浏览文件 @
43b18e4e
...
...
@@ -269,19 +269,27 @@ zap_status_t zap_span_load_tones(zap_span_t *span, char *mapname)
}
while
(
zap_config_next_pair
(
&
cfg
,
&
var
,
&
val
))
{
int
detect
=
0
;
if
(
!
strcasecmp
(
cfg
.
category
,
mapname
)
&&
var
&&
val
)
{
int
index
=
zap_str2zap_tonemap
(
var
);
char
valbuf
[
512
];
uint32_t
index
;
char
*
mapname
;
if
(
!
strncasecmp
(
var
,
"detect-"
,
7
))
{
mapname
=
var
+
7
;
detect
=
1
;
}
else
if
(
!
strncasecmp
(
var
,
"generate-"
,
9
))
{
mapname
=
var
+
9
;
}
index
=
zap_str2zap_tonemap
(
mapname
);
if
(
index
>
ZAP_TONEMAP_INVALID
||
index
==
ZAP_TONEMAP_NONE
)
{
zap_log
(
ZAP_LOG_WARNING
,
"Unknown tone name %s
\n
"
,
var
);
if
(
index
>
=
ZAP_TONEMAP_INVALID
||
index
==
ZAP_TONEMAP_NONE
)
{
zap_log
(
ZAP_LOG_WARNING
,
"Unknown tone name %s
\n
"
,
mapname
);
}
else
{
char
*
p
,
*
next
;
int
i
=
0
;
zap_set_string
(
valbuf
,
val
);
val
=
valbuf
;
if
((
p
=
strchr
(
val
,
':'
)))
{
*
p
++
=
'\0'
;
if
(
detect
)
{
char
*
p
=
val
,
*
next
;
int
i
=
0
;
do
{
teletone_process_t
this
;
next
=
strchr
(
p
,
','
);
...
...
@@ -291,12 +299,11 @@ zap_status_t zap_span_load_tones(zap_span_t *span, char *mapname)
p
=
next
+
1
;
}
}
while
(
next
);
zap_log
(
ZAP_LOG_DEBUG
,
"added tone detect [%s] = [%s]
\n
"
,
mapname
,
val
);
}
else
{
zap_log
(
ZAP_LOG_DEBUG
,
"added tone generation [%s] = [%s]
\n
"
,
mapname
,
val
);
zap_copy_string
(
span
->
tone_map
[
index
],
val
,
sizeof
(
span
->
tone_map
[
index
]));
}
zap_log
(
ZAP_LOG_DEBUG
,
"added tone [%s] = [%s]
\n
"
,
var
,
val
);
zap_copy_string
(
span
->
tone_map
[
index
],
val
,
sizeof
(
span
->
tone_map
[
index
]));
x
++
;
}
}
...
...
@@ -848,6 +855,8 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
case
ZAP_COMMAND_DISABLE_PROGRESS_DETECT
:
{
zap_clear_flag_locked
(
zchan
,
ZAP_CHANNEL_PROGRESS_DETECT
);
zap_channel_clear_detected_tones
(
zchan
);
zap_channel_clear_needed_tones
(
zchan
);
GOTO_STATUS
(
done
,
ZAP_SUCCESS
);
}
break
;
...
...
@@ -1121,6 +1130,16 @@ ZIO_CODEC_FUNCTION(zio_alaw2ulaw)
/******************************/
void
zap_channel_clear_detected_tones
(
zap_channel_t
*
zchan
)
{
memset
(
zchan
->
detected_tones
,
0
,
sizeof
(
zchan
->
detected_tones
[
0
])
*
ZAP_TONEMAP_INVALID
);
}
void
zap_channel_clear_needed_tones
(
zap_channel_t
*
zchan
)
{
memset
(
zchan
->
needed_tones
,
0
,
sizeof
(
zchan
->
needed_tones
[
0
])
*
ZAP_TONEMAP_INVALID
);
}
zap_size_t
zap_channel_dequeue_dtmf
(
zap_channel_t
*
zchan
,
char
*
dtmf
,
zap_size_t
len
)
{
zap_size_t
bytes
=
0
;
...
...
@@ -1251,11 +1270,12 @@ zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *data
if
(
zap_test_flag
(
zchan
,
ZAP_CHANNEL_PROGRESS_DETECT
))
{
uint32_t
i
;
for
(
i
=
0
;
i
<
ZAP_TONEMAP_INVALID
+
1
;
i
++
)
{
for
(
i
=
1
;
i
<
ZAP_TONEMAP_INVALID
;
i
++
)
{
if
(
zchan
->
span
->
tone_finder
[
i
].
tone_count
)
{
if
(
teletone_multi_tone_detect
(
&
zchan
->
span
->
tone_finder
[
i
],
sln
,
(
int
)
slen
)
&&
i
!=
zchan
->
last_detected_tone
)
{
zchan
->
detected_tone
=
i
;
zchan
->
last_detected_tone
=
i
;
if
(
zchan
->
needed_tones
[
i
]
&&
teletone_multi_tone_detect
(
&
zchan
->
span
->
tone_finder
[
i
],
sln
,
(
int
)
slen
))
{
zchan
->
detected_tones
[
i
]
=
1
;
zchan
->
needed_tones
[
i
]
=
0
;
zchan
->
detected_tones
[
0
]
++
;
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论