Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
518e0341
提交
518e0341
authored
2月 25, 2011
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetdm: remove remaining references to boost (sample code, visual studio project references)
上级
269906c8
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
0 行增加
和
1068 行删除
+0
-1068
freetdm.2008.sln
libs/freetdm/freetdm.2008.sln
+0
-15
freetdm.2010.sln
libs/freetdm/freetdm.2010.sln
+0
-6
CMakeLists.txt
libs/freetdm/sample/CMakeLists.txt
+0
-1
CMakeLists.txt
libs/freetdm/sample/boost/CMakeLists.txt
+0
-12
Makefile
libs/freetdm/sample/boost/Makefile
+0
-10
ftdmstart.c
libs/freetdm/sample/boost/ftdmstart.c
+0
-469
testboost.c
libs/freetdm/src/testboost.c
+0
-83
testsangomaboost.c
libs/freetdm/src/testsangomaboost.c
+0
-472
没有找到文件。
libs/freetdm/freetdm.2008.sln
浏览文件 @
518e0341
...
...
@@ -43,21 +43,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_boost", "src\ftmod\ftmod_sangoma_boost\ftmod_sangoma_boost.2008.vcproj", "{D021EF2A-460D-4827-A0F7-41FDECF46F1B}"
ProjectSection(ProjectDependencies) = postProject
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testboost", "msvc\testboost\testboost.2008.vcproj", "{2B1BAF36-0241-43E7-B865-A8338AD48E2E}"
ProjectSection(ProjectDependencies) = postProject
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsangomaboost", "msvc\testboost\testsangomaboost.2008.vcproj", "{0DA69C18-4FA1-4E8C-89CE-12498637C5BE}"
ProjectSection(ProjectDependencies) = postProject
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2008.vcproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}"
ProjectSection(ProjectDependencies) = postProject
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
...
...
libs/freetdm/freetdm.2010.sln
浏览文件 @
518e0341
...
...
@@ -19,12 +19,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_pika", "src\ftmod\ftm
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\ftmod_wanpipe\ftmod_wanpipe.2010.vcxproj", "{1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_boost", "src\ftmod\ftmod_sangoma_boost\ftmod_sangoma_boost.2010.vcxproj", "{D021EF2A-460D-4827-A0F7-41FDECF46F1B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testboost", "msvc\testboost\testboost.2010.vcxproj", "{2B1BAF36-0241-43E7-B865-A8338AD48E2E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsangomaboost", "msvc\testboost\testsangomaboost.2010.vcxproj", "{0DA69C18-4FA1-4E8C-89CE-12498637C5BE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2010.vcxproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_r2", "src\ftmod\ftmod_r2\ftmod_r2.2010.vcxproj", "{08C3EA27-A51D-47F8-B47D-B189C649CF30}"
...
...
libs/freetdm/sample/CMakeLists.txt
浏览文件 @
518e0341
...
...
@@ -4,5 +4,4 @@
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
PROJECT
(
sample
)
ADD_SUBDIRECTORY
(
boost
)
#ADD_SUBDIRECTORY(sched) FIXME: this code doesnt compile
libs/freetdm/sample/boost/CMakeLists.txt
deleted
100644 → 0
浏览文件 @
269906c8
#
# Arnaldo M Pereira <arnaldo@sangoma.com>
#
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
PROJECT
(
boost
)
IF
(
NOT DEFINED WIN32
)
INCLUDE_DIRECTORIES
(
/usr/local/freeswitch/include
)
ADD_DEFINITIONS
(
-Wall
)
ADD_EXECUTABLE
(
ftdmstart ftdmstart.c
)
TARGET_LINK_LIBRARIES
(
ftdmstart freetdm
)
ENDIF
(
NOT DEFINED WIN32
)
libs/freetdm/sample/boost/Makefile
deleted
100644 → 0
浏览文件 @
269906c8
CC
=
gcc
CFLAGS
=
-Wall
-I
/usr/local/freeswitch/include
LDFLAGS
=
-L
/usr/local/freeswitch/lib
-lfreetdm
ftdmstart
:
ftdmstart.o
clean
:
rm
-rf
ftdmstart.o
libs/freetdm/sample/boost/ftdmstart.c
deleted
100644 → 0
浏览文件 @
269906c8
/*
* 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.
*/
/**
* Sample program for the boost signaling absraction.
* Usage: testboostalone <spanno-1> <spanno-2> ... -d [number-to-dial-if-any]
* compile this program linking to the freetdm library (ie -lfreetdm)
**/
#ifndef __linux__
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include <signal.h>
#include "freetdm.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
/* arbitrary limit for max calls in this sample program */
#define MAX_CALLS 255
/* some timers (in seconds) to fake responses in incoming calls */
#define PROGRESS_TIMER 1
#define ANSWER_TIMER 5
#define HANGUP_TIMER 15
/* simple variable used to stop the application */
static
int
app_running
=
0
;
typedef
void
(
*
expired_function_t
)(
ftdm_channel_t
*
channel
);
typedef
struct
dummy_timer_s
{
int
time
;
ftdm_channel_t
*
channel
;
expired_function_t
expired
;
}
dummy_timer_t
;
/* dummy second resolution timers */
static
dummy_timer_t
g_timers
[
MAX_CALLS
];
/* mutex to protect the timers (both, the test thread and the signaling thread may modify them) */
static
ftdm_mutex_t
*
g_schedule_mutex
;
/* unique outgoing channel */
static
ftdm_channel_t
*
g_outgoing_channel
=
NULL
;
static
void
interrupt_requested
(
int
signal
)
{
app_running
=
0
;
}
static
void
schedule_timer
(
ftdm_channel_t
*
channel
,
int
sec
,
expired_function_t
expired
)
{
int
i
;
ftdm_mutex_lock
(
g_schedule_mutex
);
for
(
i
=
0
;
i
<
sizeof
(
g_timers
)
/
sizeof
(
g_timers
[
0
]);
i
++
)
{
/* check the timer slot is free to use */
if
(
!
g_timers
[
i
].
time
)
{
g_timers
[
i
].
time
=
sec
;
g_timers
[
i
].
channel
=
channel
;
g_timers
[
i
].
expired
=
expired
;
ftdm_mutex_unlock
(
g_schedule_mutex
);
return
;
}
}
ftdm_log
(
FTDM_LOG_ERROR
,
"Failed to schedule timer
\n
"
);
ftdm_mutex_unlock
(
g_schedule_mutex
);
}
static
void
run_timers
(
void
)
{
int
i
;
void
*
channel
;
expired_function_t
expired_func
=
NULL
;
ftdm_mutex_lock
(
g_schedule_mutex
);
for
(
i
=
0
;
i
<
sizeof
(
g_timers
)
/
sizeof
(
g_timers
[
0
]);
i
++
)
{
/* if there's time left, decrement */
if
(
g_timers
[
i
].
time
)
{
g_timers
[
i
].
time
--
;
}
/* if time expired and we have an expired function, call it */
if
(
!
g_timers
[
i
].
time
&&
g_timers
[
i
].
expired
)
{
expired_func
=
g_timers
[
i
].
expired
;
channel
=
g_timers
[
i
].
channel
;
memset
(
&
g_timers
[
i
],
0
,
sizeof
(
g_timers
[
i
]));
expired_func
(
channel
);
}
}
ftdm_mutex_unlock
(
g_schedule_mutex
);
}
static
void
release_timers
(
ftdm_channel_t
*
channel
)
{
int
i
;
ftdm_mutex_lock
(
g_schedule_mutex
);
for
(
i
=
0
;
i
<
sizeof
(
g_timers
)
/
sizeof
(
g_timers
[
0
]);
i
++
)
{
/* clear any timer belonging to the given channel */
if
(
g_timers
[
i
].
channel
==
channel
)
{
memset
(
&
g_timers
[
i
],
0
,
sizeof
(
g_timers
[
i
]));
}
}
ftdm_mutex_unlock
(
g_schedule_mutex
);
}
/* hangup the call */
static
void
send_hangup
(
ftdm_channel_t
*
channel
)
{
int
spanid
=
ftdm_channel_get_span_id
(
channel
);
int
chanid
=
ftdm_channel_get_id
(
channel
);
ftdm_log
(
FTDM_LOG_NOTICE
,
"-- Requesting hangup in channel %d:%d
\n
"
,
spanid
,
chanid
);
ftdm_channel_call_hangup
(
channel
);
}
/* send answer for an incoming call */
static
void
send_answer
(
ftdm_channel_t
*
channel
)
{
/* we move the channel signaling state machine to UP (answered) */
int
spanid
=
ftdm_channel_get_span_id
(
channel
);
int
chanid
=
ftdm_channel_get_id
(
channel
);
ftdm_log
(
FTDM_LOG_NOTICE
,
"-- Requesting answer in channel %d:%d
\n
"
,
spanid
,
chanid
);
ftdm_channel_call_answer
(
channel
);
schedule_timer
(
channel
,
HANGUP_TIMER
,
send_hangup
);
}
/* send progress for an incoming */
static
void
send_progress
(
ftdm_channel_t
*
channel
)
{
/* we move the channel signaling state machine to UP (answered) */
int
spanid
=
ftdm_channel_get_span_id
(
channel
);
int
chanid
=
ftdm_channel_get_id
(
channel
);
ftdm_log
(
FTDM_LOG_NOTICE
,
"-- Requesting progress
\n
"
,
spanid
,
chanid
);
ftdm_channel_call_indicate
(
channel
,
FTDM_CHANNEL_INDICATE_PROGRESS
);
schedule_timer
(
channel
,
ANSWER_TIMER
,
send_answer
);
}
/* This function will be called in an undetermined signaling thread, you must not do
* any blocking operations here or the signaling stack may delay other call event processing
* The arguments for this function are defined in FIO_SIGNAL_CB_FUNCTION prototype, I just
* name them here for your convenience:
* ftdm_sigmsg_t *sigmsg
* - The sigmsg structure contains the ftdm_channel structure that represents the channel where
* the event occurred and the event_id of the signaling event that just occurred.
* */
static
FIO_SIGNAL_CB_FUNCTION
(
on_signaling_event
)
{
switch
(
sigmsg
->
event_id
)
{
/* This event signals the start of an incoming call */
case
FTDM_SIGEVENT_START
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Incoming call received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
schedule_timer
(
sigmsg
->
channel
,
PROGRESS_TIMER
,
send_progress
);
break
;
/* This event signals progress on an outgoing call */
case
FTDM_SIGEVENT_PROGRESS_MEDIA
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Progress message received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
break
;
/* This event signals answer in an outgoing call */
case
FTDM_SIGEVENT_UP
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Answer received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
/* now the channel is answered and we can use
* ftdm_channel_wait() to wait for input/output in a channel (equivalent to poll() or select())
* ftdm_channel_read() to read available data in a channel
* ftdm_channel_write() to write to the channel */
break
;
/* This event signals hangup from the other end */
case
FTDM_SIGEVENT_STOP
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Hangup received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
if
(
g_outgoing_channel
==
sigmsg
->
channel
)
{
g_outgoing_channel
=
NULL
;
}
/* release any timer for this channel */
release_timers
(
sigmsg
->
channel
);
/* acknowledge the hangup */
ftdm_channel_call_hangup
(
sigmsg
->
channel
);
break
;
default:
ftdm_log
(
FTDM_LOG_WARNING
,
"Unhandled event %s in channel %d:%d
\n
"
,
ftdm_signal_event2str
(
sigmsg
->
event_id
),
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
break
;
}
return
FTDM_SUCCESS
;
}
static
void
place_call
(
const
ftdm_span_t
*
span
,
const
char
*
number
)
{
ftdm_channel_t
*
ftdmchan
=
NULL
;
ftdm_caller_data_t
caller_data
=
{{
0
}};
ftdm_status_t
status
=
FTDM_FAIL
;
/* set destiny number */
ftdm_set_string
(
caller_data
.
dnis
.
digits
,
number
);
/* set callerid */
ftdm_set_string
(
caller_data
.
cid_name
,
"testsangomaboost"
);
ftdm_set_string
(
caller_data
.
cid_num
.
digits
,
"1234"
);
/* request to search for an outgoing channel top down with the given caller data.
* it is also an option to use ftdm_channel_open_by_group to let freetdm hunt
* an available channel in a given group instead of per span
* */
status
=
ftdm_channel_open_by_span
(
ftdm_span_get_id
(
span
),
FTDM_TOP_DOWN
,
&
caller_data
,
&
ftdmchan
);
if
(
status
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Failed to originate call
\n
"
);
return
;
}
g_outgoing_channel
=
ftdmchan
;
/* set the caller data for the outgoing channel */
ftdm_channel_set_caller_data
(
ftdmchan
,
&
caller_data
);
status
=
ftdm_channel_call_place
(
ftdmchan
);
if
(
status
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Failed to originate call
\n
"
);
return
;
}
/* this is required to initialize the outgoing channel */
ftdm_channel_init
(
ftdmchan
);
}
#define ARRLEN(arr) (sizeof(arr)/sizeof(arr[0]))
int
main
(
int
argc
,
char
*
argv
[])
{
/* span names can be any null-terminated string, does not need to be a wanpipe port */
int
span_numbers
[
32
];
char
span_names
[
ARRLEN
(
span_numbers
)][
ARRLEN
(
span_numbers
)];
const
char
*
spanname
=
NULL
;
char
wpchans
[
25
];
unsigned
configured
=
0
;
int
i
,
spanno
;
int
numspans
=
0
;
ftdm_status_t
status
;
ftdm_span_t
*
span_list
[
ARRLEN
(
span_numbers
)];
ftdm_span_t
*
span
;
ftdm_channel_config_t
chan_config
;
ftdm_conf_parameter_t
parameters
[
20
];
char
*
todial
=
NULL
;
int32_t
ticks
=
0
;
/* register a handler to shutdown things properly */
#ifdef _WIN64
// still trying to figure this one out otherwise triggers error
if
(
signal
(
SIGINT
,
interrupt_requested
)
<
0
)
{
#else
if
(
signal
(
SIGINT
,
interrupt_requested
)
==
SIG_ERR
)
{
#endif
fprintf
(
stderr
,
"Could not set the SIGINT signal handler: %s
\n
"
,
strerror
(
errno
));
exit
(
-
1
);
}
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
argv
[
i
][
0
]
==
'-'
&&
argv
[
i
][
1
]
==
'd'
)
{
i
++
;
if
(
i
>=
argc
)
{
fprintf
(
stderr
,
"Error, -d specified but no number to dial!
\n
"
);
exit
(
1
);
}
todial
=
argv
[
i
];
if
(
!
strlen
(
todial
))
{
todial
=
NULL
;
}
printf
(
"Number to dial: %s
\n
"
,
todial
);
continue
;
}
spanno
=
atoi
(
argv
[
i
]);
span_numbers
[
numspans
]
=
spanno
;
snprintf
(
span_names
[
numspans
],
sizeof
(
span_names
[
numspans
]),
"wanpipe%d"
,
spanno
);
numspans
++
;
}
if
(
!
numspans
)
{
fprintf
(
stderr
,
"please specify a at least 1 wanpipe port number
\n
"
);
exit
(
-
1
);
}
/* clear any outstanding timers */
memset
(
&
g_timers
,
0
,
sizeof
(
g_timers
));
/* set the logging level to use */
ftdm_global_set_default_logger
(
FTDM_LOG_LEVEL_DEBUG
);
/* Initialize the FTDM library */
if
(
ftdm_global_init
()
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error loading FreeTDM
\n
"
);
exit
(
-
1
);
}
/* create the schedule mutex */
ftdm_mutex_create
(
&
g_schedule_mutex
);
/* now we can start creating spans */
memset
(
&
chan_config
,
0
,
sizeof
(
chan_config
));
strncpy
(
chan_config
.
group_name
,
"mygroup"
,
sizeof
(
chan_config
.
group_name
)
-
1
);
chan_config
.
group_name
[
sizeof
(
chan_config
.
group_name
)
-
1
]
=
0
;
for
(
i
=
0
;
i
<
numspans
;
i
++
)
{
spanname
=
span_names
[
i
];
/* "wanpipe" is the special I/O identifier for Sangoma devices */
ftdm_log
(
FTDM_LOG_NOTICE
,
"Creating span %s
\n
"
,
spanname
);
status
=
ftdm_span_create
(
"wanpipe"
,
spanname
,
&
span_list
[
i
]);
if
(
status
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_CRIT
,
"Failed to create span %s
\n
"
,
spanname
);
goto
done
;
}
span
=
span_list
[
i
];
spanno
=
span_numbers
[
i
];
/* set the trunk type for the span */
ftdm_span_set_trunk_type
(
span_list
[
i
],
FTDM_TRUNK_T1
);
/* configure B channels (syntax for wanpipe channels is span:low_chan-high_chan) */
chan_config
.
type
=
FTDM_CHAN_TYPE_B
;
snprintf
(
wpchans
,
sizeof
(
wpchans
),
"%d:1-23"
,
spanno
);
ftdm_configure_span_channels
(
span
,
wpchans
,
&
chan_config
,
&
configured
);
ftdm_log
(
FTDM_LOG_NOTICE
,
"registered %d b channels
\n
"
,
configured
);
}
/* At this point FreeTDM is ready to be used, the spans defined in freetdm.conf have the basic I/O board configuration
* but no telephony signaling configuration at all. */
ftdm_log
(
FTDM_LOG_NOTICE
,
"FreeTDM loaded ...
\n
"
);
/* now we can start configuring signaling for the previously created spans */
for
(
i
=
0
;
i
<
numspans
;
i
++
)
{
spanname
=
span_names
[
i
];
/* Retrieve a span by name (as specified in ftdm_span_create()) */
if
(
ftdm_span_find_by_name
(
spanname
,
&
span
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Error finding FreeTDM span %s
\n
"
,
ftdm_span_get_name
(
span
));
goto
done
;
}
/* prepare the configuration parameters that will be sent down to the signaling stack, the array of paramters must be terminated by an
* array element with a null .var member */
/* for sangoma_boost signaling (abstraction signaling used by Sangoma for PRI, BRI and SS7) the first parameter you must send
* is sigmod, which must be either sangoma_prid, if you have the PRI stack available, or sangoma_brid for the BRI stack */
parameters
[
0
].
var
=
"sigmod"
;
parameters
[
0
].
val
=
"sangoma_prid"
;
/* following parameters are signaling stack specific, this ones are for PRI */
parameters
[
1
].
var
=
"switchtype"
;
parameters
[
1
].
val
=
"national"
;
parameters
[
2
].
var
=
"signalling"
;
parameters
[
2
].
val
=
"pri_cpe"
;
/*
* parameters[3].var = "nfas_primary";
* parameters[3].val = "4"; //span number
*
* parameters[4].var = "nfas_secondary";
* parameters[4].val = "2"; //span number
*
* parameters[5].var = "nfas_group";
* parameters[5].val = "1";
* */
/* the last parameter .var member must be NULL! */
parameters
[
3
].
var
=
NULL
;
/* send the configuration values down to the stack */
if
(
ftdm_configure_span_signaling
(
span
,
"sangoma_boost"
,
on_signaling_event
,
parameters
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Error configuring sangoma_boost signaling abstraction in span %s
\n
"
,
ftdm_span_get_name
(
span
));
goto
done
;
}
}
/* configuration succeeded, we can proceed now to start each span
* This step will launch at least 1 background (may be more, depending on the signaling stack used)
* to handle *ALL* signaling events for this span, your on_signaling_event callback will be called always
* in one of those infraestructure threads and you MUST NOT block in that handler to avoid delays and errors
* in the signaling processing for any call.
* */
for
(
i
=
0
;
i
<
numspans
;
i
++
)
{
spanname
=
span_names
[
i
];
/* Retrieve a span by name (as specified in ftdm_span_create()) */
if
(
ftdm_span_find_by_name
(
spanname
,
&
span
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Error finding FreeTDM span %s
\n
"
,
ftdm_span_get_name
(
span
));
goto
done
;
}
if
(
ftdm_span_start
(
span
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Failing starting signaling on span %s
\n
"
,
ftdm_span_get_name
(
span
));
goto
done
;
}
}
app_running
=
1
;
/* Retrieve the first created span to place the call (if dialing was specified) */
if
(
ftdm_span_find
(
1
,
&
span
)
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Error finding FreeTDM span 1
\n
"
);
goto
done
;
}
/* The application thread can go on and do anything else, like waiting for a shutdown signal */
while
(
ftdm_running
()
&&
app_running
)
{
ftdm_sleep
(
1000
);
run_timers
();
ticks
++
;
if
(
!
(
ticks
%
10
)
&&
todial
&&
!
g_outgoing_channel
)
{
ftdm_log
(
FTDM_LOG_NOTICE
,
"Originating call to number %s
\n
"
,
todial
);
place_call
(
span
,
todial
);
}
}
done:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Shutting down FreeTDM ...
\n
"
);
ftdm_mutex_destroy
(
&
g_schedule_mutex
);
/* whenever you're done, this function will shutdown the signaling threads in any span that was started */
ftdm_global_destroy
();
printf
(
"Terminated!
\n
"
);
sleep
(
2
);
exit
(
0
);
}
/* 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/testboost.c
deleted
100644 → 0
浏览文件 @
269906c8
#include "freetdm.h"
#include <stdlib.h>
static
FIO_SIGNAL_CB_FUNCTION
(
on_signal
)
{
return
FTDM_FAIL
;
}
static
int
R
=
0
;
#if 0
static void handle_SIGINT(int sig)
{
if (sig);
R = 0;
return;
}
#endif
int
main
(
int
argc
,
char
*
argv
[])
{
ftdm_conf_parameter_t
parameters
[
20
];
ftdm_span_t
*
span
;
int
local_port
,
remote_port
;
local_port
=
remote_port
=
53000
;
ftdm_global_set_default_logger
(
FTDM_LOG_LEVEL_DEBUG
);
#if 0
if (argc < 2) {
printf("invalid arguments\n");
exit(-1);
}
#endif
if
(
ftdm_global_init
()
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error loading FreeTDM
\n
"
);
exit
(
-
1
);
}
if
(
ftdm_global_configuration
()
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error configuring FreeTDM
\n
"
);
exit
(
-
1
);
}
printf
(
"FreeTDM loaded
\n
"
);
if
(
ftdm_span_find_by_name
(
"wp1"
,
&
span
)
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error finding FreeTDM span %s
\n
"
,
argv
[
1
]);
goto
done
;
}
parameters
[
0
].
var
=
"sigmod"
;
parameters
[
0
].
val
=
"sangoma_prid"
;
parameters
[
1
].
var
=
"switchtype"
;
parameters
[
1
].
val
=
"euroisdn"
;
parameters
[
1
].
var
=
"signalling"
;
parameters
[
1
].
val
=
"pri_cpe"
;
parameters
[
2
].
var
=
NULL
;
if
(
ftdm_configure_span_signaling
(
span
,
"sangoma_boost"
,
on_signal
,
parameters
)
==
FTDM_SUCCESS
)
{
ftdm_span_start
(
span
);
}
else
{
fprintf
(
stderr
,
"Error starting SS7_BOOST
\n
"
);
goto
done
;
}
while
(
ftdm_running
()
&&
R
)
{
ftdm_sleep
(
1
*
1000
);
}
done:
ftdm_global_destroy
();
return
0
;
}
/* 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/testsangomaboost.c
deleted
100644 → 0
浏览文件 @
269906c8
/*
* 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.
*/
/**
* Sample program for the boost signaling absraction.
* Usage: boostsample <span name>
* The span name must be a valid span defined in freetdm.conf
* compile this program linking to the freetdm library (ie -lfreetdm)
**/
#ifndef __linux__
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "freetdm.h"
/* arbitrary limit for max calls in this sample program */
#define MAX_CALLS 255
/* some timers (in seconds) to fake responses in incoming calls */
#define PROGRESS_TIMER 1
#define ANSWER_TIMER 5
#define HANGUP_TIMER 15
/* simple variable used to stop the application */
static
int
app_running
=
0
;
typedef
void
(
*
expired_function_t
)(
ftdm_channel_t
*
channel
);
typedef
struct
dummy_timer_s
{
int
time
;
ftdm_channel_t
*
channel
;
expired_function_t
expired
;
}
dummy_timer_t
;
/* dummy second resolution timers */
static
dummy_timer_t
g_timers
[
MAX_CALLS
];
/* mutex to protect the timers (both, the test thread and the signaling thread may modify them) */
static
ftdm_mutex_t
*
g_schedule_mutex
;
/* mutex to protect the channel */
static
ftdm_mutex_t
*
g_channel_mutex
;
/* unique outgoing channel */
static
ftdm_channel_t
*
g_outgoing_channel
=
NULL
;
static
void
interrupt_requested
(
int
signal
)
{
app_running
=
0
;
}
static
void
schedule_timer
(
ftdm_channel_t
*
channel
,
int
sec
,
expired_function_t
expired
)
{
int
i
;
ftdm_mutex_lock
(
g_schedule_mutex
);
for
(
i
=
0
;
i
<
sizeof
(
g_timers
)
/
sizeof
(
g_timers
[
0
]);
i
++
)
{
/* check the timer slot is free to use */
if
(
!
g_timers
[
i
].
time
)
{
g_timers
[
i
].
time
=
sec
;
g_timers
[
i
].
channel
=
channel
;
g_timers
[
i
].
expired
=
expired
;
ftdm_mutex_unlock
(
g_schedule_mutex
);
return
;
}
}
ftdm_log
(
FTDM_LOG_ERROR
,
"Failed to schedule timer
\n
"
);
ftdm_mutex_unlock
(
g_schedule_mutex
);
}
static
void
run_timers
(
void
)
{
int
i
;
void
*
channel
;
expired_function_t
expired_func
=
NULL
;
ftdm_mutex_lock
(
g_schedule_mutex
);
for
(
i
=
0
;
i
<
sizeof
(
g_timers
)
/
sizeof
(
g_timers
[
0
]);
i
++
)
{
/* if there's time left, decrement */
if
(
g_timers
[
i
].
time
)
{
g_timers
[
i
].
time
--
;
}
/* if time expired and we have an expired function, call it */
if
(
!
g_timers
[
i
].
time
&&
g_timers
[
i
].
expired
)
{
expired_func
=
g_timers
[
i
].
expired
;
channel
=
g_timers
[
i
].
channel
;
memset
(
&
g_timers
[
i
],
0
,
sizeof
(
g_timers
[
i
]));
expired_func
(
channel
);
}
}
ftdm_mutex_unlock
(
g_schedule_mutex
);
}
static
void
release_timers
(
ftdm_channel_t
*
channel
)
{
int
i
;
ftdm_mutex_lock
(
g_schedule_mutex
);
for
(
i
=
0
;
i
<
sizeof
(
g_timers
)
/
sizeof
(
g_timers
[
0
]);
i
++
)
{
/* clear any timer belonging to the given channel */
if
(
g_timers
[
i
].
channel
==
channel
)
{
memset
(
&
g_timers
[
i
],
0
,
sizeof
(
g_timers
[
i
]));
}
}
ftdm_mutex_unlock
(
g_schedule_mutex
);
}
/* hangup the call */
static
void
send_hangup
(
ftdm_channel_t
*
channel
)
{
char
dtmfbuff
[
100
];
int
rc
;
int
spanid
=
ftdm_channel_get_span_id
(
channel
);
int
chanid
=
ftdm_channel_get_id
(
channel
);
rc
=
ftdm_channel_dequeue_dtmf
(
channel
,
dtmfbuff
,
sizeof
(
dtmfbuff
));
if
(
rc
)
{
ftdm_log
(
FTDM_LOG_NOTICE
,
"Not hanging up channel %d:%d because has DTMF: %s
\n
"
,
spanid
,
chanid
,
dtmfbuff
);
schedule_timer
(
channel
,
HANGUP_TIMER
,
send_hangup
);
return
;
}
ftdm_log
(
FTDM_LOG_NOTICE
,
"-- Requesting hangup in channel %d:%d
\n
"
,
spanid
,
chanid
);
ftdm_channel_call_hangup
(
channel
);
}
/* send answer for an incoming call */
static
void
send_answer
(
ftdm_channel_t
*
channel
)
{
/* we move the channel signaling state machine to UP (answered) */
int
spanid
=
ftdm_channel_get_span_id
(
channel
);
int
chanid
=
ftdm_channel_get_id
(
channel
);
ftdm_log
(
FTDM_LOG_NOTICE
,
"-- Requesting answer in channel %d:%d
\n
"
,
spanid
,
chanid
);
ftdm_channel_call_answer
(
channel
);
schedule_timer
(
channel
,
HANGUP_TIMER
,
send_hangup
);
}
/* send progress for an incoming */
static
void
send_progress
(
ftdm_channel_t
*
channel
)
{
/* we move the channel signaling state machine to UP (answered) */
int
spanid
=
ftdm_channel_get_span_id
(
channel
);
int
chanid
=
ftdm_channel_get_id
(
channel
);
ftdm_log
(
FTDM_LOG_NOTICE
,
"-- Requesting progress
\n
"
,
spanid
,
chanid
);
ftdm_channel_call_indicate
(
channel
,
FTDM_CHANNEL_INDICATE_PROGRESS
);
schedule_timer
(
channel
,
ANSWER_TIMER
,
send_answer
);
}
/* This function will be called in an undetermined signaling thread, you must not do
* any blocking operations here or the signaling stack may delay other call event processing
* The arguments for this function are defined in FIO_SIGNAL_CB_FUNCTION prototype, I just
* name them here for your convenience:
* ftdm_sigmsg_t *sigmsg
* - The sigmsg structure contains the ftdm_channel structure that represents the channel where
* the event occurred and the event_id of the signaling event that just occurred.
* */
static
FIO_SIGNAL_CB_FUNCTION
(
on_signaling_event
)
{
switch
(
sigmsg
->
event_id
)
{
/* This event signals the start of an incoming call */
case
FTDM_SIGEVENT_START
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Incoming call received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
schedule_timer
(
sigmsg
->
channel
,
PROGRESS_TIMER
,
send_progress
);
break
;
/* This event signals progress on an outgoing call */
case
FTDM_SIGEVENT_PROGRESS_MEDIA
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Progress message received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
break
;
/* This event signals answer in an outgoing call */
case
FTDM_SIGEVENT_UP
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Answer received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
ftdm_channel_command
(
sigmsg
->
channel
,
FTDM_COMMAND_ENABLE_DTMF_DETECT
,
NULL
);
/* now the channel is answered and we can use
* ftdm_channel_wait() to wait for input/output in a channel (equivalent to poll() or select())
* ftdm_channel_read() to read available data in a channel
* ftdm_channel_write() to write to the channel */
break
;
/* This event signals hangup from the other end */
case
FTDM_SIGEVENT_STOP
:
ftdm_log
(
FTDM_LOG_NOTICE
,
"Hangup received in channel %d:%d
\n
"
,
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
ftdm_mutex_lock
(
g_channel_mutex
);
if
(
g_outgoing_channel
==
sigmsg
->
channel
)
{
g_outgoing_channel
=
NULL
;
}
ftdm_mutex_unlock
(
g_channel_mutex
);
/* release any timer for this channel */
release_timers
(
sigmsg
->
channel
);
/* acknowledge the hangup */
ftdm_channel_call_hangup
(
sigmsg
->
channel
);
break
;
default:
ftdm_log
(
FTDM_LOG_WARNING
,
"Unhandled event %s in channel %d:%d
\n
"
,
ftdm_signal_event2str
(
sigmsg
->
event_id
),
sigmsg
->
span_id
,
sigmsg
->
chan_id
);
break
;
}
return
FTDM_SUCCESS
;
}
static
void
place_call
(
const
ftdm_span_t
*
span
,
const
char
*
number
)
{
ftdm_channel_t
*
ftdmchan
=
NULL
;
ftdm_caller_data_t
caller_data
=
{{
0
}};
ftdm_status_t
status
=
FTDM_FAIL
;
/* set destiny number */
ftdm_set_string
(
caller_data
.
dnis
.
digits
,
number
);
/* set callerid */
ftdm_set_string
(
caller_data
.
cid_name
,
"testsangomaboost"
);
ftdm_set_string
(
caller_data
.
cid_num
.
digits
,
"1234"
);
/* request to search for an outgoing channel top down with the given caller data.
* it is also an option to use ftdm_channel_open_by_group to let freetdm hunt
* an available channel in a given group instead of per span
* */
status
=
ftdm_channel_open_by_span
(
ftdm_span_get_id
(
span
),
FTDM_TOP_DOWN
,
&
caller_data
,
&
ftdmchan
);
if
(
status
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Failed to originate call
\n
"
);
return
;
}
ftdm_mutex_lock
(
g_channel_mutex
);
g_outgoing_channel
=
ftdmchan
;
ftdm_mutex_unlock
(
g_channel_mutex
);
/* set the caller data for the outgoing channel */
ftdm_channel_set_caller_data
(
ftdmchan
,
&
caller_data
);
status
=
ftdm_channel_call_place
(
ftdmchan
);
if
(
status
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"Failed to originate call
\n
"
);
return
;
}
/* this is required to initialize the outgoing channel */
ftdm_channel_init
(
ftdmchan
);
}
static
void
*
media_thread
(
ftdm_thread_t
*
th
,
void
*
data
)
{
/* The application thread can go on and do anything else, like waiting for a shutdown signal */
ftdm_wait_flag_t
flags
=
FTDM_NO_FLAGS
;
ftdm_status_t
status
;
ftdm_channel_t
*
chan
;
char
iobuff
[
160
];
char
dnis_str
[]
=
"1234"
;
int
tx_dtmf
=
0
;
ftdm_size_t
datalen
=
0
;
memset
(
iobuff
,
0
,
sizeof
(
iobuff
));
while
(
ftdm_running
()
&&
app_running
)
{
ftdm_mutex_lock
(
g_channel_mutex
);
chan
=
g_outgoing_channel
;
ftdm_mutex_unlock
(
g_channel_mutex
);
if
(
chan
&&
tx_dtmf
)
{
flags
=
FTDM_WRITE
|
FTDM_READ
;
ftdm_channel_wait
(
chan
,
&
flags
,
100
);
if
(
flags
&
FTDM_WRITE
)
{
datalen
=
sizeof
(
iobuff
);
status
=
ftdm_channel_write
(
chan
,
iobuff
,
datalen
,
&
datalen
);
if
(
status
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"writing to channel failed
\n
"
);
}
}
if
(
flags
&
FTDM_READ
)
{
datalen
=
sizeof
(
iobuff
);
status
=
ftdm_channel_read
(
chan
,
iobuff
,
&
datalen
);
if
(
status
!=
FTDM_SUCCESS
)
{
ftdm_log
(
FTDM_LOG_ERROR
,
"reading from channel failed
\n
"
);
}
}
}
else
if
(
chan
&&
ftdm_channel_call_check_answered
(
chan
))
{
ftdm_log
(
FTDM_LOG_NOTICE
,
"Transmitting DNIS %s
\n
"
,
dnis_str
);
ftdm_channel_command
(
g_outgoing_channel
,
FTDM_COMMAND_SEND_DTMF
,
dnis_str
);
tx_dtmf
=
1
;
}
else
{
tx_dtmf
=
0
;
ftdm_sleep
(
100
);
}
}
printf
(
"Shutting down media thread ...
\n
"
);
return
NULL
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
ftdm_conf_parameter_t
parameters
[
20
];
ftdm_span_t
*
span
;
char
*
todial
=
NULL
;
const
char
*
sigtype
=
NULL
;
int32_t
ticks
=
0
;
if
(
argc
<
3
)
{
fprintf
(
stderr
,
"Usage: %s <span name> <cpe|net> [number to dial if any]
\n
"
,
argv
[
0
]);
exit
(
-
1
);
}
/* register a handler to shutdown things properly */
#ifdef _WIN64
// still trying to figure this one out otherwise triggers error
if
(
signal
(
SIGINT
,
interrupt_requested
)
<
0
)
{
#else
if
(
signal
(
SIGINT
,
interrupt_requested
)
==
SIG_ERR
)
{
#endif
fprintf
(
stderr
,
"Could not set the SIGINT signal handler: %s
\n
"
,
strerror
(
errno
));
exit
(
-
1
);
}
if
(
!
strcmp
(
argv
[
2
],
"cpe"
))
{
sigtype
=
"pri_cpe"
;
}
else
if
(
!
strcmp
(
argv
[
2
],
"net"
))
{
sigtype
=
"pri_net"
;
}
else
{
fprintf
(
stderr
,
"Valid signaling types are cpe and net only
\n
"
);
exit
(
-
1
);
}
printf
(
"Using signalling %s
\n
"
,
sigtype
);
if
(
argc
>=
4
)
{
todial
=
argv
[
3
];
if
(
!
strlen
(
todial
))
{
todial
=
NULL
;
}
}
/* clear any outstanding timers */
memset
(
&
g_timers
,
0
,
sizeof
(
g_timers
));
/* set the logging level to use */
ftdm_global_set_default_logger
(
FTDM_LOG_LEVEL_DEBUG
);
/* Initialize the FTDM library */
if
(
ftdm_global_init
()
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error loading FreeTDM
\n
"
);
exit
(
-
1
);
}
/* create the schedule and channel mutex */
ftdm_mutex_create
(
&
g_schedule_mutex
);
ftdm_mutex_create
(
&
g_channel_mutex
);
/* Load the FreeTDM configuration */
if
(
ftdm_global_configuration
()
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error configuring FreeTDM
\n
"
);
exit
(
-
1
);
}
/* At this point FreeTDM is ready to be used, the spans defined in freetdm.conf have the basic I/O board configuration
* but no telephony signaling configuration at all. */
printf
(
"FreeTDM loaded ...
\n
"
);
/* Retrieve a span by name (according to freetdm.conf) */
if
(
ftdm_span_find_by_name
(
argv
[
1
],
&
span
)
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error finding FreeTDM span %s
\n
"
,
argv
[
1
]);
goto
done
;
}
/* prepare the configuration parameters that will be sent down to the signaling stack, the array of paramters must be terminated by an
* array element with a null .var member */
/* for sangoma_boost signaling (abstraction signaling used by Sangoma for PRI, BRI and SS7) the first parameter you must send
* is sigmod, which must be either sangoma_prid, if you have the PRI stack available, or sangoma_brid for the BRI stack */
parameters
[
0
].
var
=
"sigmod"
;
parameters
[
0
].
val
=
"sangoma_prid"
;
/* following parameters are signaling stack specific, this ones are for PRI */
parameters
[
1
].
var
=
"switchtype"
;
parameters
[
1
].
val
=
"national"
;
parameters
[
2
].
var
=
"signalling"
;
parameters
[
2
].
val
=
sigtype
;
/*
* parameters[3].var = "nfas_primary";
* parameters[3].val = "4"; //span number
*
* parameters[4].var = "nfas_secondary";
* parameters[4].val = "2"; //span number
*
* parameters[5].var = "nfas_group";
* parameters[5].val = "1";
* */
/* the last parameter .var member must be NULL! */
parameters
[
3
].
var
=
NULL
;
/* send the configuration values down to the stack */
if
(
ftdm_configure_span_signaling
(
span
,
"sangoma_boost"
,
on_signaling_event
,
parameters
)
!=
FTDM_SUCCESS
)
{
fprintf
(
stderr
,
"Error configuring sangoma_boost signaling abstraction in span %s
\n
"
,
ftdm_span_get_name
(
span
));
goto
done
;
}
/* configuration succeeded, we can proceed now to start the span
* This step will launch at least 1 background (may be more, depending on the signaling stack used)
* to handle *ALL* signaling events for this span, your on_signaling_event callback will be called always
* in one of those infraestructure threads and you MUST NOT block in that handler to avoid delays and errors
* in the signaling processing for any call.
* */
ftdm_span_start
(
span
);
if
(
ftdm_thread_create_detached
(
media_thread
,
NULL
)
!=
FTDM_SUCCESS
){
fprintf
(
stderr
,
"Error launching media thread
\n
"
);
goto
done
;
}
app_running
=
1
;
/* The application thread can go on and do anything else, like waiting for a shutdown signal */
while
(
ftdm_running
()
&&
app_running
)
{
ftdm_sleep
(
1000
);
run_timers
();
ticks
++
;
if
(
!
(
ticks
%
10
)
&&
todial
&&
!
g_outgoing_channel
)
{
ftdm_log
(
FTDM_LOG_NOTICE
,
"Originating call to number %s
\n
"
,
todial
);
place_call
(
span
,
todial
);
}
}
printf
(
"Shutting down FreeTDM ...
\n
"
);
done:
ftdm_mutex_destroy
(
&
g_schedule_mutex
);
ftdm_mutex_destroy
(
&
g_channel_mutex
);
/* whenever you're done, this function will shutdown the signaling threads in any span that was started */
ftdm_global_destroy
();
return
0
;
}
/* 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:
*/
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论