Merged from master branch
This commit is contained in:
commit
995c250518
|
@ -108,5 +108,26 @@ libs/freetdm/testpri
|
|||
libs/freetdm/testr2
|
||||
libs/freetdm/testsangomaboost
|
||||
libs/freetdm/testtones
|
||||
libs/esl/fs_cli
|
||||
libs/esl/ivrd
|
||||
libs/esl/testserver
|
||||
libs/esl/testclient
|
||||
libs/libcodec2/Makefile
|
||||
libs/libcodec2/Makefile.in
|
||||
libs/libcodec2/config.guess
|
||||
libs/libcodec2/config.sub
|
||||
libs/libcodec2/configure
|
||||
libs/libcodec2/depcomp
|
||||
libs/libcodec2/install-sh
|
||||
libs/libcodec2/libtool
|
||||
libs/libcodec2/ltmain.sh
|
||||
libs/libcodec2/missing
|
||||
libs/libcodec2/src/Makefile
|
||||
libs/libcodec2/src/Makefile.in
|
||||
libs/libcodec2/unittest/Makefile
|
||||
libs/libcodec2/unittest/Makefile.in
|
||||
src/mod/applications/mod_osp/Makefile
|
||||
|
||||
src/mod/applications/mod_osp/Makefile.in
|
||||
src/mod/applications/mod_hash/Makefile
|
||||
src/mod/applications/mod_hash/Makefile.in
|
||||
src/mod/applications/mod_hash/mod_hash.log
|
||||
|
|
|
@ -48,6 +48,7 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug", "Debug", "{6374D55C-FABE-4A02-9CF1-4145308A56C5}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
debug\conf\freeswitch.xml = debug\conf\freeswitch.xml
|
||||
debug\conf\vars.xml = debug\conf\vars.xml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Build System", "_Build System", "{DB1024A8-41BF-4AD7-9AE6-13202230D1F3}"
|
||||
|
@ -58,6 +59,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Build System", "_Build Sys
|
|||
configure.in = configure.in
|
||||
Makefile.am = Makefile.am
|
||||
build\modmake.rules.in = build\modmake.rules.in
|
||||
build\modules.conf.in = build\modules.conf.in
|
||||
libs\win32\util.vbs = libs\win32\util.vbs
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -90,11 +92,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa
|
|||
conf\autoload_configs\limit.conf.xml = conf\autoload_configs\limit.conf.xml
|
||||
conf\autoload_configs\local_stream.conf.xml = conf\autoload_configs\local_stream.conf.xml
|
||||
conf\autoload_configs\logfile.conf.xml = conf\autoload_configs\logfile.conf.xml
|
||||
conf\autoload_configs\modules.conf.xml = conf\autoload_configs\modules.conf.xml
|
||||
conf\autoload_configs\openmrcp.conf.xml = conf\autoload_configs\openmrcp.conf.xml
|
||||
conf\autoload_configs\portaudio.conf.xml = conf\autoload_configs\portaudio.conf.xml
|
||||
conf\autoload_configs\rss.conf.xml = conf\autoload_configs\rss.conf.xml
|
||||
conf\autoload_configs\sofia.conf.xml = conf\autoload_configs\sofia.conf.xml
|
||||
conf\autoload_configs\spidermonkey.conf.xml = conf\autoload_configs\spidermonkey.conf.xml
|
||||
conf\autoload_configs\switch.conf.xml = conf\autoload_configs\switch.conf.xml
|
||||
conf\autoload_configs\syslog.conf.xml = conf\autoload_configs\syslog.conf.xml
|
||||
conf\autoload_configs\voicemail.conf.xml = conf\autoload_configs\voicemail.conf.xml
|
||||
conf\autoload_configs\wanpipe.conf.xml = conf\autoload_configs\wanpipe.conf.xml
|
||||
|
@ -119,6 +123,7 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profiles", "{8E2E8798-8B6F-4A55-8E4F-4E6FDE40ED26}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
conf\sip_profiles\external.xml = conf\sip_profiles\external.xml
|
||||
conf\sip_profiles\internal.xml = conf\sip_profiles\internal.xml
|
||||
conf\sip_profiles\nat.xml = conf\sip_profiles\nat.xml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -207,6 +212,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{D44DD429-FE98-42AA-B5B7-4B4EBE33AEFD}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
debug\conf\dialplan\default.xml = debug\conf\dialplan\default.xml
|
||||
debug\conf\dialplan\US.conf.xml = debug\conf\dialplan\US.conf.xml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -2207,10 +2213,12 @@ Global
|
|||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.All|x64.ActiveCfg = Release|Any CPU
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Debug|Win32.Build.0 = Debug|Any CPU
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Debug|x64.Build.0 = Debug|x64
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Release|x64.ActiveCfg = Release|x64
|
||||
{834E2B2F-5483-4B80-8FE3-FE48FF76E5C0}.Release|x64.Build.0 = Release|x64
|
||||
{E796E337-DE78-4303-8614-9A590862EE95}.All|Win32.ActiveCfg = Release|Win32
|
||||
{E796E337-DE78-4303-8614-9A590862EE95}.All|Win32.Build.0 = Release|Win32
|
||||
{E796E337-DE78-4303-8614-9A590862EE95}.All|x64.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -63,7 +63,7 @@ endpoints/mod_loopback
|
|||
#endpoints/mod_skypopen
|
||||
#endpoints/mod_h323
|
||||
#../../libs/openzap/mod_openzap
|
||||
../../libs/freetdm/mod_freetdm
|
||||
#../../libs/freetdm/mod_freetdm
|
||||
#asr_tts/mod_unimrcp
|
||||
#asr_tts/mod_flite
|
||||
#asr_tts/mod_pocketsphinx
|
||||
|
|
|
@ -48,6 +48,24 @@ fi
|
|||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that sets ulimit values for the daemon
|
||||
#
|
||||
do_setlimits() {
|
||||
ulimit -c unlimited
|
||||
ulimit -d unlimited
|
||||
ulimit -f unlimited
|
||||
ulimit -i unlimited
|
||||
ulimit -n 999999
|
||||
ulimit -q unlimited
|
||||
ulimit -u unlimited
|
||||
ulimit -v unlimited
|
||||
ulimit -x unlimited
|
||||
ulimit -s 240
|
||||
ulimit -l unlimited
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
|
@ -59,6 +77,7 @@ do_start()
|
|||
# 2 if daemon could not be started
|
||||
start-stop-daemon -d $WORKDIR -c $USER --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
||||
|| return 1
|
||||
do_setlimits
|
||||
start-stop-daemon -d $WORKDIR -c $USER --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
|
||||
$FREESWITCH_PARAMS \
|
||||
|| return 2
|
||||
|
|
|
@ -2434,7 +2434,7 @@ static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans)
|
|||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (ftdm_array_len(spanparameters) == paramindex) {
|
||||
if (ftdm_array_len(spanparameters) - 1 == paramindex) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Too many parameters for ss7 span, ignoring any parameter after %s\n", var);
|
||||
break;
|
||||
}
|
||||
|
@ -2594,7 +2594,7 @@ static switch_status_t load_config(void)
|
|||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (sizeof(spanparameters)/sizeof(spanparameters[0]) == paramindex) {
|
||||
if (ftdm_array_len(spanparameters) - 1 == paramindex) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Too many parameters for ss7 span, ignoring any parameter after %s\n", var);
|
||||
break;
|
||||
}
|
||||
|
@ -2923,102 +2923,56 @@ static switch_status_t load_config(void)
|
|||
|
||||
if ((spans = switch_xml_child(cfg, "pri_spans"))) {
|
||||
for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
|
||||
char *id = (char *) switch_xml_attr(myspan, "id");
|
||||
char *name = (char *) switch_xml_attr(myspan, "name");
|
||||
ftdm_conf_parameter_t spanparameters[10];
|
||||
ftdm_status_t zstatus = FTDM_FAIL;
|
||||
const char *context = "default";
|
||||
const char *dialplan = "XML";
|
||||
//Q921NetUser_t mode = Q931_TE;
|
||||
//Q931Dialect_t dialect = Q931_Dialect_National;
|
||||
char *mode = NULL;
|
||||
char *dialect = NULL;
|
||||
uint32_t span_id = 0;
|
||||
unsigned paramindex = 0;
|
||||
ftdm_span_t *span = NULL;
|
||||
const char *tonegroup = NULL;
|
||||
char *digit_timeout = NULL;
|
||||
const char *opts = "none";
|
||||
uint32_t to = 0;
|
||||
int q921loglevel = -1;
|
||||
int q931loglevel = -1;
|
||||
uint32_t span_id = 0;
|
||||
|
||||
// quick debug
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ID: '%s', Name:'%s'\n",id,name);
|
||||
if (!name) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required attribute 'name'\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(spanparameters, 0, sizeof(spanparameters));
|
||||
|
||||
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcasecmp(var, "tonegroup")) {
|
||||
tonegroup = val;
|
||||
} else if (!strcasecmp(var, "mode")) {
|
||||
mode = val;
|
||||
} else if (!strcasecmp(var, "dialect")) {
|
||||
dialect = val;
|
||||
} else if (!strcasecmp(var, "q921loglevel")) {
|
||||
if ((q921loglevel = switch_log_str2level(val)) == SWITCH_LOG_INVALID) {
|
||||
q921loglevel = -1;
|
||||
}
|
||||
} else if (!strcasecmp(var, "q931loglevel")) {
|
||||
if ((q931loglevel = switch_log_str2level(val)) == SWITCH_LOG_INVALID) {
|
||||
q931loglevel = -1;
|
||||
}
|
||||
} else if (!strcasecmp(var, "context")) {
|
||||
if (ftdm_array_len(spanparameters) - 1 == paramindex) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Too many parameters for pri span '%s', ignoring everything after '%s'\n", name, var);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ftdm_strlen_zero(var) || ftdm_strlen_zero(val)) {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Skipping parameter with empty name or value\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcasecmp(var, "context")) {
|
||||
context = val;
|
||||
} else if (!strcasecmp(var, "opts")) {
|
||||
opts = val;
|
||||
} else if (!strcasecmp(var, "dialplan")) {
|
||||
dialplan = val;
|
||||
} else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) {
|
||||
digit_timeout = val;
|
||||
} else {
|
||||
spanparameters[paramindex].var = var;
|
||||
spanparameters[paramindex].val = val;
|
||||
paramindex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!id && !name) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required param 'id'\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name) {
|
||||
zstatus = ftdm_span_find_by_name(name, &span);
|
||||
} else {
|
||||
if (switch_is_number(id)) {
|
||||
span_id = atoi(id);
|
||||
zstatus = ftdm_span_find(span_id, &span);
|
||||
}
|
||||
|
||||
if (zstatus != FTDM_SUCCESS) {
|
||||
zstatus = ftdm_span_find_by_name(id, &span);
|
||||
}
|
||||
}
|
||||
|
||||
if (digit_timeout) {
|
||||
to = atoi(digit_timeout);
|
||||
}
|
||||
|
||||
zstatus = ftdm_span_find_by_name(name, &span);
|
||||
if (zstatus != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name));
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span %s\n", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!span_id) {
|
||||
span_id = ftdm_span_get_id(span);
|
||||
}
|
||||
|
||||
if (!tonegroup) {
|
||||
tonegroup = "us";
|
||||
}
|
||||
|
||||
if (ftdm_configure_span(span, "isdn", on_clear_channel_signal,
|
||||
"mode", mode,
|
||||
"dialect", dialect,
|
||||
"digit_timeout", &to,
|
||||
"opts", opts,
|
||||
"tonemap", tonegroup,
|
||||
"q921loglevel", q921loglevel,
|
||||
"q931loglevel", q931loglevel,
|
||||
FTDM_TAG_END) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error starting FreeTDM span %d mode: %s dialect: %s error: %s\n", span_id,
|
||||
mode, dialect, ftdm_span_get_last_error(span));
|
||||
span_id = ftdm_span_get_id(span);
|
||||
if (ftdm_configure_span_signaling(span, "isdn", on_clear_channel_signal, spanparameters) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM span %s\n", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3049,10 +3003,17 @@ static switch_status_t load_config(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
memset(spanparameters, 0, sizeof(spanparameters));
|
||||
|
||||
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (ftdm_array_len(spanparameters) - 1 == paramindex) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Too many parameters for pritap span '%s', ignoring everything after '%s'\n", name, var);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strcasecmp(var, "context")) {
|
||||
context = val;
|
||||
} else if (!strcasecmp(var, "dialplan")) {
|
||||
|
@ -3102,10 +3063,22 @@ static switch_status_t load_config(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
for (param = switch_xml_child(myspan, "param"); param && paramindex < 10; param = param->next) {
|
||||
memset(spanparameters, 0, sizeof(spanparameters));
|
||||
|
||||
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (ftdm_array_len(spanparameters) - 1 == paramindex) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Too many parameters for libpri span, ignoring everything after '%s'\n", var);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ftdm_strlen_zero(var) || ftdm_strlen_zero(val)) {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Skipping parameter with empty name or value\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcasecmp(var, "context")) {
|
||||
context = val;
|
||||
} else if (!strcasecmp(var, "dialplan")) {
|
||||
|
@ -3165,7 +3138,8 @@ static switch_status_t load_config(void)
|
|||
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (sizeof(spanparameters)/sizeof(spanparameters[0]) == paramindex) {
|
||||
|
||||
if (ftdm_array_len(spanparameters) - 1 == paramindex) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Too many parameters for boost span, ignoring any parameter after %s\n", var);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,134 +0,0 @@
|
|||
Index: src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c
|
||||
===================================================================
|
||||
--- src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c (revision 745)
|
||||
+++ src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c (working copy)
|
||||
@@ -98,19 +98,21 @@
|
||||
* so we can have one analong handler thread that will deal with all the idle analog channels for events
|
||||
* the alternative would be for the driver to provide one socket for all of the oob events for all analog channels
|
||||
*/
|
||||
-static __inline__ int tdmv_api_wait_socket(sng_fd_t fd, int timeout, int *flags)
|
||||
+static __inline__ int tdmv_api_wait_socket(zap_channel_t *zchan, int timeout, int *flags)
|
||||
{
|
||||
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
int err;
|
||||
- sangoma_wait_obj_t sangoma_wait_obj;
|
||||
+ sangoma_wait_obj_t *sangoma_wait_obj = zchan->mod_data;
|
||||
|
||||
- sangoma_init_wait_obj(&sangoma_wait_obj, fd, 1, 1, *flags, SANGOMA_WAIT_OBJ);
|
||||
+ sangoma_init_wait_obj(sangoma_wait_obj, zchan->sockfd, 1, 1, 0, SANGOMA_WAIT_OBJ);
|
||||
|
||||
- err=sangoma_socket_waitfor_many(&sangoma_wait_obj,1 , timeout);
|
||||
+ err = sangoma_socket_waitfor_many(&sangoma_wait_obj, 1, timeout);
|
||||
+
|
||||
if (err > 0) {
|
||||
- *flags=sangoma_wait_obj.flags_out;
|
||||
+ *flags = sangoma_wait_obj.flags_out;
|
||||
}
|
||||
+
|
||||
return err;
|
||||
|
||||
#else
|
||||
@@ -118,7 +120,7 @@
|
||||
int res;
|
||||
|
||||
memset(&pfds[0], 0, sizeof(pfds[0]));
|
||||
- pfds[0].fd = fd;
|
||||
+ pfds[0].fd = zchan->sockfd;
|
||||
pfds[0].events = *flags;
|
||||
res = poll(pfds, 1, timeout);
|
||||
*flags = 0;
|
||||
@@ -200,6 +202,15 @@
|
||||
|
||||
if (sockfd != WP_INVALID_SOCKET && zap_span_add_channel(span, sockfd, type, &chan) == ZAP_SUCCESS) {
|
||||
wanpipe_tdm_api_t tdm_api;
|
||||
+#ifdef LIBSANGOMA_VERSION
|
||||
+ sangoma_wait_obj_t *sangoma_wait_obj;
|
||||
+
|
||||
+ sangoma_wait_obj = malloc(sizeof(*sangoma_wait_obj));
|
||||
+ memset(sangoma_wait_obj, 0, sizeof(*sangoma_wait_obj));
|
||||
+ sangoma_init_wait_obj(sangoma_wait_obj, sockfd, 1, 1, 0, SANGOMA_WAIT_OBJ);
|
||||
+ chan->mod_data = sangoma_wait_obj;
|
||||
+#endif
|
||||
+
|
||||
memset(&tdm_api,0,sizeof(tdm_api));
|
||||
|
||||
chan->physical_span_id = spanno;
|
||||
@@ -211,7 +222,7 @@
|
||||
|
||||
dtmf = "software";
|
||||
|
||||
- /* FIXME: Handle Error Conditino Check for return code */
|
||||
+ /* FIXME: Handle Error Condition Check for return code */
|
||||
err= sangoma_tdm_get_hw_coding(chan->sockfd, &tdm_api);
|
||||
|
||||
if (tdm_api.wp_tdm_cmd.hw_tdm_coding) {
|
||||
@@ -606,7 +617,7 @@
|
||||
inflags |= POLLPRI;
|
||||
}
|
||||
|
||||
- result = tdmv_api_wait_socket(zchan->sockfd, to, &inflags);
|
||||
+ result = tdmv_api_wait_socket(zchan, to, &inflags);
|
||||
|
||||
*flags = ZAP_NO_FLAGS;
|
||||
|
||||
@@ -643,26 +654,30 @@
|
||||
ZIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event)
|
||||
{
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
- sangoma_wait_obj_t pfds[ZAP_MAX_CHANNELS_SPAN];
|
||||
+ sangoma_wait_obj_t *pfds[ZAP_MAX_CHANNELS_SPAN] = { 0 };
|
||||
#else
|
||||
struct pollfd pfds[ZAP_MAX_CHANNELS_SPAN];
|
||||
#endif
|
||||
|
||||
uint32_t i, j = 0, k = 0, l = 0;
|
||||
- int objects=0;
|
||||
int r;
|
||||
|
||||
for(i = 1; i <= span->chan_count; i++) {
|
||||
zap_channel_t *zchan = span->channels[i];
|
||||
|
||||
+
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
- sangoma_init_wait_obj(&pfds[j], zchan->sockfd , 1, 1, POLLPRI, SANGOMA_WAIT_OBJ);
|
||||
+ if (!zchan->mod_data) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ pfds[j] = zchan->mod_data;
|
||||
+
|
||||
#else
|
||||
memset(&pfds[j], 0, sizeof(pfds[j]));
|
||||
pfds[j].fd = span->channels[i]->sockfd;
|
||||
pfds[j].events = POLLPRI;
|
||||
#endif
|
||||
- objects++;
|
||||
+
|
||||
/* The driver probably should be able to do this wink/flash/ringing by itself this is sort of a hack to make it work! */
|
||||
|
||||
if (zap_test_flag(zchan, ZAP_CHANNEL_WINK) || zap_test_flag(zchan, ZAP_CHANNEL_FLASH)) {
|
||||
@@ -703,7 +718,7 @@
|
||||
ms = l;
|
||||
}
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
- r = sangoma_socket_waitfor_many(pfds,objects,ms);
|
||||
+ r = sangoma_socket_waitfor_many(pfds, j, ms);
|
||||
#else
|
||||
r = poll(pfds, j, ms);
|
||||
#endif
|
||||
@@ -935,6 +950,15 @@
|
||||
*/
|
||||
static ZIO_CHANNEL_DESTROY_FUNCTION(wanpipe_channel_destroy)
|
||||
{
|
||||
+ sangoma_wait_obj_t *sangoma_wait_obj;
|
||||
+
|
||||
+ if (zchan->mod_data) {
|
||||
+ sangoma_wait_obj = zchan->mod_data;
|
||||
+ zchan->mod_data = NULL;
|
||||
+ sangoma_release_wait_obj(sangoma_wait_obj);
|
||||
+ free(sangoma_wait_obj);
|
||||
+ }
|
||||
+
|
||||
if (zchan->sockfd > -1) {
|
||||
close(zchan->sockfd);
|
||||
zchan->sockfd = WP_INVALID_SOCKET;
|
|
@ -1918,6 +1918,11 @@ FT_DECLARE(ftdm_trunk_type_t) ftdm_span_get_trunk_type(const ftdm_span_t *span)
|
|||
return span->trunk_type;
|
||||
}
|
||||
|
||||
FT_DECLARE(const char *) ftdm_span_get_trunk_type_str(const ftdm_span_t *span)
|
||||
{
|
||||
return ftdm_trunk_type2str(span->trunk_type);
|
||||
}
|
||||
|
||||
FT_DECLARE(uint32_t) ftdm_span_get_id(const ftdm_span_t *span)
|
||||
{
|
||||
return span->span_id;
|
||||
|
@ -2117,6 +2122,15 @@ FT_DECLARE(ftdm_caller_data_t *) ftdm_channel_get_caller_data(ftdm_channel_t *ft
|
|||
return &ftdmchan->caller_data;
|
||||
}
|
||||
|
||||
FT_DECLARE(int) ftdm_channel_get_state(const ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
int state;
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
state = ftdmchan->state;
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
return state;
|
||||
}
|
||||
|
||||
FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
const char *state;
|
||||
|
@ -2126,6 +2140,15 @@ FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *ftdmch
|
|||
return state;
|
||||
}
|
||||
|
||||
FT_DECLARE(int) ftdm_channel_get_last_state(const ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
int last_state;
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
last_state = ftdmchan->last_state;
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
return last_state;
|
||||
}
|
||||
|
||||
FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
const char *state;
|
||||
|
|
|
@ -484,7 +484,7 @@ static FIO_SPAN_NEXT_EVENT_FUNCTION(m3ua_next_event)
|
|||
|
||||
static FIO_SPAN_DESTROY_FUNCTION(m3ua_span_destroy)
|
||||
{
|
||||
m3ua_span_data_t *span_data = (m3ua_span_data_t *) span->mod_data;
|
||||
m3ua_span_data_t *span_data = (m3ua_span_data_t *) span->io_data;
|
||||
|
||||
if (span_data) {
|
||||
ftdm_safe_free(span_data);
|
||||
|
@ -494,8 +494,8 @@ static FIO_SPAN_DESTROY_FUNCTION(m3ua_span_destroy)
|
|||
}
|
||||
static FIO_CHANNEL_DESTROY_FUNCTION(m3ua_channel_destroy)
|
||||
{
|
||||
m3ua_chan_data_t *chan_data = (m3ua_chan_data_t *) ftdmchan->mod_data;
|
||||
m3ua_span_data_t *span_data = (m3ua_span_data_t *) ftdmchan->span->mod_data;
|
||||
m3ua_chan_data_t *chan_data = (m3ua_chan_data_t *) ftdmchan->io_data;
|
||||
m3ua_span_data_t *span_data = (m3ua_span_data_t *) ftdmchan->span->io_data;
|
||||
|
||||
if (!chan_data) {
|
||||
return FTDM_FAIL;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -54,35 +54,20 @@ typedef enum {
|
|||
|
||||
struct ftdm_libpri_data {
|
||||
ftdm_channel_t *dchan;
|
||||
ftdm_channel_t *dchans[2];
|
||||
struct ftdm_sigmsg sigmsg;
|
||||
uint32_t flags;
|
||||
int32_t mode;
|
||||
ftdm_isdn_opts_t opts;
|
||||
uint32_t flags;
|
||||
uint32_t debug_mask;
|
||||
|
||||
int node;
|
||||
int pswitch;
|
||||
char *dialplan;
|
||||
unsigned int l1;
|
||||
unsigned int dp;
|
||||
|
||||
int debug;
|
||||
int mode;
|
||||
int dialect;
|
||||
unsigned int layer1;
|
||||
unsigned int ton;
|
||||
|
||||
lpwrap_pri_t spri;
|
||||
};
|
||||
|
||||
typedef struct ftdm_libpri_data ftdm_libpri_data_t;
|
||||
|
||||
|
||||
/* b-channel private data */
|
||||
struct ftdm_isdn_bchan_data
|
||||
{
|
||||
int32_t digit_timeout;
|
||||
};
|
||||
|
||||
typedef struct ftdm_isdn_bchan_data ftdm_isdn_bchan_data_t;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
|
|
|
@ -266,7 +266,7 @@ PK_VOID PK_CALLBACK media_out_callback(PKH_TPikaEvent *event)
|
|||
{
|
||||
PK_STATUS pk_status;
|
||||
ftdm_channel_t *ftdmchan = event->userData;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
|
||||
//PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH];
|
||||
//PKH_EVENT_GetText(event->id, event_text, sizeof(event_text));
|
||||
|
@ -345,8 +345,8 @@ static unsigned pika_open_range(ftdm_span_t *span, unsigned boardno, unsigned sp
|
|||
|
||||
}
|
||||
|
||||
if (span->mod_data) {
|
||||
span_data = span->mod_data;
|
||||
if (span->io_data) {
|
||||
span_data = span->io_data;
|
||||
} else {
|
||||
span_data = ftdm_malloc(sizeof(*span_data));
|
||||
assert(span_data != NULL);
|
||||
|
@ -364,7 +364,7 @@ static unsigned pika_open_range(ftdm_span_t *span, unsigned boardno, unsigned sp
|
|||
|
||||
//PKH_QUEUE_Attach(span_data->event_queue, globals.open_boards[boardno], NULL);
|
||||
|
||||
span->mod_data = span_data;
|
||||
span->io_data = span_data;
|
||||
}
|
||||
|
||||
if (type == FTDM_CHAN_TYPE_FXS || type == FTDM_CHAN_TYPE_FXO) {
|
||||
|
@ -380,7 +380,7 @@ static unsigned pika_open_range(ftdm_span_t *span, unsigned boardno, unsigned sp
|
|||
assert(chan_data);
|
||||
memset(chan_data, 0, sizeof(*chan_data));
|
||||
ftdm_span_add_channel(span, 0, type, &chan);
|
||||
chan->mod_data = chan_data;
|
||||
chan->io_data = chan_data;
|
||||
|
||||
if ((type == FTDM_CHAN_TYPE_B || type == FTDM_CHAN_TYPE_DQ921) && !span_data->handle) {
|
||||
PKH_TBoardConfig boardConfig;
|
||||
|
@ -680,7 +680,7 @@ static FIO_CONFIGURE_SPAN_FUNCTION(pika_configure_span)
|
|||
*/
|
||||
static FIO_OPEN_FUNCTION(pika_open)
|
||||
{
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
|
||||
if (!chan_data && !ftdm_test_flag(chan_data, PK_FLAG_READY)) {
|
||||
return FTDM_FAIL;
|
||||
|
@ -715,7 +715,7 @@ static FIO_CLOSE_FUNCTION(pika_close)
|
|||
*/
|
||||
static FIO_WAIT_FUNCTION(pika_wait)
|
||||
{
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
PK_STATUS status;
|
||||
ftdm_wait_flag_t myflags = *flags;
|
||||
PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH];
|
||||
|
@ -754,7 +754,7 @@ static FIO_WAIT_FUNCTION(pika_wait)
|
|||
*/
|
||||
static FIO_READ_FUNCTION(pika_read)
|
||||
{
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
PK_STATUS status;
|
||||
PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH];
|
||||
uint32_t len;
|
||||
|
@ -795,7 +795,7 @@ static FIO_READ_FUNCTION(pika_read)
|
|||
*/
|
||||
static FIO_WRITE_FUNCTION(pika_write)
|
||||
{
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
PK_STATUS status;
|
||||
|
||||
if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) {
|
||||
|
@ -821,8 +821,8 @@ static FIO_WRITE_FUNCTION(pika_write)
|
|||
*/
|
||||
static FIO_COMMAND_FUNCTION(pika_command)
|
||||
{
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
//pika_span_data_t *span_data = (pika_span_data_t *) ftdmchan->span->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
//pika_span_data_t *span_data = (pika_span_data_t *) ftdmchan->span->io_data;
|
||||
PK_STATUS pk_status;
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
|
||||
|
@ -956,7 +956,7 @@ static FIO_COMMAND_FUNCTION(pika_command)
|
|||
*/
|
||||
static FIO_SPAN_POLL_EVENT_FUNCTION(pika_poll_event)
|
||||
{
|
||||
pika_span_data_t *span_data = (pika_span_data_t *) span->mod_data;
|
||||
pika_span_data_t *span_data = (pika_span_data_t *) span->io_data;
|
||||
PK_STATUS status;
|
||||
PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH];
|
||||
|
||||
|
@ -1025,7 +1025,7 @@ static FIO_SPAN_POLL_EVENT_FUNCTION(pika_poll_event)
|
|||
for(x = 1; x <= span->chan_count; x++) {
|
||||
ftdmchan = span->channels[x];
|
||||
assert(ftdmchan != NULL);
|
||||
chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
assert(chan_data != NULL);
|
||||
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ static FIO_SPAN_POLL_EVENT_FUNCTION(pika_poll_event)
|
|||
//ftdm_log(FTDM_LOG_DEBUG, "Event: %s\n", event_text);
|
||||
|
||||
if (ftdmchan) {
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
|
||||
assert(chan_data != NULL);
|
||||
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_EVENT);
|
||||
|
@ -1068,7 +1068,7 @@ static FIO_SPAN_NEXT_EVENT_FUNCTION(pika_next_event)
|
|||
|
||||
for(i = 1; i <= span->chan_count; i++) {
|
||||
if (ftdm_test_flag(span->channels[i], FTDM_CHANNEL_EVENT)) {
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) span->channels[i]->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) span->channels[i]->io_data;
|
||||
PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH];
|
||||
|
||||
ftdm_clear_flag(span->channels[i], FTDM_CHANNEL_EVENT);
|
||||
|
@ -1207,7 +1207,7 @@ static FIO_SPAN_NEXT_EVENT_FUNCTION(pika_next_event)
|
|||
*/
|
||||
static FIO_SPAN_DESTROY_FUNCTION(pika_span_destroy)
|
||||
{
|
||||
pika_span_data_t *span_data = (pika_span_data_t *) span->mod_data;
|
||||
pika_span_data_t *span_data = (pika_span_data_t *) span->io_data;
|
||||
|
||||
if (span_data) {
|
||||
PKH_QUEUE_Destroy(span_data->event_queue);
|
||||
|
@ -1224,8 +1224,8 @@ static FIO_SPAN_DESTROY_FUNCTION(pika_span_destroy)
|
|||
*/
|
||||
static FIO_CHANNEL_DESTROY_FUNCTION(pika_channel_destroy)
|
||||
{
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->mod_data;
|
||||
pika_span_data_t *span_data = (pika_span_data_t *) ftdmchan->span->mod_data;
|
||||
pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data;
|
||||
pika_span_data_t *span_data = (pika_span_data_t *) ftdmchan->span->io_data;
|
||||
|
||||
if (!chan_data) {
|
||||
return FTDM_FAIL;
|
||||
|
|
|
@ -31,11 +31,15 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef __linux__
|
||||
#ifndef _BSD_SOURCE
|
||||
#define _BSD_SOURCE /* for strsep() */
|
||||
#endif
|
||||
#include <syscall.h>
|
||||
#include <poll.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <openr2.h>
|
||||
#include "freetdm.h"
|
||||
#include "private/ftdm_core.h"
|
||||
|
@ -879,7 +883,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_r2_configure_span)
|
|||
ftdm_r2_call_t *r2call = NULL;
|
||||
openr2_chan_t *r2chan = NULL;
|
||||
openr2_log_level_t tmplevel;
|
||||
char *clevel;
|
||||
char *clevel = NULL;
|
||||
char *logval = NULL;
|
||||
|
||||
ft_r2_conf_t r2conf =
|
||||
|
@ -887,20 +891,21 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_r2_configure_span)
|
|||
/* .variant */ OR2_VAR_ITU,
|
||||
/* .category */ OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER,
|
||||
/* .loglevel */ OR2_LOG_ERROR | OR2_LOG_WARNING,
|
||||
/* .logdir */ NULL,
|
||||
/* .advanced_protocol_file */ NULL,
|
||||
/* .max_ani */ 10,
|
||||
/* .max_dnis */ 4,
|
||||
/* .mfback_timeout */ -1,
|
||||
/* .metering_pulse_timeout */ -1,
|
||||
/* .allow_collect_calls */ -1,
|
||||
/* .immediate_accept */ -1,
|
||||
/* .skip_category */ -1,
|
||||
/* .forced_release */ -1,
|
||||
/* .charge_calls */ -1,
|
||||
/* .get_ani_first */ -1,
|
||||
/* .call_files */ 0,
|
||||
/* .mf_files */ 0,
|
||||
/* .logdir */ NULL,
|
||||
/* .advanced_protocol_file */ NULL
|
||||
/* .double_answer */ 0,
|
||||
/* .charge_calls */ -1,
|
||||
/* .forced_release */ -1,
|
||||
/* .allow_collect_calls */ -1
|
||||
};
|
||||
|
||||
assert(sig_cb != NULL);
|
||||
|
@ -982,15 +987,6 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_r2_configure_span)
|
|||
}
|
||||
if (ftdm_strlen_zero_buf(val)) {
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Ignoring empty R2 advanced_protocol_file parameter\n");
|
||||
/*
|
||||
* TODO: investigate this
|
||||
*
|
||||
* despite the fact advanced_protocol_file was initialized as NULL, it's now a bad
|
||||
* pointer - hence, this workaround.
|
||||
* this seems to happen only on windows.
|
||||
*
|
||||
*/
|
||||
r2conf.advanced_protocol_file = NULL;
|
||||
continue;
|
||||
}
|
||||
r2conf.advanced_protocol_file = val;
|
||||
|
@ -1615,22 +1611,13 @@ static FIO_API_FUNCTION(ftdm_r2_api)
|
|||
r2data->loops,
|
||||
r2data->monitor_thread_id);
|
||||
stream->write_function(stream, "\n");
|
||||
stream->write_function(stream, "%4s %-12.12s %-12.12s %6s %6s %6s %6s\n", "Channel", "Tx CAS", "Rx CAS",
|
||||
"Rx Avg", "Tx Avg", "Rx", "Tx");
|
||||
stream->write_function(stream, "%4s %-12.12s %-12.12s\n", "Channel", "Tx CAS", "Rx CAS");
|
||||
for (i = 1; i <= span->chan_count; i++) {
|
||||
char rx_str[25];
|
||||
char tx_str[25];
|
||||
char rxavg_str[25];
|
||||
char txavg_str[25];
|
||||
r2chan = R2CALL(span->channels[i])->r2chan;
|
||||
stream->write_function(stream, "%4d %-12.12s %-12.12s %6s %6s %6s %6s\n",
|
||||
stream->write_function(stream, "%4d %-12.12s %-12.12s\n",
|
||||
span->channels[i]->chan_id,
|
||||
openr2_chan_get_tx_cas_string(r2chan),
|
||||
openr2_chan_get_rx_cas_string(r2chan),
|
||||
rxavg_str,
|
||||
txavg_str,
|
||||
rx_str,
|
||||
tx_str);
|
||||
openr2_chan_get_rx_cas_string(r2chan));
|
||||
}
|
||||
stream->write_function(stream, "\n");
|
||||
stream->write_function(stream, "+OK.\n");
|
||||
|
|
|
@ -59,9 +59,6 @@ static sng_isdn_event_interface_t g_sngisdn_event_interface;
|
|||
|
||||
ftdm_sngisdn_data_t g_sngisdn_data;
|
||||
|
||||
extern ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt);
|
||||
extern ftdm_status_t sngisdn_check_free_ids(void);
|
||||
|
||||
ftdm_state_map_t sangoma_isdn_state_map = {
|
||||
{
|
||||
{
|
||||
|
|
|
@ -270,16 +270,13 @@ extern ftdm_sngisdn_data_t g_sngisdn_data;
|
|||
ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span);
|
||||
|
||||
/* Support functions */
|
||||
FT_DECLARE_INLINE(uint32_t) get_unique_suInstId(int16_t cc_id);
|
||||
FT_DECLARE_INLINE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info);
|
||||
FT_DECLARE_INLINE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info);
|
||||
FT_DECLARE(uint32_t) get_unique_suInstId(int16_t cc_id);
|
||||
FT_DECLARE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info);
|
||||
FT_DECLARE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info);
|
||||
|
||||
|
||||
void stack_hdr_init(Header *hdr);
|
||||
void stack_pst_init(Pst *pst);
|
||||
FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data);
|
||||
FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data);
|
||||
FT_DECLARE_INLINE(ftdm_status_t) sngisdn_set_avail_rate(ftdm_span_t *ftdmspan, sngisdn_avail_t avail);
|
||||
|
||||
/* Outbound Call Control functions */
|
||||
void sngisdn_snd_setup(ftdm_channel_t *ftdmchan);
|
||||
|
@ -340,6 +337,14 @@ void sngisdn_process_rst_ind (sngisdn_event_data_t *sngisdn_event);
|
|||
|
||||
void sngisdn_rcv_phy_ind(SuId suId, Reason reason);
|
||||
void sngisdn_rcv_q921_ind(BdMngmt *status);
|
||||
|
||||
void sngisdn_trace_q921(char* str, uint8_t* data, uint32_t data_len);
|
||||
void sngisdn_trace_q931(char* str, uint8_t* data, uint32_t data_len);
|
||||
void get_memory_info(void);
|
||||
|
||||
ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt);
|
||||
ftdm_status_t sngisdn_check_free_ids(void);
|
||||
|
||||
void sngisdn_rcv_q921_trace(BdMngmt *trc, Buffer *mBuf);
|
||||
void sngisdn_rcv_q931_ind(InMngmt *status);
|
||||
void sngisdn_rcv_q931_trace(InMngmt *trc, Buffer *mBuf);
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
|
||||
#include "ftmod_sangoma_isdn.h"
|
||||
|
||||
extern ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb);
|
||||
extern ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb);
|
||||
extern ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb);
|
||||
extern ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display);
|
||||
|
||||
/* Remote side transmit a SETUP */
|
||||
void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
|
||||
{
|
||||
|
|
|
@ -34,12 +34,6 @@
|
|||
|
||||
#include "ftmod_sangoma_isdn.h"
|
||||
|
||||
extern ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm);
|
||||
extern ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm);
|
||||
extern ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan);
|
||||
extern ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm);
|
||||
|
||||
|
||||
void sngisdn_snd_setup(ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
ConEvnt conEvnt;
|
||||
|
|
|
@ -34,10 +34,6 @@
|
|||
|
||||
#include "ftmod_sangoma_isdn.h"
|
||||
|
||||
extern void sngisdn_trace_q921(char* str, uint8_t* data, uint32_t data_len);
|
||||
extern void sngisdn_trace_q931(char* str, uint8_t* data, uint32_t data_len);
|
||||
extern void get_memory_info(void);
|
||||
|
||||
#define MAX_DECODE_STR_LEN 2000
|
||||
|
||||
|
||||
|
|
|
@ -34,22 +34,12 @@
|
|||
|
||||
#include "ftmod_sangoma_isdn.h"
|
||||
|
||||
ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb);
|
||||
ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb);
|
||||
ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb);
|
||||
ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display);
|
||||
|
||||
ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm);
|
||||
ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm);
|
||||
ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm);
|
||||
ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan);
|
||||
|
||||
ftdm_status_t sngisdn_check_free_ids(void);
|
||||
|
||||
extern ftdm_sngisdn_data_t g_sngisdn_data;
|
||||
void get_memory_info(void);
|
||||
|
||||
FT_DECLARE_INLINE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info)
|
||||
FT_DECLARE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info)
|
||||
{
|
||||
uint32_t cc_id = ((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->cc_id;
|
||||
|
||||
|
@ -66,7 +56,7 @@ FT_DECLARE_INLINE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info)
|
|||
return;
|
||||
}
|
||||
|
||||
FT_DECLARE_INLINE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info)
|
||||
FT_DECLARE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info)
|
||||
{
|
||||
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_DEBUG, "Clearing glare data (suId:%d suInstId:%u spInstId:%u actv-suInstId:%u actv-spInstId:%u)\n",
|
||||
sngisdn_info->glare.suId,
|
||||
|
@ -91,7 +81,7 @@ FT_DECLARE_INLINE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info)
|
|||
}
|
||||
|
||||
|
||||
FT_DECLARE_INLINE(uint32_t) get_unique_suInstId(int16_t cc_id)
|
||||
FT_DECLARE(uint32_t) get_unique_suInstId(int16_t cc_id)
|
||||
{
|
||||
uint32_t suInstId;
|
||||
ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n");
|
||||
|
@ -113,7 +103,7 @@ FT_DECLARE_INLINE(uint32_t) get_unique_suInstId(int16_t cc_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data)
|
||||
FT_DECLARE(ftdm_status_t) get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data)
|
||||
{
|
||||
ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n");
|
||||
ftdm_assert_return(g_sngisdn_data.ccs[cc_id].activation_done, FTDM_FAIL, "Trying to find call on unconfigured CC\n");
|
||||
|
@ -125,7 +115,7 @@ FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_suInstId(int16_t cc_id, uint32_
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data)
|
||||
FT_DECLARE(ftdm_status_t) get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data)
|
||||
{
|
||||
ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n");
|
||||
ftdm_assert_return(g_sngisdn_data.ccs[cc_id].activation_done, FTDM_FAIL, "Trying to find call on unconfigured CC\n");
|
||||
|
@ -157,7 +147,7 @@ ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail)
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb)
|
||||
FT_DECLARE(ftdm_status_t) cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb)
|
||||
{
|
||||
if (cgPtyNmb->eh.pres != PRSNT_NODEF) {
|
||||
return FTDM_FAIL;
|
||||
|
@ -184,7 +174,7 @@ ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgP
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb)
|
||||
FT_DECLARE(ftdm_status_t) cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb)
|
||||
{
|
||||
if (cdPtyNmb->eh.pres != PRSNT_NODEF) {
|
||||
return FTDM_FAIL;
|
||||
|
@ -206,7 +196,7 @@ ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPt
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb)
|
||||
FT_DECLARE(ftdm_status_t) cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb)
|
||||
{
|
||||
if (redirNmb->eh.pres != PRSNT_NODEF) {
|
||||
return FTDM_FAIL;
|
||||
|
@ -226,7 +216,7 @@ ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redir
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display)
|
||||
FT_DECLARE(ftdm_status_t) cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display)
|
||||
{
|
||||
if (display->eh.pres != PRSNT_NODEF) {
|
||||
return FTDM_FAIL;
|
||||
|
@ -239,7 +229,7 @@ ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *dis
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm)
|
||||
FT_DECLARE(ftdm_status_t) cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm)
|
||||
{
|
||||
uint8_t len = strlen(ftdm->cid_num.digits);
|
||||
if (!len) {
|
||||
|
@ -267,7 +257,7 @@ ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm)
|
||||
FT_DECLARE(ftdm_status_t) cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm)
|
||||
{
|
||||
uint8_t len = strlen(ftdm->dnis.digits);
|
||||
if (!len) {
|
||||
|
@ -297,7 +287,7 @@ ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *f
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm)
|
||||
FT_DECLARE(ftdm_status_t) cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm)
|
||||
{
|
||||
uint8_t len = strlen(ftdm->rdnis.digits);
|
||||
if (!len) {
|
||||
|
@ -329,7 +319,7 @@ ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ft
|
|||
}
|
||||
|
||||
|
||||
ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan)
|
||||
FT_DECLARE(ftdm_status_t) cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
uint8_t len;
|
||||
ftdm_caller_data_t *ftdm = &ftdmchan->caller_data;
|
||||
|
|
|
@ -1347,7 +1347,7 @@ int ftmod_ss7_isup_isap_config(int id)
|
|||
cfg.t.cfg.s.siSap.natAddrInd = ADDR_NOTPRSNT; /* SID Nature of Addres Indicator */
|
||||
cfg.t.cfg.s.siSap.sidNPlan = NP_ISDN; /* SID Numbering Plan */
|
||||
cfg.t.cfg.s.siSap.sidPresInd = FALSE; /* default presentation indicator */
|
||||
cfg.t.cfg.s.siSap.incSidPresRes = TRUE; /* Presentation Restriction of incoming SID */
|
||||
cfg.t.cfg.s.siSap.incSidPresRes = FALSE; /* Presentation Restriction of incoming SID */
|
||||
cfg.t.cfg.s.siSap.sidPresRes = 0; /* Presentation Restriction */
|
||||
}
|
||||
cfg.t.cfg.s.siSap.reqOpt = FALSE; /* Request option */
|
||||
|
|
|
@ -1482,7 +1482,7 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
|
|||
|
||||
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
|
||||
ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
if ((ftdmchan->physical_span_id == span) &&
|
||||
((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) {
|
||||
|
@ -1529,7 +1529,7 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
|
|||
|
||||
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
|
||||
ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
if ((ftdmchan->physical_span_id == span) &&
|
||||
((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) {
|
||||
|
@ -1572,7 +1572,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c
|
|||
/* extract the channel and span info for this circuit */
|
||||
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
|
||||
ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
/* check if this circuit is part of the block */
|
||||
if ((ftdmchan->physical_span_id == span) &&
|
||||
|
@ -1628,7 +1628,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c
|
|||
|
||||
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
|
||||
ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
if ((ftdmchan->physical_span_id == span) &&
|
||||
((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) {
|
||||
|
@ -1672,7 +1672,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c
|
|||
/* extract the channel and span info for this circuit */
|
||||
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
|
||||
ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
/* check if this circuit is part of the block */
|
||||
if ((ftdmchan->physical_span_id == span) &&
|
||||
|
@ -1728,7 +1728,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c
|
|||
|
||||
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
|
||||
ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
if ((ftdmchan->physical_span_id == span) &&
|
||||
((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) {
|
||||
|
|
|
@ -1722,7 +1722,7 @@ ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
|
|||
}
|
||||
|
||||
/* fill in the span structure for this circuit */
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_span->rx_grs.circuit = circuit;
|
||||
sngss7_span->rx_grs.range = range;
|
||||
|
||||
|
@ -1758,7 +1758,7 @@ ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
|
|||
}
|
||||
|
||||
/* fill in the span structure for this circuit */
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_span->rx_gra.circuit = circuit;
|
||||
sngss7_span->rx_gra.range = range;
|
||||
|
||||
|
@ -1866,7 +1866,7 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit
|
|||
}
|
||||
|
||||
/* check if we just sent a GRS request...*/
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
if (sngss7_span->tx_grs.circuit > 0) {
|
||||
/* we need to put all circuits on this UCIC */
|
||||
sngss7_span->ucic.circuit = sngss7_span->tx_grs.circuit;
|
||||
|
@ -1917,7 +1917,7 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
|
|||
}
|
||||
|
||||
/* grab the span info */
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
/* figure out what type of block needs to be applied */
|
||||
if ((siStaEvnt->cgsmti.eh.pres == PRSNT_NODEF) && (siStaEvnt->cgsmti.typeInd.pres == PRSNT_NODEF)) {
|
||||
|
@ -2058,7 +2058,7 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
|
|||
}
|
||||
|
||||
/* grab the span info */
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
/* figure out what type of block needs to be applied */
|
||||
if ((siStaEvnt->cgsmti.eh.pres == PRSNT_NODEF) && (siStaEvnt->cgsmti.typeInd.pres == PRSNT_NODEF)) {
|
||||
|
|
|
@ -90,7 +90,7 @@ void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
|
|||
memcpy(&sngss7_event->event.siConEvnt, siConEvnt, sizeof(*siConEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
|
|||
memcpy(&sngss7_event->event.siConEvnt, siConEvnt, sizeof(*siConEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCn
|
|||
memcpy(&sngss7_event->event.siCnStEvnt, siCnStEvnt, sizeof(*siCnStEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
|
|||
memcpy(&sngss7_event->event.siRelEvnt, siRelEvnt, sizeof(*siRelEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
|
|||
memcpy(&sngss7_event->event.siRelEvnt, siRelEvnt, sizeof(*siRelEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiIn
|
|||
memcpy(&sngss7_event->event.siInfoEvnt, siInfoEvnt, sizeof(*siInfoEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
|||
memcpy(&sngss7_event->event.siFacEvnt, siFacEvnt, sizeof(*siFacEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
|||
memcpy(&sngss7_event->event.siFacEvnt, siFacEvnt, sizeof(*siFacEvnt));
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit)
|
|||
sngss7_event->event_id = SNGSS7_UMSG_IND_EVENT;
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
|
||||
|
@ -438,7 +438,7 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
|||
}
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiS
|
|||
}
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
|
||||
|
@ -519,7 +519,7 @@ void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiR
|
|||
}
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
|
||||
|
@ -560,7 +560,7 @@ void sngss7_ssp_sta_cfm(uint32_t infId)
|
|||
}
|
||||
|
||||
/* enqueue this event */
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->mod_data)->event_queue, sngss7_event);
|
||||
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
|
||||
#endif
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
|
|||
ftdm_span_t *ftdmspan = (ftdm_span_t *) obj;
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
|
||||
|
||||
ftdm_log (FTDM_LOG_INFO, "ftmod_sangoma_ss7 monitor thread for span=%u started.\n", ftdmspan->span_id);
|
||||
|
||||
|
@ -788,7 +788,7 @@ void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/* check if this is the base circuit and send out the GRA
|
||||
* we insure that this is the last circuit to have the state change queued
|
||||
*/
|
||||
sngss7_span_data_t *span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *span = ftdmchan->span->signal_data;
|
||||
if (span->rx_grs.circuit == sngss7_info->circuit->id) {
|
||||
/* send out the GRA */
|
||||
ft_to_sngss7_gra(ftdmchan);
|
||||
|
@ -1350,7 +1350,7 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
|
|||
ftdmchan = span->channels[x];
|
||||
if (ftdmchan->call_data == NULL) continue;
|
||||
sngss7_info = ftdmchan->call_data;
|
||||
sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
|
||||
|
||||
|
||||
|
@ -1474,7 +1474,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_ss7_span_config)
|
|||
span->get_channel_sig_status = ftdm_sangoma_ss7_get_sig_status;
|
||||
span->set_channel_sig_status = ftdm_sangoma_ss7_set_sig_status;
|
||||
span->state_map = &sangoma_ss7_state_map;
|
||||
span->mod_data = ss7_span_info;
|
||||
span->signal_data = ss7_span_info;
|
||||
|
||||
/* set the flag to indicate that this span uses channel state change queues */
|
||||
ftdm_set_flag (span, FTDM_SPAN_USE_CHAN_QUEUE);
|
||||
|
|
|
@ -619,7 +619,7 @@ void ft_to_sngss7_gra (ftdm_channel_t * ftdmchan)
|
|||
{
|
||||
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
|
||||
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
SiStaEvnt gra;
|
||||
|
||||
|
@ -663,7 +663,7 @@ void ft_to_sngss7_grs (ftdm_channel_t * ftdmchan)
|
|||
{
|
||||
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
|
||||
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
|
||||
SiStaEvnt grs;
|
||||
|
@ -696,7 +696,7 @@ void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan)
|
|||
{
|
||||
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
|
||||
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
int x = 0;
|
||||
|
||||
|
@ -745,7 +745,7 @@ void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan)
|
|||
{
|
||||
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
|
||||
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
int x = 0;
|
||||
|
||||
|
@ -794,7 +794,7 @@ void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan)
|
|||
{
|
||||
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
|
||||
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
SiStaEvnt cgb;
|
||||
int x = 0;
|
||||
|
@ -844,7 +844,7 @@ void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan)
|
|||
{
|
||||
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
|
||||
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
SiStaEvnt cgu;
|
||||
int x = 0;
|
||||
|
|
|
@ -513,7 +513,7 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
|
|||
{
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_chan_data_t *sngss7_info = NULL;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
|
||||
int i;
|
||||
|
||||
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
|
||||
|
@ -575,7 +575,7 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
|
|||
{
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_chan_data_t *sngss7_info = NULL;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
|
||||
int i;
|
||||
int byte = 0;
|
||||
int bit = 0;
|
||||
|
@ -667,7 +667,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
|
|||
{
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_chan_data_t *sngss7_info = NULL;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
|
||||
int i;
|
||||
|
||||
for (i = sngss7_span->rx_gra.circuit; i < (sngss7_span->rx_gra.circuit + sngss7_span->rx_gra.range + 1); i++) {
|
||||
|
@ -817,7 +817,7 @@ ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan)
|
|||
{
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_chan_data_t *sngss7_info = NULL;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
|
||||
int i;
|
||||
|
||||
for (i = sngss7_span->ucic.circuit; i < (sngss7_span->ucic.circuit + sngss7_span->ucic.range + 1); i++) {
|
||||
|
@ -869,7 +869,7 @@ ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info)
|
|||
ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info)
|
||||
{
|
||||
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
/* clear the rx_grs data fields */
|
||||
memset(&sngss7_span->rx_grs, 0x0, sizeof(sngss7_group_data_t));
|
||||
|
@ -881,7 +881,7 @@ ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info)
|
|||
ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info)
|
||||
{
|
||||
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
/* clear the rx_grs data fields */
|
||||
memset(&sngss7_span->rx_gra, 0x0, sizeof(sngss7_group_data_t));
|
||||
|
@ -904,7 +904,7 @@ ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info)
|
|||
ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info)
|
||||
{
|
||||
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
|
||||
sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data;
|
||||
|
||||
/* clear the rx_grs data fields */
|
||||
memset(&sngss7_span->tx_grs, 0x0, sizeof(sngss7_group_data_t));
|
||||
|
|
|
@ -2121,7 +2121,7 @@ static int ftmod_ss7_fill_in_circuits(sng_isupCkt_t *isupCkt)
|
|||
ftdmchan->call_data = ss7_info;
|
||||
|
||||
/* prepare the timer structures */
|
||||
ss7_info->t35.sched = ((sngss7_span_data_t *)isupCkt->span->mod_data)->sched;
|
||||
ss7_info->t35.sched = ((sngss7_span_data_t *)isupCkt->span->signal_data)->sched;
|
||||
ss7_info->t35.counter = 1;
|
||||
ss7_info->t35.beat = g_ftdm_sngss7_data.cfg.isupIntf[isupCkt->isupInf].t35*100; /* beat is in ms, t35 is in 100ms */
|
||||
ss7_info->t35.callback = handle_isup_t35;
|
||||
|
|
|
@ -117,29 +117,28 @@ static __inline__ int tdmv_api_wait_socket(ftdm_channel_t *ftdmchan, int timeout
|
|||
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
int err;
|
||||
uint32_t inflags = *flags;
|
||||
uint32_t outflags = 0;
|
||||
sangoma_wait_obj_t *sangoma_wait_obj = ftdmchan->mod_data;
|
||||
uint32_t inflags = *flags;
|
||||
uint32_t outflags = 0;
|
||||
sangoma_wait_obj_t *sangoma_wait_obj = ftdmchan->io_data;
|
||||
|
||||
err = sangoma_waitfor(sangoma_wait_obj, inflags, &outflags, timeout);
|
||||
*flags = 0;
|
||||
if (err == SANG_STATUS_SUCCESS) {
|
||||
*flags = outflags;
|
||||
err = 1; /* ideally should be the number of file descriptors with something to read */
|
||||
}
|
||||
if (err == SANG_STATUS_APIPOLL_TIMEOUT) {
|
||||
err = 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
if (err == SANG_STATUS_SUCCESS) {
|
||||
*flags = outflags;
|
||||
err = 1; /* ideally should be the number of file descriptors with something to read */
|
||||
}
|
||||
if (err == SANG_STATUS_APIPOLL_TIMEOUT) {
|
||||
err = 0;
|
||||
}
|
||||
return err;
|
||||
#else
|
||||
struct pollfd pfds[1];
|
||||
int res;
|
||||
int res;
|
||||
|
||||
memset(&pfds[0], 0, sizeof(pfds[0]));
|
||||
pfds[0].fd = ftdmchan->sockfd;
|
||||
pfds[0].events = *flags;
|
||||
res = poll(pfds, 1, timeout);
|
||||
memset(&pfds[0], 0, sizeof(pfds[0]));
|
||||
pfds[0].fd = ftdmchan->sockfd;
|
||||
pfds[0].events = *flags;
|
||||
res = poll(pfds, 1, timeout);
|
||||
*flags = 0;
|
||||
|
||||
if (pfds[0].revents & POLLERR) {
|
||||
|
@ -150,7 +149,7 @@ static __inline__ int tdmv_api_wait_socket(ftdm_channel_t *ftdmchan, int timeout
|
|||
*flags = pfds[0].revents;
|
||||
}
|
||||
|
||||
return res;
|
||||
return res;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -253,7 +252,7 @@ static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start
|
|||
ftdm_log(FTDM_LOG_ERROR, "failure create waitable object for s%dc%d\n", spanno, x);
|
||||
continue;
|
||||
}
|
||||
chan->mod_data = sangoma_wait_obj;
|
||||
chan->io_data = sangoma_wait_obj;
|
||||
#endif
|
||||
|
||||
chan->physical_span_id = spanno;
|
||||
|
@ -542,7 +541,7 @@ static FIO_OPEN_FUNCTION(wanpipe_open)
|
|||
static FIO_CLOSE_FUNCTION(wanpipe_close)
|
||||
{
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
sangoma_wait_obj_t *waitobj = ftdmchan->mod_data;
|
||||
sangoma_wait_obj_t *waitobj = ftdmchan->io_data;
|
||||
/* kick any I/O waiters */
|
||||
sangoma_wait_obj_signal(waitobj);
|
||||
#endif
|
||||
|
@ -960,10 +959,10 @@ FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event)
|
|||
for(i = 1; i <= span->chan_count; i++) {
|
||||
ftdm_channel_t *ftdmchan = span->channels[i];
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
if (!ftdmchan->mod_data) {
|
||||
if (!ftdmchan->io_data) {
|
||||
continue; /* should never happen but happens when shutting down */
|
||||
}
|
||||
pfds[j] = ftdmchan->mod_data;
|
||||
pfds[j] = ftdmchan->io_data;
|
||||
inflags[j] = poll_events ? poll_events[j] : POLLPRI;
|
||||
#else
|
||||
memset(&pfds[j], 0, sizeof(pfds[j]));
|
||||
|
@ -1299,10 +1298,10 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
static FIO_CHANNEL_DESTROY_FUNCTION(wanpipe_channel_destroy)
|
||||
{
|
||||
#ifdef LIBSANGOMA_VERSION
|
||||
if (ftdmchan->mod_data) {
|
||||
if (ftdmchan->io_data) {
|
||||
sangoma_wait_obj_t *sangoma_wait_obj;
|
||||
sangoma_wait_obj = ftdmchan->mod_data;
|
||||
ftdmchan->mod_data = NULL;
|
||||
sangoma_wait_obj = ftdmchan->io_data;
|
||||
ftdmchan->io_data = NULL;
|
||||
sangoma_wait_obj_delete(&sangoma_wait_obj);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -658,6 +658,14 @@ static FIO_OPEN_FUNCTION(zt_open)
|
|||
*/
|
||||
static FIO_CLOSE_FUNCTION(zt_close)
|
||||
{
|
||||
if (ftdmchan->type == FTDM_CHAN_TYPE_B) {
|
||||
int value = 0; /* disable audio mode */
|
||||
if (ioctl(ftdmchan->sockfd, codes.AUDIOMODE, &value)) {
|
||||
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno));
|
||||
ftdm_log(FTDM_LOG_ERROR, "%s\n", ftdmchan->last_error);
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1243,6 +1243,9 @@ FT_DECLARE(void) ftdm_span_set_trunk_type(ftdm_span_t *span, ftdm_trunk_type_t t
|
|||
*/
|
||||
FT_DECLARE(ftdm_trunk_type_t) ftdm_span_get_trunk_type(const ftdm_span_t *span);
|
||||
|
||||
/*! \brief For display debugging purposes you can display this string which describes the trunk type of a span */
|
||||
FT_DECLARE(const char *) ftdm_span_get_trunk_type_str(const ftdm_span_t *span);
|
||||
|
||||
/*!
|
||||
* \brief Return the channel identified by the provided id
|
||||
*
|
||||
|
@ -1262,6 +1265,12 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_caller_data(ftdm_channel_t *ftdmchan,
|
|||
/*! \brief Get the caller data for a channel, typically you need this when receiving FTDM_SIGEVENT_START */
|
||||
FT_DECLARE(ftdm_caller_data_t *) ftdm_channel_get_caller_data(ftdm_channel_t *channel);
|
||||
|
||||
/*! \brief Get current state of a channel */
|
||||
FT_DECLARE(int) ftdm_channel_get_state(const ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*! \brief Get last state of a channel */
|
||||
FT_DECLARE(int) ftdm_channel_get_last_state(const ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*! \brief For display debugging purposes you can display this string which describes the current channel internal state */
|
||||
FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *channel);
|
||||
|
||||
|
|
|
@ -451,7 +451,9 @@ struct ftdm_channel {
|
|||
ftdm_fsk_data_state_t fsk;
|
||||
uint8_t fsk_buf[80];
|
||||
uint32_t ring_count;
|
||||
void *mod_data;
|
||||
/* Private I/O data. Do not touch unless you are an I/O module */
|
||||
void *io_data;
|
||||
/* Private signaling data. Do not touch unless you are a signaling module */
|
||||
void *call_data;
|
||||
struct ftdm_caller_data caller_data;
|
||||
struct ftdm_span *span;
|
||||
|
@ -484,6 +486,7 @@ struct ftdm_span {
|
|||
ftdm_trunk_type_t trunk_type;
|
||||
ftdm_analog_start_type_t start_type;
|
||||
ftdm_signal_type_t signal_type;
|
||||
/* Private signaling data. Do not touch unless you are a signaling module */
|
||||
void *signal_data;
|
||||
fio_signal_cb_t signal_cb;
|
||||
ftdm_event_t event_header;
|
||||
|
@ -501,7 +504,8 @@ struct ftdm_span {
|
|||
ftdm_span_start_t start;
|
||||
ftdm_span_stop_t stop;
|
||||
ftdm_channel_sig_read_t sig_read;
|
||||
void *mod_data;
|
||||
/* Private I/O data per span. Do not touch unless you are an I/O module */
|
||||
void *io_data;
|
||||
char *type;
|
||||
char *dtmf_hangup;
|
||||
size_t dtmf_hangup_len;
|
||||
|
|
142
libs/stfu/stfu.c
142
libs/stfu/stfu.c
|
@ -38,7 +38,6 @@ struct stfu_queue {
|
|||
uint32_t array_size;
|
||||
uint32_t array_len;
|
||||
uint32_t wr_len;
|
||||
uint32_t last_index;
|
||||
};
|
||||
typedef struct stfu_queue stfu_queue_t;
|
||||
|
||||
|
@ -47,10 +46,12 @@ struct stfu_instance {
|
|||
struct stfu_queue b_queue;
|
||||
struct stfu_queue *in_queue;
|
||||
struct stfu_queue *out_queue;
|
||||
uint32_t last_ts;
|
||||
struct stfu_frame *last_frame;
|
||||
uint32_t last_wr_ts;
|
||||
uint32_t last_rd_ts;
|
||||
uint32_t interval;
|
||||
uint32_t miss_count;
|
||||
uint8_t running;
|
||||
uint32_t max_plc;
|
||||
};
|
||||
|
||||
|
||||
|
@ -112,7 +113,7 @@ stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen)
|
|||
return s;
|
||||
}
|
||||
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen)
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_plc)
|
||||
{
|
||||
struct stfu_instance *i;
|
||||
|
||||
|
@ -125,6 +126,13 @@ stfu_instance_t *stfu_n_init(uint32_t qlen)
|
|||
stfu_n_init_aqueue(&i->b_queue, qlen);
|
||||
i->in_queue = &i->a_queue;
|
||||
i->out_queue = &i->b_queue;
|
||||
|
||||
if (max_plc) {
|
||||
i->max_plc = max_plc;
|
||||
} else {
|
||||
i->max_plc = qlen / 2;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -135,10 +143,9 @@ void stfu_n_reset(stfu_instance_t *i)
|
|||
i->in_queue->array_len = 0;
|
||||
i->out_queue->array_len = 0;
|
||||
i->out_queue->wr_len = 0;
|
||||
i->out_queue->last_index = 0;
|
||||
i->last_frame = NULL;
|
||||
i->miss_count = 0;
|
||||
i->last_ts = 0;
|
||||
i->running = 0;
|
||||
i->last_wr_ts = 0;
|
||||
i->miss_count = 0;
|
||||
i->interval = 0;
|
||||
}
|
||||
|
@ -197,7 +204,7 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
|
||||
i->in_queue->array_len = 0;
|
||||
i->out_queue->wr_len = 0;
|
||||
i->out_queue->last_index = 0;
|
||||
i->last_frame = NULL;
|
||||
i->miss_count = 0;
|
||||
|
||||
if (stfu_n_process(i, i->out_queue) < 0) {
|
||||
|
@ -222,6 +229,8 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
cplen = sizeof(frame->data);
|
||||
}
|
||||
|
||||
i->last_rd_ts = ts;
|
||||
|
||||
memcpy(frame->data, data, cplen);
|
||||
frame->pt = pt;
|
||||
frame->ts = ts;
|
||||
|
@ -231,88 +240,71 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
return STFU_IT_WORKED;
|
||||
}
|
||||
|
||||
static int stfu_n_find_frame(stfu_queue_t *queue, uint32_t ts, stfu_frame_t **r_frame, uint32_t *index)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
stfu_frame_t *frame = NULL;
|
||||
|
||||
assert(r_frame);
|
||||
assert(index);
|
||||
|
||||
*r_frame = NULL;
|
||||
|
||||
for(i = 0; i < queue->array_len; i++) {
|
||||
frame = &queue->array[i];
|
||||
|
||||
if (frame->ts == ts) {
|
||||
*r_frame = frame;
|
||||
*index = i;
|
||||
frame->was_read = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)
|
||||
{
|
||||
uint32_t index, index2;
|
||||
uint32_t index;
|
||||
uint32_t should_have = 0;
|
||||
stfu_frame_t *frame = NULL, *rframe = NULL;
|
||||
stfu_frame_t *rframe = NULL;
|
||||
|
||||
if (((i->out_queue->wr_len == i->out_queue->array_len) || !i->out_queue->array_len)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (i->running) {
|
||||
should_have = i->last_ts + i->interval;
|
||||
if (i->last_wr_ts) {
|
||||
should_have = i->last_wr_ts + i->interval;
|
||||
} else {
|
||||
should_have = i->out_queue->array[0].ts;
|
||||
}
|
||||
|
||||
for(index = 0; index < i->out_queue->array_len; index++) {
|
||||
if (i->out_queue->array[index].was_read) {
|
||||
continue;
|
||||
}
|
||||
|
||||
frame = &i->out_queue->array[index];
|
||||
|
||||
if (frame->ts != should_have) {
|
||||
unsigned int tried = 0;
|
||||
for (index2 = 0; index2 < i->out_queue->array_len; index2++) {
|
||||
if (i->out_queue->array[index2].was_read) {
|
||||
continue;
|
||||
}
|
||||
tried++;
|
||||
if (i->out_queue->array[index2].ts == should_have) {
|
||||
rframe = &i->out_queue->array[index2];
|
||||
i->out_queue->last_index = index2;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
for (index2 = 0; index2 < i->in_queue->array_len; index2++) {
|
||||
if (i->in_queue->array[index2].was_read) {
|
||||
continue;
|
||||
}
|
||||
tried++;
|
||||
if (i->in_queue->array[index2].ts == should_have) {
|
||||
rframe = &i->in_queue->array[index2];
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
i->miss_count++;
|
||||
|
||||
if (i->miss_count > 10 || (i->in_queue->array_len == i->in_queue->array_size) ||
|
||||
tried >= (i->in_queue->array_size + i->out_queue->array_size)) {
|
||||
i->running = 0;
|
||||
i->interval = 0;
|
||||
i->out_queue->wr_len = i->out_queue->array_size;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i->last_ts = should_have;
|
||||
rframe = &i->out_queue->int_frame;
|
||||
rframe->dlen = i->out_queue->array[i->out_queue->last_index].dlen;
|
||||
/* poor man's plc.. Copy the last frame, but we flag it so you can use a better one if you wish */
|
||||
memcpy(rframe->data, i->out_queue->array[i->out_queue->last_index].data, rframe->dlen);
|
||||
rframe->ts = should_have;
|
||||
i->out_queue->wr_len++;
|
||||
i->running = 1;
|
||||
return rframe;
|
||||
} else {
|
||||
rframe = &i->out_queue->array[index];
|
||||
i->out_queue->last_index = index;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
if (rframe) {
|
||||
if (stfu_n_find_frame(i->out_queue, should_have, &rframe, &index) || stfu_n_find_frame(i->in_queue, should_have, &rframe, &index)) {
|
||||
i->last_frame = rframe;
|
||||
i->out_queue->wr_len++;
|
||||
i->last_ts = rframe->ts;
|
||||
i->last_wr_ts = rframe->ts;
|
||||
rframe->was_read = 1;
|
||||
i->running = 1;
|
||||
i->miss_count = 0;
|
||||
}
|
||||
} else {
|
||||
i->last_wr_ts = should_have;
|
||||
rframe = &i->out_queue->int_frame;
|
||||
|
||||
if (i->last_frame && i->last_frame != rframe) {
|
||||
rframe->dlen = i->last_frame->dlen;
|
||||
/* poor man's plc.. Copy the last frame, but we flag it so you can use a better one if you wish */
|
||||
memcpy(rframe->data, i->last_frame->data, rframe->dlen);
|
||||
}
|
||||
|
||||
rframe->ts = should_have;
|
||||
|
||||
if (++i->miss_count > i->max_plc) {
|
||||
i->interval = 0;
|
||||
i->out_queue->wr_len = i->out_queue->array_size;
|
||||
i->last_wr_ts = 0;
|
||||
rframe = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return rframe;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ typedef struct {
|
|||
|
||||
void stfu_n_report(stfu_instance_t *i, stfu_report_t *r);
|
||||
void stfu_n_destroy(stfu_instance_t **i);
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen);
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_plc);
|
||||
stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen);
|
||||
stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, int last);
|
||||
stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i);
|
||||
|
|
|
@ -8,7 +8,7 @@ session:sleep(3000);
|
|||
-- Give the agent time to bring up ZRTP.
|
||||
|
||||
local zrtp_secure_media_confirmed = session:getVariable("zrtp_secure_media_confirmed_audio");
|
||||
local zrtp_new_user_enrolled = session:getVariable("zrtp_new_user_enrolled");
|
||||
local zrtp_new_user_enrolled = session:getVariable("zrtp_new_user_enrolled_audio");
|
||||
local zrtp_already_enrolled = session:getVariable("zrtp_already_enrolled_audio");
|
||||
|
||||
if zrtp_secure_media_confirmed == "true" then
|
||||
|
|
|
@ -596,7 +596,7 @@ typedef enum {
|
|||
*/
|
||||
|
||||
|
||||
RTP_BUG_IGNORE_MARK_BIT = (1 << 2)
|
||||
RTP_BUG_IGNORE_MARK_BIT = (1 << 2),
|
||||
|
||||
/*
|
||||
A Huawei SBC has been discovered that sends the mark bit on every single RTP packet.
|
||||
|
@ -607,6 +607,34 @@ typedef enum {
|
|||
*/
|
||||
|
||||
|
||||
RTP_BUG_SEND_LINEAR_TIMESTAMPS = (1 << 3),
|
||||
|
||||
/*
|
||||
Our friends at Sonus get real mad when the timestamps are not in perfect sequence even during periods of silence.
|
||||
With this flag, we will only increment the timestamp when write packets even if they are eons apart.
|
||||
|
||||
*/
|
||||
|
||||
RTP_BUG_START_SEQ_AT_ZERO = (1 << 4),
|
||||
|
||||
/*
|
||||
Our friends at Sonus also get real mad if the sequence number does not start at 0.
|
||||
Typically, we set this to a random starting value for your saftey.
|
||||
This is a security risk you take upon yourself when you enable this flag.
|
||||
*/
|
||||
|
||||
|
||||
RTP_BUG_NEVER_SEND_MARKER = (1 << 5),
|
||||
|
||||
/*
|
||||
Our friends at Sonus are on a roll, They also get easily dumbfounded by marker bits.
|
||||
This flag will never send any. Sheesh....
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} switch_rtp_bug_flag_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -54,6 +54,13 @@ SWITCH_DECLARE(int) switch_isspace(int c);
|
|||
SWITCH_DECLARE(int) switch_isupper(int c);
|
||||
SWITCH_DECLARE(int) switch_isxdigit(int c);
|
||||
|
||||
typedef union{
|
||||
uint32_t v4;
|
||||
struct in6_addr v6;
|
||||
} ip_t;
|
||||
|
||||
SWITCH_DECLARE(switch_bool_t) switch_testv6_subnet(ip_t _ip, ip_t _net, ip_t _mask);
|
||||
|
||||
#define switch_goto_status(_status, _label) status = _status; goto _label
|
||||
#define switch_goto_int(_n, _i, _label) _n = _i; goto _label
|
||||
#define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
|
||||
|
@ -694,7 +701,7 @@ SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char clos
|
|||
|
||||
|
||||
|
||||
SWITCH_DECLARE(int) switch_parse_cidr(const char *string, uint32_t *ip, uint32_t *mask, uint32_t *bitp);
|
||||
SWITCH_DECLARE(int) switch_parse_cidr(const char *string, ip_t *ip, ip_t *mask, uint32_t *bitp);
|
||||
SWITCH_DECLARE(switch_status_t) switch_network_list_create(switch_network_list_t **list, const char *name, switch_bool_t default_type,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_network_list_add_cidr_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok, const char *token);
|
||||
|
@ -703,6 +710,7 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_add_cidr_token(switch_networ
|
|||
|
||||
SWITCH_DECLARE(switch_status_t) switch_network_list_add_host_mask(switch_network_list_t *list, const char *host, const char *mask_str, switch_bool_t ok);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip_token(switch_network_list_t *list, uint32_t ip, const char **token);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip6_token(switch_network_list_t *list, ip_t ip, const char **token);
|
||||
#define switch_network_list_validate_ip(_list, _ip) switch_network_list_validate_ip_token(_list, _ip, NULL);
|
||||
|
||||
#define switch_test_subnet(_ip, _net, _mask) (_mask ? ((_net & _mask) == (_ip & _mask)) : _net ? _net == _ip : 1)
|
||||
|
|
|
@ -78,18 +78,18 @@ extern size_t next_power_of_2(size_t v);
|
|||
|
||||
#define CALC_BUFF_LEN(fl, bl) (((fl) >= (bl))? next_power_of_2((fl) << 1): next_power_of_2((bl) << 1))
|
||||
|
||||
#define INIT_CIRC_BUFFER(bf, bl, fl) \
|
||||
#define INIT_CIRC_BUFFER(bf, bl, fl, s) \
|
||||
{ \
|
||||
(bf)->buf_len = CALC_BUFF_LEN((fl), (bl)); \
|
||||
(bf)->mask = (bf)->buf_len - 1; \
|
||||
(bf)->buf = (BUFF_TYPE *)calloc((bf)->buf_len, sizeof(BUFF_TYPE)); \
|
||||
(bf)->buf = (BUFF_TYPE *) switch_core_session_alloc(s, (bf)->buf_len * sizeof(BUFF_TYPE)); \
|
||||
assert((bf)->buf != NULL); \
|
||||
(bf)->pos = 0; \
|
||||
(bf)->lpos = 0; \
|
||||
(bf)->backlog = 0; \
|
||||
}
|
||||
|
||||
#define DESTROY_CIRC_BUFFER(b) free((b)->buf)
|
||||
//#define DESTROY_CIRC_BUFFER(b) free((b)->buf)
|
||||
#define GET_BACKLOG_POS(b) ((b)->lpos - (b)->backlog)
|
||||
#define GET_CURRENT_POS(b) ((b)->lpos)
|
||||
#define GET_CURRENT_SAMPLE(b) GET_SAMPLE((b), GET_CURRENT_POS((b)))
|
||||
|
|
|
@ -130,7 +130,7 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se
|
|||
{
|
||||
/*! This is a worst case sample rate estimate */
|
||||
avmd_session->rate = 48000;
|
||||
INIT_CIRC_BUFFER(&avmd_session->b, BEEP_LEN(avmd_session->rate), FRAME_LEN(avmd_session->rate));
|
||||
INIT_CIRC_BUFFER(&avmd_session->b, BEEP_LEN(avmd_session->rate), FRAME_LEN(avmd_session->rate), fs_session);
|
||||
|
||||
avmd_session->session = fs_session;
|
||||
avmd_session->pos = 0;
|
||||
|
@ -176,6 +176,7 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
|
|||
case SWITCH_ABC_TYPE_READ_PING:
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_CLOSE:
|
||||
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_READ:
|
||||
break;
|
||||
|
|
|
@ -4324,7 +4324,7 @@ SWITCH_STANDARD_API(uuid_loglevel)
|
|||
#define SQL_ESCAPE_SYNTAX "<string>"
|
||||
SWITCH_STANDARD_API(sql_escape)
|
||||
{
|
||||
if (zstr(cmd)) {
|
||||
if (!cmd) {
|
||||
stream->write_function(stream, "-USAGE: %s\n", SQL_ESCAPE_SYNTAX);
|
||||
} else {
|
||||
stream->write_function(stream, "%q", cmd);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
LOCAL_LDFLAGS=-lmp4v2
|
||||
LOCAL_SOURCES=mp4_helper.cpp
|
||||
LOCAL_OBJS=mp4_helper.o
|
||||
|
||||
BASE=../../../..
|
||||
include $(BASE)/build/modmake.rules
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is MP4 Helper Library to Freeswitch MP4 module.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Paulo Rogério Panhoto <paulo@voicetechnology.com.br>.
|
||||
Portions created by the Initial Developer are Copyright (C)
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef EXCEPTION_HPP_
|
||||
#define EXCEPTION_HPP_
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
class Exception: public std::exception {
|
||||
public:
|
||||
Exception()
|
||||
{
|
||||
}
|
||||
|
||||
Exception(const std::string & message): message_(message)
|
||||
{
|
||||
}
|
||||
|
||||
Exception(const std::exception & e): message_(e.what())
|
||||
{
|
||||
}
|
||||
|
||||
Exception(const Exception & e): message_(e.message_)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
const char * what() const throw()
|
||||
{
|
||||
return message_.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string message_;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,547 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Paulo Rogério Panhoto <paulo@voicetechnology.com.br>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* mod_mp4 -- MP4 File Format support for video apps.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include "mp4_helper.hpp"
|
||||
#include "exception.hpp"
|
||||
|
||||
|
||||
#ifndef min
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_mp4_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_mp4, mod_mp4_load, NULL, NULL);
|
||||
|
||||
#define VID_BIT (1 << 31)
|
||||
#define VERSION 4201
|
||||
|
||||
/*
|
||||
struct file_header {
|
||||
int32_t version;
|
||||
char video_codec_name[32];
|
||||
char video_fmtp[128];
|
||||
uint32_t audio_rate;
|
||||
uint32_t audio_ptime;
|
||||
switch_time_t created;
|
||||
};
|
||||
|
||||
struct record_helper {
|
||||
switch_core_session_t *session;
|
||||
switch_mutex_t *mutex;
|
||||
int fd;
|
||||
int up;
|
||||
};
|
||||
*/
|
||||
|
||||
struct AVParams {
|
||||
switch_core_session_t * session;
|
||||
switch_channel_t * channel;
|
||||
switch_timer_t * timer;
|
||||
switch_frame_t * frame;
|
||||
switch_mutex_t * mutex;
|
||||
bool video;
|
||||
switch_payload_t pt;
|
||||
MP4::Context * vc;
|
||||
bool done;
|
||||
bool * quit;
|
||||
};
|
||||
|
||||
static void *SWITCH_THREAD_FUNC record_video_thread(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
/*
|
||||
record_helper *eh = reinterpret_cast<record_helper *>(obj);
|
||||
switch_core_session_t *session = eh->session;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_status_t status;
|
||||
switch_frame_t *read_frame;
|
||||
int bytes;
|
||||
|
||||
eh->up = 1;
|
||||
while (switch_channel_ready(channel)) {
|
||||
status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bytes = read_frame->packetlen | VID_BIT;
|
||||
|
||||
switch_mutex_lock(eh->mutex);
|
||||
|
||||
if (write(eh->fd, &bytes, sizeof(bytes)) != (int) sizeof(bytes)) {
|
||||
switch_mutex_unlock(eh->mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
if (write(eh->fd, read_frame->packet, read_frame->packetlen) != (int) read_frame->packetlen) {
|
||||
switch_mutex_unlock(eh->mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
switch_mutex_unlock(eh->mutex);
|
||||
|
||||
switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
}
|
||||
eh->up = 0;
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(record_mp4_function)
|
||||
{
|
||||
/*
|
||||
switch_status_t status;
|
||||
switch_frame_t *read_frame;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
struct record_helper eh = { 0 };
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
int fd;
|
||||
switch_mutex_t *mutex = NULL;
|
||||
switch_codec_t codec, *vid_codec;
|
||||
switch_codec_implementation_t read_impl = { };
|
||||
int count = 0, sanity = 30;
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
switch_channel_answer(channel);
|
||||
|
||||
|
||||
while (switch_channel_up(channel) && !switch_channel_test_flag(channel, CF_VIDEO)) {
|
||||
switch_yield(10000);
|
||||
|
||||
if (count) count--;
|
||||
|
||||
if (count == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s waiting for video.\n", switch_channel_get_name(channel));
|
||||
count = 100;
|
||||
if (!--sanity) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
|
||||
switch_channel_get_name(channel));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!switch_channel_ready(channel)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not ready.\n", switch_channel_get_name(channel));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((fd = open((char *) data, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
|
||||
return;
|
||||
}
|
||||
**
|
||||
|
||||
MP4::Context ctx(reinterpret_cast<char*>(data), true);
|
||||
|
||||
if (switch_core_codec_init(&codec,
|
||||
"L16",
|
||||
NULL,
|
||||
read_impl.samples_per_second,
|
||||
read_impl.microseconds_per_packet / 1000,
|
||||
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Activation Success\n");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Audio Codec Activation Fail\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
switch_core_session_set_read_codec(session, &codec);
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_VIDEO)) {
|
||||
struct file_header h;
|
||||
memset(&h, 0, sizeof(h));
|
||||
vid_codec = switch_core_session_get_video_read_codec(session);
|
||||
|
||||
h.version = VERSION;
|
||||
h.created = switch_micro_time_now();
|
||||
switch_set_string(h.video_codec_name, vid_codec->implementation->iananame);
|
||||
if (vid_codec->fmtp_in) {
|
||||
switch_set_string(h.video_fmtp, vid_codec->fmtp_in);
|
||||
}
|
||||
h.audio_rate = read_impl.samples_per_second;
|
||||
h.audio_ptime = read_impl.microseconds_per_packet / 1000;
|
||||
|
||||
if (write(fd, &h, sizeof(h)) != sizeof(h)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
eh.mutex = mutex;
|
||||
eh.fd = fd;
|
||||
eh.session = session;
|
||||
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, record_video_thread, &eh, switch_core_session_get_pool(session));
|
||||
}
|
||||
|
||||
|
||||
while (switch_channel_ready(channel)) {
|
||||
|
||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mutex) {
|
||||
switch_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
if (write(fd, &read_frame->datalen, sizeof(read_frame->datalen)) != sizeof(read_frame->datalen)) {
|
||||
if (mutex) {
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (write(fd, read_frame->data, read_frame->datalen) != (int) read_frame->datalen) {
|
||||
if (mutex) {
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (mutex) {
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
|
||||
if (eh.up) {
|
||||
while (eh.up) {
|
||||
switch_cond_next();
|
||||
}
|
||||
}
|
||||
|
||||
switch_core_session_set_read_codec(session, NULL);
|
||||
switch_core_codec_destroy(&codec);
|
||||
*/
|
||||
}
|
||||
|
||||
static void *SWITCH_THREAD_FUNC play_video_function(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
AVParams * pt = reinterpret_cast<AVParams*>(obj);
|
||||
u_int next = 0, first = 0xffffffff;
|
||||
u_int64_t ts = 0, control = 0;
|
||||
|
||||
bool ok;
|
||||
bool sent = true;
|
||||
pt->done = false;
|
||||
switch_time_t start = switch_time_now();
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pt->session), SWITCH_LOG_DEBUG, "Video thread Started\n");
|
||||
while (!*pt->quit && switch_channel_ready(pt->channel)) {
|
||||
if (pt->video) {
|
||||
if (sent) {
|
||||
switch_mutex_lock(pt->mutex);
|
||||
pt->frame->packetlen = pt->frame->buflen;
|
||||
ok = pt->vc->getVideoPacket(pt->frame->packet, pt->frame->packetlen, next);
|
||||
switch_mutex_unlock(pt->mutex);
|
||||
sent = false;
|
||||
if (ok) {
|
||||
switch_rtp_hdr_t *hdr = reinterpret_cast<switch_rtp_hdr_t *>(pt->frame->packet);
|
||||
if(first == 0xffffffff) first = next;
|
||||
next -= first;
|
||||
control = next * 90000LL / pt->vc->videoTrack().track.clock;
|
||||
control -= first;
|
||||
hdr->ts = htonl(control);
|
||||
control = control * 1000 / 90;
|
||||
if (pt->pt)
|
||||
hdr->pt = pt->pt;
|
||||
} else break;
|
||||
}
|
||||
|
||||
ts = switch_time_now() - start;
|
||||
int64_t wait = control > ts ? (control - ts) : 0;
|
||||
|
||||
if (wait > 0) {
|
||||
switch_cond_next();
|
||||
// wait the time for the next Video frame
|
||||
switch_sleep(wait);
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(pt->channel, CF_VIDEO)) {
|
||||
switch_byte_t *data = (switch_byte_t *) pt->frame->packet;
|
||||
|
||||
pt->frame->data = data + 12;
|
||||
pt->frame->datalen = pt->frame->packetlen - 12;
|
||||
switch_core_session_write_video_frame(pt->session, pt->frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
sent = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pt->session), SWITCH_LOG_DEBUG, "Video thread ended\n");
|
||||
pt->done = true;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *SWITCH_THREAD_FUNC play_audio_function(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
AVParams * pt = reinterpret_cast<AVParams*>(obj);
|
||||
u_int next = 0, first = 0xffffffff;
|
||||
u_int64_t ts = 0, control = 0;
|
||||
|
||||
bool ok;
|
||||
bool sent = true;
|
||||
switch_dtmf_t dtmf = {0};
|
||||
pt->done = false;
|
||||
switch_frame_t * read_frame;
|
||||
|
||||
while (!*pt->quit && switch_channel_ready(pt->channel)) {
|
||||
// event processing.
|
||||
// -- SEE switch_ivr_play_say.c:1231 && mod_dptools.c:1428 && mod_dptools.c:1919
|
||||
switch_core_session_read_frame(pt->session, &read_frame, SWITCH_IO_FLAG_SINGLE_READ, 0);
|
||||
|
||||
if (switch_channel_test_flag(pt->channel, CF_BREAK)) {
|
||||
switch_channel_clear_flag(pt->channel, CF_BREAK);
|
||||
break;
|
||||
}
|
||||
|
||||
switch_ivr_parse_all_events(pt->session);
|
||||
|
||||
if (switch_channel_has_dtmf(pt->channel)) {
|
||||
switch_channel_dequeue_dtmf(pt->channel, &dtmf);
|
||||
const char * terminators = switch_channel_get_variable(pt->channel, SWITCH_PLAYBACK_TERMINATORS_VARIABLE);
|
||||
if (terminators && !strcasecmp(terminators, "none")) terminators = NULL;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pt->session), SWITCH_LOG_DEBUG, "Digit %c\n", dtmf.digit);
|
||||
if (terminators && strchr(terminators, dtmf.digit)) {
|
||||
std::string digit(&dtmf.digit, 0, 1);
|
||||
switch_channel_set_variable(pt->channel, SWITCH_PLAYBACK_TERMINATOR_USED, digit.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_mutex_lock(pt->mutex);
|
||||
pt->frame->datalen = pt->frame->buflen;
|
||||
ok = pt->vc->getAudioPacket(pt->frame->data, pt->frame->datalen, next);
|
||||
switch_mutex_unlock(pt->mutex);
|
||||
|
||||
if (ok) {
|
||||
if (pt->frame->datalen > (int) pt->frame->buflen)
|
||||
pt->frame->datalen = pt->frame->buflen;
|
||||
|
||||
switch_core_session_write_frame(pt->session, pt->frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
switch_core_timer_next(pt->timer);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pt->session), SWITCH_LOG_DEBUG, "Audio done\n");
|
||||
*pt->quit = pt->done = true;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(play_mp4_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_frame_t write_frame = { 0 }, vid_frame = {0};
|
||||
switch_codec_t codec = { 0 }, vid_codec = {0}, *read_vid_codec;
|
||||
unsigned char *aud_buffer;
|
||||
unsigned char *vid_buffer;
|
||||
switch_timer_t timer = { 0 };
|
||||
switch_codec_implementation_t read_impl = {};
|
||||
bool done = false;
|
||||
|
||||
try {
|
||||
MP4::Context vc((char *) data);
|
||||
|
||||
switch_payload_t pt = 0;
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
aud_buffer = (unsigned char *) switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
vid_buffer = (unsigned char *) switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
|
||||
/*
|
||||
if (!vc.isOpen())
|
||||
{
|
||||
char msgbuf[1024];
|
||||
sprintf(msgbuf, "PLAYBACK ERROR (%s): FILE NOT FOUND.", (char*) data);
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, msgbuf);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!vc.isSupported())
|
||||
{
|
||||
char msgbuf[1024];
|
||||
sprintf(msgbuf, "PLAYBACK ERROR (%s): UNSUPPORTED FORMAT OR FILE NOT HINTED.", (char*) data);
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, msgbuf);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
|
||||
"Error reading track info. Maybe this file is not hinted.\n");
|
||||
throw 1;
|
||||
}
|
||||
*/
|
||||
|
||||
switch_channel_set_variable(channel, "sip_force_video_fmtp", vc.videoTrack().fmtp.c_str());
|
||||
switch_channel_answer(channel);
|
||||
|
||||
if ((read_vid_codec = switch_core_session_get_video_read_codec(session))) {
|
||||
pt = read_vid_codec->agreed_pt;
|
||||
}
|
||||
|
||||
write_frame.codec = &codec;
|
||||
write_frame.data = aud_buffer;
|
||||
write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
|
||||
|
||||
vid_frame.codec = &vid_codec;
|
||||
vid_frame.packet = vid_buffer;
|
||||
vid_frame.data = vid_buffer + 12;
|
||||
vid_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE - 12;
|
||||
switch_set_flag((&vid_frame), SFF_RAW_RTP);
|
||||
switch_set_flag((&vid_frame), SFF_PROXY_PACKET);
|
||||
|
||||
if (switch_core_timer_init(&timer, "soft", read_impl.microseconds_per_packet / 1000,
|
||||
read_impl.samples_per_packet, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Timer Activation Fail\n");
|
||||
throw 2;
|
||||
}
|
||||
|
||||
if (switch_core_codec_init(&codec,
|
||||
vc.audioTrack().codecName,
|
||||
NULL,
|
||||
vc.audioTrack().clock,
|
||||
vc.audioTrack().packetLength,
|
||||
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Activation Success\n");
|
||||
} else {
|
||||
throw Exception("Audio Codec Activation Fail");
|
||||
}
|
||||
|
||||
if (switch_core_codec_init(&vid_codec,
|
||||
vc.videoTrack().track.codecName,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Activation Success\n");
|
||||
} else
|
||||
{
|
||||
throw Exception("Video Codec Activation Fail");
|
||||
}
|
||||
switch_core_session_set_read_codec(session, &codec);
|
||||
|
||||
AVParams vpt;
|
||||
vpt.session = session;
|
||||
vpt.channel = channel;
|
||||
vpt.frame = &vid_frame;
|
||||
vpt.timer = &timer;
|
||||
vpt.video = true;
|
||||
vpt.pt = pt;
|
||||
vpt.vc = &vc;
|
||||
switch_mutex_init(&vpt.mutex, SWITCH_MUTEX_DEFAULT, switch_core_session_get_pool(session));
|
||||
vpt.quit = &done;
|
||||
|
||||
switch_threadattr_t * thd_attr;
|
||||
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_t *thread;
|
||||
switch_thread_create(&thread, thd_attr, play_video_function, (void*)&vpt, switch_core_session_get_pool(session));
|
||||
|
||||
AVParams apt;
|
||||
apt.session = session;
|
||||
apt.channel = channel;
|
||||
apt.frame = &write_frame;
|
||||
apt.timer = &timer;
|
||||
apt.video = false;
|
||||
apt.vc = &vc;
|
||||
apt.mutex = vpt.mutex;
|
||||
apt.quit = &done;
|
||||
play_audio_function(NULL, &apt);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Waiting for video thread to join.\n");
|
||||
while (!vpt.done) {
|
||||
switch_cond_next();
|
||||
}
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE PLAYED");
|
||||
} catch(const std::exception & e)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s\n", e.what());
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE,
|
||||
(std::string("PLAYBACK_FAILED - ") + e.what()).c_str());
|
||||
}catch(...)
|
||||
{
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "PLAYBACK_FAILED - See FS logs for detail.");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Exception caught.\n");
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "All done.\n");
|
||||
if (timer.interval) switch_core_timer_destroy(&timer);
|
||||
|
||||
switch_core_session_set_read_codec(session, NULL);
|
||||
|
||||
if (switch_core_codec_ready(&codec)) switch_core_codec_destroy(&codec);
|
||||
|
||||
if (switch_core_codec_ready(&vid_codec)) switch_core_codec_destroy(&vid_codec);
|
||||
}
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_mp4_load)
|
||||
{
|
||||
switch_application_interface_t *app_interface;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "play_mp4", "play an MP4 file", "play an MP4 file", play_mp4_function, "<file>", SAF_NONE);
|
||||
//SWITCH_ADD_APP(app_interface, "record_mp4", "record an MP4 file", "record an MP4 file", record_mp4_function, "<file>", SAF_NONE);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* 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:
|
||||
*/
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is MP4 Helper Library to the Freeswitch MP4 Module.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Paulo Rogério Panhoto <paulo@voicetechnology.com.br>.
|
||||
Portions created by the Initial Developer are Copyright (C)
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "mp4_helper.hpp"
|
||||
|
||||
namespace MP4
|
||||
{
|
||||
|
||||
Context::Context(const char * file, bool newFile)
|
||||
{
|
||||
if(newFile) create(file);
|
||||
else open(file);
|
||||
}
|
||||
|
||||
Context::~Context()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void Context::open(const char * file)
|
||||
{
|
||||
fh = MP4Read(file, 0);
|
||||
if (fh == MP4_INVALID_FILE_HANDLE) throw Exception(file, "Open failed");
|
||||
getTracks(file);
|
||||
}
|
||||
|
||||
void Context::create(const char * file)
|
||||
{
|
||||
fh = MP4Create(file);
|
||||
if (fh == MP4_INVALID_FILE_HANDLE) throw Exception(file, "Create file failed");
|
||||
}
|
||||
|
||||
void Context::close()
|
||||
{
|
||||
if (!isOpen()) return;
|
||||
MP4Close(fh);
|
||||
}
|
||||
|
||||
void Context::getTracks(const char * file)
|
||||
{
|
||||
int i = 0;
|
||||
bool audioTrack = false, videoTrack = false;
|
||||
|
||||
if (!isOpen()) throw Exception(file, "File is closed.");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
TrackProperties track;
|
||||
if((track.hint = MP4FindTrackId(fh, i++, MP4_HINT_TRACK_TYPE, 0)) == MP4_INVALID_TRACK_ID) break;
|
||||
|
||||
MP4GetHintTrackRtpPayload(fh, track.hint, &track.codecName, &track.payload, NULL, NULL);
|
||||
|
||||
track.track = MP4GetHintTrackReferenceTrackId(fh, track.hint);
|
||||
if(track.track == MP4_INVALID_TRACK_ID) continue;
|
||||
track.clock = MP4GetTrackTimeScale(fh, track.hint);
|
||||
|
||||
if (!strcmp(MP4GetTrackType(fh, track.track), MP4_AUDIO_TRACK_TYPE)) {
|
||||
audioTrack = true;
|
||||
|
||||
if(!strncmp(track.codecName, "PCM", 3))
|
||||
track.packetLength = 20;
|
||||
else
|
||||
track.packetLength = track.clock = 0;
|
||||
|
||||
audio = track;
|
||||
} else if (!strcmp(MP4GetTrackType(fh, track.track), MP4_VIDEO_TRACK_TYPE)) {
|
||||
videoTrack = true;
|
||||
|
||||
const char * sdp = MP4GetHintTrackSdp(fh, track.hint);
|
||||
const char * fmtp = strstr(sdp, "fmtp");
|
||||
|
||||
if (fmtp) {
|
||||
// finds beginning of 'fmtp' value;
|
||||
for(fmtp += 5; *fmtp != ' '; ++fmtp);
|
||||
++fmtp;
|
||||
|
||||
const char * eol = fmtp;
|
||||
for(;*eol != '\r' && *eol != '\n'; ++eol);
|
||||
video.fmtp = std::string(fmtp, eol);
|
||||
}
|
||||
video.track = track;
|
||||
}
|
||||
}
|
||||
|
||||
if (!audioTrack || !videoTrack) throw Exception(file, "Missing audio/video track.");
|
||||
}
|
||||
|
||||
bool Context::getVideoPacket(void * buffer, u_int & size, u_int & ts)
|
||||
{
|
||||
return getPacket(video.track.hint, video.track.runtime, true, buffer, size, ts);
|
||||
}
|
||||
|
||||
bool Context::getAudioPacket(void * buffer, u_int & size, u_int & ts)
|
||||
{
|
||||
return getPacket(audio.hint, audio.runtime, false, buffer, size, ts);
|
||||
}
|
||||
|
||||
bool Context::getPacket(MP4TrackId hint, RuntimeProperties & rt,
|
||||
bool header, void * buffer, u_int & size, u_int & ts)
|
||||
{
|
||||
if (rt.frame == 0 || rt.packet == rt.packetsPerFrame) {
|
||||
++rt.frame;
|
||||
if(!MP4ReadRtpHint(fh, hint, rt.frame, &rt.packetsPerFrame))
|
||||
return false;
|
||||
rt.packet = 0;
|
||||
rt.last_frame = MP4GetSampleTime(fh, hint, rt.frame);
|
||||
}
|
||||
|
||||
ts = rt.last_frame;
|
||||
if (!MP4ReadRtpPacket(fh, hint, rt.packet, (u_int8_t **) &buffer, &size, 0, header, true)) return false;
|
||||
++rt.packet;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is MP4 Helper Library to Freeswitch MP4 module.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Paulo Rogério Panhoto <paulo@voicetechnology.com.br>.
|
||||
Portions created by the Initial Developer are Copyright (C)
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MP4_HELPER_HPP_
|
||||
#define MP4_HELPER_HPP_
|
||||
|
||||
#include <mp4.h>
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
namespace MP4
|
||||
{
|
||||
class Exception: public std::exception {
|
||||
public:
|
||||
Exception(const std::string & file, const std::string & error)
|
||||
: description_(file + ':' + error)
|
||||
{
|
||||
}
|
||||
|
||||
const char * what() const throw()
|
||||
{
|
||||
return description_.c_str();
|
||||
}
|
||||
|
||||
~Exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
std::string description_;
|
||||
};
|
||||
|
||||
struct RuntimeProperties {
|
||||
u_int32_t frame; // sampleID
|
||||
u_int16_t packetsPerFrame;
|
||||
u_int16_t packet; // packetID
|
||||
u_int32_t last_frame; // timestamp
|
||||
|
||||
RuntimeProperties(): frame(0), packetsPerFrame(0), packet(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct TrackProperties {
|
||||
MP4TrackId hint;
|
||||
MP4TrackId track;
|
||||
|
||||
char * codecName;
|
||||
u_int8_t payload;
|
||||
u_int32_t clock;
|
||||
u_int32_t packetLength; // packet Length in time (ms)
|
||||
|
||||
RuntimeProperties runtime;
|
||||
|
||||
TrackProperties(): hint(MP4_INVALID_TRACK_ID), track(MP4_INVALID_TRACK_ID),
|
||||
codecName(NULL), payload(0), clock(0), packetLength(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef TrackProperties AudioProperties;
|
||||
|
||||
struct VideoProperties {
|
||||
TrackProperties track;
|
||||
std::string fmtp;
|
||||
|
||||
VideoProperties()
|
||||
{
|
||||
}
|
||||
|
||||
VideoProperties(const TrackProperties & rhs): track(rhs)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class Context {
|
||||
public:
|
||||
|
||||
Context(const char * file, bool create = false);
|
||||
~Context();
|
||||
|
||||
void open(const char * file);
|
||||
|
||||
void create(const char * file);
|
||||
|
||||
void close();
|
||||
|
||||
// returns: TRUE = has more data, FALSE = end-of-stream or failure
|
||||
bool getVideoPacket(void * buffer, u_int & size, u_int & ts);
|
||||
|
||||
// returns: TRUE = has more data, FALSE = end-of-stream or failure
|
||||
bool getAudioPacket(void * buffer, u_int & size, u_int & ts);
|
||||
|
||||
bool isOpen() const { return fh != MP4_INVALID_FILE_HANDLE; }
|
||||
|
||||
bool isSupported() const { return audio.track != MP4_INVALID_TRACK_ID && video.track.track != MP4_INVALID_TRACK_ID; }
|
||||
|
||||
const AudioProperties & audioTrack() const { return audio; }
|
||||
|
||||
const VideoProperties & videoTrack() const { return video; }
|
||||
|
||||
private:
|
||||
MP4FileHandle fh;
|
||||
AudioProperties audio;
|
||||
|
||||
VideoProperties video;
|
||||
|
||||
// Prevent copy construction.
|
||||
Context(const Context &);
|
||||
|
||||
bool getPacket(MP4TrackId hint, RuntimeProperties & rt,
|
||||
bool header, void * buffer, u_int & size, u_int & ts);
|
||||
|
||||
void getTracks(const char * file);
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -78,6 +78,8 @@ typedef struct vocallo_codec_s {
|
|||
int bpfd; /* bytes per frame decompressed */
|
||||
int bpfc; /* bytes per frame compressed */
|
||||
|
||||
int sampling_rate; /* declared sampling rate */
|
||||
int actual_sampling_rate; /* true sampling rate */
|
||||
int autoinit; /* initialize on start loop or manually */
|
||||
} vocallo_codec_t;
|
||||
|
||||
|
@ -85,20 +87,22 @@ typedef struct vocallo_codec_s {
|
|||
#define ILBC_152_PAYLOAD 98
|
||||
vocallo_codec_t g_codec_map[] =
|
||||
{
|
||||
{ SNGTC_CODEC_PCMU, 0, "PCMU", "Sangoma PCMU", 40, 64000, 10000, 80, 160, 80, 1 },
|
||||
{ SNGTC_CODEC_PCMA, 8, "PCMA", "Sangoma PCMA", 40, 64000, 10000, 80, 160, 80, 1 },
|
||||
{ SNGTC_CODEC_L16_1, 10, "L16", "Sangoma L16", 40, 120000, 10000, 80, 160, 160, 1 },
|
||||
{ SNGTC_CODEC_G729AB, 18, "G729", "Sangoma G729", 40, 8000, 10000, 80, 160, 10, 1 },
|
||||
{ SNGTC_CODEC_G726_32, 122, "G726-32", "Sangoma G.726 32k", 40, 32000, 10000, 80, 160, 40, 1 },
|
||||
{ SNGTC_CODEC_GSM_FR, 3, "GSM", "Sangoma GSM", 20, 13200, 20000, 160, 320, 33, 0 },
|
||||
{ SNGTC_CODEC_ILBC_133, ILBC_133_PAYLOAD, "iLBC", "Sangoma iLBC", -1, -1, -1, -1, -1, -1, 0 },
|
||||
{ SNGTC_CODEC_ILBC_152, ILBC_152_PAYLOAD, "iLBC", "Sangoma iLBC", -1, -1, -1, -1, -1, -1, 0 },
|
||||
{ SNGTC_CODEC_G723_1_63, 4, "G723", "Sangoma G723", 90, 6300, 30000, 240, 480, 24, 0},
|
||||
#if 0
|
||||
/* FIXME: sampling rate seems wrong with this, audioooo soooundssssss sloooooow ... */
|
||||
{ SNGTC_CODEC_G722, 9, "G722", "Sangoma G722", 20, 64000, 20000, 160, 640, 160, 0 },
|
||||
#endif
|
||||
{ -1, -1, NULL, NULL, -1, -1, -1, -1, -1, -1 },
|
||||
/* auto-init codecs */
|
||||
{ SNGTC_CODEC_PCMU, 0, "PCMU", "Sangoma PCMU", 40, 64000, 10000, 80, 160, 80, 8000, 8000, 1 },
|
||||
{ SNGTC_CODEC_PCMA, 8, "PCMA", "Sangoma PCMA", 40, 64000, 10000, 80, 160, 80, 8000, 8000, 1 },
|
||||
{ SNGTC_CODEC_L16_1, 10, "L16", "Sangoma L16", 40, 120000, 10000, 80, 160, 160, 8000, 8000, 0 },
|
||||
{ SNGTC_CODEC_L16_2, 10, "L16", "Sangoma L16 2", 40, 320000, 10000, 80, 320, 320, 16000, 16000, 0 },
|
||||
{ SNGTC_CODEC_G729AB, 18, "G729", "Sangoma G729", 40, 8000, 10000, 80, 160, 10, 8000, 8000, 1 },
|
||||
{ SNGTC_CODEC_G726_32, 122, "G726-32", "Sangoma G.726 32k", 40, 32000, 10000, 80, 160, 40, 8000, 8000, 1 },
|
||||
{ SNGTC_CODEC_G722, 9, "G722", "Sangoma G722", 20, 64000, 10000, 80, 160, 80, 8000, 8000, 1 },
|
||||
|
||||
/* manually initialized */
|
||||
{ SNGTC_CODEC_GSM_FR, 3, "GSM", "Sangoma GSM", 20, 13200, 20000, 160, 320, 33, 8000, 8000, 0 },
|
||||
{ SNGTC_CODEC_G723_1_63, 4, "G723", "Sangoma G723", 90, 6300, 30000, 240, 480, 24, 8000, 8000, 0 },
|
||||
{ SNGTC_CODEC_AMR_1220, 96, "AMR", "Sangoma AMR", 20, 12200, 20000, 160, 320, 0, 8000, 8000, 0 },
|
||||
{ SNGTC_CODEC_ILBC_133, ILBC_133_PAYLOAD, "iLBC", "Sangoma iLBC", -1, -1, -1, -1, -1, -1, -1, -1, 0 },
|
||||
{ SNGTC_CODEC_ILBC_152, ILBC_152_PAYLOAD, "iLBC", "Sangoma iLBC", -1, -1, -1, -1, -1, -1, -1, -1, 0 },
|
||||
{ -1, -1, NULL, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 0 },
|
||||
};
|
||||
|
||||
/* RFC3389 RTP Payload for Comfort Noise */
|
||||
|
@ -322,7 +326,8 @@ static switch_status_t switch_sangoma_init(switch_codec_t *codec, switch_codec_f
|
|||
if (encoding) {
|
||||
sess->encoder.request.usr_priv = sess;
|
||||
sess->encoder.request.a.host_ip = g_rtpip;
|
||||
sess->encoder.request.a.codec_id = SNGTC_CODEC_L16_1;
|
||||
sess->encoder.request.a.codec_id = vcodec->actual_sampling_rate == 16000
|
||||
? SNGTC_CODEC_L16_2 : SNGTC_CODEC_L16_1;
|
||||
sess->encoder.request.a.ms = codec->implementation->microseconds_per_packet/1000;
|
||||
|
||||
sess->encoder.request.b.host_ip = g_rtpip;
|
||||
|
@ -337,7 +342,8 @@ static switch_status_t switch_sangoma_init(switch_codec_t *codec, switch_codec_f
|
|||
sess->decoder.request.a.ms = codec->implementation->microseconds_per_packet/1000;
|
||||
|
||||
sess->decoder.request.b.host_ip = g_rtpip;
|
||||
sess->decoder.request.b.codec_id = SNGTC_CODEC_L16_1;
|
||||
sess->decoder.request.b.codec_id = vcodec->actual_sampling_rate == 16000
|
||||
? SNGTC_CODEC_L16_2 : SNGTC_CODEC_L16_1;
|
||||
sess->decoder.request.b.ms = codec->implementation->microseconds_per_packet/1000;
|
||||
|
||||
}
|
||||
|
@ -786,7 +792,6 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
|
|||
}
|
||||
} else {
|
||||
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No output from sangoma decoder, returning silent frame of %d bytes\n", *decoded_data_len);
|
||||
memset(dbuf_linear, 0, *decoded_data_len);
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1195,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sangoma_codec_load)
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading codecs, register='%s', noregister='%s'\n", g_codec_register_list, g_codec_noregister_list);
|
||||
for (c = 0; g_codec_map[c].codec_id != -1; c++) {
|
||||
|
||||
if (g_codec_map[c].codec_id == SNGTC_CODEC_L16_1) {
|
||||
if (g_codec_map[c].codec_id == SNGTC_CODEC_L16_1 || g_codec_map[c].codec_id == SNGTC_CODEC_L16_2) {
|
||||
/* registering L16 does not make any sense */
|
||||
continue;
|
||||
}
|
||||
|
@ -1227,19 +1232,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sangoma_codec_load)
|
|||
|
||||
/* Now add as many codec implementations as needed, just up to 40ms for now */
|
||||
if (g_codec_map[c].autoinit) {
|
||||
int ms = 0;
|
||||
for (i = 1; i <= 4; i++) {
|
||||
|
||||
if ((g_codec_map[c].maxms/10) < i) {
|
||||
continue;
|
||||
ms = i * 10;
|
||||
if (g_codec_map[c].maxms < ms) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding %dms implementation of codec %s\n", ms, g_codec_map[c].fs_name);
|
||||
switch_core_codec_add_implementation(pool, codec_interface, /* the codec interface we allocated and we want to register with the core */
|
||||
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||
g_codec_map[c].iana, /* the IANA code number, ie http://www.iana.org/assignments/rtp-parameters */
|
||||
g_codec_map[c].iana_name, /* the IANA code name */
|
||||
NULL, /* default fmtp to send (can be overridden by the init function), fmtp is used in SDP for format specific parameters */
|
||||
8000, /* samples transferred per second */
|
||||
8000, /* actual samples transferred per second */
|
||||
g_codec_map[c].sampling_rate, /* samples transferred per second */
|
||||
g_codec_map[c].actual_sampling_rate, /* actual samples transferred per second */
|
||||
g_codec_map[c].bps, /* bits transferred per second */
|
||||
g_codec_map[c].mpf * i, /* microseconds per frame */
|
||||
g_codec_map[c].spf * i, /* samples per frame */
|
||||
|
@ -1253,7 +1260,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sangoma_codec_load)
|
|||
switch_sangoma_destroy); /* deinitalize a codec handle using this implementation */
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* custom implementation for some codecs */
|
||||
|
@ -1331,8 +1337,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sangoma_codec_load)
|
|||
g_codec_map[c].iana, /* the IANA code number, ie http://www.iana.org/assignments/rtp-parameters */
|
||||
g_codec_map[c].iana_name, /* the IANA code name */
|
||||
NULL, /* default fmtp to send (can be overridden by the init function), fmtp is used in SDP for format specific parameters */
|
||||
8000, /* samples transferred per second */
|
||||
8000, /* actual samples transferred per second */
|
||||
g_codec_map[c].sampling_rate, /* samples transferred per second */
|
||||
g_codec_map[c].actual_sampling_rate, /* actual samples transferred per second */
|
||||
g_codec_map[c].bps, /* bits transferred per second */
|
||||
g_codec_map[c].mpf * i, /* microseconds per frame */
|
||||
g_codec_map[c].spf * i, /* samples per frame */
|
||||
|
@ -1347,15 +1353,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sangoma_codec_load)
|
|||
}
|
||||
|
||||
break;
|
||||
|
||||
case SNGTC_CODEC_G722:
|
||||
case SNGTC_CODEC_AMR_1220:
|
||||
switch_core_codec_add_implementation(pool, codec_interface, /* the codec interface we allocated and we want to register with the core */
|
||||
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||
g_codec_map[c].iana, /* the IANA code number, ie http://www.iana.org/assignments/rtp-parameters */
|
||||
g_codec_map[c].iana_name, /* the IANA code name */
|
||||
NULL, /* default fmtp to send (can be overridden by the init function), fmtp is used in SDP for format specific parameters */
|
||||
8000, /* samples transferred per second */
|
||||
16000, /* actual samples transferred per second */
|
||||
g_codec_map[c].sampling_rate, /* samples transferred per second */
|
||||
g_codec_map[c].actual_sampling_rate, /* actual samples transferred per second */
|
||||
g_codec_map[c].bps, /* bits transferred per second */
|
||||
g_codec_map[c].mpf, /* microseconds per frame */
|
||||
g_codec_map[c].spf, /* samples per frame */
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
BASE=../../../..
|
||||
LOCAL_CFLAGS+=-g -ggdb -I/usr/local/include/ptlib -I/usr/local/include/openh323 -I. -DPTRACING=1 -D_REENTRANT -fno-exceptions
|
||||
LOCAL_LDFLAGS= -lopenh323 -lpt -lrt
|
||||
|
||||
export PTLIBDIR = $(shell /usr/bin/ptlib-config --ptlibdir)
|
||||
LOCAL_CFLAGS+=-g -I$PTLIBDIR -I/usr/include/openh323 -I. -DPTRACING=1 -D_REENTRANT -fno-exceptions
|
||||
LOCAL_LDFLAGS= -L/usr/lib -lopenh323 -lpt -lrt
|
||||
|
||||
ifeq ($(shell uname -m),x86_64)
|
||||
LOCAL_CFLAGS+=-DP_64BIT
|
||||
endif
|
||||
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
|
||||
|
|
|
@ -558,6 +558,7 @@ struct sofia_profile {
|
|||
char *user_agent_filter;
|
||||
uint32_t max_registrations_perext;
|
||||
switch_rtp_bug_flag_t auto_rtp_bugs;
|
||||
switch_rtp_bug_flag_t manual_rtp_bugs;
|
||||
uint32_t ib_calls;
|
||||
uint32_t ob_calls;
|
||||
uint32_t ib_failed_calls;
|
||||
|
@ -1035,3 +1036,4 @@ void sofia_glue_proxy_codec(switch_core_session_t *session, const char *r_sdp);
|
|||
switch_status_t sofia_glue_sdp_map(const char *r_sdp, switch_event_t **fmtp, switch_event_t **pt);
|
||||
void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl);
|
||||
void sofia_glue_check_dtmf_type(private_object_t *tech_pvt);
|
||||
void sofia_glue_parse_rtp_bugs(uint32_t *flag_pole, const char *str);
|
||||
|
|
|
@ -2220,39 +2220,6 @@ static void parse_domain_tag(sofia_profile_t *profile, switch_xml_t x_domain_tag
|
|||
}
|
||||
}
|
||||
|
||||
static void parse_rtp_bugs(sofia_profile_t *profile, const char *str)
|
||||
{
|
||||
|
||||
if (switch_stristr("clear", str)) {
|
||||
profile->auto_rtp_bugs = 0;
|
||||
}
|
||||
|
||||
if (switch_stristr("CISCO_SKIP_MARK_BIT_2833", str)) {
|
||||
profile->auto_rtp_bugs |= RTP_BUG_CISCO_SKIP_MARK_BIT_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("~CISCO_SKIP_MARK_BIT_2833", str)) {
|
||||
profile->auto_rtp_bugs &= ~RTP_BUG_CISCO_SKIP_MARK_BIT_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("SONUS_SEND_INVALID_TIMESTAMP_2833", str)) {
|
||||
profile->auto_rtp_bugs |= RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("~SONUS_SEND_INVALID_TIMESTAMP_2833", str)) {
|
||||
profile->auto_rtp_bugs &= ~RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("IGNORE_MARK_BIT", str)) {
|
||||
profile->auto_rtp_bugs |= RTP_BUG_IGNORE_MARK_BIT;
|
||||
}
|
||||
|
||||
if (switch_stristr("~IGNORE_MARK_BIT", str)) {
|
||||
profile->auto_rtp_bugs &= ~RTP_BUG_IGNORE_MARK_BIT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
||||
{
|
||||
switch_xml_t cfg, xml = NULL, xprofile, profiles, gateways_tag, domain_tag, domains_tag, aliases_tag, alias_tag, settings, param;
|
||||
|
@ -2382,7 +2349,9 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
|||
sofia_clear_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
|
||||
}
|
||||
} else if (!strcasecmp(var, "auto-rtp-bugs")) {
|
||||
parse_rtp_bugs(profile, val);
|
||||
sofia_glue_parse_rtp_bugs(&profile->auto_rtp_bugs, val);
|
||||
} else if (!strcasecmp(var, "manual-rtp-bugs")) {
|
||||
sofia_glue_parse_rtp_bugs(&profile->manual_rtp_bugs, val);
|
||||
} else if (!strcasecmp(var, "user-agent-string")) {
|
||||
profile->user_agent = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "auto-restart")) {
|
||||
|
@ -3103,7 +3072,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||
profile->rport_level = 2;
|
||||
}
|
||||
} else if (!strcasecmp(var, "auto-rtp-bugs")) {
|
||||
parse_rtp_bugs(profile, val);
|
||||
sofia_glue_parse_rtp_bugs(&profile->auto_rtp_bugs, val);
|
||||
} else if (!strcasecmp(var, "manual-rtp-bugs")) {
|
||||
sofia_glue_parse_rtp_bugs(&profile->manual_rtp_bugs, val);
|
||||
} else if (!strcasecmp(var, "dbname")) {
|
||||
profile->dbname = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "presence-hosts")) {
|
||||
|
@ -4700,9 +4671,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
|
||||
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
|
||||
}
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
switch_channel_pre_answer(other_channel);
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
//switch_channel_pre_answer(other_channel);
|
||||
switch_core_session_queue_indication(other_session, SWITCH_MESSAGE_INDICATE_PROGRESS);
|
||||
switch_core_session_rwunlock(other_session);
|
||||
}
|
||||
goto done;
|
||||
|
@ -5129,10 +5099,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
|
||||
&& (other_session = switch_core_session_locate(uuid))) {
|
||||
other_channel = switch_core_session_get_channel(other_session);
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
switch_channel_answer(other_channel);
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
//other_channel = switch_core_session_get_channel(other_session);
|
||||
//switch_channel_answer(other_channel);
|
||||
switch_core_session_queue_indication(other_session, SWITCH_MESSAGE_INDICATE_ANSWER);
|
||||
switch_core_session_rwunlock(other_session);
|
||||
}
|
||||
}
|
||||
|
@ -5161,9 +5130,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
|
||||
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
|
||||
}
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
switch_channel_answer(other_channel);
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
//switch_channel_answer(other_channel);
|
||||
switch_core_session_queue_indication(other_session, SWITCH_MESSAGE_INDICATE_ANSWER);
|
||||
|
||||
switch_core_session_rwunlock(other_session);
|
||||
}
|
||||
goto done;
|
||||
|
|
|
@ -3106,7 +3106,11 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
|||
tech_pvt->rtp_bugs |= RTP_BUG_IGNORE_MARK_BIT;
|
||||
}
|
||||
|
||||
switch_rtp_intentional_bugs(tech_pvt->rtp_session, tech_pvt->rtp_bugs);
|
||||
if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_manual_rtp_bugs"))) {
|
||||
sofia_glue_parse_rtp_bugs(&tech_pvt->rtp_bugs, val);
|
||||
}
|
||||
|
||||
switch_rtp_intentional_bugs(tech_pvt->rtp_session, tech_pvt->rtp_bugs | tech_pvt->profile->manual_rtp_bugs);
|
||||
|
||||
if ((vad_in && inb) || (vad_out && !inb)) {
|
||||
switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
|
||||
|
@ -5990,6 +5994,62 @@ void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const
|
|||
}
|
||||
|
||||
|
||||
void sofia_glue_parse_rtp_bugs(uint32_t *flag_pole, const char *str)
|
||||
{
|
||||
|
||||
if (switch_stristr("clear", str)) {
|
||||
*flag_pole = 0;
|
||||
}
|
||||
|
||||
if (switch_stristr("CISCO_SKIP_MARK_BIT_2833", str)) {
|
||||
*flag_pole |= RTP_BUG_CISCO_SKIP_MARK_BIT_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("~CISCO_SKIP_MARK_BIT_2833", str)) {
|
||||
*flag_pole &= ~RTP_BUG_CISCO_SKIP_MARK_BIT_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("SONUS_SEND_INVALID_TIMESTAMP_2833", str)) {
|
||||
*flag_pole |= RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("~SONUS_SEND_INVALID_TIMESTAMP_2833", str)) {
|
||||
*flag_pole &= ~RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
|
||||
}
|
||||
|
||||
if (switch_stristr("IGNORE_MARK_BIT", str)) {
|
||||
*flag_pole |= RTP_BUG_IGNORE_MARK_BIT;
|
||||
}
|
||||
|
||||
if (switch_stristr("~IGNORE_MARK_BIT", str)) {
|
||||
*flag_pole &= ~RTP_BUG_IGNORE_MARK_BIT;
|
||||
}
|
||||
|
||||
if (switch_stristr("SEND_LINEAR_TIMESTAMPS", str)) {
|
||||
*flag_pole |= RTP_BUG_SEND_LINEAR_TIMESTAMPS;
|
||||
}
|
||||
|
||||
if (switch_stristr("~SEND_LINEAR_TIMESTAMPS", str)) {
|
||||
*flag_pole &= ~RTP_BUG_SEND_LINEAR_TIMESTAMPS;
|
||||
}
|
||||
|
||||
if (switch_stristr("START_SEQ_AT_ZERO", str)) {
|
||||
*flag_pole |= RTP_BUG_START_SEQ_AT_ZERO;
|
||||
}
|
||||
|
||||
if (switch_stristr("~START_SEQ_AT_ZERO", str)) {
|
||||
*flag_pole &= ~RTP_BUG_START_SEQ_AT_ZERO;
|
||||
}
|
||||
|
||||
if (switch_stristr("NEVER_SEND_MARKER", str)) {
|
||||
*flag_pole |= RTP_BUG_NEVER_SEND_MARKER;
|
||||
}
|
||||
|
||||
if (switch_stristr("~NEVER_SEND_MARKER", str)) {
|
||||
*flag_pole &= ~RTP_BUG_NEVER_SEND_MARKER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1259,7 +1259,6 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
char *to = NULL;
|
||||
char *open;
|
||||
char *prpid;
|
||||
char *sql;
|
||||
time_t exptime = switch_epoch_time_now(NULL) + 3600;
|
||||
int is_dialog = 0;
|
||||
sofia_profile_t *ext_profile = NULL, *profile = helper->profile;
|
||||
|
@ -1617,15 +1616,16 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
|
||||
}
|
||||
|
||||
/* commenting to test
|
||||
if (helper->event){
|
||||
const char *uuid = switch_event_get_header_nil(helper->event, "unique-id");
|
||||
|
||||
if (!zstr(uuid) && strchr(uuid, '-')) {
|
||||
sql = switch_mprintf("update sip_dialogs set rpid='%q',status='%q' where uuid='%q'", rpid, status_line, uuid);
|
||||
char *sql = switch_mprintf("update sip_dialogs set rpid='%q',status='%q' where uuid='%q'", rpid, status_line, uuid);
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
nua_handle_bind(nh, &mod_sofia_globals.keep_private);
|
||||
|
||||
|
|
|
@ -1490,6 +1490,7 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h
|
|||
int network_port = 0;
|
||||
char *is_nat = NULL;
|
||||
|
||||
#if 0 /* This seems to cause undesirable effects so nevermind */
|
||||
if (sip->sip_to && sip->sip_to->a_url && sip->sip_to->a_url->url_host) {
|
||||
const char *to_host = sip->sip_to->a_url->url_host;
|
||||
if (profile->reg_db_domain) {
|
||||
|
@ -1500,6 +1501,7 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
|
||||
|
||||
|
|
|
@ -173,68 +173,74 @@ static switch_status_t handle_msg_fetch_reply(listener_t *listener, ei_x_buff *
|
|||
ei_x_encode_atom(rbuf, "error");
|
||||
ei_x_encode_atom(rbuf, "badarg");
|
||||
} else {
|
||||
ei_x_buff *nbuf = malloc(sizeof(nbuf));
|
||||
nbuf->buff = malloc(buf->buffsz);
|
||||
memcpy(nbuf->buff, buf->buff, buf->buffsz);
|
||||
nbuf->index = buf->index;
|
||||
nbuf->buffsz = buf->buffsz;
|
||||
/* TODO - maybe use a rwlock instead */
|
||||
if ((p = switch_core_hash_find_locked(globals.fetch_reply_hash, uuid_str, globals.fetch_reply_mutex))) {
|
||||
/* try to lock the mutex, so no other responder can */
|
||||
if (switch_mutex_trylock(p->mutex) == SWITCH_STATUS_SUCCESS) {
|
||||
if (p->state == reply_waiting) {
|
||||
/* alright, we've got the lock and we're the first to reply */
|
||||
|
||||
switch_mutex_lock(globals.fetch_reply_mutex);
|
||||
if ((p = switch_core_hash_find(globals.fetch_reply_hash, uuid_str))) {
|
||||
/* Get the status and release the lock ASAP. */
|
||||
enum { is_timeout, is_waiting, is_filled } status;
|
||||
if (p->state == reply_not_ready) {
|
||||
switch_thread_cond_wait(p->ready_or_found, globals.fetch_reply_mutex);
|
||||
}
|
||||
/* clone the reply so it doesn't get destroyed on us */
|
||||
ei_x_buff *nbuf = malloc(sizeof(nbuf));
|
||||
nbuf->buff = malloc(buf->buffsz);
|
||||
memcpy(nbuf->buff, buf->buff, buf->buffsz);
|
||||
nbuf->index = buf->index;
|
||||
nbuf->buffsz = buf->buffsz;
|
||||
|
||||
if (p->state == reply_waiting) {
|
||||
/* update the key with a reply */
|
||||
status = is_waiting;
|
||||
p->reply = nbuf;
|
||||
p->state = reply_found;
|
||||
strncpy(p->winner, listener->peer_nodename, MAXNODELEN);
|
||||
switch_thread_cond_broadcast(p->ready_or_found);
|
||||
} else if (p->state == reply_timeout) {
|
||||
status = is_timeout;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Got reply for %s\n", uuid_str);
|
||||
|
||||
/* copy info into the reply struct */
|
||||
p->state = reply_found;
|
||||
p->reply = nbuf;
|
||||
strncpy(p->winner, listener->peer_nodename, MAXNODELEN);
|
||||
|
||||
/* signal waiting thread that its time to wake up */
|
||||
switch_thread_cond_signal(p->ready_or_found);
|
||||
|
||||
/* reply OK */
|
||||
ei_x_encode_tuple_header(rbuf, 2);
|
||||
ei_x_encode_atom(rbuf, "ok");
|
||||
_ei_x_encode_string(rbuf, uuid_str);
|
||||
|
||||
/* unlock */
|
||||
switch_mutex_unlock(p->mutex);
|
||||
} else {
|
||||
if (p->state == reply_found) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Reply for already complete request %s\n", uuid_str);
|
||||
ei_x_encode_tuple_header(rbuf, 3);
|
||||
ei_x_encode_atom(rbuf, "error");
|
||||
_ei_x_encode_string(rbuf, uuid_str);
|
||||
ei_x_encode_atom(rbuf, "duplicate_response");
|
||||
} else if (p->state == reply_timeout) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Reply for timed out request %s\n", uuid_str);
|
||||
ei_x_encode_tuple_header(rbuf, 3);
|
||||
ei_x_encode_atom(rbuf, "error");
|
||||
_ei_x_encode_string(rbuf, uuid_str);
|
||||
ei_x_encode_atom(rbuf, "timeout");
|
||||
} else if (p->state == reply_not_ready) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Request %s is not ready?!\n", uuid_str);
|
||||
ei_x_encode_tuple_header(rbuf, 3);
|
||||
ei_x_encode_atom(rbuf, "error");
|
||||
_ei_x_encode_string(rbuf, uuid_str);
|
||||
ei_x_encode_atom(rbuf, "not_ready");
|
||||
}
|
||||
switch_mutex_unlock(p->mutex);
|
||||
}
|
||||
} else {
|
||||
status = is_filled;
|
||||
}
|
||||
|
||||
put_reply_unlock(p, uuid_str);
|
||||
|
||||
/* Relay the status back to the fetch responder. */
|
||||
if (status == is_waiting) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found waiting slot for %s\n", uuid_str);
|
||||
ei_x_encode_tuple_header(rbuf, 2);
|
||||
ei_x_encode_atom(rbuf, "ok");
|
||||
_ei_x_encode_string(rbuf, uuid_str);
|
||||
/* Return here to avoid freeing the reply. */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (status == is_timeout) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handler for %s timed out\n", uuid_str);
|
||||
ei_x_encode_tuple_header(rbuf, 3);
|
||||
ei_x_encode_atom(rbuf, "error");
|
||||
_ei_x_encode_string(rbuf, uuid_str);
|
||||
ei_x_encode_atom(rbuf, "timeout");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found filled slot for %s\n", uuid_str);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not lock mutex for reply %s\n", uuid_str);
|
||||
ei_x_encode_tuple_header(rbuf, 3);
|
||||
ei_x_encode_atom(rbuf, "error");
|
||||
_ei_x_encode_string(rbuf, uuid_str);
|
||||
ei_x_encode_atom(rbuf, "duplicate_response");
|
||||
}
|
||||
} else {
|
||||
/* nothing in the hash */
|
||||
switch_mutex_unlock(globals.fetch_reply_mutex);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Empty slot for %s\n", uuid_str);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not find request for reply %s\n", uuid_str);
|
||||
ei_x_encode_tuple_header(rbuf, 2);
|
||||
ei_x_encode_atom(rbuf, "error");
|
||||
ei_x_encode_atom(rbuf, "invalid_uuid");
|
||||
}
|
||||
|
||||
switch_safe_free(nbuf->buff);
|
||||
switch_safe_free(nbuf);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1058,7 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg,
|
|||
|
||||
if (se->spawn_reply->state == reply_waiting) {
|
||||
se->spawn_reply->pid = pid;
|
||||
switch_thread_cond_broadcast(se->spawn_reply->ready_or_found);
|
||||
switch_thread_cond_signal(se->spawn_reply->ready_or_found);
|
||||
ei_x_encode_atom(rbuf, "ok");
|
||||
switch_thread_rwlock_unlock(listener->session_rwlock);
|
||||
switch_mutex_unlock(se->spawn_reply->mutex);
|
||||
|
|
|
@ -366,13 +366,21 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c
|
|||
ei_x_buff buf;
|
||||
ei_x_new_with_version(&buf);
|
||||
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
|
||||
ei_x_encode_tuple_header(&buf, 7);
|
||||
ei_x_encode_atom(&buf, "fetch");
|
||||
ei_x_encode_atom(&buf, sectionstr);
|
||||
_ei_x_encode_string(&buf, tag_name ? tag_name : "undefined");
|
||||
_ei_x_encode_string(&buf, key_name ? key_name : "undefined");
|
||||
_ei_x_encode_string(&buf, key_value ? key_value : "undefined");
|
||||
_ei_x_encode_string(&buf, uuid_str);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "looking for bindings\n");
|
||||
|
||||
section = switch_xml_parse_section_string((char *) sectionstr);
|
||||
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
|
||||
for (ptr = bindings.head; ptr; ptr = ptr->next) {
|
||||
if (ptr->section != section)
|
||||
continue;
|
||||
|
@ -384,13 +392,6 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c
|
|||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "binding for %s in section %s with key %s and value %s requested from node %s\n", tag_name, sectionstr, key_name, key_value, ptr->process.pid.node);
|
||||
|
||||
ei_x_encode_tuple_header(&buf, 7);
|
||||
ei_x_encode_atom(&buf, "fetch");
|
||||
ei_x_encode_atom(&buf, sectionstr);
|
||||
_ei_x_encode_string(&buf, tag_name ? tag_name : "undefined");
|
||||
_ei_x_encode_string(&buf, key_name ? key_name : "undefined");
|
||||
_ei_x_encode_string(&buf, key_value ? key_value : "undefined");
|
||||
_ei_x_encode_string(&buf, uuid_str);
|
||||
if (params) {
|
||||
ei_encode_switch_event_headers(&buf, params);
|
||||
} else {
|
||||
|
@ -401,41 +402,42 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c
|
|||
/* Create a new fetch object. */
|
||||
p = malloc(sizeof(*p));
|
||||
switch_thread_cond_create(&p->ready_or_found, module_pool);
|
||||
p->usecount = 1;
|
||||
switch_mutex_init(&p->mutex, SWITCH_MUTEX_UNNESTED, module_pool);
|
||||
p->state = reply_not_ready;
|
||||
p->reply = NULL;
|
||||
switch_core_hash_insert_locked(globals.fetch_reply_hash, uuid_str, p, globals.fetch_reply_mutex);
|
||||
p->state = reply_waiting;
|
||||
now = switch_micro_time_now();
|
||||
}
|
||||
/* We don't need to lock here because everybody is waiting
|
||||
on our condition before the action starts. */
|
||||
p->usecount ++;
|
||||
|
||||
switch_mutex_lock(ptr->listener->sock_mutex);
|
||||
ei_sendto(ptr->listener->ec, ptr->listener->sockfd, &ptr->process, &buf);
|
||||
switch_mutex_unlock(ptr->listener->sock_mutex);
|
||||
}
|
||||
|
||||
ei_x_free(&buf);
|
||||
|
||||
if (!p) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no binding for %s\n", sectionstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Tell the threads to be ready, and wait five seconds for a reply. */
|
||||
switch_mutex_lock(globals.fetch_reply_mutex);
|
||||
p->state = reply_waiting;
|
||||
switch_thread_cond_broadcast(p->ready_or_found);
|
||||
switch_mutex_lock(p->mutex);
|
||||
//p->state = reply_waiting;
|
||||
switch_thread_cond_timedwait(p->ready_or_found,
|
||||
globals.fetch_reply_mutex, 5000000);
|
||||
p->mutex, 5000000);
|
||||
if (!p->reply) {
|
||||
p->state = reply_timeout;
|
||||
switch_mutex_unlock(globals.fetch_reply_mutex);
|
||||
switch_mutex_unlock(p->mutex);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out after %d milliseconds when waiting for XML fetch response for %s\n", (int) (switch_micro_time_now() - now) / 1000, uuid_str);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rep = p->reply;
|
||||
switch_mutex_unlock(globals.fetch_reply_mutex);
|
||||
switch_mutex_unlock(p->mutex);
|
||||
|
||||
ei_get_type(rep->buff, &rep->index, &type, &size);
|
||||
|
||||
|
@ -450,7 +452,6 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
if (!(xmlstr = malloc(size + 1))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error\n");
|
||||
goto cleanup;
|
||||
|
@ -471,29 +472,20 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c
|
|||
/* cleanup */
|
||||
cleanup:
|
||||
if (p) {
|
||||
switch_mutex_lock(globals.fetch_reply_mutex);
|
||||
put_reply_unlock(p, uuid_str);
|
||||
/* lock so nothing can have it while we delete it */
|
||||
switch_mutex_lock(p->mutex);
|
||||
switch_core_hash_delete_locked(globals.fetch_reply_hash, uuid_str, globals.fetch_reply_mutex);
|
||||
switch_mutex_unlock(p->mutex);
|
||||
switch_mutex_destroy(p->mutex);
|
||||
switch_thread_cond_destroy(p->ready_or_found);
|
||||
switch_safe_free(p->reply);
|
||||
switch_safe_free(p);
|
||||
}
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
||||
void put_reply_unlock(fetch_reply_t *p, char *uuid_str)
|
||||
{
|
||||
if (-- p->usecount == 0) {
|
||||
switch_core_hash_delete(globals.fetch_reply_hash, uuid_str);
|
||||
switch_thread_cond_destroy(p->ready_or_found);
|
||||
if (p->reply) {
|
||||
switch_safe_free(p->reply->buff);
|
||||
switch_safe_free(p->reply);
|
||||
}
|
||||
switch_safe_free(p);
|
||||
}
|
||||
switch_mutex_unlock(globals.fetch_reply_mutex);
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t notify_new_session(listener_t *listener, session_elem_t *session_element)
|
||||
{
|
||||
int result;
|
||||
|
|
|
@ -60,7 +60,7 @@ enum reply_state { reply_not_ready, reply_waiting, reply_found, reply_timeout };
|
|||
struct fetch_reply_struct
|
||||
{
|
||||
switch_thread_cond_t *ready_or_found;
|
||||
int usecount;
|
||||
switch_mutex_t *mutex;
|
||||
enum reply_state state;
|
||||
ei_x_buff *reply;
|
||||
char winner[MAXNODELEN + 1];
|
||||
|
|
|
@ -71,7 +71,7 @@ static int next_file(switch_file_handle_t *handle)
|
|||
switch_core_file_close(&context->fh);
|
||||
}
|
||||
|
||||
if (context->index == context->argc) {
|
||||
if (context->index >= context->argc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,24 @@ static int next_file(switch_file_handle_t *handle)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t file_string_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
|
||||
{
|
||||
file_string_context_t *context = handle->private_info;
|
||||
|
||||
if (samples == 0 && whence == SEEK_SET) {
|
||||
context->index = -1;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (!handle->seekable) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n");
|
||||
return SWITCH_STATUS_NOTIMPL;
|
||||
}
|
||||
|
||||
return switch_core_file_seek(&context->fh, cur_sample, samples, whence);
|
||||
}
|
||||
|
||||
static switch_status_t file_string_file_open(switch_file_handle_t *handle, const char *path)
|
||||
{
|
||||
file_string_context_t *context;
|
||||
|
@ -185,6 +203,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_file_string_load)
|
|||
file_interface->file_open = file_string_file_open;
|
||||
file_interface->file_close = file_string_file_close;
|
||||
file_interface->file_read = file_string_file_read;
|
||||
file_interface->file_seek = file_string_file_seek;
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
/* indicate that the module should continue to be loaded */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.0
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
|
@ -11634,6 +11634,108 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_isxdigit(int jarg1) {
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_ip_t_v4_set(void * jarg1, unsigned long jarg2) {
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
uint32_t arg2 ;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
arg2 = (uint32_t)jarg2;
|
||||
if (arg1) (arg1)->v4 = arg2;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT unsigned long SWIGSTDCALL CSharp_ip_t_v4_get(void * jarg1) {
|
||||
unsigned long jresult ;
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
uint32_t result;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
result = (uint32_t) ((arg1)->v4);
|
||||
jresult = (unsigned long)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_ip_t_v6_set(void * jarg1, void * jarg2) {
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
in6_addr arg2 ;
|
||||
in6_addr *argp2 ;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
argp2 = (in6_addr *)jarg2;
|
||||
if (!argp2) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null in6_addr", 0);
|
||||
return ;
|
||||
}
|
||||
arg2 = *argp2;
|
||||
if (arg1) (arg1)->v6 = arg2;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_ip_t_v6_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
in6_addr result;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
result = ((arg1)->v6);
|
||||
jresult = new in6_addr((const in6_addr &)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_new_ip_t() {
|
||||
void * jresult ;
|
||||
ip_t *result = 0 ;
|
||||
|
||||
result = (ip_t *)new ip_t();
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_delete_ip_t(void * jarg1) {
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
delete arg1;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_testv6_subnet(void * jarg1, void * jarg2, void * jarg3) {
|
||||
int jresult ;
|
||||
ip_t arg1 ;
|
||||
ip_t arg2 ;
|
||||
ip_t arg3 ;
|
||||
ip_t *argp1 ;
|
||||
ip_t *argp2 ;
|
||||
ip_t *argp3 ;
|
||||
switch_bool_t result;
|
||||
|
||||
argp1 = (ip_t *)jarg1;
|
||||
if (!argp1) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg1 = *argp1;
|
||||
argp2 = (ip_t *)jarg2;
|
||||
if (!argp2) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg2 = *argp2;
|
||||
argp3 = (ip_t *)jarg3;
|
||||
if (!argp3) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg3 = *argp3;
|
||||
result = (switch_bool_t)switch_testv6_subnet(arg1,arg2,arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_SMAX_get() {
|
||||
int jresult ;
|
||||
int result;
|
||||
|
@ -12589,14 +12691,14 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_is_file_path(char * jarg1) {
|
|||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_parse_cidr(char * jarg1, void * jarg2, void * jarg3, void * jarg4) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
uint32_t *arg2 = (uint32_t *) 0 ;
|
||||
uint32_t *arg3 = (uint32_t *) 0 ;
|
||||
ip_t *arg2 = (ip_t *) 0 ;
|
||||
ip_t *arg3 = (ip_t *) 0 ;
|
||||
uint32_t *arg4 = (uint32_t *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
arg2 = (uint32_t *)jarg2;
|
||||
arg3 = (uint32_t *)jarg3;
|
||||
arg2 = (ip_t *)jarg2;
|
||||
arg3 = (ip_t *)jarg3;
|
||||
arg4 = (uint32_t *)jarg4;
|
||||
result = (int)switch_parse_cidr((char const *)arg1,arg2,arg3,arg4);
|
||||
jresult = result;
|
||||
|
@ -12674,6 +12776,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_network_list_validate_ip_token(void * j
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_network_list_validate_ip6_token(void * jarg1, void * jarg2, void * jarg3) {
|
||||
int jresult ;
|
||||
switch_network_list_t *arg1 = (switch_network_list_t *) 0 ;
|
||||
ip_t arg2 ;
|
||||
char **arg3 = (char **) 0 ;
|
||||
ip_t *argp2 ;
|
||||
switch_bool_t result;
|
||||
|
||||
arg1 = (switch_network_list_t *)jarg1;
|
||||
argp2 = (ip_t *)jarg2;
|
||||
if (!argp2) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg2 = *argp2;
|
||||
arg3 = (char **)jarg3;
|
||||
result = (switch_bool_t)switch_network_list_validate_ip6_token(arg1,arg2,(char const **)arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_dow_int2str(int jarg1) {
|
||||
char * jresult ;
|
||||
int arg1 ;
|
||||
|
|
|
@ -11949,6 +11949,111 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_isxdigit(int jarg1) {
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_ip_t_v4_set(void * jarg1, unsigned long jarg2) {
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
uint32_t arg2 ;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
arg2 = (uint32_t)jarg2;
|
||||
if (arg1) (arg1)->v4 = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT unsigned long SWIGSTDCALL CSharp_ip_t_v4_get(void * jarg1) {
|
||||
unsigned long jresult ;
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
uint32_t result;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
result = (uint32_t) ((arg1)->v4);
|
||||
jresult = (unsigned long)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_ip_t_v6_set(void * jarg1, void * jarg2) {
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
in6_addr arg2 ;
|
||||
in6_addr *argp2 ;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
argp2 = (in6_addr *)jarg2;
|
||||
if (!argp2) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null in6_addr", 0);
|
||||
return ;
|
||||
}
|
||||
arg2 = *argp2;
|
||||
if (arg1) (arg1)->v6 = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_ip_t_v6_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
in6_addr result;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
result = ((arg1)->v6);
|
||||
jresult = new in6_addr((in6_addr &)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_new_ip_t() {
|
||||
void * jresult ;
|
||||
ip_t *result = 0 ;
|
||||
|
||||
result = (ip_t *)new ip_t();
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_delete_ip_t(void * jarg1) {
|
||||
ip_t *arg1 = (ip_t *) 0 ;
|
||||
|
||||
arg1 = (ip_t *)jarg1;
|
||||
delete arg1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_testv6_subnet(void * jarg1, void * jarg2, void * jarg3) {
|
||||
int jresult ;
|
||||
ip_t arg1 ;
|
||||
ip_t arg2 ;
|
||||
ip_t arg3 ;
|
||||
switch_bool_t result;
|
||||
ip_t *argp1 ;
|
||||
ip_t *argp2 ;
|
||||
ip_t *argp3 ;
|
||||
|
||||
argp1 = (ip_t *)jarg1;
|
||||
if (!argp1) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg1 = *argp1;
|
||||
argp2 = (ip_t *)jarg2;
|
||||
if (!argp2) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg2 = *argp2;
|
||||
argp3 = (ip_t *)jarg3;
|
||||
if (!argp3) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg3 = *argp3;
|
||||
result = (switch_bool_t)switch_testv6_subnet(arg1,arg2,arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_SMAX_get() {
|
||||
int jresult ;
|
||||
int result;
|
||||
|
@ -12906,14 +13011,14 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_is_file_path(char * jarg1) {
|
|||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_parse_cidr(char * jarg1, void * jarg2, void * jarg3, void * jarg4) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
uint32_t *arg2 = (uint32_t *) 0 ;
|
||||
uint32_t *arg3 = (uint32_t *) 0 ;
|
||||
ip_t *arg2 = (ip_t *) 0 ;
|
||||
ip_t *arg3 = (ip_t *) 0 ;
|
||||
uint32_t *arg4 = (uint32_t *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
arg2 = (uint32_t *)jarg2;
|
||||
arg3 = (uint32_t *)jarg3;
|
||||
arg2 = (ip_t *)jarg2;
|
||||
arg3 = (ip_t *)jarg3;
|
||||
arg4 = (uint32_t *)jarg4;
|
||||
result = (int)switch_parse_cidr((char const *)arg1,arg2,arg3,arg4);
|
||||
jresult = result;
|
||||
|
@ -12991,6 +13096,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_network_list_validate_ip_token(void * j
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_network_list_validate_ip6_token(void * jarg1, void * jarg2, void * jarg3) {
|
||||
int jresult ;
|
||||
switch_network_list_t *arg1 = (switch_network_list_t *) 0 ;
|
||||
ip_t arg2 ;
|
||||
char **arg3 = (char **) 0 ;
|
||||
switch_bool_t result;
|
||||
ip_t *argp2 ;
|
||||
|
||||
arg1 = (switch_network_list_t *)jarg1;
|
||||
argp2 = (ip_t *)jarg2;
|
||||
if (!argp2) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null ip_t", 0);
|
||||
return 0;
|
||||
}
|
||||
arg2 = *argp2;
|
||||
arg3 = (char **)jarg3;
|
||||
result = (switch_bool_t)switch_network_list_validate_ip6_token(arg1,arg2,(char const **)arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_dow_int2str(int jarg1) {
|
||||
char * jresult ;
|
||||
int arg1 ;
|
||||
|
@ -13019,11 +13146,11 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_dow_cmp(char * jarg1, int jarg2) {
|
|||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
switch_bool_t result;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)switch_dow_cmp((char const *)arg1,arg2);
|
||||
result = (switch_bool_t)switch_dow_cmp((char const *)arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
@ -15706,6 +15833,29 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_routines_write_video_frame_get(vo
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_state_run_set(void * jarg1, void * jarg2) {
|
||||
switch_io_routines *arg1 = (switch_io_routines *) 0 ;
|
||||
switch_io_state_run_t arg2 = (switch_io_state_run_t) 0 ;
|
||||
|
||||
arg1 = (switch_io_routines *)jarg1;
|
||||
arg2 = (switch_io_state_run_t)jarg2;
|
||||
if (arg1) (arg1)->state_run = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_routines_state_run_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_io_routines *arg1 = (switch_io_routines *) 0 ;
|
||||
switch_io_state_run_t result;
|
||||
|
||||
arg1 = (switch_io_routines *)jarg1;
|
||||
result = (switch_io_state_run_t) ((arg1)->state_run);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_routines_resurrect_session_set(void * jarg1, void * jarg2) {
|
||||
switch_io_routines *arg1 = (switch_io_routines *) 0 ;
|
||||
switch_io_resurrect_session_t arg2 = (switch_io_resurrect_session_t) 0 ;
|
||||
|
@ -27923,15 +28073,17 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_sound_test(void * jarg1) {
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_process_import(void * jarg1, void * jarg2, char * jarg3) {
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_process_import(void * jarg1, void * jarg2, char * jarg3, char * jarg4) {
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_channel_t *arg2 = (switch_channel_t *) 0 ;
|
||||
char *arg3 = (char *) 0 ;
|
||||
char *arg4 = (char *) 0 ;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
arg2 = (switch_channel_t *)jarg2;
|
||||
arg3 = (char *)jarg3;
|
||||
switch_process_import(arg1,arg2,(char const *)arg3);
|
||||
arg4 = (char *)jarg4;
|
||||
switch_process_import(arg1,arg2,(char const *)arg3,(char const *)arg4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27947,6 +28099,26 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_uuid_exists(char * jarg1) {
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_set_match_callback(void * jarg1, void * jarg2) {
|
||||
switch_ivr_dmachine_t *arg1 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_ivr_dmachine_callback_t arg2 = (switch_ivr_dmachine_callback_t) 0 ;
|
||||
|
||||
arg1 = (switch_ivr_dmachine_t *)jarg1;
|
||||
arg2 = (switch_ivr_dmachine_callback_t)jarg2;
|
||||
switch_ivr_dmachine_set_match_callback(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_set_nonmatch_callback(void * jarg1, void * jarg2) {
|
||||
switch_ivr_dmachine_t *arg1 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_ivr_dmachine_callback_t arg2 = (switch_ivr_dmachine_callback_t) 0 ;
|
||||
|
||||
arg1 = (switch_ivr_dmachine_t *)jarg1;
|
||||
arg2 = (switch_ivr_dmachine_callback_t)jarg2;
|
||||
switch_ivr_dmachine_set_nonmatch_callback(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_dmachine_create(void * jarg1, char * jarg2, void * jarg3, unsigned long jarg4, unsigned long jarg5, void * jarg6, void * jarg7, void * jarg8) {
|
||||
int jresult ;
|
||||
switch_ivr_dmachine_t **arg1 = (switch_ivr_dmachine_t **) 0 ;
|
||||
|
@ -31234,6 +31406,71 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_state_change(void
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_state_run_state_run_set(void * jarg1, void * jarg2) {
|
||||
switch_io_event_hook_state_run *arg1 = (switch_io_event_hook_state_run *) 0 ;
|
||||
switch_state_run_hook_t arg2 = (switch_state_run_hook_t) 0 ;
|
||||
|
||||
arg1 = (switch_io_event_hook_state_run *)jarg1;
|
||||
arg2 = (switch_state_run_hook_t)jarg2;
|
||||
if (arg1) (arg1)->state_run = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hook_state_run_state_run_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_io_event_hook_state_run *arg1 = (switch_io_event_hook_state_run *) 0 ;
|
||||
switch_state_run_hook_t result;
|
||||
|
||||
arg1 = (switch_io_event_hook_state_run *)jarg1;
|
||||
result = (switch_state_run_hook_t) ((arg1)->state_run);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_state_run_next_set(void * jarg1, void * jarg2) {
|
||||
switch_io_event_hook_state_run *arg1 = (switch_io_event_hook_state_run *) 0 ;
|
||||
switch_io_event_hook_state_run *arg2 = (switch_io_event_hook_state_run *) 0 ;
|
||||
|
||||
arg1 = (switch_io_event_hook_state_run *)jarg1;
|
||||
arg2 = (switch_io_event_hook_state_run *)jarg2;
|
||||
if (arg1) (arg1)->next = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hook_state_run_next_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_io_event_hook_state_run *arg1 = (switch_io_event_hook_state_run *) 0 ;
|
||||
switch_io_event_hook_state_run *result = 0 ;
|
||||
|
||||
arg1 = (switch_io_event_hook_state_run *)jarg1;
|
||||
result = (switch_io_event_hook_state_run *) ((arg1)->next);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_io_event_hook_state_run() {
|
||||
void * jresult ;
|
||||
switch_io_event_hook_state_run *result = 0 ;
|
||||
|
||||
result = (switch_io_event_hook_state_run *)new switch_io_event_hook_state_run();
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_io_event_hook_state_run(void * jarg1) {
|
||||
switch_io_event_hook_state_run *arg1 = (switch_io_event_hook_state_run *) 0 ;
|
||||
|
||||
arg1 = (switch_io_event_hook_state_run *)jarg1;
|
||||
delete arg1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hook_resurrect_session_resurrect_session_set(void * jarg1, void * jarg2) {
|
||||
switch_io_event_hook_resurrect_session *arg1 = (switch_io_event_hook_resurrect_session *) 0 ;
|
||||
switch_resurrect_session_hook_t arg2 = (switch_resurrect_session_hook_t) 0 ;
|
||||
|
@ -31552,6 +31789,29 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hooks_state_change_get(void
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_state_run_set(void * jarg1, void * jarg2) {
|
||||
switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ;
|
||||
switch_io_event_hook_state_run_t *arg2 = (switch_io_event_hook_state_run_t *) 0 ;
|
||||
|
||||
arg1 = (switch_io_event_hooks *)jarg1;
|
||||
arg2 = (switch_io_event_hook_state_run_t *)jarg2;
|
||||
if (arg1) (arg1)->state_run = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_io_event_hooks_state_run_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ;
|
||||
switch_io_event_hook_state_run_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_io_event_hooks *)jarg1;
|
||||
result = (switch_io_event_hook_state_run_t *) ((arg1)->state_run);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_io_event_hooks_resurrect_session_set(void * jarg1, void * jarg2) {
|
||||
switch_io_event_hooks *arg1 = (switch_io_event_hooks *) 0 ;
|
||||
switch_io_event_hook_resurrect_session_t *arg2 = (switch_io_event_hook_resurrect_session_t *) 0 ;
|
||||
|
@ -31650,6 +31910,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_add_state_change(void *
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_add_state_run(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_state_run_hook_t arg2 = (switch_state_run_hook_t) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
arg2 = (switch_state_run_hook_t)jarg2;
|
||||
result = (switch_status_t)switch_core_event_hook_add_state_run(arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_add_read_frame(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
|
@ -31818,6 +32092,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_state_change(voi
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_state_run(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_state_run_hook_t arg2 = (switch_state_run_hook_t) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
arg2 = (switch_state_run_hook_t)jarg2;
|
||||
result = (switch_status_t)switch_core_event_hook_remove_state_run(arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_event_hook_remove_read_frame(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2643,6 +2643,12 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static switch_bool_t switch_testv6_subnet(ip_t _ip, ip_t _net, ip_t _mask) {
|
||||
switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_testv6_subnet(ip_t.getCPtr(_ip), ip_t.getCPtr(_net), ip_t.getCPtr(_mask));
|
||||
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int _zstr(string s) {
|
||||
int ret = freeswitchPINVOKE._zstr(s);
|
||||
return ret;
|
||||
|
@ -2949,8 +2955,8 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static int switch_parse_cidr(string arg0, SWIGTYPE_p_unsigned_long ip, SWIGTYPE_p_unsigned_long mask, SWIGTYPE_p_unsigned_long bitp) {
|
||||
int ret = freeswitchPINVOKE.switch_parse_cidr(arg0, SWIGTYPE_p_unsigned_long.getCPtr(ip), SWIGTYPE_p_unsigned_long.getCPtr(mask), SWIGTYPE_p_unsigned_long.getCPtr(bitp));
|
||||
public static int switch_parse_cidr(string arg0, ip_t ip, ip_t mask, SWIGTYPE_p_unsigned_long bitp) {
|
||||
int ret = freeswitchPINVOKE.switch_parse_cidr(arg0, ip_t.getCPtr(ip), ip_t.getCPtr(mask), SWIGTYPE_p_unsigned_long.getCPtr(bitp));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2974,6 +2980,12 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static switch_bool_t switch_network_list_validate_ip6_token(SWIGTYPE_p_switch_network_list list, ip_t ip, ref string token) {
|
||||
switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_network_list_validate_ip6_token(SWIGTYPE_p_switch_network_list.getCPtr(list), ip_t.getCPtr(ip), ref token);
|
||||
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string switch_dow_int2str(int val) {
|
||||
string ret = freeswitchPINVOKE.switch_dow_int2str(val);
|
||||
return ret;
|
||||
|
@ -2984,8 +2996,8 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static int switch_dow_cmp(string exp, int val) {
|
||||
int ret = freeswitchPINVOKE.switch_dow_cmp(exp, val);
|
||||
public static switch_bool_t switch_dow_cmp(string exp, int val) {
|
||||
switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_dow_cmp(exp, val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -4374,8 +4386,8 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_process_import(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_channel peer_channel, string varname) {
|
||||
freeswitchPINVOKE.switch_process_import(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_channel.getCPtr(peer_channel), varname);
|
||||
public static void switch_process_import(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_channel peer_channel, string varname, string prefix) {
|
||||
freeswitchPINVOKE.switch_process_import(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_channel.getCPtr(peer_channel), varname, prefix);
|
||||
}
|
||||
|
||||
public static switch_bool_t switch_ivr_uuid_exists(string uuid) {
|
||||
|
@ -4383,6 +4395,14 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_ivr_dmachine_set_match_callback(SWIGTYPE_p_switch_ivr_dmachine dmachine, SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t match_callback) {
|
||||
freeswitchPINVOKE.switch_ivr_dmachine_set_match_callback(SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine), SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t.getCPtr(match_callback));
|
||||
}
|
||||
|
||||
public static void switch_ivr_dmachine_set_nonmatch_callback(SWIGTYPE_p_switch_ivr_dmachine dmachine, SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t nonmatch_callback) {
|
||||
freeswitchPINVOKE.switch_ivr_dmachine_set_nonmatch_callback(SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine), SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t.getCPtr(nonmatch_callback));
|
||||
}
|
||||
|
||||
public static switch_status_t switch_ivr_dmachine_create(SWIGTYPE_p_p_switch_ivr_dmachine dmachine_p, string name, SWIGTYPE_p_apr_pool_t pool, uint digit_timeout, uint input_timeout, SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t match_callback, SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t nonmatch_callback, SWIGTYPE_p_void user_data) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_dmachine_create(SWIGTYPE_p_p_switch_ivr_dmachine.getCPtr(dmachine_p), name, SWIGTYPE_p_apr_pool_t.getCPtr(pool), digit_timeout, input_timeout, SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t.getCPtr(match_callback), SWIGTYPE_p_f_p_switch_ivr_dmachine_match__switch_status_t.getCPtr(nonmatch_callback), SWIGTYPE_p_void.getCPtr(user_data));
|
||||
return ret;
|
||||
|
@ -5038,6 +5058,11 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_event_hook_add_state_run(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_switch_core_session__switch_status_t state_run) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_add_state_run(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_core_session__switch_status_t.getCPtr(state_run));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_event_hook_add_read_frame(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_switch_core_session_p_p_switch_frame_unsigned_long_int__switch_status_t read_frame) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_add_read_frame(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_core_session_p_p_switch_frame_unsigned_long_int__switch_status_t.getCPtr(read_frame));
|
||||
return ret;
|
||||
|
@ -5098,6 +5123,11 @@ public class freeswitch {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_event_hook_remove_state_run(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_switch_core_session__switch_status_t state_run) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_remove_state_run(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_core_session__switch_status_t.getCPtr(state_run));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_event_hook_remove_read_frame(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_f_p_switch_core_session_p_p_switch_frame_unsigned_long_int__switch_status_t read_frame) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_event_hook_remove_read_frame(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_core_session_p_p_switch_frame_unsigned_long_int__switch_status_t.getCPtr(read_frame));
|
||||
return ret;
|
||||
|
@ -8412,6 +8442,27 @@ class freeswitchPINVOKE {
|
|||
[DllImport("mod_managed", EntryPoint="CSharp_switch_isxdigit")]
|
||||
public static extern int switch_isxdigit(int jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_ip_t_v4_set")]
|
||||
public static extern void ip_t_v4_set(HandleRef jarg1, uint jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_ip_t_v4_get")]
|
||||
public static extern uint ip_t_v4_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_ip_t_v6_set")]
|
||||
public static extern void ip_t_v6_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_ip_t_v6_get")]
|
||||
public static extern IntPtr ip_t_v6_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_new_ip_t")]
|
||||
public static extern IntPtr new_ip_t();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_delete_ip_t")]
|
||||
public static extern void delete_ip_t(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_testv6_subnet")]
|
||||
public static extern int switch_testv6_subnet(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_SMAX_get")]
|
||||
public static extern int SWITCH_SMAX_get();
|
||||
|
||||
|
@ -8610,6 +8661,9 @@ class freeswitchPINVOKE {
|
|||
[DllImport("mod_managed", EntryPoint="CSharp_switch_network_list_validate_ip_token")]
|
||||
public static extern int switch_network_list_validate_ip_token(HandleRef jarg1, uint jarg2, ref string jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_network_list_validate_ip6_token")]
|
||||
public static extern int switch_network_list_validate_ip6_token(HandleRef jarg1, HandleRef jarg2, ref string jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_dow_int2str")]
|
||||
public static extern string switch_dow_int2str(int jarg1);
|
||||
|
||||
|
@ -9264,6 +9318,12 @@ class freeswitchPINVOKE {
|
|||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_write_video_frame_get")]
|
||||
public static extern IntPtr switch_io_routines_write_video_frame_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_state_run_set")]
|
||||
public static extern void switch_io_routines_state_run_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_state_run_get")]
|
||||
public static extern IntPtr switch_io_routines_state_run_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_routines_resurrect_session_set")]
|
||||
public static extern void switch_io_routines_resurrect_session_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
|
@ -12121,11 +12181,17 @@ class freeswitchPINVOKE {
|
|||
public static extern int switch_ivr_sound_test(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_process_import")]
|
||||
public static extern void switch_process_import(HandleRef jarg1, HandleRef jarg2, string jarg3);
|
||||
public static extern void switch_process_import(HandleRef jarg1, HandleRef jarg2, string jarg3, string jarg4);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_uuid_exists")]
|
||||
public static extern int switch_ivr_uuid_exists(string jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_set_match_callback")]
|
||||
public static extern void switch_ivr_dmachine_set_match_callback(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_set_nonmatch_callback")]
|
||||
public static extern void switch_ivr_dmachine_set_nonmatch_callback(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_create")]
|
||||
public static extern int switch_ivr_dmachine_create(HandleRef jarg1, string jarg2, HandleRef jarg3, uint jarg4, uint jarg5, HandleRef jarg6, HandleRef jarg7, HandleRef jarg8);
|
||||
|
||||
|
@ -12897,6 +12963,24 @@ class freeswitchPINVOKE {
|
|||
[DllImport("mod_managed", EntryPoint="CSharp_delete_switch_io_event_hook_state_change")]
|
||||
public static extern void delete_switch_io_event_hook_state_change(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_state_run_state_run_set")]
|
||||
public static extern void switch_io_event_hook_state_run_state_run_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_state_run_state_run_get")]
|
||||
public static extern IntPtr switch_io_event_hook_state_run_state_run_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_state_run_next_set")]
|
||||
public static extern void switch_io_event_hook_state_run_next_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_state_run_next_get")]
|
||||
public static extern IntPtr switch_io_event_hook_state_run_next_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_new_switch_io_event_hook_state_run")]
|
||||
public static extern IntPtr new_switch_io_event_hook_state_run();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_delete_switch_io_event_hook_state_run")]
|
||||
public static extern void delete_switch_io_event_hook_state_run(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hook_resurrect_session_resurrect_session_set")]
|
||||
public static extern void switch_io_event_hook_resurrect_session_resurrect_session_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
|
@ -12981,6 +13065,12 @@ class freeswitchPINVOKE {
|
|||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_state_change_get")]
|
||||
public static extern IntPtr switch_io_event_hooks_state_change_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_state_run_set")]
|
||||
public static extern void switch_io_event_hooks_state_run_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_state_run_get")]
|
||||
public static extern IntPtr switch_io_event_hooks_state_run_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_io_event_hooks_resurrect_session_set")]
|
||||
public static extern void switch_io_event_hooks_resurrect_session_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
|
@ -13005,6 +13095,9 @@ class freeswitchPINVOKE {
|
|||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_add_state_change")]
|
||||
public static extern int switch_core_event_hook_add_state_change(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_add_state_run")]
|
||||
public static extern int switch_core_event_hook_add_state_run(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_add_read_frame")]
|
||||
public static extern int switch_core_event_hook_add_read_frame(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
|
@ -13041,6 +13134,9 @@ class freeswitchPINVOKE {
|
|||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_state_change")]
|
||||
public static extern int switch_core_event_hook_remove_state_change(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_state_run")]
|
||||
public static extern int switch_core_event_hook_remove_state_run(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_event_hook_remove_read_frame")]
|
||||
public static extern int switch_core_event_hook_remove_read_frame(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
|
@ -13725,6 +13821,75 @@ namespace FreeSWITCH.Native {
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class ip_t : IDisposable {
|
||||
private HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal ip_t(IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(ip_t obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
~ip_t() {
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public virtual void Dispose() {
|
||||
lock(this) {
|
||||
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
freeswitchPINVOKE.delete_ip_t(swigCPtr);
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public uint v4 {
|
||||
set {
|
||||
freeswitchPINVOKE.ip_t_v4_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
uint ret = freeswitchPINVOKE.ip_t_v4_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_in6_addr v6 {
|
||||
set {
|
||||
freeswitchPINVOKE.ip_t_v6_set(swigCPtr, SWIGTYPE_p_in6_addr.getCPtr(value));
|
||||
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
get {
|
||||
SWIGTYPE_p_in6_addr ret = new SWIGTYPE_p_in6_addr(freeswitchPINVOKE.ip_t_v6_get(swigCPtr), true);
|
||||
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public ip_t() : this(freeswitchPINVOKE.new_ip_t(), true) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class IvrMenu : IDisposable {
|
||||
private HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
@ -16338,6 +16503,36 @@ namespace FreeSWITCH.Native {
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_in6_addr {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal SWIGTYPE_p_in6_addr(IntPtr cPtr, bool futureUse) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
protected SWIGTYPE_p_in6_addr() {
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(SWIGTYPE_p_in6_addr obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_int {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
|
@ -21201,6 +21396,7 @@ public enum switch_channel_flag_t {
|
|||
CF_CONSUME_ON_ORIGINATE,
|
||||
CF_PASSTHRU_PTIME_MISMATCH,
|
||||
CF_BRIDGE_NOWRITE,
|
||||
CF_RECOVERED,
|
||||
CF_FLAG_MAX
|
||||
}
|
||||
|
||||
|
@ -24310,7 +24506,8 @@ namespace FreeSWITCH.Native {
|
|||
SWITCH_FILE_CALLBACK = (1 << 12),
|
||||
SWITCH_FILE_DONE = (1 << 13),
|
||||
SWITCH_FILE_BUFFER_DONE = (1 << 14),
|
||||
SWITCH_FILE_WRITE_APPEND = (1 << 15)
|
||||
SWITCH_FILE_WRITE_APPEND = (1 << 15),
|
||||
SWITCH_FILE_WRITE_OVER = (1 << 16)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25990,6 +26187,17 @@ public class switch_io_event_hooks : IDisposable {
|
|||
}
|
||||
}
|
||||
|
||||
public switch_io_event_hook_state_run state_run {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_io_event_hooks_state_run_set(swigCPtr, switch_io_event_hook_state_run.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_state_run_get(swigCPtr);
|
||||
switch_io_event_hook_state_run ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_state_run(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_io_event_hook_resurrect_session resurrect_session {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_set(swigCPtr, switch_io_event_hook_resurrect_session.getCPtr(value));
|
||||
|
@ -26158,6 +26366,75 @@ namespace FreeSWITCH.Native {
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class switch_io_event_hook_state_run : IDisposable {
|
||||
private HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal switch_io_event_hook_state_run(IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(switch_io_event_hook_state_run obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
~switch_io_event_hook_state_run() {
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public virtual void Dispose() {
|
||||
lock(this) {
|
||||
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
freeswitchPINVOKE.delete_switch_io_event_hook_state_run(swigCPtr);
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_f_p_switch_core_session__switch_status_t state_run {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_io_event_hook_state_run_state_run_set(swigCPtr, SWIGTYPE_p_f_p_switch_core_session__switch_status_t.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_state_run_state_run_get(swigCPtr);
|
||||
SWIGTYPE_p_f_p_switch_core_session__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_core_session__switch_status_t(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_io_event_hook_state_run next {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_io_event_hook_state_run_next_set(swigCPtr, switch_io_event_hook_state_run.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_state_run_next_get(swigCPtr);
|
||||
switch_io_event_hook_state_run ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_state_run(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_io_event_hook_state_run() : this(freeswitchPINVOKE.new_switch_io_event_hook_state_run(), true) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class switch_io_event_hook_video_read_frame : IDisposable {
|
||||
private HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
@ -26545,6 +26822,17 @@ public class switch_io_routines : IDisposable {
|
|||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_f_p_switch_core_session__switch_status_t state_run {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_io_routines_state_run_set(swigCPtr, SWIGTYPE_p_f_p_switch_core_session__switch_status_t.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_io_routines_state_run_get(swigCPtr);
|
||||
SWIGTYPE_p_f_p_switch_core_session__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_core_session__switch_status_t(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t resurrect_session {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_io_routines_resurrect_session_set(swigCPtr, SWIGTYPE_p_f_p_p_switch_core_session_p_p_apr_pool_t_p_void__switch_call_cause_t.getCPtr(value));
|
||||
|
@ -27578,7 +27866,8 @@ namespace FreeSWITCH.Native {
|
|||
SMBF_STEREO = (1 << 5),
|
||||
SMBF_ANSWER_REQ = (1 << 6),
|
||||
SMBF_THREAD_LOCK = (1 << 7),
|
||||
SMBF_PRUNE = (1 << 8)
|
||||
SMBF_PRUNE = (1 << 8),
|
||||
SMBF_NO_PAUSE = (1 << 9)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27899,7 +28188,10 @@ public enum switch_rtp_bug_flag_t {
|
|||
RTP_BUG_NONE = 0,
|
||||
RTP_BUG_CISCO_SKIP_MARK_BIT_2833 = (1 << 0),
|
||||
RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833 = (1 << 1),
|
||||
RTP_BUG_IGNORE_MARK_BIT = (1 << 2)
|
||||
RTP_BUG_IGNORE_MARK_BIT = (1 << 2),
|
||||
RTP_BUG_SEND_LINEAR_TIMESTAMPS = (1 << 3),
|
||||
RTP_BUG_START_SEQ_AT_ZERO = (1 << 4),
|
||||
RTP_BUG_NEVER_SEND_MARKER = (1 << 5)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29660,6 +29952,7 @@ public enum switch_status_t {
|
|||
SWITCH_STATUS_IGNORE,
|
||||
SWITCH_STATUS_TOO_SMALL,
|
||||
SWITCH_STATUS_FOUND,
|
||||
SWITCH_STATUS_CONTINUE,
|
||||
SWITCH_STATUS_NOT_INITALIZED
|
||||
}
|
||||
|
||||
|
|
|
@ -9732,17 +9732,17 @@ XS(SWIG_init) {
|
|||
SWIG_TypeClientData(SWIGTYPE_p_IVRMenu, (void*) "freeswitch::IVRMenu");
|
||||
SWIG_TypeClientData(SWIGTYPE_p_API, (void*) "freeswitch::API");
|
||||
SWIG_TypeClientData(SWIGTYPE_p_input_callback_state, (void*) "freeswitch::input_callback_state_t");
|
||||
/*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
|
||||
/*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
|
||||
SV *sv = get_sv((char*) SWIG_prefix "S_HUP", TRUE | 0x2 | GV_ADDMULTI);
|
||||
sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_HUP)));
|
||||
SvREADONLY_on(sv);
|
||||
} while(0) /*@SWIG@*/;
|
||||
/*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
|
||||
/*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
|
||||
SV *sv = get_sv((char*) SWIG_prefix "S_FREE", TRUE | 0x2 | GV_ADDMULTI);
|
||||
sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_FREE)));
|
||||
SvREADONLY_on(sv);
|
||||
} while(0) /*@SWIG@*/;
|
||||
/*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
|
||||
/*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
|
||||
SV *sv = get_sv((char*) SWIG_prefix "S_RDLOCK", TRUE | 0x2 | GV_ADDMULTI);
|
||||
sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_RDLOCK)));
|
||||
SvREADONLY_on(sv);
|
||||
|
|
|
@ -901,16 +901,25 @@ static switch_ip_list_t IP_LIST = { 0 };
|
|||
SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token)
|
||||
{
|
||||
switch_network_list_t *list;
|
||||
uint32_t ip, net, mask, bits;
|
||||
ip_t ip, mask, net;
|
||||
uint32_t bits;
|
||||
char *ipv6 = strchr(ip_str,':');
|
||||
switch_bool_t ok = SWITCH_FALSE;
|
||||
|
||||
switch_mutex_lock(runtime.global_mutex);
|
||||
switch_inet_pton(AF_INET, ip_str, &ip);
|
||||
|
||||
ip = htonl(ip);
|
||||
if (ipv6) {
|
||||
switch_inet_pton(AF_INET6, ip_str, &ip);
|
||||
} else {
|
||||
switch_inet_pton(AF_INET, ip_str, &ip);
|
||||
ip.v4 = htonl(ip.v4);
|
||||
}
|
||||
|
||||
if ((list = switch_core_hash_find(IP_LIST.hash, list_name))) {
|
||||
ok = switch_network_list_validate_ip_token(list, ip, token);
|
||||
if (ipv6) {
|
||||
ok = switch_network_list_validate_ip6_token(list, ip, token);
|
||||
} else {
|
||||
ok = switch_network_list_validate_ip_token(list, ip.v4, token);
|
||||
}
|
||||
} else if (strchr(list_name, '/')) {
|
||||
if (strchr(list_name, ',')) {
|
||||
char *list_name_dup = strdup(list_name);
|
||||
|
@ -923,15 +932,21 @@ SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip_token(const char *ip_
|
|||
int i;
|
||||
for (i = 0; i < argc; i++) {
|
||||
switch_parse_cidr(argv[i], &net, &mask, &bits);
|
||||
if ((ok = switch_test_subnet(ip, net, mask))) {
|
||||
break;
|
||||
if (ipv6) {
|
||||
if ((ok = switch_testv6_subnet(ip, net, mask))){
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((ok = switch_test_subnet(ip.v4, net.v4, mask.v4))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(list_name_dup);
|
||||
} else {
|
||||
switch_parse_cidr(list_name, &net, &mask, &bits);
|
||||
ok = switch_test_subnet(ip, net, mask);
|
||||
ok = switch_test_subnet(ip.v4, net.v4, mask.v4);
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(runtime.global_mutex);
|
||||
|
|
|
@ -411,7 +411,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh,
|
|||
int ok = 1;
|
||||
|
||||
switch_assert(fh != NULL);
|
||||
switch_assert(fh->file_interface != NULL);
|
||||
|
||||
if (!switch_test_flag(fh, SWITCH_FILE_OPEN) || !fh->file_interface->file_seek) {
|
||||
ok = 0;
|
||||
|
|
276
src/switch_ivr.c
276
src/switch_ivr.c
|
@ -658,12 +658,38 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_next_event(switch_core_session_
|
|||
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_session_t *session)
|
||||
{
|
||||
switch_core_session_message_t *message;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
int i = 0;
|
||||
|
||||
while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
|
||||
i++;
|
||||
switch_core_session_receive_message(session, message);
|
||||
|
||||
switch(message->message_id) {
|
||||
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
||||
if (switch_channel_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
switch_core_session_free_message(&message);
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_PROGRESS:
|
||||
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
switch_core_session_free_message(&message);
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_RINGING:
|
||||
if (switch_channel_ring_ready(channel) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
switch_core_session_free_message(&message);
|
||||
break;
|
||||
default:
|
||||
switch_core_session_receive_message(session, message);
|
||||
break;
|
||||
}
|
||||
|
||||
message = NULL;
|
||||
|
||||
}
|
||||
|
||||
return i ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
||||
|
@ -702,7 +728,40 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
|
|||
time_t expires = 0;
|
||||
switch_codec_implementation_t read_impl = { 0 };
|
||||
switch_call_cause_t timeout_cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
switch_codec_t codec = { 0 };
|
||||
int sval = 0;
|
||||
const char *var;
|
||||
switch_frame_t write_frame = { 0 };
|
||||
unsigned char *abuf = NULL;
|
||||
switch_codec_implementation_t imp = { 0 };
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
|
||||
switch_core_session_get_read_impl(session, &imp);
|
||||
|
||||
if (switch_core_codec_init(&codec,
|
||||
"L16",
|
||||
NULL,
|
||||
imp.samples_per_second,
|
||||
imp.microseconds_per_packet / 1000,
|
||||
imp.number_of_channels,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
|
||||
imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Codec Activated L16@%uhz %u channels %dms\n",
|
||||
imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
|
||||
|
||||
write_frame.codec = &codec;
|
||||
switch_zmalloc(abuf, SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
write_frame.data = abuf;
|
||||
write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
|
||||
write_frame.datalen = imp.decoded_bytes_per_packet;
|
||||
write_frame.samples = write_frame.datalen / sizeof(int16_t);
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_CONTROLLED)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot park channels that are under control already.\n");
|
||||
|
@ -746,7 +805,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
|
|||
}
|
||||
|
||||
if (rate) {
|
||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);
|
||||
if (switch_channel_test_flag(channel, CF_SERVICE)) {
|
||||
switch_cond_next();
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);
|
||||
}
|
||||
} else {
|
||||
switch_yield(20000);
|
||||
|
||||
|
@ -760,111 +824,141 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
|
|||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
} else {
|
||||
if (expires && switch_epoch_time_now(NULL) >= expires) {
|
||||
switch_channel_hangup(channel, timeout_cause);
|
||||
break;
|
||||
}
|
||||
|
||||
if (write_frame.data) {
|
||||
switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, sval);
|
||||
switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
}
|
||||
|
||||
if (expires && switch_epoch_time_now(NULL) >= expires) {
|
||||
switch_channel_hangup(channel, timeout_cause);
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_UNICAST)) {
|
||||
if (!switch_channel_media_ready(channel)) {
|
||||
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_UNICAST)) {
|
||||
if (!switch_channel_media_ready(channel)) {
|
||||
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conninfo) {
|
||||
if (!(conninfo = switch_channel_get_private(channel, "unicast"))) {
|
||||
switch_channel_clear_flag(channel, CF_UNICAST);
|
||||
}
|
||||
|
||||
if (conninfo) {
|
||||
unicast_thread_launch(conninfo);
|
||||
}
|
||||
if (!conninfo) {
|
||||
if (!(conninfo = switch_channel_get_private(channel, "unicast"))) {
|
||||
switch_channel_clear_flag(channel, CF_UNICAST);
|
||||
}
|
||||
|
||||
if (conninfo) {
|
||||
switch_size_t len = 0;
|
||||
uint32_t flags = 0;
|
||||
switch_byte_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
uint32_t dlen = sizeof(decoded);
|
||||
switch_status_t tstatus;
|
||||
switch_byte_t *sendbuf = NULL;
|
||||
uint32_t sendlen = 0;
|
||||
|
||||
switch_assert(read_frame);
|
||||
|
||||
if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||
sendlen = bpf;
|
||||
switch_assert(sendlen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
memset(decoded, 255, sendlen);
|
||||
sendbuf = decoded;
|
||||
tstatus = SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
if (switch_test_flag(conninfo, SUF_NATIVE)) {
|
||||
tstatus = SWITCH_STATUS_NOOP;
|
||||
} else {
|
||||
switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
|
||||
tstatus = switch_core_codec_decode(read_codec,
|
||||
&conninfo->read_codec,
|
||||
read_frame->data,
|
||||
read_frame->datalen, read_impl.actual_samples_per_second, decoded, &dlen, &rate, &flags);
|
||||
}
|
||||
switch (tstatus) {
|
||||
case SWITCH_STATUS_NOOP:
|
||||
case SWITCH_STATUS_BREAK:
|
||||
sendbuf = read_frame->data;
|
||||
sendlen = read_frame->datalen;
|
||||
tstatus = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
sendbuf = decoded;
|
||||
sendlen = dlen;
|
||||
tstatus = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Codec Error\n");
|
||||
switch_ivr_deactivate_unicast(session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tstatus == SWITCH_STATUS_SUCCESS) {
|
||||
len = sendlen;
|
||||
if (switch_socket_sendto(conninfo->socket, conninfo->remote_addr, 0, (void *) sendbuf, &len) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_ivr_deactivate_unicast(session);
|
||||
}
|
||||
}
|
||||
unicast_thread_launch(conninfo);
|
||||
}
|
||||
}
|
||||
|
||||
switch_ivr_parse_all_events(session);
|
||||
if (conninfo) {
|
||||
switch_size_t len = 0;
|
||||
uint32_t flags = 0;
|
||||
switch_byte_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
uint32_t dlen = sizeof(decoded);
|
||||
switch_status_t tstatus;
|
||||
switch_byte_t *sendbuf = NULL;
|
||||
uint32_t sendlen = 0;
|
||||
|
||||
switch_assert(read_frame);
|
||||
|
||||
if (switch_channel_has_dtmf(channel)) {
|
||||
switch_dtmf_t dtmf = { 0 };
|
||||
switch_channel_dequeue_dtmf(channel, &dtmf);
|
||||
if (args && args->input_callback) {
|
||||
if ((status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
|
||||
if (args && args->input_callback) {
|
||||
if ((status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||
sendlen = bpf;
|
||||
switch_assert(sendlen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
memset(decoded, 255, sendlen);
|
||||
sendbuf = decoded;
|
||||
tstatus = SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
if (switch_test_flag(conninfo, SUF_NATIVE)) {
|
||||
tstatus = SWITCH_STATUS_NOOP;
|
||||
} else {
|
||||
switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
|
||||
tstatus = switch_core_codec_decode(read_codec,
|
||||
&conninfo->read_codec,
|
||||
read_frame->data,
|
||||
read_frame->datalen, read_impl.actual_samples_per_second, decoded, &dlen, &rate, &flags);
|
||||
}
|
||||
switch (tstatus) {
|
||||
case SWITCH_STATUS_NOOP:
|
||||
case SWITCH_STATUS_BREAK:
|
||||
sendbuf = read_frame->data;
|
||||
sendlen = read_frame->datalen;
|
||||
tstatus = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
sendbuf = decoded;
|
||||
sendlen = dlen;
|
||||
tstatus = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Codec Error\n");
|
||||
switch_ivr_deactivate_unicast(session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tstatus == SWITCH_STATUS_SUCCESS) {
|
||||
len = sendlen;
|
||||
if (switch_socket_sendto(conninfo->socket, conninfo->remote_addr, 0, (void *) sendbuf, &len) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_ivr_deactivate_unicast(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_ivr_parse_all_events(session);
|
||||
|
||||
|
||||
if (switch_channel_has_dtmf(channel)) {
|
||||
switch_dtmf_t dtmf = { 0 };
|
||||
|
||||
if (!args->input_callback && !args->buf && !args->dmachine) {
|
||||
status = SWITCH_STATUS_BREAK;
|
||||
break;
|
||||
}
|
||||
|
||||
switch_channel_dequeue_dtmf(channel, &dtmf);
|
||||
|
||||
if (args->dmachine) {
|
||||
char ds[2] = {dtmf.digit, '\0'};
|
||||
if ((status = switch_ivr_dmachine_feed(args->dmachine, ds, NULL)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
} else if (args && args->input_callback) {
|
||||
if ((status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
|
||||
if (args && args->input_callback) {
|
||||
if ((status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
|
||||
if (args && args->dmachine) {
|
||||
if ((status = switch_ivr_dmachine_ping(args->dmachine, NULL)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (write_frame.codec) {
|
||||
switch_core_codec_destroy(&codec);
|
||||
}
|
||||
|
||||
switch_safe_free(abuf);
|
||||
|
||||
switch_channel_clear_flag(channel, CF_CONTROLLED);
|
||||
switch_channel_clear_flag(channel, CF_PARK);
|
||||
|
||||
|
@ -2190,7 +2284,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
|
|||
|
||||
qlen = delay_ms / (interval);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen);
|
||||
jb = stfu_n_init(qlen);
|
||||
jb = stfu_n_init(qlen, 0);
|
||||
|
||||
write_frame.codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
|
|
|
@ -1391,6 +1391,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
|
|||
data++;
|
||||
}
|
||||
|
||||
if (session) {
|
||||
switch_caller_profile_t *cpp = NULL;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
if ((cpp = switch_channel_get_caller_profile(channel))) {
|
||||
cp = switch_caller_profile_dup(pool, cpp);
|
||||
}
|
||||
}
|
||||
|
||||
if (ovars) {
|
||||
var_event = ovars;
|
||||
} else {
|
||||
|
@ -1436,14 +1444,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
|
|||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
|
||||
if (session) {
|
||||
switch_caller_profile_t *cpp = NULL;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
if ((cpp = switch_channel_get_caller_profile(channel))) {
|
||||
cp = switch_caller_profile_dup(pool, cpp);
|
||||
}
|
||||
}
|
||||
|
||||
switch_threadattr_create(&thd_attr, pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
|
||||
|
|
|
@ -772,6 +772,11 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip)
|
|||
SWITCH_DECLARE(void) switch_rtp_intentional_bugs(switch_rtp_t *rtp_session, switch_rtp_bug_flag_t bugs)
|
||||
{
|
||||
rtp_session->rtp_bugs = bugs;
|
||||
|
||||
if ((rtp_session->rtp_bugs & RTP_BUG_START_SEQ_AT_ZERO)) {
|
||||
rtp_session->seq = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1616,7 +1621,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_stun_ping(switch_rtp_t *rtp_
|
|||
SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, uint32_t queue_frames)
|
||||
{
|
||||
|
||||
rtp_session->jb = stfu_n_init(queue_frames);
|
||||
rtp_session->jb = stfu_n_init(queue_frames, 0);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -3179,10 +3184,15 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
|||
send_msg = &rtp_session->send_msg;
|
||||
send_msg->header.pt = payload;
|
||||
|
||||
if (timestamp) {
|
||||
if (rtp_session->rtp_bugs & RTP_BUG_SEND_LINEAR_TIMESTAMPS) {
|
||||
rtp_session->ts += rtp_session->samples_per_interval;
|
||||
if (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->ts > 0) {
|
||||
rtp_session->ts = rtp_session->last_write_ts + rtp_session->samples_per_interval;
|
||||
}
|
||||
} else if (timestamp) {
|
||||
rtp_session->ts = (uint32_t) timestamp;
|
||||
/* Send marker bit if timestamp is lower/same as before (resetted/new timer) */
|
||||
if (rtp_session->ts <= rtp_session->last_write_ts) {
|
||||
if (rtp_session->ts <= rtp_session->last_write_ts && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) {
|
||||
m++;
|
||||
}
|
||||
} else if (rtp_session->timer.timer_interface) {
|
||||
|
@ -3217,7 +3227,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
|||
m++;
|
||||
}
|
||||
|
||||
send_msg->header.m = m ? 1 : 0;
|
||||
send_msg->header.m = (m && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) ? 1 : 0;
|
||||
|
||||
memcpy(send_msg->body, data, datalen);
|
||||
bytes = datalen + rtp_header_len;
|
||||
|
@ -3287,7 +3297,9 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
|||
if (diff >= rtp_session->vad_data.diff_level || ++rtp_session->vad_data.hangunder_hits >= rtp_session->vad_data.hangunder) {
|
||||
|
||||
switch_set_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING);
|
||||
send_msg->header.m = 1;
|
||||
if (!(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) {
|
||||
send_msg->header.m = 1;
|
||||
}
|
||||
rtp_session->vad_data.hangover_hits = rtp_session->vad_data.hangunder_hits = rtp_session->vad_data.cng_count = 0;
|
||||
if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_EVENTS_TALK)) {
|
||||
switch_event_t *event;
|
||||
|
@ -3755,7 +3767,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
|
|||
rtp_session->write_msg.header.seq = htons(++rtp_session->seq);
|
||||
rtp_session->write_msg.header.ts = htonl(ts);
|
||||
rtp_session->write_msg.header.pt = payload;
|
||||
rtp_session->write_msg.header.m = m ? 1 : 0;
|
||||
rtp_session->write_msg.header.m = (m && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) ? 1 : 0;
|
||||
memcpy(rtp_session->write_msg.body, data, datalen);
|
||||
|
||||
bytes = rtp_header_len + datalen;
|
||||
|
|
|
@ -39,9 +39,10 @@
|
|||
#define ESCAPE_META '\\'
|
||||
|
||||
struct switch_network_node {
|
||||
uint32_t ip;
|
||||
uint32_t mask;
|
||||
ip_t ip;
|
||||
ip_t mask;
|
||||
uint32_t bits;
|
||||
int family;
|
||||
switch_bool_t ok;
|
||||
char *token;
|
||||
char *str;
|
||||
|
@ -140,6 +141,50 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_create(switch_network_list_t
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define IN6_AND_MASK(result, ip, mask) \
|
||||
((uint32_t *) (result))[0] =((const uint32_t *) (ip))[0] & ((const uint32_t *)(mask))[0]; \
|
||||
((uint32_t *) (result))[1] =((const uint32_t *) (ip))[1] & ((const uint32_t *)(mask))[1]; \
|
||||
((uint32_t *) (result))[2] =((const uint32_t *) (ip))[2] & ((const uint32_t *)(mask))[2]; \
|
||||
((uint32_t *) (result))[3] =((const uint32_t *) (ip))[3] & ((const uint32_t *)(mask))[3];
|
||||
SWITCH_DECLARE(switch_bool_t) switch_testv6_subnet(ip_t _ip, ip_t _net, ip_t _mask) {
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&_mask.v6)) {
|
||||
struct in6_addr a, b;
|
||||
IN6_AND_MASK(&a, &_net, &_mask);
|
||||
IN6_AND_MASK(&b, &_ip, &_mask);
|
||||
return !memcmp(&a,&b, sizeof(struct in6_addr));
|
||||
} else {
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&_net.v6)) {
|
||||
return !memcmp(&_net,&_ip,sizeof(struct in6_addr));
|
||||
}
|
||||
else return SWITCH_TRUE;
|
||||
}
|
||||
}
|
||||
SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip6_token(switch_network_list_t *list, ip_t ip, const char **token)
|
||||
{
|
||||
switch_network_node_t *node;
|
||||
switch_bool_t ok = list->default_type;
|
||||
uint32_t bits = 0;
|
||||
|
||||
for (node = list->node_head; node; node = node->next) {
|
||||
if (node->family == AF_INET) continue;
|
||||
if (node->bits > bits && switch_testv6_subnet(ip, node->ip, node->mask)) {
|
||||
if (node->ok) {
|
||||
ok = SWITCH_TRUE;
|
||||
} else {
|
||||
ok = SWITCH_FALSE;
|
||||
}
|
||||
|
||||
bits = node->bits;
|
||||
|
||||
if (token) {
|
||||
*token = node->token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip_token(switch_network_list_t *list, uint32_t ip, const char **token)
|
||||
{
|
||||
switch_network_node_t *node;
|
||||
|
@ -147,7 +192,8 @@ SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip_token(switch_netwo
|
|||
uint32_t bits = 0;
|
||||
|
||||
for (node = list->node_head; node; node = node->next) {
|
||||
if (node->bits > bits && switch_test_subnet(ip, node->ip, node->mask)) {
|
||||
if (node->family == AF_INET6) continue; /* want AF_INET */
|
||||
if (node->bits > bits && switch_test_subnet(ip, node->ip.v4, node->mask.v4)) {
|
||||
if (node->ok) {
|
||||
ok = SWITCH_TRUE;
|
||||
} else {
|
||||
|
@ -168,7 +214,8 @@ SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip_token(switch_netwo
|
|||
SWITCH_DECLARE(switch_status_t) switch_network_list_perform_add_cidr_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok,
|
||||
const char *token)
|
||||
{
|
||||
uint32_t ip, mask, bits;
|
||||
ip_t ip, mask;
|
||||
uint32_t bits;
|
||||
switch_network_node_t *node;
|
||||
|
||||
if (switch_parse_cidr(cidr_str, &ip, &mask, &bits)) {
|
||||
|
@ -185,6 +232,12 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_perform_add_cidr_token(switc
|
|||
node->bits = bits;
|
||||
node->str = switch_core_strdup(list->pool, cidr_str);
|
||||
|
||||
if (strchr(cidr_str,':')) {
|
||||
node->family = AF_INET6;
|
||||
} else {
|
||||
node->family = AF_INET;
|
||||
}
|
||||
|
||||
if (!zstr(token)) {
|
||||
node->token = switch_core_strdup(list->pool, token);
|
||||
}
|
||||
|
@ -227,7 +280,7 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_add_cidr_token(switch_networ
|
|||
|
||||
SWITCH_DECLARE(switch_status_t) switch_network_list_add_host_mask(switch_network_list_t *list, const char *host, const char *mask_str, switch_bool_t ok)
|
||||
{
|
||||
int ip, mask;
|
||||
ip_t ip, mask;
|
||||
switch_network_node_t *node;
|
||||
|
||||
switch_inet_pton(AF_INET, host, &ip);
|
||||
|
@ -235,14 +288,15 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_add_host_mask(switch_network
|
|||
|
||||
node = switch_core_alloc(list->pool, sizeof(*node));
|
||||
|
||||
node->ip = ntohl(ip);
|
||||
node->mask = ntohl(mask);
|
||||
node->ip.v4 = ntohl(ip.v4);
|
||||
node->mask.v4 = ntohl(mask.v4);
|
||||
node->ok = ok;
|
||||
|
||||
/* http://graphics.stanford.edu/~seander/bithacks.html */
|
||||
mask = mask - ((mask >> 1) & 0x55555555);
|
||||
mask = (mask & 0x33333333) + ((mask >> 2) & 0x33333333);
|
||||
node->bits = (((mask + (mask >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
|
||||
mask.v4 = mask.v4 - ((mask.v4 >> 1) & 0x55555555);
|
||||
mask.v4 = (mask.v4 & 0x33333333) + ((mask.v4 >> 2) & 0x33333333);
|
||||
node->bits = (((mask.v4 + (mask.v4 >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
|
||||
|
||||
node->str = switch_core_sprintf(list->pool, "%s:%s", host, mask_str);
|
||||
|
||||
node->next = list->node_head;
|
||||
|
@ -252,13 +306,16 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_add_host_mask(switch_network
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(int) switch_parse_cidr(const char *string, uint32_t *ip, uint32_t *mask, uint32_t *bitp)
|
||||
SWITCH_DECLARE(int) switch_parse_cidr(const char *string, ip_t *ip, ip_t *mask, uint32_t *bitp)
|
||||
{
|
||||
char host[128];
|
||||
char *bit_str;
|
||||
int32_t bits;
|
||||
const char *ipv6;
|
||||
ip_t *maskv = mask;
|
||||
ip_t *ipv = ip;
|
||||
|
||||
switch_copy_string(host, string, sizeof(host));
|
||||
memcpy(host, string, sizeof(host));
|
||||
bit_str = strchr(host, '/');
|
||||
|
||||
if (!bit_str) {
|
||||
|
@ -267,17 +324,36 @@ SWITCH_DECLARE(int) switch_parse_cidr(const char *string, uint32_t *ip, uint32_t
|
|||
|
||||
*bit_str++ = '\0';
|
||||
bits = atoi(bit_str);
|
||||
ipv6 = strchr(string, ':');
|
||||
if (ipv6) {
|
||||
int i,n;
|
||||
if (bits < 0 || bits > 128) {
|
||||
return -2;
|
||||
}
|
||||
bits = atoi(bit_str);
|
||||
switch_inet_pton(AF_INET6, host, (unsigned char *)ip);
|
||||
for (n=bits,i=0 ;i < 16; i++){
|
||||
if (n >= 8) {
|
||||
maskv->v6.s6_addr[i] = 0xFF;
|
||||
n -= 8;
|
||||
} else if (n < 8) {
|
||||
maskv->v6.s6_addr[i] = 0xFF & ~(0xFF >> n);
|
||||
n -= n;
|
||||
} else if (n == 0) {
|
||||
maskv->v6.s6_addr[i] = 0x00;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (bits < 0 || bits > 32) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (bits < 0 || bits > 32) {
|
||||
return -2;
|
||||
bits = atoi(bit_str);
|
||||
switch_inet_pton(AF_INET, host, (unsigned char *)ip);
|
||||
ipv->v4 = htonl(ipv->v4);
|
||||
|
||||
maskv->v4 = 0xFFFFFFFF & ~(0xFFFFFFFF >> bits);
|
||||
}
|
||||
|
||||
bits = atoi(bit_str);
|
||||
switch_inet_pton(AF_INET, host, ip);
|
||||
*ip = htonl(*ip);
|
||||
|
||||
*mask = 0xFFFFFFFF & ~(0xFFFFFFFF >> bits);
|
||||
|
||||
*bitp = bits;
|
||||
|
||||
return 0;
|
||||
|
@ -394,7 +470,7 @@ SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size
|
|||
if (++y != 72) {
|
||||
continue;
|
||||
}
|
||||
//out[bytes++] = '\n';
|
||||
/* out[bytes++] = '\n'; */
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
|
@ -963,7 +1039,7 @@ static int get_netmask(struct sockaddr_in *me, int *mask)
|
|||
if (ip.s_addr == me->sin_addr.s_addr) {
|
||||
ioctl(sock, SIOCGIFNETMASK, &ifreqs[i]);
|
||||
sin = (struct sockaddr_in *) &ifreqs[i].ifr_addr;
|
||||
//mask = sin->sin_addr;
|
||||
/* mask = sin->sin_addr; */
|
||||
*mask = sin->sin_addr.s_addr;
|
||||
r = 0;
|
||||
break;
|
||||
|
@ -1094,7 +1170,7 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma
|
|||
break;
|
||||
case AF_INET6:
|
||||
switch_copy_string(buf, "::1", len);
|
||||
base = "2001:503:BA3E::2:30"; // DNS Root server A
|
||||
base = "2001:503:BA3E::2:30"; /* DNS Root server A */
|
||||
break;
|
||||
default:
|
||||
base = "127.0.0.1";
|
||||
|
|
Loading…
Reference in New Issue