From c75a129323d323c572922db4d6da2a40d8b74756 Mon Sep 17 00:00:00 2001
From: "Kevin P. Fleming" <kpfleming@digium.com>
Date: Fri, 10 Jul 2009 15:28:11 +0000
Subject: [PATCH] Fix some remaining T.38 negotiation problems in app_fax.

Revision 205696 did not quite fix all the issues with the T.38 negotiation
changes and app_fax; this patch corrects them, along with a couple of other
minor issues.

(closes issue #15480)
Reported by: dimas
Patches:
      test2-15480.patch uploaded by dimas (license 88)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@205770 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_fax.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/apps/app_fax.c b/apps/app_fax.c
index 815bb84f20..83ae2cded5 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -497,6 +497,7 @@ static int transmit_audio(fax_session *s)
 				res = 1;
 				break;
 			} else if (parameters->request_response == AST_T38_REQUEST_NEGOTIATE) {
+				ast_debug(1, "T38 request received, accepting\n");
 				if (parameters->version > 0) {
 					/* Only T.38 Version 0 is supported at this time */
 					parameters->version = 0;
@@ -508,12 +509,10 @@ static int transmit_audio(fax_session *s)
 				}
 				/* we only support bit rates up to 9.6kbps */
 				parameters->rate = AST_T38_RATE_9600;
+				/* Complete T38 switchover */
 				ast_indicate_data(s->chan, AST_CONTROL_T38_PARAMETERS, parameters, sizeof(*parameters));
-				/* T38 switchover completed */
-				s->t38parameters = *parameters;
-				ast_debug(1, "T38 negotiated, finishing audio loop\n");
-				res = 1;
-				break;
+				/* Do not break audio loop, wait until channel driver finally acks switchover
+				   with AST_T38_NEGOTIATED */
 			}
 		}
 
@@ -598,7 +597,8 @@ static int transmit_t38(fax_session *s)
 	}
 	if (s->t38parameters.transcoding_mmr) {
 		t38_set_mmr_transcoding(t38state, TRUE);
-	} else if (s->t38parameters.transcoding_jbig) {
+	}
+	if (s->t38parameters.transcoding_jbig) {
 		t38_set_jbig_transcoding(t38state, TRUE);
 	}
 
@@ -647,9 +647,8 @@ static int transmit_t38(fax_session *s)
 			}
 		} else if (inf->frametype == AST_FRAME_CONTROL && inf->subclass == AST_CONTROL_T38_PARAMETERS) {
 			struct ast_control_t38_parameters *parameters = inf->data.ptr;
-			if (parameters->request_response == AST_T38_TERMINATED || parameters->request_response == AST_T38_REFUSED) {
-				ast_debug(1, "T38 down, terminating\n");
-				res = -1;
+			if (parameters->request_response == AST_T38_TERMINATED) {
+				ast_debug(1, "T38 down, finishing\n");
 				break;
 			}
 		}
-- 
GitLab