Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b2d8e055
提交
b2d8e055
authored
5月 11, 2010
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetdm: modify prototype for ftdm_span_create to accept I/O module name instead of pointer
上级
5d15dc10
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
122 行增加
和
59 行删除
+122
-59
ftdm_io.c
libs/freetdm/src/ftdm_io.c
+65
-41
freetdm.h
libs/freetdm/src/include/freetdm.h
+57
-4
ftdm_types.h
libs/freetdm/src/include/private/ftdm_types.h
+0
-14
没有找到文件。
libs/freetdm/src/ftdm_io.c
浏览文件 @
b2d8e055
...
...
@@ -522,17 +522,41 @@ FT_DECLARE(ftdm_status_t) ftdm_span_stop(ftdm_span_t *span)
return
FTDM_FAIL
;
}
FT_DECLARE
(
ftdm_status_t
)
ftdm_span_create
(
ftdm_io_interface_t
*
fio
,
ftdm_span_t
**
span
,
const
char
*
name
)
FT_DECLARE
(
ftdm_status_t
)
ftdm_span_create
(
const
char
*
iotype
,
const
char
*
name
,
ftdm_span_t
**
span
)
{
ftdm_span_t
*
new_span
=
NULL
;
ftdm_io_interface_t
*
fio
=
NULL
;
ftdm_status_t
status
=
FTDM_FAIL
;
char
buf
[
128
]
=
""
;
ftdm_assert
(
fio
!=
NULL
,
"No IO provided
\n
"
);
ftdm_assert_return
(
iotype
!=
NULL
,
FTDM_FAIL
,
"No IO type provided
\n
"
);
ftdm_assert_return
(
name
!=
NULL
,
FTDM_FAIL
,
"No span name provided
\n
"
);
*
span
=
NULL
;
ftdm_mutex_lock
(
globals
.
mutex
);
if
(
!
(
fio
=
(
ftdm_io_interface_t
*
)
hashtable_search
(
globals
.
interface_hash
,
(
void
*
)
iotype
)))
{
ftdm_load_module_assume
(
iotype
);
if
((
fio
=
(
ftdm_io_interface_t
*
)
hashtable_search
(
globals
.
interface_hash
,
(
void
*
)
iotype
)))
{
ftdm_log
(
FTDM_LOG_INFO
,
"Auto-loaded I/O module '%s'
\n
"
,
iotype
);
}
}
ftdm_mutex_unlock
(
globals
.
mutex
);
if
(
!
fio
)
{
ftdm_log
(
FTDM_LOG_CRIT
,
"failure creating span, no such I/O type '%s'
\n
"
,
iotype
);
return
FTDM_FAIL
;
}
if
(
!
fio
->
configure_span
)
{
ftdm_log
(
FTDM_LOG_CRIT
,
"failure creating span, no configure_span method for I/O type '%s'
\n
"
,
iotype
);
return
FTDM_FAIL
;
}
ftdm_mutex_lock
(
globals
.
mutex
);
if
(
globals
.
span_index
<
FTDM_MAX_SPANS_INTERFACE
)
{
new_span
=
ftdm_calloc
(
sizeof
(
*
new_span
),
1
);
ftdm_assert
(
new_span
,
"allocating span failed
\n
"
);
status
=
ftdm_mutex_create
(
&
new_span
->
mutex
);
...
...
@@ -556,11 +580,11 @@ FT_DECLARE(ftdm_status_t) ftdm_span_create(ftdm_io_interface_t *fio, ftdm_span_t
ftdm_mutex_unlock
(
globals
.
span_mutex
);
if
(
!
name
)
{
char
buf
[
128
]
=
""
;
snprintf
(
buf
,
sizeof
(
buf
),
"span%d"
,
new_span
->
span_id
);
name
=
buf
;
}
new_span
->
name
=
ftdm_strdup
(
name
);
new_span
->
type
=
ftdm_strdup
(
iotype
);
ftdm_span_add
(
new_span
);
*
span
=
new_span
;
status
=
FTDM_SUCCESS
;
...
...
@@ -1657,6 +1681,16 @@ FT_DECLARE(const char *) ftdm_channel_get_span_name(const ftdm_channel_t *ftdmch
return
ftdmchan
->
span
->
name
;
}
FT_DECLARE
(
void
)
ftdm_span_set_trunk_type
(
ftdm_span_t
*
span
,
ftdm_trunk_type_t
type
)
{
span
->
trunk_type
=
type
;
}
FT_DECLARE
(
ftdm_trunk_type_t
)
ftdm_span_get_trunk_type
(
const
ftdm_span_t
*
span
)
{
return
span
->
trunk_type
;
}
FT_DECLARE
(
uint32_t
)
ftdm_span_get_id
(
const
ftdm_span_t
*
span
)
{
return
span
->
span_id
;
...
...
@@ -3227,7 +3261,15 @@ static ftdm_status_t ftdm_set_channels_alarms(ftdm_span_t *span, int currindex)
FT_DECLARE
(
ftdm_status_t
)
ftdm_configure_span_channels
(
ftdm_span_t
*
span
,
const
char
*
str
,
ftdm_channel_config_t
*
chan_config
,
unsigned
*
configured
)
{
int
currindex
=
span
->
chan_count
;
int
currindex
;
ftdm_assert_return
(
span
!=
NULL
,
FTDM_EINVAL
,
"span is null
\n
"
);
ftdm_assert_return
(
chan_config
!=
NULL
,
FTDM_EINVAL
,
"config is null
\n
"
);
ftdm_assert_return
(
configured
!=
NULL
,
FTDM_EINVAL
,
"configured pointer is null
\n
"
);
ftdm_assert_return
(
span
->
fio
!=
NULL
,
FTDM_EINVAL
,
"span with no I/O configured
\n
"
);
ftdm_assert_return
(
span
->
fio
->
configure_span
!=
NULL
,
FTDM_NOTIMPL
,
"span I/O with no channel configuration implemented
\n
"
);
currindex
=
span
->
chan_count
;
*
configured
=
0
;
*
configured
=
span
->
fio
->
configure_span
(
span
,
str
,
chan_config
->
type
,
chan_config
->
name
,
chan_config
->
number
);
if
(
!*
configured
)
{
...
...
@@ -3235,18 +3277,24 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const
return
FTDM_FAIL
;
}
if
(
ftdm_group_add_channels
(
span
,
currindex
,
chan_config
->
group_name
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"%d:Failed to add channels to group %s
\n
"
,
span
->
span_id
,
chan_config
->
group_name
);
if
(
chan_config
->
group_name
[
0
])
{
if
(
ftdm_group_add_channels
(
span
,
currindex
,
chan_config
->
group_name
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"%d:Failed to add channels to group %s
\n
"
,
span
->
span_id
,
chan_config
->
group_name
);
return
FTDM_FAIL
;
}
}
if
(
ftdm_set_channels_gains
(
span
,
currindex
,
chan_config
->
rxgain
,
chan_config
->
txgain
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"%d:Failed to set channel gains
\n
"
,
span
->
span_id
);
return
FTDM_FAIL
;
}
if
(
ftdm_set_channels_alarms
(
span
,
currindex
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"%d:Failed to set channel alarms
\n
"
,
span
->
span_id
);
return
FTDM_FAIL
;
}
if
(
ftdm_set_channels_gains
(
span
,
currindex
,
chan_config
->
rxgain
,
chan_config
->
txgain
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"%d:Failed to set channel gains
\n
"
,
span
->
span_id
);
return
FTDM_FAIL
;
}
return
FTDM_SUCCESS
;
}
...
...
@@ -3260,7 +3308,6 @@ static ftdm_status_t load_config(void)
int
intparam
=
0
;
ftdm_span_t
*
span
=
NULL
;
unsigned
configured
=
0
,
d
=
0
;
ftdm_io_interface_t
*
fio
=
NULL
;
ftdm_analog_start_type_t
tmp
;
ftdm_size_t
len
=
0
;
ftdm_channel_config_t
chan_config
;
...
...
@@ -3271,7 +3318,7 @@ static ftdm_status_t load_config(void)
if
(
!
ftdm_config_open_file
(
&
cfg
,
cfg_name
))
{
return
FTDM_FAIL
;
}
ftdm_log
(
FTDM_LOG_DEBUG
,
"Reading FreeTDM configuration file
\n
"
);
while
(
ftdm_config_next_pair
(
&
cfg
,
&
var
,
&
val
))
{
if
(
*
cfg
.
category
==
'#'
)
{
if
(
cfg
.
catno
!=
catno
)
{
...
...
@@ -3300,33 +3347,9 @@ static ftdm_status_t load_config(void)
*
name
++
=
'\0'
;
}
ftdm_mutex_lock
(
globals
.
mutex
);
if
(
!
(
fio
=
(
ftdm_io_interface_t
*
)
hashtable_search
(
globals
.
interface_hash
,
type
)))
{
ftdm_load_module_assume
(
type
);
if
((
fio
=
(
ftdm_io_interface_t
*
)
hashtable_search
(
globals
.
interface_hash
,
type
)))
{
ftdm_log
(
FTDM_LOG_INFO
,
"auto-loaded '%s'
\n
"
,
type
);
}
}
ftdm_mutex_unlock
(
globals
.
mutex
);
if
(
!
fio
)
{
ftdm_log
(
FTDM_LOG_CRIT
,
"failure creating span, no such type '%s'
\n
"
,
type
);
span
=
NULL
;
continue
;
}
if
(
!
fio
->
configure_span
)
{
ftdm_log
(
FTDM_LOG_CRIT
,
"failure creating span, no configure_span method for '%s'
\n
"
,
type
);
span
=
NULL
;
continue
;
}
if
(
ftdm_span_create
(
fio
,
&
span
,
name
)
==
FTDM_SUCCESS
)
{
span
->
type
=
ftdm_strdup
(
type
);
d
=
0
;
if
(
ftdm_span_create
(
type
,
name
,
&
span
)
==
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_DEBUG
,
"created span %d (%s) of type %s
\n
"
,
span
->
span_id
,
span
->
name
,
type
);
d
=
0
;
}
else
{
ftdm_log
(
FTDM_LOG_CRIT
,
"failure creating span of type %s
\n
"
,
type
);
span
=
NULL
;
...
...
@@ -3341,8 +3364,9 @@ static ftdm_status_t load_config(void)
ftdm_log
(
FTDM_LOG_DEBUG
,
"span %d [%s]=[%s]
\n
"
,
span
->
span_id
,
var
,
val
);
if
(
!
strcasecmp
(
var
,
"trunk_type"
))
{
span
->
trunk_type
=
ftdm_str2ftdm_trunk_type
(
val
);
ftdm_log
(
FTDM_LOG_DEBUG
,
"setting trunk type to '%s'
\n
"
,
ftdm_trunk_type2str
(
span
->
trunk_type
));
ftdm_trunk_type_t
trtype
=
ftdm_str2ftdm_trunk_type
(
val
);
ftdm_span_set_trunk_type
(
span
,
trtype
);
ftdm_log
(
FTDM_LOG_DEBUG
,
"setting trunk type to '%s'
\n
"
,
ftdm_trunk_type2str
(
trtype
));
}
else
if
(
!
strcasecmp
(
var
,
"name"
))
{
if
(
!
strcasecmp
(
val
,
"undef"
))
{
chan_config
.
name
[
0
]
=
'\0'
;
...
...
@@ -3371,7 +3395,7 @@ static ftdm_status_t load_config(void)
ftdm_analog_start_type2str
(
span
->
start_type
));
}
if
(
span
->
trunk_type
==
FTDM_TRUNK_FXO
)
{
unsigned
chans_configured
=
0
;
unsigned
chans_configured
=
0
;
chan_config
.
type
=
FTDM_CHAN_TYPE_FXO
;
if
(
ftdm_configure_span_channels
(
span
,
val
,
&
chan_config
,
&
chans_configured
)
==
FTDM_SUCCESS
)
{
configured
+=
chans_configured
;
...
...
libs/freetdm/src/include/freetdm.h
浏览文件 @
b2d8e055
...
...
@@ -67,7 +67,8 @@ typedef enum {
FTDM_MEMERR
,
/*!< Memory error, most likely allocation failure */
FTDM_TIMEOUT
,
/*!< Operation timed out (ie: polling on a device)*/
FTDM_NOTIMPL
,
/*!< Operation not implemented */
FTDM_BREAK
/*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */
FTDM_BREAK
,
/*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */
FTDM_EINVAL
/*!< Invalid argument */
}
ftdm_status_t
;
/*! \brief FreeTDM bool type. */
...
...
@@ -299,6 +300,23 @@ typedef enum {
/*! \brief Move from string to ftdm_signal_event_t and viceversa */
FTDM_STR2ENUM_P
(
ftdm_str2ftdm_signal_event
,
ftdm_signal_event2str
,
ftdm_signal_event_t
)
/*! \brief Span trunk types */
typedef
enum
{
FTDM_TRUNK_E1
,
FTDM_TRUNK_T1
,
FTDM_TRUNK_J1
,
FTDM_TRUNK_BRI
,
FTDM_TRUNK_BRI_PTMP
,
FTDM_TRUNK_FXO
,
FTDM_TRUNK_FXS
,
FTDM_TRUNK_EM
,
FTDM_TRUNK_NONE
}
ftdm_trunk_type_t
;
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "NONE"
/*! \brief Move from string to ftdm_trunk_type_t and viceversa */
FTDM_STR2ENUM_P
(
ftdm_str2ftdm_trunk_type
,
ftdm_trunk_type2str
,
ftdm_trunk_type_t
)
/*! \brief Basic channel configuration provided to ftdm_configure_span_channels */
typedef
struct
ftdm_channel_config
{
char
name
[
FTDM_MAX_NAME_STR_SZ
];
...
...
@@ -809,14 +827,18 @@ FT_DECLARE(const char *) ftdm_span_get_last_error(const ftdm_span_t *span);
/*!
* \brief Create a new span (not needed if you are using freetdm.conf)
*
* \param fio The I/O interface the span will use
* \param span Pointer to store the create span
* \param iotype The I/O interface type this span will use.
* This depends on the available I/O modules
* ftmod_wanpipe = "wanpipe" (Sangoma)
* ftmod_zt = "zt" (DAHDI or Zaptel)
* ftmod_pika "pika" (this one is most likely broken)
* \param name Name for the span
* \param span Pointer to store the create span
*
* \retval FTDM_SUCCESS success (the span was created)
* \retval FTDM_FAIL failure (span was not created)
*/
FT_DECLARE
(
ftdm_status_t
)
ftdm_span_create
(
ftdm_io_interface_t
*
fio
,
ftdm_span_t
**
span
,
const
char
*
name
);
FT_DECLARE
(
ftdm_status_t
)
ftdm_span_create
(
const
char
*
iotype
,
const
char
*
name
,
ftdm_span_t
**
span
);
/*!
* \brief Add a new channel to a span
...
...
@@ -1144,8 +1166,39 @@ FT_DECLARE(ftdm_status_t) ftdm_conf_node_add_param(ftdm_conf_node_t *node, const
* \return FTDM_FAIL failure
*/
FT_DECLARE
(
ftdm_status_t
)
ftdm_conf_node_destroy
(
ftdm_conf_node_t
*
node
);
/*!
* \brief Create and configure channels in the given span
*
* \param span The span container
* \param str The channel range null terminated string. "1-10", "24" etc
* \param chan_config The basic channel configuration for each channel within the range
* \param configured Pointer where the number of channels configured will be stored
*
* \return FTDM_SUCCESS success
* \return FTDM_FAIL failure
*/
FT_DECLARE
(
ftdm_status_t
)
ftdm_configure_span_channels
(
ftdm_span_t
*
span
,
const
char
*
str
,
ftdm_channel_config_t
*
chan_config
,
unsigned
*
configured
);
/*!
* \brief Set the trunk type for a span
* This must be called before configuring any channels within the span
*
* \param span The span
* \param type The trunk type
*
*/
FT_DECLARE
(
void
)
ftdm_span_set_trunk_type
(
ftdm_span_t
*
span
,
ftdm_trunk_type_t
type
);
/*!
* \brief Get the trunk type for a span
*
* \param span The span
*
* \return The span trunk type
*/
FT_DECLARE
(
ftdm_trunk_type_t
)
ftdm_span_get_trunk_type
(
const
ftdm_span_t
*
span
);
/*!
* \brief Return the channel identified by the provided id
*
...
...
libs/freetdm/src/include/private/ftdm_types.h
浏览文件 @
b2d8e055
...
...
@@ -111,20 +111,6 @@ typedef enum {
#define TONEMAP_STRINGS "NONE", "DIAL", "RING", "BUSY", "FAIL1", "FAIL2", "FAIL3", "ATTN", "CALLWAITING-CAS", "CALLWAITING-SAS", "CALLWAITING-ACK", "INVALID"
FTDM_STR2ENUM_P
(
ftdm_str2ftdm_tonemap
,
ftdm_tonemap2str
,
ftdm_tonemap_t
)
typedef
enum
{
FTDM_TRUNK_E1
,
FTDM_TRUNK_T1
,
FTDM_TRUNK_J1
,
FTDM_TRUNK_BRI
,
FTDM_TRUNK_BRI_PTMP
,
FTDM_TRUNK_FXO
,
FTDM_TRUNK_FXS
,
FTDM_TRUNK_EM
,
FTDM_TRUNK_NONE
}
ftdm_trunk_type_t
;
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "NONE"
FTDM_STR2ENUM_P
(
ftdm_str2ftdm_trunk_type
,
ftdm_trunk_type2str
,
ftdm_trunk_type_t
)
typedef
enum
{
FTDM_ANALOG_START_KEWL
,
FTDM_ANALOG_START_LOOP
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论