[svn-commits] oej: branch oej/teapot-1.8 r412032 - in /team/oej/teapot-1.8: channels/sip/in...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Apr 9 05:09:27 CDT 2014


Author: oej
Date: Wed Apr  9 05:09:20 2014
New Revision: 412032

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=412032
Log:
Cleaning up after the merge

Modified:
    team/oej/teapot-1.8/channels/sip/include/sip.h
    team/oej/teapot-1.8/funcs/func_frame_trace.c
    team/oej/teapot-1.8/main/channel.c
    team/oej/teapot-1.8/main/features.c
    team/oej/teapot-1.8/res/res_noise.c

Modified: team/oej/teapot-1.8/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/teapot-1.8/channels/sip/include/sip.h?view=diff&rev=412032&r1=412031&r2=412032
==============================================================================
--- team/oej/teapot-1.8/channels/sip/include/sip.h (original)
+++ team/oej/teapot-1.8/channels/sip/include/sip.h Wed Apr  9 05:09:20 2014
@@ -370,6 +370,7 @@
 #define SIP_PAGE3_100REL                      (1 << 3)  /*!< D: If PRACK is active for a specific dialog */
 #define SIP_PAGE3_INVITE_WAIT_FOR_PRACK (1 << 4)  /*!< D: Wait for PRACK response before sending 200 OK */
 #define SIP_PAGE3_ANSWER_WAIT_FOR_PRACK       (1 << 5)  /*!< D: Send ANSWER when PRACK is received */
+#define SIP_PAGE3_SILENCE_DETECTION      (1 << 21)  /*!< DPG: Enable silence detection?  */
 
 #define SIP_PAGE3_FLAGS_TO_COPY \
        (SIP_PAGE3_SNOM_AOC | SIP_PAGE3_PRACK | SIP_PAGE3_DIRECT_MEDIA_OUTGOING | SIP_PAGE3_SILENCE_DETECTION)

Modified: team/oej/teapot-1.8/funcs/func_frame_trace.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/teapot-1.8/funcs/func_frame_trace.c?view=diff&rev=412032&r1=412031&r2=412032
==============================================================================
--- team/oej/teapot-1.8/funcs/func_frame_trace.c (original)
+++ team/oej/teapot-1.8/funcs/func_frame_trace.c Wed Apr  9 05:09:20 2014
@@ -329,9 +329,6 @@
 		case AST_CONTROL_CNG_END:
 			ast_verbose("SubClass: CNG_END");
 			break;
-		case AST_CONTROL_CNG_END:
-			ast_verbose("SubClass: CNG_END");
-			break;
 		}
 		
 		if (frame->subclass.integer == -1) {

Modified: team/oej/teapot-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/teapot-1.8/main/channel.c?view=diff&rev=412032&r1=412031&r2=412032
==============================================================================
--- team/oej/teapot-1.8/main/channel.c (original)
+++ team/oej/teapot-1.8/main/channel.c Wed Apr  9 05:09:20 2014
@@ -4431,7 +4431,6 @@
 	case AST_CONTROL_AOC:
 	case AST_CONTROL_END_OF_Q:
 	case AST_CONTROL_UPDATE_RTP_PEER:
-	case AST_CONTROL_CNG_END:
 		break;
 
 	case AST_CONTROL_INCOMPLETE:
@@ -7345,12 +7344,6 @@
 				ast_debug(1, "*** Bridge got CNG END frame \n");
 				ast_channel_stop_noise_generator(other, NULL);
 				break;
-			case AST_CONTROL_CNG_END:
-				/* If we are playing out CNG noise on the bridged channel, stop it now. 
-				   otherwise, ignore this frame. */
-				ast_debug(1, "*** Bridge got CNG END frame \n");
-				ast_channel_stop_noise_generator(other, NULL);
-				break;
 			case AST_CONTROL_HOLD:
 			case AST_CONTROL_UNHOLD:
 			case AST_CONTROL_VIDUPDATE:
@@ -8709,306 +8702,6 @@
 
 	ast_free(state);
 }
