[asterisk-commits] res fax/t38 gateway: Peer V.21 session is created on wrong c... (asterisk[11])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 11 10:37:26 CDT 2016


Joshua Colp has submitted this change and it was merged.

Change subject: res_fax/t38_gateway: Peer V.21 session is created on wrong channel
......................................................................


res_fax/t38_gateway: Peer V.21 session is created on wrong channel

The channel and peer V.21 sessions are created on the same channel now.
The peer V.21 session should be created only on peer channel
when one of channel can handle T.38.

Also this patch enable debug for T.38 gateway session
if global fax debug enabled.

ASTERISK-25982

Change-Id: I78387156ea521a77eb0faf170179ddd37a50430e
---
M res/res_fax.c
1 file changed, 28 insertions(+), 16 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/res/res_fax.c b/res/res_fax.c
index 16a3d58..03a71b2 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -2545,6 +2545,23 @@
 	}
 }
 
+static struct ast_fax_session *fax_v21_session_new (struct ast_channel *chan) {
+	struct ast_fax_session_details *v21_details;
+	struct ast_fax_session *v21_session;
+
+	if (!chan || !(v21_details = session_details_new())) {
+		return NULL;
+	}
+
+	v21_details->caps = AST_FAX_TECH_V21_DETECT;
+	if (!(v21_session = fax_session_new(v21_details, chan, NULL, NULL))) {
+		ao2_ref(v21_details, -1);
+		return NULL;
+	}
+
+	return v21_session;
+}
+
 /*! \brief Create a new fax gateway object.
  * \param chan the channel the gateway object will be attached to
  * \param details the fax session details
@@ -2553,29 +2570,15 @@
 static struct fax_gateway *fax_gateway_new(struct ast_channel *chan, struct ast_fax_session_details *details)
 {
 	struct fax_gateway *gateway = ao2_alloc(sizeof(*gateway), destroy_gateway);
-	struct ast_fax_session_details *v21_details;
 	if (!gateway) {
 		return NULL;
 	}
 
-	if (!(v21_details = session_details_new())) {
+	if (!(gateway->chan_v21_session = fax_v21_session_new(chan))) {
+		ast_log(LOG_ERROR, "Can't create V21 session on chan %s for T.38 gateway session\n", ast_channel_name(chan));
 		ao2_ref(gateway, -1);
 		return NULL;
 	}
-
-	v21_details->caps = AST_FAX_TECH_V21_DETECT;
-	if (!(gateway->chan_v21_session = fax_session_new(v21_details, chan, NULL, NULL))) {
-		ao2_ref(v21_details, -1);
-		ao2_ref(gateway, -1);
-		return NULL;
-	}
-
-	if (!(gateway->peer_v21_session = fax_session_new(v21_details, chan, NULL, NULL))) {
-		ao2_ref(v21_details, -1);
-		ao2_ref(gateway, -1);
-		return NULL;
-	}
-	ao2_ref(v21_details, -1);
 
 	gateway->framehook = -1;
 
@@ -3055,6 +3058,11 @@
 
 		ast_channel_make_compatible(chan, peer);
 		gateway->bridged = 1;
+		if (!(gateway->peer_v21_session = fax_v21_session_new(peer))) {
+			ast_log(LOG_ERROR, "Can't create V21 session on chan %s for T.38 gateway session\n", ast_channel_name(peer));
+			ast_framehook_detach(chan, gateway->framehook);
+			return f;
+		}
 	}
 
 	if (gateway->bridged && !ast_tvzero(gateway->timeout_start)) {
@@ -3196,6 +3204,10 @@
 		.destroy_cb = fax_gateway_framehook_destroy,
 	};
 
+    	if (global_fax_debug) {
+        	details->option.debug = AST_FAX_OPTFLAG_TRUE;
+    	}
+
 	ast_string_field_set(details, result, "SUCCESS");
 	ast_string_field_set(details, resultstr, "gateway operation started successfully");
 	ast_string_field_set(details, error, "NO_ERROR");

-- 
To view, visit https://gerrit.asterisk.org/2798
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I78387156ea521a77eb0faf170179ddd37a50430e
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list