[Freeswitch-svn] [commit] r4899 - in freeswitch/branches/mikej/sofiasip-upgrade: . conf libs/apr/include/arch/unix libs/libdingaling/src src src/include src/mod src/mod/applications/mod_commands src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_sofia
Freeswitch SVN
mikej at freeswitch.org
Mon Apr 9 12:32:11 EDT 2007
Author: mikej
Date: Mon Apr 9 12:32:10 2007
New Revision: 4899
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh
freeswitch/branches/mikej/sofiasip-upgrade/conf/dingaling.conf.xml
freeswitch/branches/mikej/sofiasip-upgrade/conf/freeswitch_combined.xml
freeswitch/branches/mikej/sofiasip-upgrade/conf/sofia.conf.xml
freeswitch/branches/mikej/sofiasip-upgrade/conf/switch.conf.xml
freeswitch/branches/mikej/sofiasip-upgrade/configure.in
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/include/arch/unix/apr_private.h.in
freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_xml.c
Log:
merged changes from trunk revisions 4873-4898.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am Mon Apr 9 12:32:10 2007
@@ -14,6 +14,9 @@
AM_CFLAGS += -DCRASH_PROT
endif
+.DEFAULT:
+ @cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@
+
libfreeswitch_la_SOURCES = \
src/switch_apr.c \
src/switch_buffer.c \
@@ -90,8 +93,6 @@
libs/libteletone/src/libteletone_generate.h\
libs/libteletone/src/libteletone.h
-
-
CORE_CFLAGS = `$(switch_srcdir)/libs/apr/apr-1-config --cflags --cppflags --includes`
CORE_CFLAGS += `$(switch_srcdir)/libs/apr-util/apu-1-config --includes`
CORE_CFLAGS += -I$(switch_srcdir)/libs/sqlite
@@ -118,7 +119,7 @@
MOD_LINK = $(BASE)/libfreeswitch.la
CLEANFILES = src/include/switch_version.h
-BUILT_SOURCES = src/include/switch_version.h ./$(DEPDIR)/modules.targets
+BUILT_SOURCES = src/include/switch_version.h
bin_PROGRAMS = freeswitch
freeswitch_SOURCES = src/switch.c
@@ -244,15 +245,10 @@
megaclean: eclean modclean
rm -f `find ./libs -name \*.la`
- at am__include@ @am__quote at ./$(DEPDIR)/modules.targets at am__quote@
-
modules.conf:
if test -f $@; then touch $@; else cp build/modules.conf.in $@ ;fi
-./$(DEPDIR)/modules.targets: modules.conf
- mods=`cat modules.conf | sed -e 's|^.*/||'`; echo MODULE_TARGETS=\"$$mods\" > ./$(DEPDIR)/modules.targets
-
-$(MODULE_TARGETS):
+$(OUR_MODULES):
@set fnord $$MAKEFLAGS; amf=$$2; \
(cd src/mod && $(MAKE) $(AM_MAKEFLAGS) $@) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
Modified: freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh Mon Apr 9 12:32:10 2007
@@ -15,7 +15,7 @@
touch ChangeLog
# autoconf 2.59 or newer
-ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;q'`
+ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
if test -z "$ac_version"; then
echo "bootstrap: autoconf not found."
echo " You need autoconf version 2.59 or newer installed"
@@ -33,7 +33,7 @@
fi
# automake 1.7 or newer
-am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;q'`
+am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
if test -z "$am_version"; then
echo "bootstrap: automake not found."
echo " You need automake version 1.7 or newer installed"
@@ -70,7 +70,7 @@
if test -z "$1"; then a=0 ; else a=$1;fi
if test -z "$2"; then b=0 ; else b=$2;fi
-if test -z "$3"; then c=0 ; else c=$3;fi
+if test -z "$3"; then c=0 ; else c=$3;fi
if test "$a" -lt "2"; then
if test "$b" -lt "5" -o "$b" = "5" -a "$c" -lt "14" ; then
Modified: freeswitch/branches/mikej/sofiasip-upgrade/conf/dingaling.conf.xml
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/conf/dingaling.conf.xml (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/conf/dingaling.conf.xml Mon Apr 9 12:32:10 2007
@@ -15,7 +15,6 @@
<param name="message" value="Jingle all the way"/>
<param name="rtp-ip" value="auto"/>
<param name="auto-login" value="true"/>
- <param name="auto-reply" value="Press *Call* to call FreeSWITCH and be sure to come to ClueCon! http://www.cluecon.com"/>
<!-- SASL "plain" or "md5" -->
<param name="sasl" value="plain"/>
<!-- if the server where the jabber is hosted is not the same as the one in the jid -->
Modified: freeswitch/branches/mikej/sofiasip-upgrade/conf/freeswitch_combined.xml
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/conf/freeswitch_combined.xml (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/conf/freeswitch_combined.xml Mon Apr 9 12:32:10 2007
@@ -7,6 +7,9 @@
<settings>
<!--Most channels to allow at once -->
<param name="max-sessions" value="1000"/>
+ <!--RTP port range -->
+ <!--<param name="rtp-start-port" value="16384"/>-->
+ <!--<param name="rtp-end-port" value="32768"/>-->
</settings>
<!--Any variables defined here will be available in every channel, in the dialplan etc -->
<variables>
Modified: freeswitch/branches/mikej/sofiasip-upgrade/conf/sofia.conf.xml
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/conf/sofia.conf.xml (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/conf/sofia.conf.xml Mon Apr 9 12:32:10 2007
@@ -16,6 +16,8 @@
<!--<param name="proxy" value="asterlink.com"/>-->
<!--/// expire in seconds: *optional* 3600, if blank ///-->
<!--<param name="expire-seconds" value="60"/>-->
+ <!--/// do not register ///-->
+ <!--<param name="register" value="false"/>-->
<!--</gateway>-->
</gateways>
<settings>
Modified: freeswitch/branches/mikej/sofiasip-upgrade/conf/switch.conf.xml
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/conf/switch.conf.xml (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/conf/switch.conf.xml Mon Apr 9 12:32:10 2007
@@ -2,6 +2,9 @@
<settings>
<!--Most channels to allow at once -->
<param name="max-sessions" value="1000"/>
+ <!--RTP port range -->
+ <!--<param name="rtp-start-port" value="16384"/>-->
+ <!--<param name="rtp-end-port" value="32768"/>-->
</settings>
<!--Any variables defined here will be available in every channel, in the dialplan etc -->
<variables>
Modified: freeswitch/branches/mikej/sofiasip-upgrade/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/configure.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/configure.in Mon Apr 9 12:32:10 2007
@@ -340,9 +340,20 @@
#LIBS+=> core.log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat core.log;fi;if test "$$error" = "yes";then exit 1;fi
LIBTOOL='`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`'
TOUCH_TARGET='if test -f "$@";then touch "$@";fi;'
-AM_MAKEFLAGS='`test -n "$(VERBOSE)" || echo -s`'
+CONF_MODULES='\`grep -v "\#" $(switch_builddir)/modules.conf | sed -e "s|^.*/||" \`'
+OUR_MODS='`if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods=\`for i in $$tmp_mods ; do echo $$i-all ; done \`; echo $$mods `'
+OUR_CLEAN_MODS='`if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods=\`for i in $$tmp_mods ; do echo $$i-clean ; done \`; echo $$mods `'
+OUR_INSTALL_MODS='`if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods=\`for i in $$tmp_mods ; do echo $$i-install ; done\`; echo $$mods `'
+OUR_UNINSTALL_MODS='`if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods=\`for i in $$tmp_mods ; do echo $$i-uninstall ; done\`; echo $$mods `'
+AM_MAKEFLAGS='"OUR_MODULES=$(OUR_MODS)" "OUR_CLEAN_MODULES=$(OUR_CLEAN_MODS)" "OUR_INSTALL_MODULES=$(OUR_INSTALL_MODS)" "OUR_UNINSTALL_MODULES=$(OUR_UNINSTALL_MODS)" `test -n "$(VERBOSE)" || echo -s`'
+#AM_MAKEFLAGS='`test -n "$(VERBOSE)" || echo -s`'
AC_SUBST(LIBTOOL)
AC_SUBST(TOUCH_TARGET)
+AC_SUBST(CONF_MODULES)
+AC_SUBST(OUR_MODS)
+AC_SUBST(OUR_CLEAN_MODS)
+AC_SUBST(OUR_INSTALL_MODS)
+AC_SUBST(OUR_UNINSTALL_MODS)
AC_SUBST(AM_MAKEFLAGS)
# Run configure in all the subdirs
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/include/arch/unix/apr_private.h.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/include/arch/unix/apr_private.h.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/include/arch/unix/apr_private.h.in Mon Apr 9 12:32:10 2007
@@ -632,16 +632,16 @@
/* */
#undef SIGWAIT_TAKES_ONE_ARG
-/* The size of a `char', as computed by sizeof. */
+/* The size of `char', as computed by sizeof. */
#undef SIZEOF_CHAR
-/* The size of a `int', as computed by sizeof. */
+/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
-/* The size of a `long', as computed by sizeof. */
+/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
-/* The size of a `long long', as computed by sizeof. */
+/* The size of `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* The size of off_t */
@@ -650,7 +650,7 @@
/* The size of pid_t */
#undef SIZEOF_PID_T
-/* The size of a `short', as computed by sizeof. */
+/* The size of `short', as computed by sizeof. */
#undef SIZEOF_SHORT
/* The size of size_t */
@@ -659,7 +659,7 @@
/* The size of ssize_t */
#undef SIZEOF_SSIZE_T
-/* The size of a `void*', as computed by sizeof. */
+/* The size of `void*', as computed by sizeof. */
#undef SIZEOF_VOIDP
/* Define to 1 if you have the ANSI C header files. */
@@ -752,13 +752,13 @@
#undef inline
#endif
-/* Define to `long' if <sys/types.h> does not define. */
+/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
-/* Define to `unsigned' if <sys/types.h> does not define. */
+/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* Define to `int' if <sys/types.h> does not define. */
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c Mon Apr 9 12:32:10 2007
@@ -526,97 +526,6 @@
const char *marker = "TRUE";
-static int on_disco_info(void *user_data, ikspak *pak)
-{
- ldl_handle_t *handle = user_data;
-
- if (pak->subtype == IKS_TYPE_RESULT) {
- if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) {
- char *from = iks_find_attrib(pak->x, "from");
- char id[1024];
- char *resource;
- struct ldl_buffer *buffer;
- size_t x;
-
-
- apr_cpystrn(id, from, sizeof(id));
- if ((resource = strchr(id, '/'))) {
- *resource++ = '\0';
- }
-
- if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) {
- iks *msg;
- apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker);
- msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, "Ding A Ling....");
- apr_queue_push(handle->queue, msg);
- }
-
-
-
- if (resource) {
- for (x = 0; x < strlen(resource); x++) {
- resource[x] = (char)tolower((int)resource[x]);
- }
- }
-
- if (resource && strstr(resource, "talk") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) {
- apr_cpystrn(buffer->buf, from, buffer->len);
- fflush(stderr);
- buffer->hit = 1;
- }
- }
- return IKS_FILTER_EAT;
- }
-
- if (pak->subtype == IKS_TYPE_GET) {
- iks *iq, *query, *tag;
- uint8_t send = 0;
-
- if ((iq = iks_new("iq"))) {
- do {
- iks_insert_attrib(iq, "from", handle->login);
- iks_insert_attrib(iq, "to", pak->from->full);
- iks_insert_attrib(iq, "id", pak->id);
- iks_insert_attrib(iq, "type", "result");
-
- if (!(query = iks_insert (iq, "query"))) {
- break;
- }
- iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info");
-
- if (!(tag = iks_insert (query, "identity"))) {
- break;
- }
- iks_insert_attrib(tag, "category", "client");
- iks_insert_attrib(tag, "type", "voice");
- iks_insert_attrib(tag, "name", "LibDingaLing");
-
-
- if (!(tag = iks_insert (query, "feature"))) {
- break;
- }
- iks_insert_attrib(tag, "var", "http://jabber.org/protocol/disco#info");
-
- if (!(tag = iks_insert (query, "feature"))) {
- break;
- }
- iks_insert_attrib(tag, "var", "http://www.google.com/xmpp/protocol/voice/v1");
-
- iks_send(handle->parser, iq);
- send = 1;
- } while (0);
-
- iks_delete(iq);
- }
-
- if (!send) {
- globals.logger(DL_LOG_DEBUG, "Memory Error!\n");
- }
- }
-
- return IKS_FILTER_EAT;
-}
-
static int on_vcard(void *user_data, ikspak *pak)
{
@@ -635,7 +544,7 @@
static int on_disco_default(void *user_data, ikspak *pak)
{
char *node = NULL;
- char *ns;
+ char *ns = NULL;
ldl_handle_t *handle = user_data;
iks *iq, *query, *tag;
uint8_t send = 0;
@@ -650,6 +559,8 @@
globals.logger(DL_LOG_DEBUG, "FixME!!! node=[%s]\n", node?node:"");
} else if (pak->subtype == IKS_TYPE_GET) {
if ((iq = iks_new("iq"))) {
+ int all = 0;
+
iks_insert_attrib(iq, "from", handle->login);
iks_insert_attrib(iq, "to", pak->from->full);
iks_insert_attrib(iq, "id", pak->id);
@@ -667,13 +578,17 @@
if (!(tag = iks_insert (query, "identity"))) {
goto fail;
}
+
+ if (!strcasecmp(ns, FEATURE_DISCO) && !node) {
+ all++;
+ }
iks_insert_attrib(tag, "category", "gateway");
iks_insert_attrib(tag, "type", "voice");
iks_insert_attrib(tag, "name", "LibDingaLing");
for (x = 0; FEATURES[x].name; x++) {
- if (!ns || !strcasecmp(ns, FEATURES[x].name)) {
+ if (all || !ns || !strcasecmp(ns, FEATURES[x].name)) {
if (!(tag = iks_insert (query, "feature"))) {
goto fail;
}
@@ -698,26 +613,6 @@
return IKS_FILTER_EAT;
}
-
-
-static int on_disco_items(void *user_data, ikspak *pak)
-{
- globals.logger(DL_LOG_DEBUG, "FixME!!!\n");
- return IKS_FILTER_EAT;
-}
-
-static int on_disco_reg_in(void *user_data, ikspak *pak)
-{
- globals.logger(DL_LOG_DEBUG, "FixME!!!\n");
- return IKS_FILTER_EAT;
-}
-
-static int on_disco_reg_out(void *user_data, ikspak *pak)
-{
- globals.logger(DL_LOG_DEBUG, "FixME!!!\n");
- return IKS_FILTER_EAT;
-}
-
static int on_presence(void *user_data, ikspak *pak)
{
ldl_handle_t *handle = user_data;
@@ -731,6 +626,8 @@
struct ldl_buffer *buffer;
ldl_signal_t dl_signal = LDL_SIGNAL_PRESENCE_IN;
+
+
if (type && *type) {
if (!strcasecmp(type, "unavailable")) {
dl_signal = LDL_SIGNAL_PRESENCE_OUT;
@@ -754,6 +651,7 @@
*resource++ = '\0';
}
+
if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) {
iks *msg;
apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker);
@@ -761,12 +659,11 @@
apr_queue_push(handle->queue, msg);
}
-
if (resource && strstr(resource, "talk") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) {
apr_cpystrn(buffer->buf, from, buffer->len);
fflush(stderr);
buffer->hit = 1;
- }
+ }
if (handle->session_callback) {
handle->session_callback(handle, NULL, dl_signal, to, id, status ? status : "n/a", show ? show : "n/a");
@@ -1500,9 +1397,9 @@
handle,
(iksStreamHook *) (ldl_test_flag(handle, LDL_FLAG_COMPONENT) ? on_stream_component : on_stream));
- if (globals.debug) {
- iks_set_log_hook(handle->parser, (iksLogHook *) on_log);
- }
+
+ iks_set_log_hook(handle->parser, (iksLogHook *) on_log);
+
strncpy(tmp, jabber_id, sizeof(tmp)-1);
sl = strchr(tmp, '/');
@@ -1598,7 +1495,10 @@
handle->state = CS_NEW;
}
ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
-
+ if (!ldl_test_flag(handle, LDL_FLAG_TLS)) {
+ ldl_flush_queue(handle, 1);
+ }
+
while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) {
microsleep(100);
}
@@ -1872,6 +1772,15 @@
}
+int ldl_global_debug(int on)
+{
+ if (on > -1) {
+ globals.debug = on ? 1 : 0;
+ }
+
+ return globals.debug ? 1 : 0;
+}
+
void ldl_global_set_logger(ldl_logger_t logger)
{
globals.logger = logger;
@@ -1953,42 +1862,34 @@
iks *pres, *msg;
char *lid = NULL, *low_id = NULL;
struct ldl_buffer buffer;
- apr_time_t started;
+ time_t started;
unsigned int elapsed;
char *notice = "Call Me!";
- int again = 0;
-
+ int next = 0;
+
buffer.buf = buf;
buffer.len = len;
buffer.hit = 0;
- pres = iks_new("presence");
- iks_insert_attrib(pres, "type", "probe");
- iks_insert_attrib(pres, "from", from);
- iks_insert_attrib(pres, "to", id);
-
-
apr_hash_set(handle->probe_hash, id, APR_HASH_KEY_STRING, &buffer);
- msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, notice);
- iks_insert_attrib(msg, "from", from);
- apr_queue_push(handle->queue, msg);
- msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, notice);
- iks_insert_attrib(msg, "from", from);
- apr_queue_push(handle->queue, msg);
- apr_queue_push(handle->queue, pres);
-
- //schedule_packet(handle, next_id(), pres, LDL_RETRY);
- started = apr_time_now();
+ started = time(NULL);
for(;;) {
- elapsed = (unsigned int)((apr_time_now() - started) / 1000);
- if (elapsed > 5000 && ! again) {
+ elapsed = time(NULL) - started;
+ if (elapsed == next) {
msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, notice);
iks_insert_attrib(msg, "from", from);
apr_queue_push(handle->queue, msg);
- again++;
+
+ pres = iks_new("presence");
+ iks_insert_attrib(pres, "xmlns", "jabber:client");
+ iks_insert_attrib(pres, "type", "probe");
+ iks_insert_attrib(pres, "to", id);
+ iks_insert_attrib(pres, "from", from);
+ apr_queue_push(handle->queue, pres);
+ next += 5;
}
- if (elapsed > 10000) {
+ if (elapsed >= 17) {
break;
}
if (buffer.hit) {
@@ -2179,10 +2080,10 @@
ldl_status ldl_global_destroy(void)
{
- if (ldl_test_flag(&globals, LDL_FLAG_INIT)) {
+ if (!ldl_test_flag(&globals, LDL_FLAG_INIT)) {
return LDL_STATUS_FALSE;
}
-
+
apr_pool_destroy(globals.memory_pool);
ldl_clear_flag(&globals, LDL_FLAG_INIT);
apr_terminate();
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.h Mon Apr 9 12:32:10 2007
@@ -376,6 +376,13 @@
void ldl_session_accept_candidate(ldl_session_t *session, ldl_candidate_t *candidate);
/*!
+ \brief turn logging on/off
+ \param on (TRUE or FALSE)
+ \return current state
+*/
+int ldl_global_debug(int on);
+
+/*!
\brief Set a custom logger
\param logger the logger function
*/
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h Mon Apr 9 12:32:10 2007
@@ -59,7 +59,10 @@
#include <setjmp.h>
#include <ctype.h>
#include <fcntl.h>
+#ifndef _MSC_VER
#include <strings.h>
+#endif
+#include <string.h>
#include <sys/stat.h>
#include <limits.h>
#include <sys/types.h>
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h Mon Apr 9 12:32:10 2007
@@ -27,6 +27,7 @@
*
*
* switch_channel.h -- Media Channel Interface
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
*
*/
/**
@@ -53,6 +54,20 @@
*/
SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool);
+/*!
+ \brief Set/Get RTP start port
+ \param port new value (if > 0)
+ \return the current RTP start port
+*/
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port);
+
+/*!
+ \brief Set/Get RTP end port
+ \param port new value (if > 0)
+ \return the current RTP end port
+*/
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port);
+
/*!
\brief Request a new port to be used for media
\return the new port to use
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h Mon Apr 9 12:32:10 2007
@@ -222,7 +222,7 @@
///\param name the name of the tag
///\param off the offset
///\return an xml node or NULL
- switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
+ SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
///\brief wrapper for switch_xml_add_child() that strdup()s name
///\param xml the xml node
@@ -235,7 +235,7 @@
///\param xml the xml node
///\param txt the text
///\return an xml node or NULL
- switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt);
+ SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *txt);
///\brief wrapper for switch_xml_set_txt() that strdup()s txt
///\ sets the character content for the given tag and returns the tag
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am Mon Apr 9 12:32:10 2007
@@ -1,90 +1,28 @@
-CONF_MODULES=if test ! -f $(switch_builddir)/modules.conf ; then cp $(switch_builddir)/build/modules.conf.in $(switch_builddir)/modules.conf ; fi ; conf_modules=`grep -v "\#" $(switch_builddir)/modules.conf` ;
-FOUND_MODULES=found_modules=`find . -type d -name mod_\* | sed -e 's|^\./||'` ;
-OUR_MODULES=if test -z "$(MODULES)" ; then our_modules=$$conf_modules ; else our_modules="$(MODULES)" ; fi ;
-OUR_CLEAN_MODULES=if test -z "$(MODULES)" ; then tmp_clean_modules=`echo $$conf_modules $$found_modules`; \
- our_clean_modules=`for i in $$tmp_clean_modules ; do echo $$i ; done | sort | uniq` ; \
- else our_clean_modules="$(MODULES)" ; fi ;
-MOD_NAME=`echo $$i | sed -e 's|^.*/||'`
-MOD_DIR=`if test -d $(switch_srcdir)/src/mod/$$i ; then echo $(switch_srcdir)/src/mod/$$i ; else echo $$i ; fi;`
+all: $(OUR_MODULES)
+clean: $(OUR_CLEAN_MODULES)
+install: $(OUR_INSTALL_MODULES)
+uninstall: $(OUR_UNINSTALL_MODULES)
-all:
- @$(CONF_MODULES) \
- $(OUR_MODULES) \
- echo ;\
- echo making modules ; \
- for i in $$our_modules ; do \
- echo ;\
- echo making $$i ; \
- moddir=$(MOD_DIR); \
- if test -f $$moddir/Makefile ; then \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) || exit 1; else \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules || exit 1; \
- fi; \
- done
- @echo
- @echo done making modules
-
-clean:
- @$(CONF_MODULES) \
- $(FOUND_MODULES) \
- $(OUR_CLEAN_MODULES) \
- echo ;\
- echo making clean modules ; \
- for i in $$our_clean_modules ; do \
- echo ;\
- echo making clean $$i ; \
- moddir=$(MOD_DIR); \
- if test -f $$moddir/Makefile ; then \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) clean || exit 1; else \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules clean || exit 1; \
- fi; \
- done
- @echo
- @echo done making clean modules
-
-install:
- @$(CONF_MODULES) \
- $(OUR_MODULES) \
- echo ;\
- echo Installing Modules ; \
- for i in $$our_modules ; do \
- echo ;\
- echo making install $$i ; \
- moddir=$(MOD_DIR); \
- if test -f $$moddir/Makefile ; then \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) install || exit 1; else \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules install || exit 1; \
- fi; \
- done
- @echo
- @echo done Installing Modules
-
-uninstall:
- @$(CONF_MODULES) \
- $(OUR_MODULES) \
- echo ;\
- echo Uninstalling Modules ; \
- for i in $$our_modules ; do \
- echo ;\
- echo making uninstall $$i ; \
- moddir=$(MOD_DIR); \
- if test -f $$moddir/Makefile ; then \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) uninstall || exit 1; else \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules uninstall || exit 1; \
- fi; \
- done
- @echo
- @echo done Uninstalling Modules
-
-
- at am__include@ @am__quote@$(switch_builddir)/$(DEPDIR)/modules.targets at am__quote@
-
-$(MODULE_TARGETS):
+$(OUR_MODULES) $(OUR_CLEAN_MODULES) $(OUR_INSTALL_MODULES) $(OUR_UNINSTALL_MODULES):
@set fnord $$MAKEFLAGS; amf=$$2; \
- moddir=`grep $@ $(switch_builddir)/modules.conf | sed -e 's|#||'` ; \
+ target=`echo $@ | sed -e 's|^.*-||'`; \
+ modname=`echo $@ | sed -e 's|-.*||'`; \
+ confmoddir=`cat $(switch_builddir)/modules.conf | grep $$modname | sed -e 's|#||' `; \
+ if test -z "$$confmoddir" ; then moddir=$@ ; else \
+ if test -d "$(switch_srcdir)/src/mod/$$confmoddir" ; then \
+ moddir="$(switch_srcdir)/src/mod/$$confmoddir" ; else \
+ moddir="$$confmoddir" ; \
+ fi ; \
+ fi ; \
+ if test -z "$$target" ; then target="all" ; fi ; \
+ echo ;\
+ echo making $$target $$modname ;\
(if test -f $$moddir/Makefile ; then \
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS); else\
- cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules;\
+ cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) $$target; else\
+ cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules $$target ;\
fi;)\
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
test -z "$$fail"
+
+.DEFAULT:
+ @if test -z "`echo $@ | grep all`"; then $(MAKE) $(AM_MAKEFLAGS) $@-all ; else echo Unknown target `echo $@ | sed -e 's|-all||'`; exit 1; fi
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c Mon Apr 9 12:32:10 2007
@@ -27,6 +27,7 @@
* Michael Jerris <mike at jerris.com>
* Johny Kadarisman <jkr888 at gmail.com>
* Paul Tinsley <jackhammer at gmail.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
*
*
* mod_commands.c -- Misc. Command Module
@@ -724,6 +725,55 @@
return SWITCH_STATUS_SUCCESS;
}
+static switch_status_t xml_wrap_api_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+ char *dcommand, *edata = NULL, *send = NULL, *command, *arg = NULL;
+ switch_stream_handle_t mystream = { 0 };
+ int encoded = 0, elen = 0;
+
+ if ((dcommand = strdup(cmd))) {
+ if (!strncasecmp(dcommand, "encoded ", 8)) {
+ encoded++;
+ command = dcommand + 8;
+ } else {
+ command = dcommand;
+ }
+
+ if ((arg = strchr(command, ' '))) {
+ *arg++ = '\0';
+ }
+ SWITCH_STANDARD_STREAM(mystream);
+ switch_api_execute(command, arg, NULL, &mystream);
+
+ if (mystream.data) {
+ if (encoded) {
+ elen = (int) strlen(mystream.data) * 3;
+ edata = malloc(elen);
+ assert(edata != NULL);
+ memset(edata, 0, elen);
+ switch_url_encode(mystream.data, edata, elen);
+ send = edata;
+ } else {
+ send = mystream.data;
+ }
+ }
+
+ stream->write_function(stream,
+ "<result>\n"
+ " <row id=\"1\">\n"
+ " <data>%s</data>\n"
+ " </row>\n"
+ "</result>\n",
+ send ? send : "ERROR"
+ );
+ switch_safe_free(mystream.data);
+ switch_safe_free(edata);
+ free(dcommand);
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
static switch_status_t sched_api_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
char *tm = NULL, *dcmd, *group;
@@ -768,8 +818,43 @@
char *http;
uint32_t count;
int print_title;
+ switch_xml_t xml;
+ int rows;
};
+static int show_as_xml_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+ struct holder *holder = (struct holder *) pArg;
+ switch_xml_t row, field;
+ int x, f_off = 0;
+ char id[50];
+
+ if (holder->count == 0) {
+ if (!(holder->xml = switch_xml_new("result"))) {
+ return -1;
+ }
+ }
+
+ if (!(row = switch_xml_add_child_d(holder->xml, "row", holder->rows++))) {
+ return -1;
+ }
+
+ snprintf(id, sizeof(id), "%d", holder->rows);
+ switch_xml_set_attr_d(row, "id", id);
+
+ for(x = 0; x < argc; x++) {
+ if ((field = switch_xml_add_child_d(row, columnNames[x], f_off++))) {
+ switch_xml_set_txt_d(field, argv[x]);
+ } else {
+ return -1;
+ }
+ }
+
+ holder->count++;
+
+ return 0;
+}
+
static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
{
struct holder *holder = (struct holder *) pArg;
@@ -808,19 +893,33 @@
return 0;
}
-static switch_status_t show_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
+static switch_status_t show_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
{
char sql[1024];
char *errmsg;
switch_core_db_t *db = switch_core_db_handle();
struct holder holder = { 0 };
int help = 0;
+ char *mydata = NULL, *argv[5] = {0};
+ int argc;
+ char *cmd = NULL, *as = NULL;
if (session) {
return SWITCH_STATUS_FALSE;
}
- if (stream->event) {
+ if (data) {
+ if ((mydata = strdup(data))) {
+ argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
+
+ cmd = argv[0];
+ if (argv[2] && !strcasecmp(argv[1], "as")) {
+ as = argv[2];
+ }
+ }
+
+ if (!as && stream->event) {
holder.http = switch_event_get_header(stream->event, "http-host");
}
@@ -864,23 +963,44 @@
holder.stream->write_function(holder.stream, "<table cellpadding=1 cellspacing=4 border=1>\n");
}
- switch_core_db_exec(db, sql, show_callback, &holder, &errmsg);
-
- if (holder.http) {
- holder.stream->write_function(holder.stream, "</table>");
+ if (!as) {
+ as = "csv";
}
- if (errmsg) {
- stream->write_function(stream, "SQL ERR [%s]\n", errmsg);
- switch_core_db_free(errmsg);
- errmsg = NULL;
- } else if (help) {
- if (holder.count == 0)
- stream->write_function(stream, "No such command.\n");
+ if (!strcasecmp(as, "csv")) {
+ switch_core_db_exec(db, sql, show_callback, &holder, &errmsg);
+ if (holder.http) {
+ holder.stream->write_function(holder.stream, "</table>");
+ }
+
+ if (errmsg) {
+ stream->write_function(stream, "SQL ERR [%s]\n", errmsg);
+ switch_core_db_free(errmsg);
+ errmsg = NULL;
+ } else if (help) {
+ if (holder.count == 0)
+ stream->write_function(stream, "No such command.\n");
+ } else {
+ stream->write_function(stream, "\n%u total.\n", holder.count);
+ }
+ } else if (!strcasecmp(as, "xml")) {
+ switch_core_db_exec(db, sql, show_as_xml_callback, &holder, &errmsg);
+ if (holder.xml) {
+ char *xmlstr = switch_xml_toxml(holder.xml);
+ if (xmlstr) {
+ holder.stream->write_function(holder.stream, "%s", xmlstr);
+ free(xmlstr);
+ } else {
+ holder.stream->write_function(holder.stream, "ERROR\n");
+ }
+ } else {
+ holder.stream->write_function(holder.stream, "ERROR\n");
+ }
} else {
- stream->write_function(stream, "\n%u total.\n", holder.count);
+ holder.stream->write_function(holder.stream, "Cannot find format %s\n", as);
}
+ switch_safe_free(mydata);
switch_core_db_close(db);
return SWITCH_STATUS_SUCCESS;
}
@@ -914,12 +1034,21 @@
return SWITCH_STATUS_SUCCESS;
}
+
+static switch_api_interface_t xml_wrap_api_interface = {
+ /*.interface_name */ "xml_wrap",
+ /*.desc */ "Wrap another api command in xml",
+ /*.function */ xml_wrap_api_function,
+ /*.syntax */ "<command> <args>",
+ /*.next */ NULL
+};
+
static switch_api_interface_t sched_del_api_interface = {
/*.interface_name */ "sched_del",
/*.desc */ "Delete a Scheduled task",
/*.function */ sched_del_function,
/*.syntax */ "<task_id>|<group_id>",
- /*.next */ NULL
+ /*.next */ &xml_wrap_api_interface
};
static switch_api_interface_t sched_api_api_interface = {
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/Makefile Mon Apr 9 12:32:10 2007
@@ -3,7 +3,7 @@
LOCAL_CFLAGS = `$(BASE)/libs/apr/apr-1-config --cflags --cppflags --includes`
LOCAL_CFLAGS += `$(BASE)/libs/apr-util/apu-1-config --includes`
LOCAL_CFLAGS += `if test -f $(BASE)/.libs/libfreeswitch_la-switch_odbc.o ; then echo -DSWITCH_HAVE_ODBC; fi ;`
-LOCAL_CFLAGS += -w
+#LOCAL_CFLAGS += -w
IKS_DIR=$(BASE)/libs/iksemel
IKS_LA=$(IKS_DIR)/src/libiksemel.la
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c Mon Apr 9 12:32:10 2007
@@ -108,7 +108,9 @@
char *login;
char *password;
char *message;
+#ifdef AUTO_REPLY
char *auto_reply;
+#endif
char *dialplan;
char *ip;
char *extip;
@@ -192,6 +194,7 @@
static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t dl_pres(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
+static switch_status_t dl_debug(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
static switch_status_t channel_on_ring(switch_core_session_t *session);
@@ -722,13 +725,15 @@
if (ll) {
if ((xmltxt = strchr(ll, ':'))) {
*xmltxt++ = '\0';
- xml = switch_xml_parse_str(xmltxt, strlen(xmltxt));
- form = switch_xml_toxml(xml);
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, level,
- "%s:\n-------------------------------------------------------------------------------\n"
- "%s\n", ll, form);
- switch_xml_free(xml);
- free(data);
+ if (strlen(xmltxt) > 2) {
+ xml = switch_xml_parse_str(xmltxt, strlen(xmltxt));
+ form = switch_xml_toxml(xml);
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, level,
+ "%s:\n-------------------------------------------------------------------------------\n"
+ "%s\n", ll, form);
+ switch_xml_free(xml);
+ free(data);
+ }
}
}
} else {
@@ -849,9 +854,8 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
-
+
flags = SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG;
- //flags = SWITCH_RTP_FLAG_AUTOADJ;
if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
flags |= SWITCH_RTP_FLAG_USE_TIMER;
@@ -874,7 +878,11 @@
uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
switch_rtp_activate_ice(tech_pvt->rtp_session, tech_pvt->remote_user, tech_pvt->local_user);
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);
+ if (switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VAD ERROR %s\n", err);
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ return 0;
+ }
switch_set_flag_locked(tech_pvt, TFLAG_VAD);
}
switch_rtp_set_cng_pt(tech_pvt->rtp_session, 13);
@@ -1065,7 +1073,8 @@
while (!(switch_test_flag(tech_pvt, TFLAG_CODEC_READY) &&
switch_test_flag(tech_pvt, TFLAG_RTP_READY) &&
- switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT)
+ switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) &&
+ tech_pvt->remote_ip && tech_pvt->remote_port
&& switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
now = switch_time_now();
elapsed = (unsigned int) ((now - started) / 1000);
@@ -1329,89 +1338,101 @@
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
{
struct private_object *tech_pvt = NULL;
- uint32_t bytes = 0;
- switch_size_t samples = 0, frames = 0, ms = 0;
switch_channel_t *channel = NULL;
- switch_payload_t payload = 0;
- switch_status_t status;
+ int payload = 0;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
+ tech_pvt = (struct private_object *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
- if (!tech_pvt->rtp_session) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
- //terminate_session(&session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
- return SWITCH_STATUS_FALSE;
+ while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) {
+ if (switch_channel_ready(channel)) {
+ switch_yield(10000);
+ } else {
+ return SWITCH_STATUS_GENERR;
+ }
}
tech_pvt->read_frame.datalen = 0;
switch_set_flag_locked(tech_pvt, TFLAG_READING);
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- samples = tech_pvt->read_codec.implementation->samples_per_frame;
- ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
- tech_pvt->read_frame.datalen = 0;
+#if 0
+ if (tech_pvt->last_read) {
+ elapsed = (unsigned int) ((switch_time_now() - tech_pvt->last_read) / 1000);
+ if (elapsed > 60000) {
+ return SWITCH_STATUS_TIMEOUT;
+ }
+ }
+#endif
- while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO)
- && tech_pvt->read_frame.datalen == 0) {
- tech_pvt->read_frame.flags = 0;
- status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
+ if (switch_test_flag(tech_pvt, TFLAG_IO)) {
+ switch_status_t status;
- if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
- return SWITCH_STATUS_FALSE;
- }
- payload = tech_pvt->read_frame.payload;
+ assert(tech_pvt->rtp_session != NULL);
+ tech_pvt->read_frame.datalen = 0;
- if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
- char dtmf[128];
- switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, dtmf, sizeof(dtmf));
- switch_channel_queue_dtmf(channel, dtmf);
- switch_set_flag_locked(tech_pvt, TFLAG_DTMF);
- }
- if (switch_test_flag(tech_pvt, TFLAG_DTMF)) {
- switch_clear_flag_locked(tech_pvt, TFLAG_DTMF);
- return SWITCH_STATUS_BREAK;
- }
+ while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
+ tech_pvt->read_frame.flags = SFF_NONE;
- if (switch_test_flag(&tech_pvt->read_frame, SFF_CNG)) {
- tech_pvt->read_frame.datalen = tech_pvt->last_read ? tech_pvt->last_read : tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- }
+ status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
+ if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
+ return SWITCH_STATUS_FALSE;
+ }
- if (tech_pvt->read_frame.datalen > 0) {
- if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
- if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame && bytes) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (tech_pvt->read_frame.datalen / bytes);
- } else {
- frames = 1;
+
+
+ payload = tech_pvt->read_frame.payload;
+
+#if 0
+ elapsed = (unsigned int) ((switch_time_now() - started) / 1000);
+
+ if (timeout > -1) {
+ if (elapsed >= (unsigned int) timeout) {
+ return SWITCH_STATUS_BREAK;
}
- samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
- ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
- tech_pvt->timestamp_recv += (int32_t) samples;
- tech_pvt->read_frame.samples = (int) samples;
- tech_pvt->last_read = tech_pvt->read_frame.datalen;
}
- break;
- }
- switch_yield(1000);
- }
+ elapsed = (unsigned int) ((switch_time_now() - last_act) / 1000);
+ if (elapsed >= hard_timeout) {
+ return SWITCH_STATUS_BREAK;
+ }
+#endif
+ if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
+ char dtmf[128];
+ switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, dtmf, sizeof(dtmf));
+ switch_channel_queue_dtmf(channel, dtmf);
+ }
+
+
+ if (tech_pvt->read_frame.datalen > 0) {
+ size_t bytes = 0;
+ int frames = 1;
+ if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
+ if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame)) {
+ frames = (tech_pvt->read_frame.datalen / bytes);
+ }
+ tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_frame);
+ }
+ break;
+ }
+ }
+ }
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+ if (tech_pvt->read_frame.datalen == 0) {
+ *frame = NULL;
+ return SWITCH_STATUS_GENERR;
+ }
*frame = &tech_pvt->read_frame;
+
return SWITCH_STATUS_SUCCESS;
}
@@ -1422,45 +1443,46 @@
switch_status_t status = SWITCH_STATUS_SUCCESS;
int bytes = 0, samples = 0, frames = 0;
-
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
+ tech_pvt = (struct private_object *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- if (!tech_pvt->rtp_session) {
- return SWITCH_STATUS_FALSE;
+ while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) {
+ if (switch_channel_ready(channel)) {
+ switch_yield(10000);
+ } else {
+ return SWITCH_STATUS_GENERR;
+ }
}
- if (!switch_test_flag(tech_pvt, TFLAG_RTP_READY)) {
+ if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
return SWITCH_STATUS_SUCCESS;
}
-
- if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
- return SWITCH_STATUS_FALSE;
- }
-
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
- if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = ((int) frame->datalen / bytes);
- } else {
- frames = 1;
- }
+ if (!switch_test_flag(frame, SFF_CNG)) {
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = ((int) frame->datalen / bytes);
+ } else
+ frames = 1;
- samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
- tech_pvt->timestamp_send += samples;
- if (switch_rtp_write_frame(tech_pvt->rtp_session, frame, 0) < 0) {
- terminate_session(&session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
- return SWITCH_STATUS_FALSE;
+ samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
}
+#if 0
+ printf("%s %s->%s send %d bytes %d samples in %d frames ts=%d\n",
+ switch_channel_get_name(channel),
+ tech_pvt->local_sdp_audio_ip, tech_pvt->remote_sdp_audio_ip, frame->datalen, samples, frames, tech_pvt->timestamp_send);
+#endif
+ tech_pvt->timestamp_send += samples;
+ //switch_rtp_write_frame(tech_pvt->rtp_session, frame, tech_pvt->timestamp_send);
+ switch_rtp_write_frame(tech_pvt->rtp_session, frame, 0);
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
-
return status;
}
@@ -1569,12 +1591,20 @@
};
+static switch_api_interface_t debug_api_interface = {
+ /*.interface_name */ "dl_debug",
+ /*.desc */ "DingaLing Presence",
+ /*.function */ dl_debug,
+ /*.syntax */ "dl_debug [true|false]",
+ /*.next */ NULL
+};
+
static switch_api_interface_t pres_api_interface = {
/*.interface_name */ "dl_pres",
/*.desc */ "DingaLing Presence",
/*.function */ dl_pres,
/*.syntax */ "dl_pres <profile_name>",
- /*.next */ NULL
+ /*.next */ &debug_api_interface
};
static switch_api_interface_t logout_api_interface = {
@@ -1898,6 +1928,7 @@
break;
}
}
+
if (globals.init) {
ldl_global_destroy();
}
@@ -1933,8 +1964,10 @@
switch_set_flag(profile, TFLAG_TIMER);
} else if (!strcasecmp(var, "dialplan")) {
profile->dialplan = switch_core_strdup(module_pool, val);
+#ifdef AUTO_REPLY // gotta fix looping on this
} else if (!strcasecmp(var, "auto-reply")) {
profile->auto_reply = switch_core_strdup(module_pool, val);
+#endif
} else if (!strcasecmp(var, "name")) {
profile->name = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "message")) {
@@ -1981,6 +2014,27 @@
}
}
+static switch_status_t dl_debug(char *tf, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+ int on, cur;
+
+ if (session) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (tf) {
+ on = switch_true(tf);
+ cur = ldl_global_debug(on);
+ } else {
+ cur = ldl_global_debug(-1);
+ }
+
+
+ stream->write_function(stream, "DEBUG IS NOW %s\n", cur ? "ON" : "OFF");
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
static switch_status_t dl_pres(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
{
mdl_profile_t *profile;
@@ -2349,6 +2403,8 @@
switch_mutex_unlock(profile->mutex);
if (is_special(to)) {
ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call", profile->avatar);
+ } else {
+ ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Authenticated.\nCome to ClueCon!\nhttp://www.cluecon.com", profile->avatar);
}
#if 0
if (is_special(to)) {
@@ -2444,12 +2500,13 @@
char *proto = MDL_CHAT_PROTO;
char *pproto = NULL, *ffrom = NULL;
char *hint;
-
+#ifdef AUTO_REPLY
if (profile->auto_reply) {
ldl_handle_send_msg(handle,
(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->handle), from, "",
profile->auto_reply);
}
+#endif
if (strchr(to, '+')) {
pproto = strdup(to);
@@ -2526,7 +2583,7 @@
}
} else {
- if (dl_signal != LDL_SIGNAL_INITIATE) {
+ if (dl_signal != LDL_SIGNAL_INITIATE && !msg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session is already dead\n");
status = LDL_STATUS_FALSE;
goto done;
@@ -2534,6 +2591,7 @@
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
switch_core_session_add_stream(session, NULL);
+
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h Mon Apr 9 12:32:10 2007
@@ -27,6 +27,7 @@
* Ken Rice, Asteria Solutions Group, Inc <ken at asteriasgi.com>
* Paul D. Tinsley <pdt at jackhammer.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
*
*
* mod_sofia.h -- SOFIA SIP Endpoint
@@ -159,7 +160,8 @@
REG_STATE_REGISTER,
REG_STATE_REGED,
REG_STATE_FAILED,
- REG_STATE_EXPIRED
+ REG_STATE_EXPIRED,
+ REG_STATE_NOREG
} reg_state_t;
struct outbound_reg {
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c Mon Apr 9 12:32:10 2007
@@ -27,6 +27,7 @@
* Ken Rice, Asteria Solutions Group, Inc <ken at asteriasgi.com>
* Paul D. Tinsley <pdt at jackhammer.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
*
*
* sofia.c -- SOFIA SIP Endpoint (sofia code)
@@ -668,7 +669,7 @@
}
if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
- char *scheme = "Digest",
+ char *register_str = "true", *scheme = "Digest",
*realm = NULL,
*username = NULL, *password = NULL, *extension = NULL, *proxy = NULL, *context = "default", *expire_seconds = "3600";
@@ -682,7 +683,9 @@
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
- if (!strcmp(var, "scheme")) {
+ if (!strcmp(var, "register")) {
+ register_str = val;
+ } else if (!strcmp(var, "scheme")) {
scheme = val;
} else if (!strcmp(var, "realm")) {
realm = val;
@@ -725,6 +728,9 @@
proxy = realm;
}
+ if (!switch_true(register_str)) {
+ gateway->state = REG_STATE_NOREG;
+ }
gateway->register_scheme = switch_core_strdup(gateway->pool, scheme);
gateway->register_context = switch_core_strdup(gateway->pool, context);
gateway->register_realm = switch_core_strdup(gateway->pool, realm);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_reg.c Mon Apr 9 12:32:10 2007
@@ -27,6 +27,7 @@
* Ken Rice, Asteria Solutions Group, Inc <ken at asteriasgi.com>
* Paul D. Tinsley <pdt at jackhammer.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
*
*
* sofia_ref.c -- SOFIA SIP Endpoint (registration code)
@@ -56,6 +57,8 @@
reg_state_t ostate = gateway_ptr->state;
switch (ostate) {
+ case REG_STATE_NOREG:
+ break;
case REG_STATE_REGISTER:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registered %s\n", gateway_ptr->name);
gateway_ptr->expires = now + gateway_ptr->freq;
@@ -244,6 +247,7 @@
switch_event_t *event;
const char *rpid = "unknown";
const char *display = "\"user\"";
+ char network_addr[80];
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
@@ -322,7 +326,8 @@
}
if (!authorization || stale) {
- snprintf(params, sizeof(params), "from_user=%s&from_host=%s&contact=%s", from_user, from_host, contact_str);
+ get_addr(network_addr, sizeof(network_addr), &((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
+ snprintf(params, sizeof(params), "network_addr=%s&from_user=%s&from_host=%s&contact=%s", network_addr, from_user, from_host, contact_str);
if (switch_xml_locate("directory", "domain", "name", from_host, &xml, &domain, params) != SWITCH_STATUS_SUCCESS) {
@@ -777,3 +782,4 @@
+
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c Mon Apr 9 12:32:10 2007
@@ -26,6 +26,7 @@
* Anthony Minessale II <anthmct at yahoo.com>
* Michael Jerris <mike at jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
*
*
* switch_core.c -- Main Core Library
@@ -445,6 +446,12 @@
if (!strcasecmp(var, "max-sessions")) {
switch_core_session_limit(atoi(val));
}
+ else if (!strcasecmp(var, "rtp-start-port")) {
+ switch_rtp_set_start_port((switch_port_t)atoi(val));
+ }
+ else if (!strcasecmp(var, "rtp-end-port")) {
+ switch_rtp_set_end_port((switch_port_t)atoi(val));
+ }
}
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c Mon Apr 9 12:32:10 2007
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II <anthmct at yahoo.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
*
*
* switch_rtp.c -- RTP
@@ -50,6 +51,8 @@
#define MASTER_KEY_LEN 30
#define RTP_MAGIC_NUMBER 42
+static switch_port_t START_PORT = RTP_START_PORT;
+static switch_port_t END_PORT = RTP_END_PORT;
static switch_port_t NEXT_PORT = RTP_START_PORT;
static switch_mutex_t *port_lock = NULL;
@@ -263,6 +266,43 @@
global_init = 1;
}
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port)
+{
+ if (port) {
+ if (port_lock) {
+ switch_mutex_lock(port_lock);
+ }
+ if (NEXT_PORT == START_PORT) {
+ NEXT_PORT = port;
+ }
+ START_PORT = port;
+ if (NEXT_PORT < START_PORT) {
+ NEXT_PORT = START_PORT;
+ }
+ if (port_lock) {
+ switch_mutex_unlock(port_lock);
+ }
+ }
+ return START_PORT;
+}
+
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port)
+{
+ if (port) {
+ if (port_lock) {
+ switch_mutex_lock(port_lock);
+ }
+ END_PORT = port;
+ if (NEXT_PORT > END_PORT) {
+ NEXT_PORT = START_PORT;
+ }
+ if (port_lock) {
+ switch_mutex_unlock(port_lock);
+ }
+ }
+ return END_PORT;
+}
+
SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(void)
{
switch_port_t port;
@@ -270,8 +310,8 @@
switch_mutex_lock(port_lock);
port = NEXT_PORT;
NEXT_PORT += 2;
- if (NEXT_PORT > RTP_END_PORT) {
- NEXT_PORT = RTP_START_PORT;
+ if (NEXT_PORT > END_PORT) {
+ NEXT_PORT = START_PORT;
}
switch_mutex_unlock(port_lock);
return port;
@@ -772,7 +812,6 @@
return -1;
}
-
if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
@@ -787,22 +826,6 @@
if (bytes < 0) {
return (int) bytes;
- } else if (bytes > 0 && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) {
- int sbytes = (int) bytes;
- err_status_t stat;
-
- stat = srtp_unprotect(rtp_session->recv_ctx, &rtp_session->recv_msg.header, &sbytes);
- if (stat) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "error: srtp unprotection failed with code %d%s\n", stat,
- stat == err_status_replay_fail ? " (replay check failed)" : stat == err_status_auth_fail ? " (auth check failed)" : "");
- return -1;
- }
- bytes = sbytes;
- }
-
- if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
- continue;
}
if (rtp_session->timer.interval) {
@@ -818,26 +841,63 @@
}
}
-
-
if (check) {
do_2833(rtp_session);
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
+ uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
/* We're late! We're Late! */
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
switch_yield(1000);
continue;
}
- memset(&rtp_session->recv_msg, 0, SWITCH_RTP_CNG_PAYLOAD);
- rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
+
+ memset(data, 0, 2);
+ data[0] = 65;
+
+ rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
*flags |= SFF_CNG;
- /* Return a CNG frame */
- *payload_type = SWITCH_RTP_CNG_PAYLOAD;
- return SWITCH_RTP_CNG_PAYLOAD + rtp_header_len;
+ *payload_type = (switch_payload_t)rtp_session->recv_msg.header.pt;
+ return 2 + rtp_header_len;
}
}
+ if (bytes && rtp_session->recv_msg.header.version != 2) {
+ uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
+ if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) {
+ handle_ice(rtp_session, (void *) &rtp_session->recv_msg, bytes);
+ }
+
+ if (rtp_session->invalid_handler) {
+ rtp_session->invalid_handler(rtp_session, rtp_session->sock, (void *) &rtp_session->recv_msg, bytes, rtp_session->from_addr);
+ }
+
+ memset(data, 0, 2);
+ data[0] = 65;
+
+ rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
+ *flags |= SFF_CNG;
+ *payload_type = (switch_payload_t)rtp_session->recv_msg.header.pt;
+ return 2 + rtp_header_len;
+ }
+
+
+
+
+ if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) {
+ int sbytes = (int) bytes;
+ err_status_t stat;
+
+ stat = srtp_unprotect(rtp_session->recv_ctx, &rtp_session->recv_msg.header, &sbytes);
+ if (stat) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "error: srtp unprotection failed with code %d%s\n", stat,
+ stat == err_status_replay_fail ? " (replay check failed)" : stat == err_status_auth_fail ? " (auth check failed)" : "");
+ return -1;
+ }
+ bytes = sbytes;
+ }
+
if (status == SWITCH_STATUS_BREAK || bytes == 0) {
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DATAWAIT)) {
switch_yield((rtp_session->ms_per_packet / 1000) * 750);
@@ -846,49 +906,45 @@
return 0;
}
-
- if (rtp_session->recv_msg.header.version) {
- if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ)
- && switch_sockaddr_get_port(rtp_session->from_addr)) {
- char *tx_host;
- char *old_host;
- char bufa[30], bufb[30];
- tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
- old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
-
- if ((switch_sockaddr_get_port(rtp_session->from_addr) != rtp_session->remote_port)
- || strcmp(tx_host, old_host)) {
- const char *err;
- uint32_t old = rtp_session->remote_port;
-
- if (!switch_strlen_zero(tx_host) && switch_sockaddr_get_port(rtp_session->from_addr) > 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
- "Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host,
- switch_sockaddr_get_port(rtp_session->from_addr));
- switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), &err);
- }
+
+
+ if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
+
+ char *tx_host;
+ char *old_host;
+ char bufa[30], bufb[30];
+ tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
+ old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
+
+ if ((switch_sockaddr_get_port(rtp_session->from_addr) != rtp_session->remote_port)
+ || strcmp(tx_host, old_host)) {
+ const char *err;
+ uint32_t old = rtp_session->remote_port;
+
+ if (!switch_strlen_zero(tx_host) && switch_sockaddr_get_port(rtp_session->from_addr) > 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host,
+ switch_sockaddr_get_port(rtp_session->from_addr));
+ switch_rtp_set_remote_address(rtp_session, tx_host, switch_sockaddr_get_port(rtp_session->from_addr), &err);
}
- switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
+ switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
- if (rtp_session->recv_msg.header.version == 2) {
- if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) {
- rtp_session->recv_msg.header.pt = 97;
- }
- rtp_session->rseq = ntohs((uint16_t) rtp_session->recv_msg.header.seq);
- rtp_session->rpayload = (switch_payload_t) rtp_session->recv_msg.header.pt;
- } else {
- if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) {
- handle_ice(rtp_session, (void *) &rtp_session->recv_msg, bytes);
- }
+ if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
+ continue;
+ }
- if (rtp_session->invalid_handler) {
- rtp_session->invalid_handler(rtp_session, rtp_session->sock, (void *) &rtp_session->recv_msg, bytes, rtp_session->from_addr);
- }
- return 0;
+
+
+ if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) {
+ rtp_session->recv_msg.header.pt = 97;
}
+ rtp_session->rseq = ntohs((uint16_t) rtp_session->recv_msg.header.seq);
+ rtp_session->rpayload = (switch_payload_t) rtp_session->recv_msg.header.pt;
+
+
/* RFC2833 ... TBD try harder to honor the duration etc. */
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)
&& rtp_session->recv_msg.header.pt == rtp_session->te) {
@@ -923,9 +979,8 @@
rtp_session->dtmf_data.dc = 0;
}
}
-
+
continue;
-
}
break;
@@ -1182,12 +1237,11 @@
}
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) &&
- rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode &&
- ((datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) ||
- (datalen > SWITCH_RTP_CNG_PAYLOAD && rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame == 0))) {
- int16_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE / sizeof(int16_t)];
- uint32_t rate;
- uint32_t flags;
+ rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode) {
+
+ int16_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE / sizeof(int16_t)] = {0};
+ uint32_t rate = 0;
+ uint32_t flags = 0;
uint32_t len = sizeof(decoded);
time_t now = time(NULL);
send = 0;
@@ -1205,6 +1259,7 @@
datalen,
rtp_session->vad_data.read_codec->implementation->samples_per_second,
decoded, &len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
+
uint32_t energy = 0;
uint32_t x, y = 0, z = len / sizeof(int16_t);
@@ -1215,7 +1270,7 @@
energy += abs(decoded[y]);
y += rtp_session->vad_data.read_codec->implementation->number_of_channels;
}
-
+
if (++rtp_session->vad_data.start_count < rtp_session->vad_data.start) {
send = 1;
} else {
@@ -1274,35 +1329,23 @@
if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING)) {
send = 1;
- } else {
- if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_CNG)
- && ++rtp_session->vad_data.cng_count >= rtp_session->vad_data.cng_freq) {
- rtp_session->send_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
- memset(rtp_session->send_msg.body, 255, SWITCH_RTP_CNG_PAYLOAD);
- /* rtp_session->send_msg.header.ts = htonl(rtp_session->vad_data.ts);
- * rtp_session->vad_data.ts++;
- */
- bytes = SWITCH_RTP_CNG_PAYLOAD;
- send = 1;
- rtp_session->vad_data.cng_count = 0;
- }
- }
-
+ }
}
} else {
return SWITCH_STATUS_GENERR;
}
}
- rtp_session->last_write_ts = ntohl(send_msg->header.ts);
- rtp_session->last_write_ssrc = ntohl(send_msg->header.ssrc);
- rtp_session->last_write_seq = rtp_session->seq;
- if (rtp_session->last_write_seq <= rtp_session->dtmf_data.out_digit_seq) {
+ if (rtp_session->last_write_seq >0 && rtp_session->last_write_seq <= rtp_session->dtmf_data.out_digit_seq) {
send = 0;
}
if (send) {
+
+ rtp_session->last_write_ts = ntohl(send_msg->header.ts);
+ rtp_session->last_write_ssrc = ntohl(send_msg->header.ssrc);
+ rtp_session->last_write_seq = rtp_session->seq;
if (rtp_session->timer.interval) {
switch_core_timer_check(&rtp_session->timer);
rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
@@ -1360,7 +1403,8 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
return SWITCH_STATUS_FALSE;
}
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Activate VAD codec %s %dms\n", codec->implementation->iananame,
+ codec->implementation->microseconds_per_frame / 1000);
rtp_session->vad_data.diff_level = 400;
rtp_session->vad_data.hangunder = 15;
rtp_session->vad_data.hangover = 40;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_xml.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_xml.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_xml.c Mon Apr 9 12:32:10 2007
@@ -1570,7 +1570,7 @@
// Adds a child tag. off is the offset of the child tag relative to the start
// of the parent tag's character content. Returns the child tag
-switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off)
+SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off)
{
switch_xml_t child;
@@ -1587,7 +1587,7 @@
}
// sets the character content for the given tag and returns the tag
-switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt)
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *txt)
{
if (!xml)
return NULL;
More information about the Freeswitch-svn
mailing list