-
-
-
-#ifdef HAVE_EXP10L
-#define FUNC_EXP10       exp10l
-#elif (defined(HAVE_EXPL) && defined(HAVE_LOGL))
-#define FUNC_EXP10(x)   expl((x) * logl(10.0))
-#elif (defined(HAVE_EXP) && defined(HAVE_LOG))
-#define FUNC_EXP10(x)   (long double)exp((x) * log(10.0))
-#endif
-
-/*! \brief Noise generator default frame */
-static struct ast_frame noiseframedefaults = {
-	.frametype = AST_FRAME_VOICE,
-	.subclass.codec = AST_FORMAT_SLINEAR,
-	.offset = AST_FRIENDLY_OFFSET,
-	.mallocd = 0,
-	.data.ptr = NULL,
-	.datalen = 0,
-	.samples = 0,
-	.src = "noisegenerator",
-	.delivery.tv_sec = 0,
-	.delivery.tv_usec = 0
-};
-
-struct ast_noise_generator {
-	int old_write_format;
-	float level;
-};
-
-
-#ifndef LOW_MEMORY
-/*
- * We pregenerate 64k of white noise samples that will be used instead of
- * generating the samples continously and wasting CPU cycles. The buffer
- * below stores these pregenerated samples.
- */
-static float pregeneratedsamples[65536L];
-#endif
-
-/* 
- * We need a nice, not too expensive, gaussian random number generator.
- * It generates two random numbers at a time, which is great.
- * From http://www.taygeta.com/random/gaussian.html
- */
-static void box_muller_rng(float stddev, float *rn1, float *rn2) {
-	const float twicerandmaxinv = 2.0 / RAND_MAX;
-	float x1, x2, w;
-	 
-	do {
-		x1 = random() * twicerandmaxinv - 1.0;
-		x2 = random() * twicerandmaxinv - 1.0;
-		w = x1 * x1 + x2 * x2;
-	} while (w >= 1.0);
-	
-	w = stddev * sqrt((-2.0 * logf(w)) / w);
-	*rn1 = x1 * w;
-	*rn2 = x2 * w;
-}
-
-static void *noise_generator_alloc(struct ast_channel *chan, void *params) {
-	struct ast_noise_generator *state = params;
-	float level = state->level; 	/* level is noise level in dBov */
-	float *pnoisestddev; 		/* pointer to calculated noise standard dev */
-	const float maxsigma = 32767.0 / 3.0;
-
-	/*
-	 * When level is zero (full power, by definition) standard deviation
-	 * (sigma) is calculated so that 3 * sigma equals max sample value
-	 * before overload. For signed linear, which is what we use, this
-	 * value is 32767. The max value of sigma will therefore be
-	 * 32767.0 / 3.0. This guarantees that roughly 99.7% of the samples
-	 * generated will be between -32767 and +32767. The rest, 0.3%,
-	 * will be clipped to comform to the channel limits, i.e., +/-32767.
-	 * 
-	 */
-	pnoisestddev = malloc(sizeof (float));
-	if(pnoisestddev) {
-		*pnoisestddev = maxsigma * FUNC_EXP10(level / 20.0);
-	}
-
-	return (void *) pnoisestddev;
-}
-
-static void noise_generator_release(struct ast_channel *chan, void *data) {
-	free((float *)data);
-}
-
-/*! \brief Generator of White Noise at a certain level.
-
-Current level is defined in the generator data structure as noiselevel (float) in dBov's
-
-
-	Level is a non-positive number. For example, WhiteNoise(0.0) generates
-	white noise at full power, while WhiteNoise(-3.0) generates white noise at
-	half full power. Every -3dBov's reduces white noise power in half. Full
-	power in this case is defined as noise that overloads the channel roughly 0.3%
-	of the time. Note that values below -69 dBov's start to give out silence
-	frequently, resulting in intermittent noise, i.e, alternating periods of
-	silence and noise.
-
-This code orginally contributed to Asterisk by cmantunes in issue ASTERISK-5263
-as part of res_noise.c
-*/
-static int noise_generate(struct ast_channel *chan, void *data, int len, int samples) {
-#ifdef LOW_MEMORY
-	float randomnumber[2];
-	float sampleamplitude;
-	int j;
-#else
-	uint16_t start;
-#endif
-	float noisestddev = *(float *)data;
-	struct ast_frame f;
-	int16_t *buf, *pbuf;
-	int i;
-
-#ifdef LOW_MEMORY
-	/* We need samples to be an even number */
-	if (samples & 0x1) {
-		ast_log(LOG_WARNING, "Samples (%d) needs to be an even number\n", samples);
-		return -1;
-	}
-#endif
-
-	/* Allocate enough space for samples.
-	 * Remember that slin uses signed dword samples */
-	len = samples * sizeof (int16_t);
-	if(!(buf = ast_alloca(len))) {
-		ast_log(LOG_WARNING, "Unable to allocate buffer to generate %d samples\n", samples);
-		return -1;
-	}
-
-	/* Setup frame */
-	memcpy(&f, &noiseframedefaults, sizeof (f));
-	f.data.ptr = buf;
-	f.datalen = len;
-	f.samples = samples;
-
-	/* Let's put together our frame "data" */
-	pbuf = buf;
-
-#ifdef LOW_MEMORY
-	/* We need to generate samples every time we are called */
-	for (i = 0; i < samples; i += 2) {
-		box_muller_rng(noisestddev, &randomnumber[0], &randomnumber[1]);
-		for (j = 0; j < 2; j++) {
-			sampleamplitude = randomnumber[j];
-			if (sampleamplitude > 32767.0)
-				sampleamplitude = 32767.0;
-			else if (sampleamplitude < -32767.0)
-				sampleamplitude = -32767.0;
-			*(pbuf++) = (int16_t)sampleamplitude;
-		}
-	}
-#else
-	/*
-	 * We are going to use pregenerated samples. But we start at
-	 * different points on the pregenerated samples buffer every time
-	 * to create a little bit more randomness
-	 *
-	 */
-	start = (uint16_t) (65536.0 * random() / RAND_MAX);
-	for (i = 0; i < samples; i++) {
-		*(pbuf++) = (int16_t)(noisestddev * pregeneratedsamples[start++]);
-	}
-#endif
-
-	/* Send it out */
-	if (ast_write(chan, &f) < 0) {
-		ast_log(LOG_WARNING, "Failed to write frame to channel '%s'\n", chan->name);
-		return -1;
-	}
-	return 0;
-}
-
-static struct ast_generator noise_generator = 
-{
-	alloc: noise_generator_alloc,
-	release: noise_generator_release,
-	generate: noise_generate,
-} ;
-
-static void *cng_channel_params_copy(void *data)
-{
-	const struct ast_noise_generator *src = data;
-	struct ast_noise_generator *dest = ast_calloc(1, sizeof(struct ast_noise_generator));
-	if (!dest) {
-		return NULL;
-	}
-	dest->level = src->level;
-	dest->old_write_format = src->old_write_format;
-	return dest;
-}
-
-static void cng_channel_params_destroy(void *data)
-{
-	struct ast_noise_generator *ng = data;
-	ast_free(ng);
-}
-
-static const struct ast_datastore_info cng_channel_datastore_info = {
-	.type = "Comfort Noise Generator",
-	.duplicate = cng_channel_params_copy,
-	.destroy = cng_channel_params_destroy,
-};
-
-static int ast_channel_cng_params_init(struct ast_channel *chan, int level, int old_write_format)
-{
-	struct ast_noise_generator *new_cng;
-	struct ast_datastore *cng_datastore;
-
-	/* If we already have a datastore, reuse it */
-	if ((cng_datastore = ast_channel_datastore_find(chan, &cng_channel_datastore_info, NULL))) {
-		new_cng = cng_datastore->data;
-	} else {
-		/* Create new datastore */
-		new_cng = ast_calloc(1, sizeof(struct ast_noise_generator));
-		if (!new_cng) {
-			return -1;
-		}
-
-		if (!(cng_datastore = ast_datastore_alloc(&cng_channel_datastore_info, NULL))) {
-			cng_channel_params_destroy(new_cng);
-			return -1;
-		}
-		cng_datastore->data = new_cng;
-		ast_channel_datastore_add(chan, cng_datastore);
-	}
-	new_cng->level = level;
-	new_cng->old_write_format = old_write_format;
-
-	return 0;
-}
-
-struct ast_noise_generator *ast_channel_start_noise_generator(struct ast_channel *chan, const float level)
-{
-	struct ast_noise_generator  *state;
-	int i;
-
-#ifndef LOW_MEMORY
-	/* This should only be done once per asterisk instance */
-	if (pregeneratedsamples[0] == 0.0) {
-		for (i = 0; i < sizeof (pregeneratedsamples) / sizeof (pregeneratedsamples[0]); i += 2) {
-			box_muller_rng(1.0, &pregeneratedsamples[i], &pregeneratedsamples[i + 1]);
-		}
-	}
-#endif
-
-	if (level > 0) {
-		ast_log(LOG_ERROR, "Noise generator: Invalid argument -  non-positive floating-point argument for noise level in dBov's required \n");
-		return NULL;
-	}
-
-	if (!(state = ast_calloc(1, sizeof(*state)))) {
-		return NULL;
-	}
-
-	state->old_write_format = chan->writeformat;
-	state->level = level;
-
-	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
-		ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
-		ast_free(state);
-		return NULL;
-	}
-
-	/* Store noise generation data in a channel datastore */
-	ast_channel_cng_params_init(chan, level, chan->writeformat);
-
-	ast_activate_generator(chan, &noise_generator, state);
-
-	ast_debug(1, "Started noise generator on '%s'\n", chan->name);
-
-	return state;
-}
-
-void ast_channel_stop_noise_generator(struct ast_channel *chan, struct ast_noise_generator *state)
-{
-	struct ast_datastore *cng_datastore;
-	struct ast_noise_generator *cngstate = state;
-
-	if (!cngstate) {
-		if (!(cng_datastore = ast_channel_datastore_find(chan, &cng_channel_datastore_info, NULL))) {
-			return;
-		}
-		cngstate = cng_datastore->data;
-	}
-
-	/* We will leave the allocated channel datastore in memory for reuse */
-	ast_deactivate_generator(chan);
-
-	ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
-
-	if (ast_set_write_format(chan, cngstate->old_write_format) < 0)
-		ast_log(LOG_ERROR, "Could not return write format to its original state\n");
-
-	ast_free(state);
-}
-
 
 
 /*! \ brief Convert channel reloadreason (ENUM) to text string for manager event */

