[asterisk-commits] irroot: branch irroot/t38gateway-1.8 r319066 - in /team/irroot/t38gateway-1.8...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 16 04:08:35 CDT 2011


Author: irroot
Date: Mon May 16 04:08:31 2011
New Revision: 319066

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=319066
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-1.8/   (props changed)
    team/irroot/t38gateway-1.8/cel/cel_odbc.c   (props changed)
    team/irroot/t38gateway-1.8/configs/cel_odbc.conf.sample   (props changed)
    team/irroot/t38gateway-1.8/contrib/realtime/mysql/iaxfriends.sql   (props changed)
    team/irroot/t38gateway-1.8/contrib/realtime/mysql/meetme.sql   (props changed)
    team/irroot/t38gateway-1.8/contrib/realtime/mysql/sipfriends.sql   (props changed)
    team/irroot/t38gateway-1.8/contrib/realtime/mysql/voicemail.sql   (props changed)
    team/irroot/t38gateway-1.8/contrib/realtime/postgresql/realtime.sql   (props changed)
    team/irroot/t38gateway-1.8/include/asterisk/res_fax.h
    team/irroot/t38gateway-1.8/res/res_fax.c
    team/irroot/t38gateway-1.8/res/res_fax_spandsp.c
    team/irroot/t38gateway-1.8/sounds/Makefile   (props changed)

Propchange: team/irroot/t38gateway-1.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 04:08:31 2011
@@ -1,2 +1,3 @@
 /be/branches/C.3:256426
+/team/irroot/distrotech-customers-1.8:319062-319063
 /team/irroot/t38gateway-trunk:318977-319016

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

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

Propchange: team/irroot/t38gateway-1.8/contrib/realtime/mysql/iaxfriends.sql
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 04:08:31 2011
@@ -1,1 +1,2 @@
+/team/irroot/distrotech-customers-1.8/contrib/realtime/mysql/iaxfriends.sql:319062-319063
 /team/irroot/t38gateway-trunk/contrib/realtime/mysql/iaxfriends.sql:318977-319016

Propchange: team/irroot/t38gateway-1.8/contrib/realtime/mysql/meetme.sql
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 04:08:31 2011
@@ -1,1 +1,2 @@
+/team/irroot/distrotech-customers-1.8/contrib/realtime/mysql/meetme.sql:319062-319063
 /team/irroot/t38gateway-trunk/contrib/realtime/mysql/meetme.sql:318977-319016

Propchange: team/irroot/t38gateway-1.8/contrib/realtime/mysql/sipfriends.sql
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 04:08:31 2011
@@ -1,1 +1,2 @@
+/team/irroot/distrotech-customers-1.8/contrib/realtime/mysql/sipfriends.sql:319062-319063
 /team/irroot/t38gateway-trunk/contrib/realtime/mysql/sipfriends.sql:318977-319016

Propchange: team/irroot/t38gateway-1.8/contrib/realtime/mysql/voicemail.sql
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 04:08:31 2011
@@ -1,1 +1,2 @@
+/team/irroot/distrotech-customers-1.8/contrib/realtime/mysql/voicemail.sql:319062-319063
 /team/irroot/t38gateway-trunk/contrib/realtime/mysql/voicemail.sql:318977-319016

Propchange: team/irroot/t38gateway-1.8/contrib/realtime/postgresql/realtime.sql
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 04:08:31 2011
@@ -1,1 +1,2 @@
+/team/irroot/distrotech-customers-1.8/contrib/realtime/postgresql/realtime.sql:319062-319063
 /team/irroot/t38gateway-trunk/contrib/realtime/postgresql/realtime.sql:318977-319016

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

Modified: team/irroot/t38gateway-1.8/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-1.8/res/res_fax.c?view=diff&rev=319066&r1=319065&r2=319066
==============================================================================
--- team/irroot/t38gateway-1.8/res/res_fax.c (original)
+++ team/irroot/t38gateway-1.8/res/res_fax.c Mon May 16 04:08:31 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;
@@ -2578,6 +2579,10 @@
 			}
 			/* when we become active change the formats to SLIN for CED detect and T.30*/
 			if (peer && !gateway->bridged) {
+				gateway->chan_read_format = chan->readformat;
+				gateway->chan_write_format = chan->writeformat;
+				gateway->peer_read_format = peer->readformat;
+				gateway->peer_write_format = peer->writeformat;
 				ast_set_read_format(chan, AST_FORMAT_SLINEAR);
 				ast_set_write_format(chan, AST_FORMAT_SLINEAR);
 				ast_set_read_format(peer, AST_FORMAT_SLINEAR);
@@ -2628,7 +2633,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 +2718,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
@@ -3296,46 +3373,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-1.8/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-1.8/res/res_fax_spandsp.c?view=diff&rev=319066&r1=319065&r2=319066
==============================================================================
--- team/irroot/t38gateway-1.8/res/res_fax_spandsp.c (original)
+++ team/irroot/t38gateway-1.8/res/res_fax_spandsp.c Mon May 16 04:08:31 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);
 

Propchange: team/irroot/t38gateway-1.8/sounds/Makefile
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 16 04:08:31 2011
@@ -1,3 +1,4 @@
 /be/branches/C.3/sounds/Makefile:256426
+/team/irroot/distrotech-customers-1.8/sounds/Makefile:319062-319063
 /team/irroot/t38gateway-trunk/sounds/Makefile:318977-319016
 /trunk/sounds/Makefile:270974




More information about the asterisk-commits mailing list