[asterisk-commits] mnicholson: branch group/res_fax r242408 - /team/group/res_fax/res/res_fax.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jan 22 12:37:09 CST 2010
Author: mnicholson
Date: Fri Jan 22 12:37:06 2010
New Revision: 242408
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=242408
Log:
Generate 3 seconds of CED tone before T.38 negotiation when in receive mode and only send silence in between CNG bursts, not when T.38 negotiation has been requested.
Modified:
team/group/res_fax/res/res_fax.c
Modified: team/group/res_fax/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/group/res_fax/res/res_fax.c?view=diff&rev=242408&r1=242407&r2=242408
==============================================================================
--- team/group/res_fax/res/res_fax.c (original)
+++ team/group/res_fax/res/res_fax.c Fri Jan 22 12:37:06 2010
@@ -633,7 +633,7 @@
/*! \brief this is the generic FAX session handling function */
static int generic_fax_exec(struct ast_channel *chan, struct ast_fax_session_details *details)
{
- int ms = 1000;
+ int ms;
int timeout = RES_FAX_TIMEOUT;
int res = 0, chancount;
unsigned int expected_frametype = -1;
@@ -658,6 +658,63 @@
chancount = 1;
+ /* generate 3 seconds of CED if we are in receive mode */
+ if (details->caps & AST_FAX_TECH_RECEIVE) {
+ ms = 3000;
+ if (ast_tonepair_start(chan, 2100, 0, ms, 0)) {
+ ast_log(LOG_ERROR, "error generating CED tone on %s\n", chan->name);
+ return -1;
+ }
+
+ do {
+ ast_waitfor(chan, ms);
+ if (ms < 0) {
+ ast_log(LOG_ERROR, "error while generating CED tone on %s\n", chan->name);
+ ast_tonepair_stop(chan);
+ return -1;
+ }
+
+ if (ms == 0) { /* all done, nothing happened */
+ break;
+ }
+
+ if (!(frame = ast_read(chan))) {
+ ast_log(LOG_ERROR, "error reading frame while generating CED tone on %s\n", chan->name);
+ ast_tonepair_stop(chan);
+ return -1;
+ }
+
+ if ((frame->frametype == AST_FRAME_CONTROL) &&
+ (frame->subclass.integer == AST_CONTROL_T38_PARAMETERS) &&
+ (frame->datalen == sizeof(t38_parameters))) {
+ struct ast_control_t38_parameters *parameters = frame->data.ptr;
+
+ switch (parameters->request_response) {
+ case AST_T38_REQUEST_NEGOTIATE:
+ /* the other end has requested a switch to T.38, so reply that we are willing, if we can
+ * do T.38 as well
+ */
+ t38_parameters_fax_to_ast(&t38_parameters, &details->our_t38_parameters);
+ t38_parameters.request_response = (details->caps & AST_FAX_TECH_T38) ? AST_T38_NEGOTIATED : AST_T38_REFUSED;
+ ast_indicate_data(chan, AST_CONTROL_T38_PARAMETERS, &t38_parameters, sizeof(t38_parameters));
+ break;
+ case AST_T38_NEGOTIATED:
+ ast_log(LOG_NOTICE, "Negotiated T.38 for receive on %s\n", chan->name);
+ t38_parameters_ast_to_fax(&details->their_t38_parameters, parameters);
+ details->caps &= ~AST_FAX_TECH_AUDIO;
+ report_fax_status(chan, details, "T.38 Negotiated");
+ t38negotiated = 1;
+ ms = 0;
+ break;
+ default:
+ break;
+ }
+ }
+ ast_frfree(frame);
+ } while (ms > 0);
+ ast_tonepair_stop(chan);
+ }
+
switch ((t38_state = ast_channel_get_t38_state(chan))) {
case T38_STATE_UNKNOWN:
if (details->caps & AST_FAX_TECH_SEND) {
@@ -709,9 +766,11 @@
}
if (request_t38 || !details->option.allow_audio) {
- struct ast_silence_generator *silence_gen;
-
- silence_gen = ast_channel_start_silence_generator(chan);
+ struct ast_silence_generator *silence_gen = NULL;
+
+ if (send_cng != -1) {
+ silence_gen = ast_channel_start_silence_generator(chan);
+ }
while (timeout > 0) {
if (send_cng > 3000) {
@@ -719,7 +778,7 @@
silence_gen = NULL;
ast_tonepair_start(chan, 1100, 0, 500, 0);
send_cng = 0;
- } else if (!chan->generator) {
+ } else if (!chan->generator && (send_cng != -1)) {
/* The CNG tone is done so restart silence generation. */
silence_gen = ast_channel_start_silence_generator(chan);
}
More information about the asterisk-commits
mailing list