Modified: team/oej/teapot-1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/teapot-1.8/main/features.c?view=diff&rev=412032&r1=412031&r2=412032
==============================================================================
--- team/oej/teapot-1.8/main/features.c (original)
+++ team/oej/teapot-1.8/main/features.c Wed Apr  9 05:09:20 2014
@@ -4238,12 +4238,6 @@
 				ast_debug(2, "*** Bridge got CNG END frame \n");
 				ast_channel_stop_noise_generator(other, NULL);
 				break;
-			case AST_CONTROL_CNG_END:
-				/* If we are playing out CNG noise on the bridged channel, stop it now. 
-				   otherwise, ignore this frame. */
-				ast_debug(2, "*** Bridge got CNG END frame \n");
-				ast_channel_stop_noise_generator(other, NULL);
-				break;
 			case AST_CONTROL_AOC:
 			case AST_CONTROL_HOLD:
 			case AST_CONTROL_UNHOLD:
@@ -4506,21 +4500,6 @@
 			} else {
 				bridge_cdr = NULL;
 			}
-		} else if (f->frametype == AST_FRAME_CNG) {
-			/* We got a CNG frame 
-			  Check if the bridged channel has active CNG 
-			*/
-			int cngsupport = 0;
-			int len = sizeof(cngsupport);
-			ast_channel_queryoption(other, AST_OPTION_CNG_SUPPORT, &cngsupport, &len, 0);
-			if (cngsupport) {
-				ast_debug(1, "*** Bridge got CNG frame. Forwarding it \n");
-				ast_write(other, f);
-			} else {
-				ast_debug(1, "*** Bridge got CNG frame. Playing out noise. (CNG not supported by other channel) \n");
-				ast_moh_start(other, NULL, NULL);
-			}
-			
 		}
 		/* An "h" exten has been run, so indicate that one has been run. */
 		ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN);

