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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 5 04:18:56 CST 2014


Author: oej
Date: Wed Feb  5 04:18:40 2014
New Revision: 407392

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407392
Log:
Add the settings needed, but just ignore them and don't do anything about it. For now.

Modified:
    team/oej/silence-detection-games-1.8/channels/chan_sip.c
    team/oej/silence-detection-games-1.8/channels/sip/include/sip.h
    team/oej/silence-detection-games-1.8/configs/sip.conf.sample

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=407392&r1=407391&r2=407392
==============================================================================
--- team/oej/silence-detection-games-1.8/channels/chan_sip.c (original)
+++ team/oej/silence-detection-games-1.8/channels/chan_sip.c Wed Feb  5 04:18:40 2014
@@ -18288,7 +18288,7 @@
 		ast_cli(fd, "  Codec Order  : (");
 		print_codec_to_cli(fd, &peer->prefs);
 		ast_cli(fd, ")\n");
-
+		ast_cli(fd, "  Silence Det. : %s\n", AST_CLI_YESNO(ast_test_flag(&peer->flags[2], SIP_PAGE3_SILENCE_DETECTION)));
 		ast_cli(fd, "  Auto-Framing :  %s \n", AST_CLI_YESNO(peer->autoframing));
 		ast_cli(fd, "  Status       : ");
 		peer_status(peer, status, sizeof(status));
@@ -18970,6 +18970,9 @@
 	ast_cli(a->fd, "  DTMF:                   %s\n", dtmfmode2str(ast_test_flag(&global_flags[0], SIP_DTMF)));
 	ast_cli(a->fd, "  Qualify:                %d\n", default_qualify);
 	ast_cli(a->fd, "  Use ClientCode:         %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[0], SIP_USECLIENTCODE)));
+	ast_cli(a->fd, "  Silence detection:      %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[2], SIP_PAGE3_SILENCE_DETECTION)));
+	ast_cli(a->fd, "  Silence level: 	  %d\n", sip_cfg.default.silencelevel)
+	ast_cli(a->fd, "  Silence period: 	  %d\n", sip_cfg.default.silenceperiod)
 	ast_cli(a->fd, "  Progress inband:        %s\n", (ast_test_flag(&global_flags[0], SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER) ? "Never" : (AST_CLI_YESNO(ast_test_flag(&global_flags[0], SIP_PROG_INBAND) != SIP_PROG_INBAND_NO)));
 	ast_cli(a->fd, "  Language:               %s\n", default_language);
 	ast_cli(a->fd, "  MOH Interpret:          %s\n", default_mohinterpret);
@@ -19365,6 +19368,9 @@
 			ast_cli(a->fd, "  Promiscuous Redir:      %s\n", AST_CLI_YESNO(ast_test_flag(&cur->flags[0], SIP_PROMISCREDIR)));
 			ast_cli(a->fd, "  Route:                  %s\n", cur->route ? cur->route->hop : "N/A");
 			ast_cli(a->fd, "  DTMF Mode:              %s\n", dtmfmode2str(ast_test_flag(&cur->flags[0], SIP_DTMF)));
+			ast_cli(a->fd, "  Silence Detection:      %s\n", AST_CLI_YESNO(ast_test_flag(&cur->flags[2], SIP_PAGE3_SILENCE_DETECTION)));
+			ast_cli(a->fd, "  Silence level:          %d\n", cur->silencelevel);
+			ast_cli(a->fd, "  Silence period:         %d\n", cur->silenceperiod);
 			ast_cli(a->fd, "  SIP Options:            ");
 			if (cur->sipoptions) {
 				int x;
@@ -27745,6 +27751,9 @@
 	} else if (!strcasecmp(v->name, "buggymwi")) {
 		ast_set_flag(&mask[1], SIP_PAGE2_BUGGY_MWI);
 		ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_BUGGY_MWI);
+	} else if (!strcasecmp(v->name, "silencedetection")) {
+		ast_set_flag(&mask[2], SIP_PAGE3_SILENCE_DETECTION);
+		ast_set2_flag(&flags[2], ast_true(v->value), SIP_PAGE3_SILENCE_DETECTION);
 	} else
 		res = 0;
 
@@ -28962,6 +28971,8 @@
 	ast_copy_string(default_callerid, DEFAULT_CALLERID, sizeof(default_callerid));
 	ast_copy_string(default_mwi_from, DEFAULT_MWI_FROM, sizeof(default_mwi_from));
 	sip_cfg.compactheaders = DEFAULT_COMPACTHEADERS;
+	sip_cfg.silencelevel = DEFAULT_SILENCELEVEL;
+	sip_cfg.silenceperiod = DEFAULT_SILENCEPERIOD;
 	global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT;
 	global_regattempts_max = 0;
 	global_reg_retry_403 = 0;
@@ -29510,6 +29521,18 @@
 			}
 		} else if (!strcasecmp(v->name, "use_q850_reason")) {
 			ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_Q850_REASON);
