[svn-commits] mnicholson: branch irroot/t38gateway-trunk r323930 - /team/irroot/t38gateway-...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Jun 16 09:25:36 CDT 2011
Author: mnicholson
Date: Thu Jun 16 09:25:29 2011
New Revision: 323930
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=323930
Log:
framehook cleanups
Modified:
team/irroot/t38gateway-trunk/res/res_fax.c
team/irroot/t38gateway-trunk/res/res_fax_spandsp.c
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=323930&r1=323929&r2=323930
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax.c Thu Jun 16 09:25:29 2011
@@ -2342,33 +2342,35 @@
return gateway;
}
-/*! \brief create a fax session and start T.30<->T.38 gateway mode
+/*! \brief Create a fax session and start T.30<->T.38 gateway mode
+ * \param gateway a fax gateway object
* \param details fax session details
* \param chan active channel
* \return 0 on error 1 on success*/
-static int ast_t38_gateway(struct fax_gateway *gateway, struct ast_fax_session_details *details, struct ast_channel *chan)
+static int fax_gateway_start(struct fax_gateway *gateway, struct ast_fax_session_details *details, struct ast_channel *chan)
{
if (gateway->s) {
- return 0;
+ return -1;
}
/* create the FAX session */
details->caps = AST_FAX_TECH_GATEWAY;
if (!(gateway->s = fax_session_new(details, chan, NULL, NULL))) {
- ast_log(LOG_ERROR, "Can't create a FAX session, FAX attempt failed.\n");
+ ast_log(LOG_ERROR, "Can't create a FAX session, gateway attempt failed.\n");
+#if 0
+ /* XXX make report_fax_status() support the gateway */
report_fax_status(chan, details, "No Available Resource");
- return 0;
+#endif
+ return -1;
}
if (gateway->s->tech->start_session(gateway->s) < 0) {
ao2_ref(gateway->s, -1);
gateway->s = NULL;
- return 0;
- }
-
- /* looks like we good to go */
- gateway->s->state = AST_FAX_STATE_ACTIVE;
- return 1;
+ return -1;
+ }
+
+ return 0;
}
/*! \brief T38 Gateway Negotiate t38 parameters
@@ -2390,25 +2392,18 @@
return f;
}
- /* i am not a faxgateway */
- if (!details->option.t38gateway) {
- ast_debug(1, "T.38 Parameter without gateway enabled\n");
- ao2_ref(details, -1);
- return f;
- }
-
/* T.38 States*/
inactive = (active == chan) ? peer : chan;
activestate = ast_channel_get_t38_state(active);
inactivestate = ast_channel_get_t38_state(inactive);
t38_param = (active == chan) ? &details->our_t38_parameters : &details->their_t38_parameters;
- active_param=f->data.ptr;
+ active_param = f->data.ptr;
switch (active_param->request_response) {
/* ill need to do something inteligent with AST_T38_REQUEST_TERMINATE/AST_T38_TERMINATED like turn off frame hooks and reply */
case AST_T38_REFUSED:
- /*this is not good i should never get a refused connection ill fake negotiated other side need not know */
- ast_debug(1, "Refused on %s [%i] Sending Negotiated I: %s [%i]\n", active->name, activestate, inactive->name, inactivestate);
+ /* if T.38 was refused, activate the gateway and pretend it never happened */
+ ast_debug(1, "%s refused to negotiate T.38, gateway will fake success for %s\n", active->name, inactive->name);
t38_parameters_fax_to_ast(active_param, t38_param);
active_param->request_response = AST_T38_NEGOTIATED;
break;
@@ -2444,9 +2439,11 @@
/* Start gateway if both channels are in a stable T.38 (not negotiating) state and only one of them is not negotiated! */
if (((activestate == T38_STATE_NEGOTIATED) && ((inactivestate == T38_STATE_UNAVAILABLE) || (inactivestate == T38_STATE_REJECTED))) ||
((inactivestate == T38_STATE_NEGOTIATED) && ((activestate == T38_STATE_UNAVAILABLE) || (activestate == T38_STATE_REJECTED)))) {
- if (ast_t38_gateway(gateway, details, chan)) {
+ if (!fax_gateway_start(gateway, details, chan)) {
ast_verb(3, "T.38 Gateway starting for chan %s and peer %s\n", chan->name, peer->name);
}
+ /* XXX if starting the fax gateway fails, we should probably
+ * tear down the T.38 session */
}
ao2_ref(details, -1);
@@ -2493,8 +2490,8 @@
if (event == AST_FRAMEHOOK_EVENT_DETACHED && 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) {
+
+ if ((peer = ast_bridged_channel(chan))) {
ast_set_read_format(peer, &gateway->peer_read_format);
ast_set_read_format(peer, &gateway->peer_write_format);
ast_channel_make_compatible(chan, peer);
@@ -2512,11 +2509,13 @@
return f;
}
- s = gateway->s;
-
- /* when we become active change the formats to SLIN for CED detect and T.30 */
- peer = ast_bridged_channel(chan);
+ if (!(peer = ast_bridged_channel(chan))) {
+ /* not bridged, don't do anything */
+ return f;
+ }
+
if (!gateway->bridged && peer) {
+ /* we are bridged, change r/w formats to SLIN for CED detection and T.30 */
ast_format_copy(&gateway->chan_read_format, &chan->readformat);
ast_format_copy(&gateway->chan_write_format, &chan->readformat);
@@ -2532,6 +2531,9 @@
ast_channel_make_compatible(chan, peer);
gateway->bridged = 1;
}
+
+ s = gateway->s;
+
/* only handle VOICE, MODEM, and CONTROL frames*/
switch (f->frametype) {
@@ -2551,7 +2553,10 @@
}
return f;
case AST_FRAME_CONTROL:
- break;
+ if (f->subclass.integer == AST_CONTROL_T38_PARAMETERS) {
+ break;
+ }
+ return f;
default:
return f;
}
@@ -2569,26 +2574,18 @@
return f;
}
- /*handle control frames*/
- if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass.integer) {
- case AST_CONTROL_T38_PARAMETERS:
- /* invalaid frame im either commited to gateway or incorect size*/
- if (s || (f->datalen != sizeof(struct ast_control_t38_parameters))) {
- ast_frfree(f);
- return &ast_null_frame;
- }
- /* i have got a T.38 request before im bridged ?? perhaps im in a app or func*/
- if (!peer) {
- return f;
- }
- f = ast_t38_gateway_parameters(gateway, chan,peer,active,f);
- default:
- return f;
- }
- }
-
- /* im not a gateway let me listen for CED*/
+ /* handle control frames */
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_T38_PARAMETERS) {
+ if (s || (f->datalen != sizeof(struct ast_control_t38_parameters))) {
+ /* invalaid frame AST_CONTROL_T38_PARAMETERS frame */
+ ast_frfree(f);
+ return &ast_null_frame;
+ }
+
+ return ast_t38_gateway_parameters(gateway, chan,peer,active,f);
+ }
+
+ /* not in gateway mode yet, listen for CED */
dsp = (active == chan) ? gateway->chan_dsp : gateway->peer_dsp;
if (!s && chan && peer && dsp && (f->frametype == AST_FRAME_VOICE)) {
dfr = ast_frdup(f);
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=323930&r1=323929&r2=323930
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax_spandsp.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax_spandsp.c Thu Jun 16 09:25:29 2011
@@ -730,6 +730,8 @@
t38_core_send_indicator(&p->t38_gw_state.t38, T38_IND_NO_SIGNAL, p->t38_gw_state.t38.indicator_tx_count);
#endif
}
+
+ s->state = AST_FAX_STATE_ACTIVE;
return 0;
}
More information about the svn-commits
mailing list