Modified: team/oej/teapot-1.8/res/res_noise.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/teapot-1.8/res/res_noise.c?view=diff&rev=412032&r1=412031&r2=412032
==============================================================================
--- team/oej/teapot-1.8/res/res_noise.c (original)
+++ team/oej/teapot-1.8/res/res_noise.c Wed Apr  9 05:09:20 2014
@@ -162,167 +162,3 @@
                 .load = load_module,
                 .unload = unload_module,
                );
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2005, Digium, Inc.
- *
- * Contributed by Carlos Antunes <cmantunes at gmail.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 Just generate white noise 
- * 
- */
-
-/*** MODULEINFO
-	<support_level>random</support_level>
- ***/
-
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include "asterisk/lock.h"
-#include "asterisk/file.h"
-#include "asterisk/logger.h"
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
-#include "asterisk/module.h"
-#include "asterisk/app.h"
-
-#include <math.h>
-
-static char *app = "WhiteNoise";
-
-
-/*** DOCUMENTATION
-	<application name="WhiteNoise" language="en_US">
-		<synopsis>
-			Generates white noise
-		</synopsis>
-		<syntax>
-		<parameter name="args">
-			<argument name="timeout" required="true" />
-			<argument name="level" required="false" />
-		</parameter>
-		</syntax>
-		<description>
-			<para>Generates white noise at 'level' dBov's for 'timeout' seconds or indefinitely if timeout
-			is absent or is zero.</para>
-			<para>Level is a non-positive number. For example, WhiteNoise(0.0) generates
-			white noise at full power, while WhiteNoise(-3.0) generates white noise at
-			half full power. Every -3dBov's reduces white noise power in half. Full
-			power in this case is defined as noise that overloads the channel roughly 0.3%
-			of the time. Note that values below -69 dBov's start to give out silence
-			frequently, resulting in intermittent noise, i.e, alternating periods of
-			silence and noise.</para>
-
-		</description>
-	</application>
-***/
-
-static int noise_exec(struct ast_channel *chan, const char *data) {
-
-	struct ast_module_user *u;
-	char *excessdata;
-	float level = 0;
-	float timeout = 0;
-	char *s;
-	int res;
-	struct ast_noise_generator *gendata;
-
-        AST_DECLARE_APP_ARGS(args,
-                AST_APP_ARG(timeout);
-                AST_APP_ARG(level);
-        );
-
-	/* Verify we potentially have arguments and get local copy */
-        if (!data) {
-                ast_log(LOG_WARNING, "WhiteNoise usage following: WhiteNoise([timeout[, level]])\n");
-                return -1;
-        }
-	
-	/* Separate arguments */	
-        s = ast_strdupa(data);
-        AST_STANDARD_APP_ARGS(args, s);
-
-	if (args.timeout) {	
-		/* Extract second argument, if available, and validate
-		 * timeout is non-negative. Zero timeout means no timeout */
-		args.timeout = ast_trim_blanks(args.timeout);
-		timeout = strtof(args.timeout, &excessdata);
-		if ((excessdata && *excessdata) || timeout < 0) {
-			ast_log(LOG_WARNING, "Invalid argument 'timeout': WhiteNoise requires non-negative floating-point argument for timeout in seconds\n");				
-			return -1;
-		}
-
-		/* Convert timeout to milliseconds
-		 * and ensure minimum of 20ms      */
-		timeout = roundf(timeout * 1000.0);
-		if (timeout > 0 && timeout < 20) {
-			timeout = 20;
-		}
-	} 
-
-	if (args.level) {
-		/* Extract first argument and ensure we have
-		 * a valid noise level argument value        */
-		args.level = ast_trim_blanks(args.level);
-		level = strtof(args.level, &excessdata);
-		if ((excessdata && *excessdata) || level > 0) {
-			ast_log(LOG_ERROR, "Invalid argument 'level': WhiteNoise requires non-positive floating-point argument for noise level in dBov's\n");
-			return -1;
-		}
-	} 
-
-	ast_debug(1, "Setting up white noise generator with level %.1fdBov's and %.0fms %stimeout\n", level, timeout, timeout == 0 ? "(no) " : "");
-
-	u = ast_module_user_add(chan);
-	if (chan->_state != AST_STATE_UP) {
-		ast_answer(chan);
-	}
-	gendata = ast_channel_start_noise_generator(chan, level);
-	if (data == NULL)	{
-		ast_log(LOG_WARNING, "Failed to activate white noise generator on '%s'\n",chan->name);
-		res = -1;
-	} else {
-		/* Just do the noise... */
-		res = -1;
-		if (timeout > 0) {
-			res = ast_safe_sleep(chan, timeout);
-		} else  {
-			while(!ast_safe_sleep(chan, 10000));
-		}
-		ast_channel_stop_noise_generator(chan, gendata);
-	}
-	ast_module_user_remove(u);
-	return res;
-}
-
-static int unload_module(void) {
-	ast_module_user_hangup_all();
-	
-	return ast_unregister_application(app);
-}
-
-static int load_module(void) {
-	return ast_register_application_xml(app, noise_exec);
-}
-
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "White Noise Generator Application",
-                .load = load_module,
-                .unload = unload_module,
-               );




More information about the svn-commits mailing list