[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r319062 - /team/irroot/distrot...

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


Author: irroot
Date: Mon May 16 03:07:07 2011
New Revision: 319062

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=319062
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


Modified:
    team/irroot/distrotech-customers-1.8/res/res_fax.c
    team/irroot/distrotech-customers-1.8/res/res_fax_spandsp.c

Modified: team/irroot/distrotech-customers-1.8/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/res/res_fax.c?view=diff&rev=319062&r1=319061&r2=319062
==============================================================================
--- team/irroot/distrotech-customers-1.8/res/res_fax.c (original)
+++ team/irroot/distrotech-customers-1.8/res/res_fax.c Mon May 16 03:07:07 2011
@@ -481,8 +481,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);
@@ -2374,7 +2375,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;
@@ -2628,7 +2629,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);
@@ -2713,6 +2714,66 @@
 	}
 
 	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;
+
+	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);
+			ast_framehook_detach(chan, gateway->framehook);
+		}
+		ast_channel_unlock(chan);
+	}
 }
 
 /*! \brief Alternate wait app that listens for CNG
@@ -3296,46 +3357,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/distrotech-customers-1.8/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/res/res_fax_spandsp.c?view=diff&rev=319062&r1=319061&r2=319062
==============================================================================
--- team/irroot/distrotech-customers-1.8/res/res_fax_spandsp.c (original)
+++ team/irroot/distrotech-customers-1.8/res/res_fax_spandsp.c Mon May 16 03:07:07 2011
@@ -688,7 +688,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);
 




More information about the asterisk-commits mailing list