[asterisk-commits] irroot: branch irroot/t38gateway-trunk r319064 - in /team/irroot/t38gateway-t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 16 03:56:01 CDT 2011


Author: irroot
Date: Mon May 16 03:55:57 2011
New Revision: 319064

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=319064
Log:
Make sure when the framehook is turned off the datastore is removed
Revert to sending on idle not having it on messes with timing ill make it configrable latter
Restore original audio formats when the framehook is disabled.


Modified:
    team/irroot/t38gateway-trunk/   (props changed)
    team/irroot/t38gateway-trunk/cel/cel_odbc.c   (props changed)
    team/irroot/t38gateway-trunk/configs/cel_odbc.conf.sample   (props changed)
    team/irroot/t38gateway-trunk/include/asterisk/res_fax.h
    team/irroot/t38gateway-trunk/res/res_fax.c
    team/irroot/t38gateway-trunk/res/res_fax_spandsp.c
    team/irroot/t38gateway-trunk/sounds/Makefile   (props changed)

Propchange: team/irroot/t38gateway-trunk/
------------------------------------------------------------------------------
    svn:mergeinfo = /team/irroot/distrotech-customers-1.8:319062

Propchange: team/irroot/t38gateway-trunk/cel/cel_odbc.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 03:55:57 2011
@@ -1,1 +1,2 @@
 /be/branches/C.3/cel/cel_adaptive_odbc.c:256426
+/team/irroot/distrotech-customers-1.8/cel/cel_odbc.c:319062

Propchange: team/irroot/t38gateway-trunk/configs/cel_odbc.conf.sample
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 03:55:57 2011
@@ -1,1 +1,2 @@
 /be/branches/C.3/configs/cel_adaptive_odbc.conf.sample:256426
+/team/irroot/distrotech-customers-1.8/configs/cel_odbc.conf.sample:319062

Modified: team/irroot/t38gateway-trunk/include/asterisk/res_fax.h
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-trunk/include/asterisk/res_fax.h?view=diff&rev=319064&r1=319063&r2=319064
==============================================================================
--- team/irroot/t38gateway-trunk/include/asterisk/res_fax.h (original)
+++ team/irroot/t38gateway-trunk/include/asterisk/res_fax.h Mon May 16 03:55:57 2011
@@ -221,6 +221,11 @@
 	int framehook;
 	/*! bridged*/
 	int bridged;
+	/*Original audio formats*/
+	struct ast_format chan_read_format;
+	struct ast_format chan_write_format;
+	struct ast_format peer_read_format;
+	struct ast_format peer_write_format;
 };
 
 /*! \brief used to register a FAX technology module with res_fax */

Modified: team/irroot/t38gateway-trunk/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-trunk/res/res_fax.c?view=diff&rev=319064&r1=319063&r2=319064
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax.c Mon May 16 03:55:57 2011
@@ -489,8 +489,9 @@
 	/* add the datastore to the channel and increment the refcount */
 	datastore->data = details;
 
-	/*provide default T38 paramaters*/
+	/*init default T38 paramaters*/
 	t38_parameters_ast_to_fax(&details->our_t38_parameters, &our_t38_parameters);
+	t38_parameters_ast_to_fax(&details->their_t38_parameters, &our_t38_parameters);
 
 	ao2_ref(details, 1);
 	ast_channel_lock(chan);
@@ -2309,7 +2310,7 @@
 		ast_channel_lock(chan);
 		ast_channel_datastore_add(chan, datastore);
 		ast_channel_unlock(chan);
-	} else if (datastore->data) {
+	} else if (datastore && datastore->data) {
 		gateway = datastore->data;
 	} else {
 		return NULL;
@@ -2513,6 +2514,10 @@
 			}
 			/* when we become active change the formats to SLIN for CED detect and T.30*/
 			if (peer && !gateway->bridged) {
+				ast_format_copy(&gateway->chan_read_format, &chan->readformat);
+				ast_format_copy(&gateway->chan_write_format, &chan->readformat);
+				ast_format_copy(&gateway->peer_read_format, &peer->readformat);
+				ast_format_copy(&gateway->peer_write_format, &peer->readformat);
 				ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
 				ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
 				ast_set_read_format_by_id(peer, AST_FORMAT_SLINEAR);
@@ -2563,7 +2568,7 @@
 					return &ast_null_frame;
 				}
 				/* i have got a T.38 request before im bridged ?? perhaps im in a app or func*/
-				if (!active) {
+				if (!peer) {
 					return f;
 				}
 				f = ast_t38_gateway_parameters(chan,peer,active,f);
@@ -2648,6 +2653,78 @@
 	}
 
 	return f;
