[svn-commits] irroot: branch irroot/distrotech-customers-trunk r326050 - in /team/irroot/di...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Jul 1 09:09:30 CDT 2011
Author: irroot
Date: Fri Jul 1 09:09:26 2011
New Revision: 326050
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=326050
Log:
Resolve conflict in res_fax / enable automerge / re add faxwait
Modified:
team/irroot/distrotech-customers-trunk/ (props changed)
team/irroot/distrotech-customers-trunk/res/res_fax.c
team/irroot/distrotech-customers-trunk/res/res_fax_spandsp.c
Propchange: team/irroot/distrotech-customers-trunk/
------------------------------------------------------------------------------
automerge = *
Propchange: team/irroot/distrotech-customers-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jul 1 09:09:26 2011
@@ -1,1 +1,1 @@
-/trunk:1-326002
+/trunk:1-326048
Modified: team/irroot/distrotech-customers-trunk/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/res/res_fax.c?view=diff&rev=326050&r1=326049&r2=326050
==============================================================================
--- team/irroot/distrotech-customers-trunk/res/res_fax.c (original)
+++ team/irroot/distrotech-customers-trunk/res/res_fax.c Fri Jul 1 09:09:26 2011
@@ -13,7 +13,7 @@
* Sponsored by IPEX a.s. http://www.ipex.cz
*
* T.38-gateway integration into asterisk app_fax and rework
- * 2008, Gregory Hinton Nietsky <gregory at dnstelecom.co.za>
+ * 2008-2011, Gregory Hinton Nietsky <gregory at distrotech.co.za>
* dns Telecom http://www.dnstelecom.co.za
*
* Modified to make T.38-gateway compatible with Asterisk 1.6.2
@@ -45,7 +45,8 @@
* \author Dwayne M. Hubbard <dhubbard at digium.com>
* \author Kevin P. Fleming <kpfleming at digium.com>
* \author Matthew Nicholson <mnicholson at digium.com>
- *
+ * \author Gregory H. Nietsky <gregory at distrotech.co.za>
+ *
* A generic FAX resource module that provides SendFAX and ReceiveFAX applications.
* This module requires FAX technology modules, like res_fax_spandsp, to register with it
* so it can use the technology modules to perform the actual FAX transmissions.
@@ -220,10 +221,25 @@
<ref type="application">SendFax</ref>
</see-also>
</function>
+ <application name="WaitFAX" language="en_US">
+ <synopsis>
+ Generic Fax Detect CNG/T.38 (Wait For Fax)
+ </synopsis>
+ <syntax>
+ <parameter name="timeout" required="true">
+ <para>Specifies the number of seconds we attempt to detect a fax tone on the channel</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>This application sets the following channel variable upon completion</para>
+ <para> FAXDETECTED : 0 | 1</para>
+ </description>
+ </application>
***/
static const char app_receivefax[] = "ReceiveFAX";
static const char app_sendfax[] = "SendFAX";
+static const char app_waitfax[] = "WaitFAX";
struct debug_info_history {
unsigned int consec_frames;
@@ -2992,6 +3008,111 @@
return gateway->framehook;
}
+/*! \brief Alternate wait app that listens for CNG
+ * \details This app answers the channel and waits for CNG tone
+ * if the channel driver supports faxdetect it will proceed to the fax
+ * extension.
+ * it will return FAXDETECTED = 0 | 1 to allow dialplan processing where
+ * the channel does not have fax detect or the Dialplan needs to handle faxdetection*/
+static int waitfax_exec(struct ast_channel *chan, const char *data)
+{
+ char *parse;
+ int timeout, tone = 0;
+ struct ast_dsp *dsp = NULL;
+ struct ast_frame *f;
+ enum ast_t38_state t38state = T38_STATE_UNKNOWN;
+ struct ast_silence_generator *silgen = NULL;
+ struct ast_format orig_read_format;
+ AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames;
+
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(timeout);
+ );
+
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ if (args.timeout) {
+ timeout = atoi(args.timeout) * 1000;
+ } else {
+ pbx_builtin_setvar_helper(chan, "FAXDETECTED", "0");
+ return 0;
+ }
+
+ if (chan->_state != AST_STATE_UP)
+ ast_answer(chan);
+
+ /* Setup DSP CNG processing */
+ ast_format_copy(&orig_read_format, &chan->readformat);
+ if (!ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
+ if ((dsp=ast_dsp_new())) {
+ ast_dsp_set_features(dsp, DSP_FEATURE_FAX_DETECT);
+ ast_dsp_set_faxmode(dsp, DSP_FAXMODE_DETECT_CNG);
+ }
+ }
+
+ AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
+
+ /* If no other generator is present, start silencegen while waiting */
+ if (ast_opt_transmit_silence && !chan->generatordata) {
+ silgen = ast_channel_start_silence_generator(chan);
+ }
+
+ while ((timeout = ast_waitfor(chan, timeout))) {
+ if (!(f=ast_read(chan))) {
+ pbx_builtin_setvar_helper(chan, "FAXDETECTED", "0");
+ break;
+ }
+
+ if (dsp && (f->frametype == AST_FRAME_VOICE) && ((f->subclass.format.id == AST_FORMAT_SLINEAR) ||
+ (f->subclass.format.id == AST_FORMAT_ULAW) || (f->subclass.format.id == AST_FORMAT_ALAW))) {
+ f = ast_dsp_process(chan, dsp, f);
+ if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == 'f')) {
+ tone=1;
+ ast_dsp_free(dsp);
+ dsp = NULL;
+ }
+ }
+
+ if (ast_is_deferrable_frame(f)) {
+ AST_LIST_INSERT_HEAD(&deferred_frames, f, frame_list);
+ } else {
+ ast_frfree(f);
+ }
+
+ t38state = ast_channel_get_t38_state(chan);
+ if ((t38state == T38_STATE_NEGOTIATING) || (t38state == T38_STATE_NEGOTIATED) || tone) {
+ pbx_builtin_setvar_helper(chan, "FAXDETECTED", "1");
+ break;
+ }
+ }
+
+ if (timeout <= 0) {
+ pbx_builtin_setvar_helper(chan, "FAXDETECTED", "0");
+ }
+
+ /* stop silgen if present */
+ if (silgen) {
+ ast_channel_stop_silence_generator(chan, silgen);
+ }
+
+ if (orig_read_format.id) {
+ ast_set_read_format(chan, &orig_read_format);
+ }
+
+ ast_channel_lock(chan);
+ while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) {
+ ast_queue_frame_head(chan, ast_frisolate(f));
+ }
+ ast_channel_unlock(chan);
+
+ if (dsp) {
+ ast_dsp_free(dsp);
+ }
+
+ return 0;
+}
+
/*! \brief hash callback for ao2 */
static int session_hash_cb(const void *obj, const int flags)
{
@@ -3532,6 +3653,10 @@
ast_log(LOG_WARNING, "failed to unregister '%s'\n", app_receivefax);
}
+ if (ast_unregister_application(app_waitfax) < 0) {
+ ast_log(LOG_WARNING, "failed to unregister '%s'\n", app_waitfax);
+ }
+
if (fax_logger_level != -1) {
ast_logger_unregister_level("FAX");
}
@@ -3572,6 +3697,10 @@
return AST_MODULE_LOAD_DECLINE;
}
+ if (ast_register_application_xml(app_waitfax, waitfax_exec) < 0) {
+ ast_log(LOG_WARNING, "failed to register '%s'.\n", app_waitfax);
+ }
+
ast_cli_register_multiple(fax_cli, ARRAY_LEN(fax_cli));
res = ast_custom_function_register(&acf_faxopt);
fax_logger_level = ast_logger_register_level("FAX");
Modified: team/irroot/distrotech-customers-trunk/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/res/res_fax_spandsp.c?view=diff&rev=326050&r1=326049&r2=326050
==============================================================================
--- team/irroot/distrotech-customers-trunk/res/res_fax_spandsp.c (original)
+++ team/irroot/distrotech-customers-trunk/res/res_fax_spandsp.c Fri Jul 1 09:09:26 2011
@@ -37,6 +37,7 @@
* \brief Spandsp T.38 and G.711 FAX Resource
*
* \author Matthew Nicholson <mnicholson at digium.com>
+ * \author Gregory H. Nietsky <gregory at distrotech.co.za>
*
* This module registers the Spandsp FAX technology with the res_fax module.
*/
More information about the svn-commits
mailing list