[asterisk-commits] mnicholson: branch irroot/t38gateway-trunk r323861 - /team/irroot/t38gateway-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 15 14:52:12 CDT 2011


Author: mnicholson
Date: Wed Jun 15 14:52:06 2011
New Revision: 323861

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=323861
Log:
more code cleanups

Modified:
    team/irroot/t38gateway-trunk/res/res_fax_spandsp.c

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=323861&r1=323860&r2=323861
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax_spandsp.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax_spandsp.c Wed Jun 15 14:52:06 2011
@@ -77,7 +77,7 @@
 static int spandsp_fax_switch_to_t38(struct ast_fax_session *s);
 static int spandsp_fax_gateway_start(struct ast_fax_session *s);
 static int spandsp_fax_gateway_process(struct ast_fax_session *s, const struct ast_frame *f);
-static void spandsp_fax_gateway_clean(struct ast_fax_session *s);
+static void spandsp_fax_gateway_destroy(struct ast_fax_session *s);
 
 static char *spandsp_fax_cli_show_capabilities(int fd);
 static char *spandsp_fax_cli_show_session(struct ast_fax_session *s, int fd);
@@ -459,14 +459,17 @@
 		goto e_return;
 	}
 
+	if (s->details->caps & AST_FAX_TECH_GATEWAY) {
+		s->state = AST_FAX_STATE_INITIALIZED;
+		return p;
+	}
+
 	AST_LIST_HEAD_INIT(&p->read_frames);
 
 	if (s->details->caps & AST_FAX_TECH_RECEIVE) {
 		caller_mode = 0;
 	} else if (s->details->caps & AST_FAX_TECH_SEND) {
 		caller_mode = 1;
-	} else if (s->details->caps & AST_FAX_TECH_GATEWAY) {
-		caller_mode = 2;
 	} else {
 		ast_log(LOG_ERROR, "Are we sending or receiving? The FAX requirements (capabilities: 0x%X) were not properly set.\n", s->details->caps);
 		goto e_free;
@@ -515,11 +518,11 @@
 	struct spandsp_pvt *p = s->tech_pvt;
 
 	if (s->details->caps & AST_FAX_TECH_GATEWAY) {
-		spandsp_fax_gateway_clean(s);
-		return;
-	}
-
-	session_destroy(p);
+		spandsp_fax_gateway_destroy(s);
+	} else {
+		session_destroy(p);
+	}
+
 	ast_free(p);
 	s->tech_pvt = NULL;
 	s->fd = -1;
@@ -662,7 +665,7 @@
 	p->t38_core_state=&p->t38_gw_state.t38;
 #endif
 
-	if (! t38_gateway_init(&p->t38_gw_state, t38_tx_packet_handler, s)) {
+	if (!t38_gateway_init(&p->t38_gw_state, t38_tx_packet_handler, s)) {
 		return -1;
 	}
 
@@ -676,10 +679,8 @@
 	ast_activate_generator((p->ast_t38_state == T38_STATE_NEGOTIATED) ? peer : s->chan, &t30_gen , s);
 	ast_channel_unlock(s->chan);
 
-	span_log_set_message_handler(&p->t38_gw_state.logging, spandsp_log);
-	span_log_set_message_handler(&p->t38_core_state->logging, spandsp_log);
-	span_log_set_level(&p->t38_gw_state.logging, SPAN_LOG_WARNING + option_debug);
-	span_log_set_level(&p->t38_core_state->logging, SPAN_LOG_WARNING + option_debug);
+	set_logging(&p->t38_gw_state.logging, s->details);
+	set_logging(&p->t38_core_state->logging, s->details);
 
 	t38_param = (p->ast_t38_state == T38_STATE_NEGOTIATED) ? &s->details->our_t38_parameters : &s->details->their_t38_parameters;
 	t38_set_t38_version(p->t38_core_state, t38_param->version);
@@ -691,7 +692,7 @@
 	t38_set_data_rate_management_method(p->t38_core_state, 
 			(t38_param->rate_management == AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF)? 1 : 2);
 
-	/* need to be configrable FAXOPT ??*/
+	/* XXX should this be configurable via FAXOPT? */
 	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);
@@ -739,31 +740,21 @@
 
 /*! \brief gather data and clean up after gateway ends
  * \param s fax session*/
-static void spandsp_fax_gateway_clean(struct ast_fax_session *s)
+static void spandsp_fax_gateway_destroy(struct ast_fax_session *s)
 {
 	struct spandsp_pvt *p = s->tech_pvt;
 	t38_stats_t t38_stats;
-	struct ast_frame *f;
-
-	if (!p) {
-		return;
-	}
 
 	t38_gateway_get_transfer_statistics(&p->t38_gw_state, &t38_stats);
+
+	/* XXX remove this output */
 	ast_verb(3, "Connection Statistics\n\tBit Rate :%i\n\tECM : %s\n\tPages : %i\n",
 			t38_stats.bit_rate, 
 			(t38_stats.error_correcting_mode?"Yes":"No"), 
 			t38_stats.pages_transferred);
 
-	p->isdone = 1;
-	ast_timer_close(p->timer);
-
-	while ((f = AST_LIST_REMOVE_HEAD(&p->read_frames, frame_list))) {
-		ast_frfree(f);
-	}
-
-	free(p);
-	s->tech_pvt = NULL;
+	s->details->pages_transferred = t38_stats.pages_transferred;
+	ast_string_field_build(s->details, transfer_rate, "%d", t38_stats.bit_rate);
 }
 
 /*! \brief */




More information about the asterisk-commits mailing list