+}
+
+/*! \brief attach a gateway framehook object to the channel
+ * \details create and setup the gateway framehook and datastore
+ * \param chan channel im attached too*/
+static void gateway_attach_hook(struct ast_channel *chan)
+{
+	struct ast_fax_session_gateway *gateway;
+	struct ast_framehook_interface fr_hook = {
+		.version = AST_FRAMEHOOK_INTERFACE_VERSION,
+		.event_cb = t38_gw_framehook,
+		.destroy_cb = t38_gw_fh_destroy,
+	};
+
+	/* set up the frame hook*/
+	gateway = find_session_gateway(chan, 1);
+	if (gateway && (gateway->framehook < 0)) {
+		fr_hook.data = gateway;
+		ast_channel_lock(chan);
+		gateway->framehook = ast_framehook_attach(chan, &fr_hook);
+		ast_channel_unlock(chan);
+		if (gateway->framehook >= 0) {
+			gateway->chan_dsp = ast_dsp_new();
+			if (gateway->chan_dsp) {
+				ast_dsp_set_features(gateway->chan_dsp, DSP_FEATURE_FAX_DETECT);
+				ast_dsp_set_faxmode(gateway->chan_dsp, DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED);
+			}
+			gateway->peer_dsp = ast_dsp_new();
+			if (gateway->peer_dsp) {
+				ast_dsp_set_features(gateway->peer_dsp, DSP_FEATURE_FAX_DETECT);
+				ast_dsp_set_faxmode(gateway->peer_dsp, DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED);
+			}
+		} else {
+			/* im not in a frame hook*/
+			ao2_ref(gateway, -1);
+		}
+	} else if (gateway) {
+		ao2_ref(gateway, -1);
+	}
+}
+
+/*! \brief detach a gateway framehook object to the channel
+ * \details remove and destroy the gateway framehook and datastore
+ * \param chan channel im attached too*/
+static void gateway_remove_hook(struct ast_channel *chan)
+{
+	struct ast_fax_session_gateway *gateway;
+	struct ast_datastore *datastore;
+	struct ast_channel *peer;
+
+	ast_channel_lock(chan);
+	datastore = ast_channel_datastore_find(chan, &fax_datastore_gateway, NULL);
+	if (datastore) {
+		ast_channel_datastore_remove(chan, datastore);
+		if (datastore->data) {
+			gateway = datastore->data;
+			ast_datastore_free(datastore);
+			/* restore audio formats*/
+			if (gateway->bridged) {
+				ast_set_read_format(chan, &gateway->chan_read_format);
+				ast_set_read_format(chan, &gateway->chan_write_format);
+				peer = ast_bridged_channel(chan);
+				if (peer) {
+					ast_set_read_format(peer, &gateway->peer_read_format);
+					ast_set_read_format(peer, &gateway->peer_write_format);
+					ast_channel_make_compatible(chan, peer);
+				}
+			}
+			ast_framehook_detach(chan, gateway->framehook);
+		}
+		ast_channel_unlock(chan);
+	}
 }
 
 /*! \brief Alternate wait app that listens for CNG
@@ -3231,46 +3308,11 @@
 	} else if (!strcasecmp(data, "t38gateway") || !strcasecmp(data, "gateway") ||
 		   !strcasecmp(data, "t38_gateway")) {
 		const char *val = ast_skip_blanks(value);
-		struct ast_fax_session_gateway *gateway;
 		if (ast_true(val)) {
-			struct ast_framehook_interface fr_hook = {
-					.version = AST_FRAMEHOOK_INTERFACE_VERSION,
-					.event_cb = t38_gw_framehook,
-					.destroy_cb = t38_gw_fh_destroy,
-			};
-
+			gateway_attach_hook(chan);
 			details->option.t38gateway = AST_FAX_OPTFLAG_TRUE;
-			t38_parameters_ast_to_fax(&details->their_t38_parameters, &our_t38_parameters);
-			/* set up the frame hook*/
-			gateway = find_session_gateway(chan, 1);
-			if (gateway && (gateway->framehook < 0)) {
-				fr_hook.data = gateway;
-				ast_channel_lock(chan);
-				gateway->framehook = ast_framehook_attach(chan, &fr_hook);
-				ast_channel_unlock(chan);
-				if (gateway->framehook >= 0) {
-					gateway->chan_dsp = ast_dsp_new();
-					if (gateway->chan_dsp) {
-						ast_dsp_set_features(gateway->chan_dsp, DSP_FEATURE_FAX_DETECT);
-						ast_dsp_set_faxmode(gateway->chan_dsp, DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED);
-					}
-					gateway->peer_dsp = ast_dsp_new();
-					if (gateway->peer_dsp) {
-						ast_dsp_set_features(gateway->peer_dsp, DSP_FEATURE_FAX_DETECT);
-						ast_dsp_set_faxmode(gateway->peer_dsp, DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED);
-					}
-				} else {
-					/* im not in a frame hook*/
-					ao2_ref(gateway, -1);
-				}
-			} else if (gateway) {
-				ao2_ref(gateway, -1);
-			}
 		} else if (ast_false(val)) {
-			gateway = find_session_gateway(chan, 0);
-			if (gateway && (gateway->framehook > 0) && !ast_framehook_detach(chan, gateway->framehook)) {
-				gateway->framehook = -1;
-			}
+			gateway_remove_hook(chan);
 			details->option.t38gateway = AST_FAX_OPTFLAG_FALSE;
 		} else {
 			ast_log(LOG_WARNING, "Unsupported value '%s' passed to FAXOPT(t38gateway).\n", value);

Modified: team/irroot/t38gateway-trunk/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-trunk/res/res_fax_spandsp.c?view=diff&rev=319064&r1=319063&r2=319064
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax_spandsp.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax_spandsp.c Mon May 16 03:55:57 2011
@@ -687,7 +687,7 @@
 			(t38_param->rate_management == AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF)? 1 : 2);
 
 	/* need to be configrable FAXOPT ??*/
-	t38_gateway_set_transmit_on_idle(&p->t38_gw_state, FALSE);
+	t38_gateway_set_transmit_on_idle(&p->t38_gw_state, TRUE);
 	t38_set_sequence_number_handling(p->t38_core_state, TRUE);
 	t38_gateway_set_supported_modems(&p->t38_gw_state, T30_SUPPORT_V27TER | T30_SUPPORT_V17 | T30_SUPPORT_V29);
 

Propchange: team/irroot/t38gateway-trunk/sounds/Makefile
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 03:55:57 2011
@@ -1,2 +1,3 @@
 /be/branches/C.3/sounds/Makefile:256426
+/team/irroot/distrotech-customers-1.8/sounds/Makefile:319062
 /trunk/sounds/Makefile:270974




More information about the asterisk-commits mailing list