+		} else if (!strcasecmp(v->name, "silencelevel")) {
+			if (sscanf(v->value, "%30d", &sip_cfg.silencelevel) != 1
+				|| sip_cfg.silencelevel < 1 ) {
+				ast_log(LOG_WARNING, "'%s' is not a valid silencelevel value at line %d.  Using default.\n", v->value, v->lineno);
+				sip_cfg.silencelevel = DEFAULT_SILENCELEVEL;
+			}
+		} else if (!strcasecmp(v->name, "silenceperiod")) {
+			if (sscanf(v->value, "%30d", &sip_cfg.silenceperiod) != 1
+				|| sip_cfg.silenceperiod < 0 || sip_cfg.silenceperiod > 150) {
+				ast_log(LOG_WARNING, "'%s' is not a valid silencelevel value at line %d.  Using default.\n", v->value, v->lineno);
+				sip_cfg.silencelevel = DEFAULT_SILENCELEVEL;
+			}
 		} else if (!strcasecmp(v->name, "maxforwards")) {
 			if (sscanf(v->value, "%30d", &sip_cfg.default_max_forwards) != 1
 				|| sip_cfg.default_max_forwards < 1 || 255 < sip_cfg.default_max_forwards) {

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=407392&r1=407391&r2=407392
==============================================================================
--- 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 Wed Feb  5 04:18:40 2014
@@ -61,6 +61,9 @@
 
 #define DEFAULT_AUTHLIMIT            100
 #define DEFAULT_AUTHTIMEOUT          30
+#define DEFAULT_SILENCELEVEL	     850
+#define DEFAULT_SILENCEPERIOD	     42   /* Milliseconds, meaning we will kill frame #3 in a 20 ms packetized stream 
+						besides 42 being a good number in general. */
 
 /* guard limit must be larger than guard secs */
 /* guard min must be < 1000, and should be >= 250 */
@@ -359,9 +362,10 @@
 
 #define SIP_PAGE3_SNOM_AOC               (1 << 0)  /*!< DPG: Allow snom aoc messages */
 #define SIP_PAGE3_DIRECT_MEDIA_OUTGOING  (1 << 1)  /*!< DP: Only send direct media reinvites on outgoing calls */
+#define SIP_PAGE3_SILENCE_DETECTION      (1 << 21)  /*!< DPG: Enable silence detection?  */
 
 #define SIP_PAGE3_FLAGS_TO_COPY \
-	(SIP_PAGE3_SNOM_AOC | SIP_PAGE3_DIRECT_MEDIA_OUTGOING)
+	(SIP_PAGE3_SNOM_AOC | SIP_PAGE3_DIRECT_MEDIA_OUTGOING | SIP_PAGE3_SILENCE_DETECTION)
 
 /*@}*/
 
@@ -716,6 +720,8 @@
 	format_t capability;        /*!< Supported codecs */
 	int tcp_enabled;
 	int default_max_forwards;    /*!< Default max forwards (SIP Anti-loop) */
+	int silencelevel;	     /*!< Default silence treshold for silence detection */
+	int silenceperiod;	     /*!< Default silence period - how long to wait before suppressing silence */
 };
 
 /*! \brief The SIP socket definition */
@@ -1088,6 +1094,11 @@
 	uint32_t dialogver;                 /*!< SUBSCRIBE: Version for subscription dialog-info */
 
 	struct ast_dsp *dsp;                /*!< Inband DTMF or Fax CNG tone Detection dsp */
+	struct ast_dsp *sildet;             /*!< DSP used for silence detection */
+	time_t silencetimer;		    /*!< Timer used for silence detection. */
+	unsigned int silencelevel;	    /*!< Silence treshold */
+	unsigned int silenceperiod;	    /*!< How many milliseconds to wait for silence before activating silence
+						 support and sending CNG */
 
 	struct sip_peer *relatedpeer;       /*!< If this dialog is related to a peer, which one
 	                                         Used in peerpoke, mwi subscriptions */

Modified: team/oej/silence-detection-games-1.8/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/configs/sip.conf.sample?view=diff&rev=407392&r1=407391&r2=407392
==============================================================================
--- team/oej/silence-detection-games-1.8/configs/sip.conf.sample (original)
+++ team/oej/silence-detection-games-1.8/configs/sip.conf.sample Wed Feb  5 04:18:40 2014
@@ -537,6 +537,21 @@
                                 ; when we're on hold (must be > rtptimeout)
 ;rtpkeepalive=<secs>            ; Send keepalives in the RTP stream to keep NAT open
                                 ; (default is off - zero)
+
+;--------------------------- SIP Silence detection/suppression for RTP ------------------------------------
+; The silence detection assigns a software DSP to each channel and converts all audio into
+; signed linear in order to be able to detect silence. This will require a lot of CPU
+; per channel including transcoding. 
+; This is only settable in [general] right now, but should be settable per channel
+;silencedetection = YES		; Enable silence detection - by default turned off.
+;				; settable per device too
+;				; You want to enable comfort noise too
+;silencelevel = 850		; Silence detection noise level - below this is considered silent.
+				; Default = 850
+;silenceperiod = 42		; How many milliseconds of silence should we get before we supress
+				; audio. Consider packetization. A normal ALAW stream has 20 ms audio
+				; per RTP packet. 42 means we will start sending CNG at the third silent
+				; packet.
 
 ;--------------------------- SIP Session-Timers (RFC 4028)------------------------------------
 ; SIP Session-Timers provide an end-to-end keep-alive mechanism for active SIP sessions.




More information about the asterisk-commits mailing list