Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
4268bf84
提交
4268bf84
authored
12月 24, 2010
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetdm: more core state refactoring, still untested
上级
82297de7
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
685 行增加
和
111 行删除
+685
-111
Makefile.am
libs/freetdm/Makefile.am
+1
-0
ftdm_state.c
libs/freetdm/src/ftdm_state.c
+458
-0
freetdm.h
libs/freetdm/src/include/freetdm.h
+2
-1
ftdm_core.h
libs/freetdm/src/include/private/ftdm_core.h
+3
-50
ftdm_state.h
libs/freetdm/src/include/private/ftdm_state.h
+218
-0
ftdm_types.h
libs/freetdm/src/include/private/ftdm_types.h
+3
-60
没有找到文件。
libs/freetdm/Makefile.am
浏览文件 @
4268bf84
...
...
@@ -73,6 +73,7 @@ libfreetdm_la_SOURCES = \
$(SRC)
/hashtable.c
\
$(SRC)
/hashtable_itr.c
\
$(SRC)
/ftdm_io.c
\
$(SRC)
/ftdm_state.c
\
$(SRC)
/ftdm_queue.c
\
$(SRC)
/ftdm_sched.c
\
$(SRC)
/ftdm_call_utils.c
\
...
...
libs/freetdm/src/ftdm_state.c
0 → 100644
浏览文件 @
4268bf84
差异被折叠。
点击展开。
libs/freetdm/src/include/freetdm.h
浏览文件 @
4268bf84
...
...
@@ -440,6 +440,7 @@ typedef struct {
* This is used during incoming calls when you want to request the signaling stack
* to notify about indications occurring locally. See ftdm_channel_call_indicate for more info */
typedef
enum
{
FTDM_CHANNEL_INDICATE_NONE
,
FTDM_CHANNEL_INDICATE_RINGING
,
FTDM_CHANNEL_INDICATE_PROCEED
,
FTDM_CHANNEL_INDICATE_PROGRESS
,
...
...
@@ -449,7 +450,7 @@ typedef enum {
FTDM_CHANNEL_INDICATE_ANSWER
,
FTDM_CHANNEL_INDICATE_INVALID
,
}
ftdm_channel_indication_t
;
#define INDICATION_STRINGS "RINGING", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "BUSY", "ANSWER", "INVALID"
#define INDICATION_STRINGS "
NONE", "
RINGING", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "BUSY", "ANSWER", "INVALID"
/*! \brief Move from string to ftdm_channel_indication_t and viceversa */
FTDM_STR2ENUM_P
(
ftdm_str2channel_indication
,
ftdm_channel_indication2str
,
ftdm_channel_indication_t
)
...
...
libs/freetdm/src/include/private/ftdm_core.h
浏览文件 @
4268bf84
...
...
@@ -192,17 +192,6 @@ extern "C" {
#define ftdm_clear_sflag_locked(obj, flag) assert(obj->mutex != NULL); ftdm_mutex_lock(obj->mutex); (obj)->sflags &= ~(flag); ftdm_mutex_unlock(obj->mutex);
#define ftdm_set_state(obj, s) ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s, 0); \
#define ftdm_set_state_locked(obj, s) \
do { \
ftdm_channel_lock(obj); \
ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s, 0); \
ftdm_channel_unlock(obj); \
} while(0);
#define ftdm_set_state_r(obj, s, r) r = ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s, 0);
#ifdef _MSC_VER
/* The while(0) below throws a conditional expression is constant warning */
#pragma warning(disable:4127)
...
...
@@ -363,15 +352,6 @@ typedef struct {
ftdm_mutex_t
*
mutex
;
}
ftdm_dtmf_debug_t
;
typedef
struct
{
const
char
*
file
;
const
char
*
func
;
int
line
;
ftdm_channel_state_t
state
;
ftdm_channel_state_t
last_state
;
ftdm_time_t
time
;
}
ftdm_channel_history_entry_t
;
typedef
enum
{
FTDM_IOSTATS_ERROR_CRC
=
(
1
<<
0
),
FTDM_IOSTATS_ERROR_FRAME
=
(
1
<<
1
),
...
...
@@ -424,9 +404,11 @@ struct ftdm_channel {
uint32_t
native_interval
;
uint32_t
packet_len
;
ftdm_channel_state_t
state
;
ftdm_state_status_t
state_status
;
ftdm_channel_state_t
last_state
;
ftdm_channel_state_t
init_state
;
ftdm_channel_history_entry_t
history
[
10
];
ftdm_channel_indication_t
indication
;
ftdm_state_history_entry_t
history
[
10
];
uint8_t
hindex
;
ftdm_mutex_t
*
mutex
;
teletone_dtmf_detect_state_t
dtmf_detect
;
...
...
@@ -572,9 +554,6 @@ FT_DECLARE(ftdm_status_t) ftdm_fsk_data_add_checksum(ftdm_fsk_data_state_t *stat
FT_DECLARE
(
ftdm_status_t
)
ftdm_fsk_data_add_sdmf
(
ftdm_fsk_data_state_t
*
state
,
const
char
*
date
,
char
*
number
);
FT_DECLARE
(
ftdm_status_t
)
ftdm_channel_send_fsk_data
(
ftdm_channel_t
*
ftdmchan
,
ftdm_fsk_data_state_t
*
fsk_data
,
float
db_level
);
FT_DECLARE
(
ftdm_status_t
)
ftdm_channel_set_state
(
const
char
*
file
,
const
char
*
func
,
int
line
,
ftdm_channel_t
*
ftdmchan
,
ftdm_channel_state_t
state
,
int
wait
);
FT_DECLARE
(
ftdm_status_t
)
ftdm_span_load_tones
(
ftdm_span_t
*
span
,
const
char
*
mapname
);
FT_DECLARE
(
ftdm_time_t
)
ftdm_current_time_in_ms
(
void
);
...
...
@@ -589,8 +568,6 @@ FT_DECLARE(void) print_hex_bytes(uint8_t *data, ftdm_size_t dlen, char *buf, ftd
FT_DECLARE_NONSTD
(
int
)
ftdm_hash_equalkeys
(
void
*
k1
,
void
*
k2
);
FT_DECLARE_NONSTD
(
uint32_t
)
ftdm_hash_hashfromstring
(
void
*
ky
);
FT_DECLARE
(
ftdm_status_t
)
ftdm_channel_complete_state
(
ftdm_channel_t
*
ftdmchan
);
FT_DECLARE
(
int
)
ftdm_load_modules
(
void
);
FT_DECLARE
(
ftdm_status_t
)
ftdm_unload_modules
(
void
);
...
...
@@ -707,30 +684,6 @@ static __inline__ void ftdm_abort(void)
#endif
}
static
__inline__
void
ftdm_set_state_all
(
ftdm_span_t
*
span
,
ftdm_channel_state_t
state
)
{
uint32_t
j
;
ftdm_mutex_lock
(
span
->
mutex
);
for
(
j
=
1
;
j
<=
span
->
chan_count
;
j
++
)
{
if
(
!
FTDM_IS_DCHAN
(
span
->
channels
[
j
]))
{
ftdm_set_state_locked
((
span
->
channels
[
j
]),
state
);
}
}
ftdm_mutex_unlock
(
span
->
mutex
);
}
static
__inline__
int
ftdm_check_state_all
(
ftdm_span_t
*
span
,
ftdm_channel_state_t
state
)
{
uint32_t
j
;
for
(
j
=
1
;
j
<=
span
->
chan_count
;
j
++
)
{
if
(
span
->
channels
[
j
]
->
state
!=
state
||
ftdm_test_flag
(
span
->
channels
[
j
],
FTDM_CHANNEL_STATE_CHANGE
))
{
return
0
;
}
}
return
1
;
}
static
__inline__
int16_t
ftdm_saturated_add
(
int16_t
sample1
,
int16_t
sample2
)
{
int
addres
;
...
...
libs/freetdm/src/include/private/ftdm_state.h
0 → 100644
浏览文件 @
4268bf84
/*
* Copyright (c) 2010, Sangoma Technologies
* Moises Silva <moy@sangoma.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __FTDM_STATE_H__
#define __FTDM_STATE_H__
/*! \file
* \brief State handling definitions
* \note Most, if not all of the state handling functions assume you have a lock acquired. Touching the channel
* state is a sensitive matter that requires checks and careful thought and is typically a process that
* is not encapsulated within a single function, therefore the lock must be explicitly acquired by the
* caller (most of the time, signaling modules), process states, set a new state and process it, and
* finally unlock the channel. See docs/locking.txt fore more info
*/
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
enum
{
FTDM_CHANNEL_STATE_DOWN
,
FTDM_CHANNEL_STATE_HOLD
,
FTDM_CHANNEL_STATE_SUSPENDED
,
FTDM_CHANNEL_STATE_DIALTONE
,
FTDM_CHANNEL_STATE_COLLECT
,
FTDM_CHANNEL_STATE_RING
,
FTDM_CHANNEL_STATE_RINGING
,
FTDM_CHANNEL_STATE_BUSY
,
FTDM_CHANNEL_STATE_ATTN
,
FTDM_CHANNEL_STATE_GENRING
,
FTDM_CHANNEL_STATE_DIALING
,
FTDM_CHANNEL_STATE_GET_CALLERID
,
FTDM_CHANNEL_STATE_CALLWAITING
,
FTDM_CHANNEL_STATE_RESTART
,
FTDM_CHANNEL_STATE_PROCEED
,
FTDM_CHANNEL_STATE_PROGRESS
,
FTDM_CHANNEL_STATE_PROGRESS_MEDIA
,
FTDM_CHANNEL_STATE_UP
,
FTDM_CHANNEL_STATE_IDLE
,
FTDM_CHANNEL_STATE_TERMINATING
,
FTDM_CHANNEL_STATE_CANCEL
,
FTDM_CHANNEL_STATE_HANGUP
,
FTDM_CHANNEL_STATE_HANGUP_COMPLETE
,
FTDM_CHANNEL_STATE_IN_LOOP
,
FTDM_CHANNEL_STATE_RESET
,
FTDM_CHANNEL_STATE_INVALID
}
ftdm_channel_state_t
;
#define CHANNEL_STATE_STRINGS "DOWN", "HOLD", "SUSPENDED", "DIALTONE", "COLLECT", \
"RING", "RINGING", "BUSY", "ATTN", "GENRING", "DIALING", "GET_CALLERID", "CALLWAITING", \
"RESTART", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "UP", "IDLE", "TERMINATING", "CANCEL", \
"HANGUP", "HANGUP_COMPLETE", "IN_LOOP", "RESET", "INVALID"
FTDM_STR2ENUM_P
(
ftdm_str2ftdm_channel_state
,
ftdm_channel_state2str
,
ftdm_channel_state_t
)
typedef
struct
{
const
char
*
file
;
const
char
*
func
;
int
line
;
ftdm_channel_state_t
state
;
ftdm_channel_state_t
last_state
;
ftdm_time_t
time
;
ftdm_time_t
end_time
;
}
ftdm_state_history_entry_t
;
typedef
ftdm_status_t
(
*
ftdm_channel_state_processor_t
)(
ftdm_channel_t
*
fchan
);
FT_DECLARE
(
ftdm_status_t
)
ftdm_channel_advance_states
(
ftdm_channel_t
*
fchan
,
ftdm_channel_state_processor_t
processor
);
FT_DECLARE
(
ftdm_status_t
)
_ftdm_channel_complete_state
(
const
char
*
file
,
const
char
*
function
,
int
line
,
ftdm_channel_t
*
fchan
);
#define ftdm_channel_complete_state(obj) _ftdm_channel_complete_state(__FILE__, __FUNCTION__, __LINE__, obj)
FT_DECLARE
(
int
)
ftdm_check_state_all
(
ftdm_span_t
*
span
,
ftdm_channel_state_t
state
);
/*!
* \brief Status of the current channel state
* \note A given state goes thru several status (yes, states for the state!)
* The order is always FTDM_STATE_STATUS_NEW -> FTDM_STATE_STATUS_PROCESSED -> FTDM_STATUS_COMPLETED
* However, is possible to go from NEW -> COMPLETED directly when the signaling module explicitly changes
* the state of the channel in the middle of processing the current state by calling the ftdm_set_state() API
*
* FTDM_STATE_STATUS_NEW -
* Someone just set the state of the channel, either the signaling module or the user (implicitly through a call API).
* This is accomplished by calling ftdm_channel_set_state() which changes the 'state' and 'last_state' memebers of
* the ftdm_channel_t structure.
*
* FTDM_STATE_STATUS_PROCESSED -
* The signaling module did something based on the new state.
*
* This is accomplished via ftdm_channel_advance_states()
*
* When ftdm_channel_advance_states(), at the very least, if the channel has its state in FTDM_STATE_STATUS_NEW, it
* will move to FTDM_STATE_STATUS_PROCESSED, depending on what the signaling module does during the processing
* the state may move to FTDM_STATE_STATUS_COMPLETED right after or wait for a signaling specific event to complete it.
* It is also possible that more state transitions occur during the execution of ftdm_channel_advance_states() if one
* state processing/completion leads to another state change, the function will not return until the chain of events
* lead to a state that is not in FTDM_STATE_STATUS_NEW
*
* FTDM_STATE_STATUS_COMPLETED -
* The signaling module completed the processing of the state and there is nothing further to be done for this state.
*
* This is accomplished either explicitly by the signaling module by calling ftdm_channel_complete_state() or by
* the signaling module implicitly by trying to set the state of the channel to a new state via ftdm_set_state()
*
* When working with blocking channels (FTDM_CHANNEL_NONBLOCK flag not set), the user thread is signaled and unblocked
* so it can continue.
*
* When a state moves to this status is also possible for a signal FTDM_SIGEVENT_INDICATION_COMPLETED to be delivered
* by the core if the state change was associated to an indication requested by the user,
*/
typedef
enum
{
FTDM_STATE_STATUS_NEW
,
FTDM_STATE_STATUS_PROCESSED
,
FTDM_STATE_STATUS_COMPLETED
}
ftdm_state_status_t
;
typedef
enum
{
ZSM_NONE
,
ZSM_UNACCEPTABLE
,
ZSM_ACCEPTABLE
}
ftdm_state_map_type_t
;
typedef
enum
{
ZSD_INBOUND
,
ZSD_OUTBOUND
,
}
ftdm_state_direction_t
;
#define FTDM_MAP_NODE_SIZE 512
#define FTDM_MAP_MAX FTDM_CHANNEL_STATE_INVALID+2
struct
ftdm_state_map_node
{
ftdm_state_direction_t
direction
;
ftdm_state_map_type_t
type
;
ftdm_channel_state_t
check_states
[
FTDM_MAP_MAX
];
ftdm_channel_state_t
states
[
FTDM_MAP_MAX
];
};
typedef
struct
ftdm_state_map_node
ftdm_state_map_node_t
;
struct
ftdm_state_map
{
ftdm_state_map_node_t
nodes
[
FTDM_MAP_NODE_SIZE
];
};
typedef
struct
ftdm_state_map
ftdm_state_map_t
;
FT_DECLARE
(
ftdm_status_t
)
ftdm_channel_set_state
(
const
char
*
file
,
const
char
*
func
,
int
line
,
ftdm_channel_t
*
ftdmchan
,
ftdm_channel_state_t
state
,
int
wait
);
/*!\brief Set the state of a channel immediately and implicitly complete the previous state */
FT_DECLARE
(
ftdm_status_t
)
_ftdm_set_state
(
const
char
*
file
,
const
char
*
func
,
int
line
,
ftdm_channel_t
*
fchan
,
ftdm_channel_state_t
state
);
#define ftdm_set_state(obj, s) _ftdm_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s); \
/*!\brief This macro is deprecated, signaling modules should always lock the channel themselves anyways since they must
* process first the user pending state changes then set a new state before releasing the lock
*/
#define ftdm_set_state_locked(obj, s) \
do { \
ftdm_channel_lock(obj); \
ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s, 0); \
ftdm_channel_unlock(obj); \
} while(0);
#define ftdm_set_state_r(obj, s, r) r = ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s, 0);
#define ftdm_set_state_all(span, state) \
do { \
uint32_t _j; \
ftdm_mutex_lock((span)->mutex); \
for(_j = 1; _j <= (span)->chan_count; _j++) { \
if (!FTDM_IS_DCHAN(span->channels[_j])) { \
ftdm_set_state_locked((span->channels[_j]), state); \
} \
} \
ftdm_mutex_unlock((span)->mutex); \
} while (0);
#ifdef __cplusplus
}
#endif
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
libs/freetdm/src/include/private/ftdm_types.h
浏览文件 @
4268bf84
...
...
@@ -204,40 +204,6 @@ typedef enum {
FTDM_CHANNEL_FEATURE_IO_STATS
=
(
1
<<
9
),
/*!< Channel supports IO statistics (HDLC channels only) */
}
ftdm_channel_feature_t
;
typedef
enum
{
FTDM_CHANNEL_STATE_DOWN
,
FTDM_CHANNEL_STATE_HOLD
,
FTDM_CHANNEL_STATE_SUSPENDED
,
FTDM_CHANNEL_STATE_DIALTONE
,
FTDM_CHANNEL_STATE_COLLECT
,
FTDM_CHANNEL_STATE_RING
,
FTDM_CHANNEL_STATE_RINGING
,
FTDM_CHANNEL_STATE_BUSY
,
FTDM_CHANNEL_STATE_ATTN
,
FTDM_CHANNEL_STATE_GENRING
,
FTDM_CHANNEL_STATE_DIALING
,
FTDM_CHANNEL_STATE_GET_CALLERID
,
FTDM_CHANNEL_STATE_CALLWAITING
,
FTDM_CHANNEL_STATE_RESTART
,
FTDM_CHANNEL_STATE_PROCEED
,
FTDM_CHANNEL_STATE_PROGRESS
,
FTDM_CHANNEL_STATE_PROGRESS_MEDIA
,
FTDM_CHANNEL_STATE_UP
,
FTDM_CHANNEL_STATE_IDLE
,
FTDM_CHANNEL_STATE_TERMINATING
,
FTDM_CHANNEL_STATE_CANCEL
,
FTDM_CHANNEL_STATE_HANGUP
,
FTDM_CHANNEL_STATE_HANGUP_COMPLETE
,
FTDM_CHANNEL_STATE_IN_LOOP
,
FTDM_CHANNEL_STATE_RESET
,
FTDM_CHANNEL_STATE_INVALID
}
ftdm_channel_state_t
;
#define CHANNEL_STATE_STRINGS "DOWN", "HOLD", "SUSPENDED", "DIALTONE", "COLLECT", \
"RING", "RINGING", "BUSY", "ATTN", "GENRING", "DIALING", "GET_CALLERID", "CALLWAITING", \
"RESTART", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "UP", "IDLE", "TERMINATING", "CANCEL", \
"HANGUP", "HANGUP_COMPLETE", "IN_LOOP", "RESET", "INVALID"
FTDM_STR2ENUM_P
(
ftdm_str2ftdm_channel_state
,
ftdm_channel_state2str
,
ftdm_channel_state_t
)
/*!< Channel flags. This used to be an enum but we reached the 32bit limit for enums, is safer this way */
#define FTDM_CHANNEL_CONFIGURED (1ULL << 0)
#define FTDM_CHANNEL_READY (1ULL << 1)
...
...
@@ -282,33 +248,10 @@ FTDM_STR2ENUM_P(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channe
#define FTDM_CHANNEL_CALL_STARTED (1ULL << 32)
/*!< The user wants non-blocking operations in the channel */
#define FTDM_CHANNEL_NONBLOCK (1ULL << 33)
/*!< There is a pending acknowledge for an indication */
#define FTDM_CHANNEL_IND_ACK_PENDING (1ULL << 34)
typedef
enum
{
ZSM_NONE
,
ZSM_UNACCEPTABLE
,
ZSM_ACCEPTABLE
}
ftdm_state_map_type_t
;
typedef
enum
{
ZSD_INBOUND
,
ZSD_OUTBOUND
,
}
ftdm_state_direction_t
;
#define FTDM_MAP_NODE_SIZE 512
#define FTDM_MAP_MAX FTDM_CHANNEL_STATE_INVALID+2
struct
ftdm_state_map_node
{
ftdm_state_direction_t
direction
;
ftdm_state_map_type_t
type
;
ftdm_channel_state_t
check_states
[
FTDM_MAP_MAX
];
ftdm_channel_state_t
states
[
FTDM_MAP_MAX
];
};
typedef
struct
ftdm_state_map_node
ftdm_state_map_node_t
;
struct
ftdm_state_map
{
ftdm_state_map_node_t
nodes
[
FTDM_MAP_NODE_SIZE
];
};
typedef
struct
ftdm_state_map
ftdm_state_map_t
;
#include "ftdm_state.h"
typedef
enum
ftdm_channel_hw_link_status
{
FTDM_HW_LINK_DISCONNECTED
=
0
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论