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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 7 07:09:04 CDT 2014


Author: oej
Date: Mon Apr  7 07:08:53 2014
New Revision: 411788

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411788
Log:
Activating silence detection, not being able to do anything with it yet.

Modified:
    team/oej/silence-detection-games-1.8/channels/chan_sip.c
    team/oej/silence-detection-games-1.8/include/asterisk/audiohook.h
    team/oej/silence-detection-games-1.8/main/audiohook.c

Modified: team/oej/silence-detection-games-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/channels/chan_sip.c?view=diff&rev=411788&r1=411787&r2=411788
==============================================================================
--- team/oej/silence-detection-games-1.8/channels/chan_sip.c (original)
+++ team/oej/silence-detection-games-1.8/channels/chan_sip.c Mon Apr  7 07:08:53 2014
@@ -7977,6 +7977,7 @@
 	struct ast_frame *fr;
 	struct sip_pvt *p = ast->tech_pvt;
 	int faxdetected = FALSE;
+	int dsptime = 0;
 
 	sip_pvt_lock(p);
 	fr = sip_rtp_read(ast, p, &faxdetected);
@@ -8017,6 +8018,22 @@
 		ast_frfree(fr);
 		fr = &ast_null_frame;
 	}
+	if (p->sildet && fr->frametype == AST_FRAME_VOICE && ast->_state == AST_STATE_UP) {
+		ast_dsp_func(p->sildet, fr, &dsptime);
+		if (p->silencecounter == 0 && dsptime) {
+			ast_debug(8, " ++++ Silence started ++++ on chan %s\n", ast->name);
+		}
+		if (!dsptime) {
+			p->silencecounter = 0;		/* No more silence */
+			ast_debug(8, " ++++ Silence stopped ++++ on chan %s\n", ast->name);
+		} else {
+			if (p->silencecounter > 0) {
+				ast_debug(8, "          ++++ Silence continues ++++ on chan %s\n", ast->name);
+			}
+			p->silencecounter++;
+		}
+	}
+
 
 	sip_pvt_unlock(p);
 

Modified: team/oej/silence-detection-games-1.8/include/asterisk/audiohook.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/include/asterisk/audiohook.h?view=diff&rev=411788&r1=411787&r2=411788
==============================================================================
--- team/oej/silence-detection-games-1.8/include/asterisk/audiohook.h (original)
+++ team/oej/silence-detection-games-1.8/include/asterisk/audiohook.h Mon Apr  7 07:08:53 2014
@@ -37,6 +37,7 @@
 	AST_AUDIOHOOK_TYPE_SPY = 0,    /*!< Audiohook wants to receive audio */
 	AST_AUDIOHOOK_TYPE_WHISPER,    /*!< Audiohook wants to provide audio to be mixed with existing audio */
 	AST_AUDIOHOOK_TYPE_MANIPULATE, /*!< Audiohook wants to manipulate the audio */
+	AST_AUDIOHOOK_TYPE_SILDET,     /*!< Audiohook to detect silence. That's all */
 };
 
 enum ast_audiohook_status {

Modified: team/oej/silence-detection-games-1.8/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/main/audiohook.c?view=diff&rev=411788&r1=411787&r2=411788
==============================================================================
--- team/oej/silence-detection-games-1.8/main/audiohook.c (original)
+++ team/oej/silence-detection-games-1.8/main/audiohook.c Mon Apr  7 07:08:53 2014
@@ -21,6 +21,7 @@
  * \brief Audiohooks Architecture
  *
  * \author Joshua Colp <jcolp at digium.com>
+ * \author Olle E. Johansson <oej at edvina.net> - the silence detection hook
  */
 
 /*** MODULEINFO
@@ -79,6 +80,9 @@
 	case AST_AUDIOHOOK_TYPE_WHISPER:
 		ast_slinfactory_init(&audiohook->write_factory);
 		break;
+	case AST_AUDIOHOOK_TYPE_SILDET:
+		ast_slinfactory_init(&audiohook->read_factory);	/* We read and forget. */
+		break;
 	default:
 		break;
 	}
@@ -102,6 +106,9 @@
 		/* Fall through intentionally */
 	case AST_AUDIOHOOK_TYPE_WHISPER:
 		ast_slinfactory_destroy(&audiohook->write_factory);
+		break;
+	case AST_AUDIOHOOK_TYPE_SILDET:
+		ast_slinfactory_destroy(&audiohook->read_factory);
 		break;
 	default:
 		break;




More information about the asterisk-commits mailing list