[asterisk-commits] oej: branch oej/silence-detection-games-1.8 r411913 - in /team/oej/silence-de...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 8 02:37:59 CDT 2014


Author: oej
Date: Tue Apr  8 02:37:52 2014
New Revision: 411913

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411913
Log:
Looking good

Modified:
    team/oej/silence-detection-games-1.8/channels/sip/include/sip.h
    team/oej/silence-detection-games-1.8/main/silencedetection.c

Modified: team/oej/silence-detection-games-1.8/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/channels/sip/include/sip.h?view=diff&rev=411913&r1=411912&r2=411913
==============================================================================
--- team/oej/silence-detection-games-1.8/channels/sip/include/sip.h (original)
+++ team/oej/silence-detection-games-1.8/channels/sip/include/sip.h Tue Apr  8 02:37:52 2014
@@ -62,7 +62,7 @@
 #define DEFAULT_AUTHLIMIT            100
 #define DEFAULT_AUTHTIMEOUT          30
 #define DEFAULT_SILENCELEVEL	     850
-#define DEFAULT_SILENCEFRAMES	     2   /* Number of frames of silence to let through before we start suppressing it */
+#define DEFAULT_SILENCEFRAMES	     7   /* Number of frames of silence to let through before we start suppressing it */
 
 /* guard limit must be larger than guard secs */
 /* guard min must be < 1000, and should be >= 250 */

Modified: team/oej/silence-detection-games-1.8/main/silencedetection.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/main/silencedetection.c?view=diff&rev=411913&r1=411912&r2=411913
==============================================================================
--- team/oej/silence-detection-games-1.8/main/silencedetection.c (original)
+++ team/oej/silence-detection-games-1.8/main/silencedetection.c Tue Apr  8 02:37:52 2014
@@ -37,13 +37,6 @@
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-//#include <time.h>
-//#include <string.h>
-//#include <stdio.h>
-//#include <stdlib.h>
-//#include <unistd.h>
-//#include <errno.h>
 
 #include "asterisk/options.h"
 #include "asterisk/logger.h"
@@ -104,6 +97,7 @@
 
 	/* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
 	if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE) {
+		ast_debug(7, "Audiohook giving up - STATUS_DONE \n");
 		return 0;
 	}
 
@@ -116,6 +110,7 @@
 	}
 
 	sildet = datastore->data;
+	ast_debug(9, "Audiohook grabbed a frame. Mmmmmm \n");
 
 
 	/* If this is audio then allow them to increase/decrease the gains */
@@ -123,7 +118,7 @@
 		int dsptime = 0;
 
 		/* Based on direction of frame grab the gain, and confirm it is applicable */
-		if (direction == AST_AUDIOHOOK_DIRECTION_READ) {
+		if (direction == AST_AUDIOHOOK_DIRECTION_WRITE) {
 			/* DETECT SILENCE HERE */
 			ast_dsp_silence(sildet->dsp, frame, &dsptime);
 			if (option_debug && sildet->silencecounter == 0 && dsptime) {
@@ -134,14 +129,18 @@
 					ast_debug(8, " ++++ Silence stopped ++++ on chan %s\n", chan->name);
 				}
 				sildet->silencecounter = 0;		/* No more silence */
+				sildet->detect = 0;		/* No more silence */
 			} else {
 				if (option_debug && sildet->silencecounter > 0) {
-					ast_debug(8, "          ++++ Silence continues ++++ on chan %s\n", chan->name);
+					ast_debug(8, "          ++++ Silence continues %d ++++ on chan %s\n", sildet->silencecounter, chan->name);
 				}
 				sildet->silencecounter++;
 			}
-			/* Ok, we just want to reset all audio in this frame. Keep NOTHING, thanks. */
-			ast_frame_clear(frame);
+			if (sildet->detect == 0 && sildet->silencecounter > sildet->silenceframes) {
+				ast_debug(8, "          ++++ Silence suppression should start now ++++ on chan %s\n", chan->name);
+				sildet->detect = 1;
+			}
+			/* Do not touch the frame yet */
 		}
 	}
 	ast_channel_unlock(chan);
@@ -176,7 +175,7 @@
 		return NULL;
 	}
 	ast_dsp_set_threshold(sildet->dsp, ast_dsp_get_threshold_from_settings(sildet->silencelevel));
-	ast_audiohook_init(&sildet->audiohook, AST_AUDIOHOOK_TYPE_SILDET, "Sildet");
+	ast_audiohook_init(&sildet->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "Sildet");
 	sildet->audiohook.manipulate_callback = silence_detection_callback;
 	sildet->active = 0;
 	sildet->silencecounter = 0;
@@ -211,6 +210,9 @@
 	if (!chan) {
 		ast_log(LOG_WARNING, "No channel was provided.\n" );
 		return -1;
+	}
+	if (silenceframes < 3) {
+		ast_log(LOG_WARNING, "Silenceframes is set very low. Are you sure? Value=%d\n", silenceframes);
 	}
 
 	ast_channel_lock(chan);
@@ -255,5 +257,5 @@
 	}
 	ast_channel_unlock(chan);
 
-	return 0;
-}
+	return 1;
+}




More information about the asterisk-commits mailing list