[svn-commits] dhubbard: trunk r161115 - in /trunk: ./ channels/ configs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 4 17:00:31 CST 2008


Author: dhubbard
Date: Thu Dec  4 17:00:30 2008
New Revision: 161115

URL: http://svn.digium.com/view/asterisk?view=rev&rev=161115
Log:
If 'faxdetect=yes' in sip.conf, switch to a 'fax' extension (if it exists) after T38 is negotiated.  
Terry Wilson created the original patch for this functionality, which I slightly modified and added 
the faxdetect=yes|no configuration option.  This patch is only for T38 fax detection and does not 
do anything for G711 over SIP fax detection.  By default, this option is disabled. 

This functionality is for issue AST-140.


Modified:
    trunk/CHANGES
    trunk/channels/chan_sip.c
    trunk/configs/sip.conf.sample

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=161115&r1=161114&r2=161115
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Dec  4 17:00:30 2008
@@ -25,6 +25,9 @@
    remote services. For backwards compatibility, "secret" still has the
    same function as before, but now you can configure both a remote secret and a
    local secret for mutual authentication.
+ * Added a new 'faxdetect=yes|no' configuration option to sip.conf.  When this
+   option is enabled, a SIP channel will go to the fax extension (if it exists)
+   after T38 is negotiated.  This option is disabled by default.
 
 Skinny Changes
 --------------

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=161115&r1=161114&r2=161115
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Dec  4 17:00:30 2008
@@ -1334,6 +1334,7 @@
 #define SIP_PAGE2_RFC2833_COMPENSATE    (1 << 25)	/*!< DP: Compensate for buggy RFC2833 implementations */
 #define SIP_PAGE2_BUGGY_MWI		(1 << 26)	/*!< DP: Buggy CISCO MWI fix */
 #define SIP_PAGE2_DIALOG_ESTABLISHED    (1 << 27)       /*!< 29: Has a dialog been established? */
+#define SIP_PAGE2_FAX_DETECT		(1 << 28)		/*!< DP: Fax Detection support */
 #define SIP_PAGE2_REGISTERTRYING        (1 << 29)       /*!< DP: Send 100 Trying on REGISTER attempts */
 #define SIP_PAGE2_UDPTL_DESTINATION     (1 << 30)       /*!< DP: Use source IP of RTP as destination if NAT is enabled */
 #define SIP_PAGE2_VIDEOSUPPORT_ALWAYS	(1 << 31)       /*!< DP: Always set up video, even if endpoints don't support it */
@@ -1341,7 +1342,7 @@
 #define SIP_PAGE2_FLAGS_TO_COPY \
 	(SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | \
 	SIP_PAGE2_T38SUPPORT | SIP_PAGE2_RFC2833_COMPENSATE | SIP_PAGE2_BUGGY_MWI | \
-	SIP_PAGE2_TEXTSUPPORT | SIP_PAGE2_UDPTL_DESTINATION | \
+	SIP_PAGE2_TEXTSUPPORT | SIP_PAGE2_FAX_DETECT | SIP_PAGE2_UDPTL_DESTINATION | \
 	SIP_PAGE2_VIDEOSUPPORT_ALWAYS)
 
 /*@}*/ 
@@ -4528,6 +4529,28 @@
 	/* Woot we got a message, create a control frame and send it on! */
 	if (message)
 		ast_queue_control_data(chan, AST_CONTROL_T38, &message, sizeof(message));
+
+	if (ast_test_flag(&p->flags[1], SIP_PAGE2_FAX_DETECT)) {
+		/* fax detection is enabled */
+		ast_channel_lock(chan);
+		if (strcmp(chan->exten, "fax") && state == T38_ENABLED) {
+			const char *target_context = S_OR(chan->macrocontext, chan->context);
+			ast_channel_unlock(chan);
+			if (ast_exists_extension(chan, target_context, "fax", 1, chan->cid.cid_num)) {
+				/* save the DID/DNIS when we transfer the fax call to a 'fax' extension */
+				ast_verb(3, "Redirecting '%s' to fax extension\n", chan->name);
+				pbx_builtin_setvar_helper(chan, "FAXEXTEN", chan->exten);
+				if (ast_async_goto(chan, target_context, "fax", 1)) {
+					ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", chan->name, target_context);
+				}
+			} else {
+				ast_log(LOG_NOTICE, "Fax detected but no fax extension.\n");
+			}
+		} else {
+			ast_channel_unlock(chan);
+			ast_debug(1, "Already in a fax extension (or T38 was not enabled, state: '%d'), not redirecting.\n", state);
+		}
+	}
 }
 
 /*! \brief Set the global T38 capabilities on a SIP dialog structure */
@@ -21541,6 +21564,9 @@
 	} else if (!strcasecmp(v->name, "allowsubscribe")) {
 		ast_set_flag(&mask[1], SIP_PAGE2_ALLOWSUBSCRIBE);
 		ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_ALLOWSUBSCRIBE);
+	} else if (!strcasecmp(v->name, "faxdetect")) {
+		ast_set_flag(&mask[1], SIP_PAGE2_FAX_DETECT);
+		ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_FAX_DETECT);
 	} else if (!strcasecmp(v->name, "t38pt_udptl")) {
 		ast_set_flag(&mask[1], SIP_PAGE2_T38SUPPORT_UDPTL);
 		ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_T38SUPPORT_UDPTL);
@@ -22542,6 +22568,7 @@
 	/* Copy the default jb config over global_jbconf */
 	memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
 
+	ast_clear_flag(&global_flags[1], SIP_PAGE2_FAX_DETECT);
 	ast_clear_flag(&global_flags[1], SIP_PAGE2_VIDEOSUPPORT | SIP_PAGE2_VIDEOSUPPORT_ALWAYS);
 	ast_clear_flag(&global_flags[1], SIP_PAGE2_TEXTSUPPORT);
 

Modified: trunk/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=161115&r1=161114&r2=161115
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Thu Dec  4 17:00:30 2008
@@ -402,6 +402,11 @@
 ; T.38 faxing only works in SIP to SIP calls, with no local or agent channel being used.
 ;
 ; t38pt_udptl = yes            ; Default false
+;
+; Fax Detect will cause the SIP channel to jump to the 'fax' extension (if it exists)
+; after T.38 is successfully negotiated.
+; 
+; faxdetect = yes              ; Default false	
 ;
 ;----------------------------------------- OUTBOUND SIP REGISTRATIONS  ------------------------
 ; Asterisk can register as a SIP user agent to a SIP proxy (provider)




More information about the svn-commits mailing list