[asterisk-commits] may: branch may/chan_ooh323_evo r228765 - in /team/may/chan_ooh323_evo: ./ ad...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 6 19:37:22 CST 2009


Author: may
Date: Fri Nov  6 19:37:20 2009
New Revision: 228765

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=228765
Log:
changes.may, todo.may created,

chan_ooh323 debug message on hangup corection,
unsupported message removed


Added:
    team/may/chan_ooh323_evo/addons/app_fasdetect.c   (with props)
    team/may/chan_ooh323_evo/addons/todo.may   (with props)
    team/may/chan_ooh323_evo/changes.may   (with props)
Modified:
    team/may/chan_ooh323_evo/addons/chan_ooh323.c
    team/may/chan_ooh323_evo/include/asterisk/frame.h
    team/may/chan_ooh323_evo/main/channel.c
    team/may/chan_ooh323_evo/res/res_rtp_asterisk.c

Added: team/may/chan_ooh323_evo/addons/app_fasdetect.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/app_fasdetect.c?view=auto&rev=228765
==============================================================================
--- team/may/chan_ooh323_evo/addons/app_fasdetect.c (added)
+++ team/may/chan_ooh323_evo/addons/app_fasdetect.c Fri Nov  6 19:37:20 2009
@@ -1,0 +1,193 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2005, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief FasDetect application
+ *
+ * \author Alexandr Anikin <may at telecom-service.ru>
+ * 
+ * \ingroup applications
+ */
+
+#include "asterisk.h"
+
+#include "asterisk/file.h"
+#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
+#include "asterisk/module.h"
+#include "asterisk/lock.h"
+#include "asterisk/app.h"
+#include "asterisk/dsp.h"
+#include "asterisk/causes.h"
+#include "../main/dsp.c"
+
+/*** DOCUMENTATION
+	<application name="FasDetect" language="en_US">
+		<synopsis>
+			Detect false answer on channel.
+		</synopsis>
+		<syntax>
+			<parameter name="Technology/Resource" required="true" />
+			<parameter name="options">
+				<optionlist>
+					<option name="s">
+						<para>Detect silence</para>
+					</option>
+					<option name="h">
+						<para>Hang up channel on fas detected</para>
+					</option>
+				</optionlist>
+			</parameter>
+		</syntax>	
+		<description>
+			<para>Detect false answer on channel</para>
+		</description>
+	</application>
+
+ ***/
+
+static char *app = "FasDetect";
+
+#define DETECTLIMIT 3000		/* limit detection up to 3 sec */
+#define FAS_SILENCE 2000		/* silence from 2 sec is fas */
+#define SILENCE_THRESHOLD 1024		/* silence level */
+
+enum {
+	OPTION_SILENCE = (1 << 0),
+};
+
+
+AST_APP_OPTIONS(app_opts,{
+	AST_APP_OPTION('s', OPTION_SILENCE),
+});
+
+static int fasdetect_exec(struct ast_channel *chan, const char *data)
+{
+	struct ast_flags flags;
+	char* opts[0], *parse;
+	int sthreshold = SILENCE_THRESHOLD;
+	tone_detect_state_t f400_tone_state;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(channel);
+		AST_APP_ARG(options);
+	);
+	int original_read_fmt, original_write_fmt, original_peer_fmt;
+	int res, fasdetected, notsilence, csilence;
+	int count = 0, totalsilence = 0, lenmatch;
+	struct ast_dsp *dsp;
+	struct ast_channel *peer = NULL;
+	struct ast_channel_iterator *iter;
+	
+	parse = ast_strdupa(data);
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (args.argc > 0)
+		ast_app_parse_options(app_opts, &flags, opts, args.options);
+
+	if (args.channel) {
+        	lenmatch = strlen(args.channel);
+
+        	if ((iter = ast_channel_iterator_by_name_new(args.channel, lenmatch))) {
+			peer = ast_channel_iterator_next(iter);
+        	}
+		ast_channel_iterator_destroy(iter);
+	}
+
+        original_read_fmt = chan->readformat;
+	if (original_read_fmt != AST_FORMAT_SLINEAR) {
+		if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
+			ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n");
+			return -1;
+		}
+	}
+	
+	if (peer) {
+	 /* ast_verbose("peer is %s\n", peer->name); */
+         original_peer_fmt = peer->writeformat;
+		if (original_peer_fmt != AST_FORMAT_SLINEAR) {
+			if ((res = ast_set_write_format(peer, AST_FORMAT_SLINEAR)) < 0) {
+				ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n");
+				return -1;
+			}
+		}
+	}
+	
+
+	if (!(dsp = ast_dsp_new())) {
+		ast_log(LOG_ERROR, "Unable to allocate dsp structure\n");
+		return -1;
+	}
+	ast_dsp_set_threshold(dsp, sthreshold);
+	ast_tone_detect_init(&f400_tone_state, 400, 420, 16);
+
+	fasdetected = 0;
+	notsilence = 0;
+	while (ast_waitfor(chan, -1) > -1 && count < DETECTLIMIT*8) {
+		struct ast_frame *f = ast_read(chan);
+		if (!f) {
+			break;
+		}
+
+		count += f->datalen / 2;
+
+		if (tone_detect(dsp, &f400_tone_state, 
+				f->data.ptr, f->datalen / 2)) {
+			ast_debug(1,"fas tone detected on %s\n", chan->name);
+			fasdetected = 1;
+			break;
+		}
+
+		csilence = 0;
+		ast_dsp_silence(dsp, f, &csilence);
+		if (!notsilence && (csilence == count / 8)) {
+			totalsilence = csilence;
+			if (totalsilence >= FAS_SILENCE) {
+				fasdetected = 1;
+				break;
+			}
+		} else {
+			totalsilence = 0;
+			notsilence = 1;
+		}
+		if (peer) ast_write(peer, f);
+	}
+
+	if (fasdetected) {
+		ast_verbose("    -- %s fas detected, hanging up\n", chan->name);
+		ast_softhangup(chan, AST_CAUSE_NORMAL_UNSPECIFIED);
+		pbx_builtin_setvar_helper(chan, "MACRO_RESULT", "CONGESTION");
+	} else {
+		ast_set_read_format(chan, original_read_fmt);
+		if (peer)
+			ast_set_write_format(peer, original_peer_fmt);
+	}
+	return 0;
+}
+
+static int unload_module(void)
+{
+	return ast_unregister_application(app);
+}
+
+static int load_module(void)
+{
+	return ast_register_application_xml(app, fasdetect_exec);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Detect false answer on channel");

Propchange: team/may/chan_ooh323_evo/addons/app_fasdetect.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/may/chan_ooh323_evo/addons/app_fasdetect.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/may/chan_ooh323_evo/addons/app_fasdetect.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/may/chan_ooh323_evo/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/chan_ooh323.c?view=diff&rev=228765&r1=228764&r2=228765
==============================================================================
--- team/may/chan_ooh323_evo/addons/chan_ooh323.c (original)
+++ team/may/chan_ooh323_evo/addons/chan_ooh323.c Fri Nov  6 19:37:20 2009
@@ -13,6 +13,8 @@
  * maintain this copyright notice.
  *
  *****************************************************************************/
+
+/* Reworked version I, Nov-2009, by Alexandr Anikin, may at telecom-service.ru */
 
 
 /*** MODULEINFO
@@ -1015,7 +1017,7 @@
 		ast_update_use_count();
 	  
 	} else {
-		ast_log(LOG_DEBUG, "No call to hangup\n" );
+		ast_debug(1, "No call to hangup\n" );
 	}
 	
 	if (gH323Debug)
@@ -3077,14 +3079,6 @@
 		.onModeChanged = onModeChanged
 	};
 
-	ast_log(LOG_NOTICE, 
-		"---------------------------------------------------------------------------------\n"
-		"---  ******* IMPORTANT NOTE ***********\n"
-		"---\n"
-		"---  This module is currently unsupported.  Use it at your own risk.\n"
-		"---\n"
-		"---------------------------------------------------------------------------------\n");
-
 	myself = ast_module_info->self;
 
 	h225Callbacks.onReceivedSetup = &ooh323_onReceivedSetup;

Added: team/may/chan_ooh323_evo/addons/todo.may
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/todo.may?view=auto&rev=228765
==============================================================================
--- team/may/chan_ooh323_evo/addons/todo.may (added)
+++ team/may/chan_ooh323_evo/addons/todo.may Fri Nov  6 19:37:20 2009
@@ -1,0 +1,10 @@
+chan_ooh323:
+
+	directmedia interface (rtp directly between peers)
+	myip options (multihomed and multipeering based on our ip)
+	gatekeeper interface enhancement (authentication as first)
+	documentation and program code readability and cleanup
+
+other:
+	app_t38gateway (t38 transparent between t38 and non-t38 channels, this 
+	work is partially done by others)

Propchange: team/may/chan_ooh323_evo/addons/todo.may
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/may/chan_ooh323_evo/addons/todo.may
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/may/chan_ooh323_evo/addons/todo.may
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/may/chan_ooh323_evo/changes.may
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/changes.may?view=auto&rev=228765
==============================================================================
--- team/may/chan_ooh323_evo/changes.may (added)
+++ team/may/chan_ooh323_evo/changes.may Fri Nov  6 19:37:20 2009
@@ -1,0 +1,10 @@
+second stage of development chan_ooh323 and related.
+
+
+core show channels correction (issue #16161)
+
+integer instead of char framing in ast_codec_pref (framing was no more than 127 ms because signed char)
+
+g723 is smoother-aware codec (it's really ;))
+
+app_fasdetect in addons (helper application which try to detect false answer, for now it can detect 400, 444, 500 hz ringing tone and silence)

Propchange: team/may/chan_ooh323_evo/changes.may
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/may/chan_ooh323_evo/changes.may
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/may/chan_ooh323_evo/changes.may
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/may/chan_ooh323_evo/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/include/asterisk/frame.h?view=diff&rev=228765&r1=228764&r2=228765
==============================================================================
--- team/may/chan_ooh323_evo/include/asterisk/frame.h (original)
+++ team/may/chan_ooh323_evo/include/asterisk/frame.h Fri Nov  6 19:37:20 2009
@@ -37,7 +37,7 @@
 
 struct ast_codec_pref {
 	char order[sizeof(format_t) * 8];
-	char framing[sizeof(format_t) * 8];
+	int framing[sizeof(format_t) * 8];
 };
 
 /*!

Modified: team/may/chan_ooh323_evo/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/main/channel.c?view=diff&rev=228765&r1=228764&r2=228765
==============================================================================
--- team/may/chan_ooh323_evo/main/channel.c (original)
+++ team/may/chan_ooh323_evo/main/channel.c Fri Nov  6 19:37:20 2009
@@ -1321,12 +1321,12 @@
 
 	ast_channel_lock(chan);
 
-	if (cmp_args->name) { /* match by name */
+	if (cmp_args->name && cmp_args->name[0]) { /* match by name */
 		if ((!name_len && strcasecmp(chan->name, cmp_args->name)) ||
 				(name_len && strncasecmp(chan->name, cmp_args->name, name_len))) {
 			ret = 0; /* name match failed */
 		}
-	} else if (cmp_args->exten) {
+	} else if (cmp_args->exten && cmp_args->exten[0]) {
 		if (cmp_args->context && strcasecmp(chan->context, cmp_args->context) &&
 				strcasecmp(chan->macrocontext, cmp_args->context)) {
 			ret = 0; /* context match failed */
@@ -1335,11 +1335,13 @@
 				strcasecmp(chan->macroexten, cmp_args->exten)) {
 			ret = 0; /* exten match failed */
 		}
-	} else if (cmp_args->uniqueid) {
+	} else if (cmp_args->uniqueid && cmp_args->uniqueid[0]) {
 		if ((!name_len && strcasecmp(chan->uniqueid, cmp_args->uniqueid)) ||
 				(name_len && strncasecmp(chan->uniqueid, cmp_args->uniqueid, name_len))) {
 			ret = 0; /* uniqueid match failed */
 		}
+	} else {
+		ret = 0;
 	}
 
 	ast_channel_unlock(chan);

Modified: team/may/chan_ooh323_evo/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/res/res_rtp_asterisk.c?view=diff&rev=228765&r1=228764&r2=228765
==============================================================================
--- team/may/chan_ooh323_evo/res/res_rtp_asterisk.c (original)
+++ team/may/chan_ooh323_evo/res/res_rtp_asterisk.c Fri Nov  6 19:37:20 2009
@@ -1160,7 +1160,6 @@
 
 		switch (subclass) {
 		case AST_FORMAT_SPEEX:
-		case AST_FORMAT_G723_1:
 		case AST_FORMAT_SIREN7:
 		case AST_FORMAT_SIREN14:
 			/* these are all frame-based codecs and cannot be safely run through




More information about the asterisk-commits mailing list