[asterisk-commits] file: branch file/t38improvements r201330 - /team/file/t38improvements/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 17 09:35:27 CDT 2009


Author: file
Date: Wed Jun 17 09:35:23 2009
New Revision: 201330

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201330
Log:
Add a bit more progress. The parameters T38 control frame is now interpreted and the local capabilities updated. This means the outgoing reinvite now reflects what the application/channel requested. More to go, but a little bit further.

Modified:
    team/file/t38improvements/channels/chan_sip.c

Modified: team/file/t38improvements/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/t38improvements/channels/chan_sip.c?view=diff&rev=201330&r1=201329&r2=201330
==============================================================================
--- team/file/t38improvements/channels/chan_sip.c (original)
+++ team/file/t38improvements/channels/chan_sip.c Wed Jun 17 09:35:23 2009
@@ -6389,6 +6389,66 @@
 	return res;
 }
 
+/*! \brief Helper function which updates T.38 capability information and triggers a reinvite */
+static void interpret_t38_parameters(struct sip_pvt *p, enum ast_control_t38 request_response, const struct ast_control_t38_parameters *parameters)
+{
+	if (parameters) {
+		p->t38.capability = p->t38.jointcapability = T38FAX_VERSION_0;
+
+		if (parameters->ec == AST_T38_EC_NONE) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_UDP_EC_NONE;
+		} else if (parameters->ec == AST_T38_EC_FEC) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_UDP_EC_FEC;
+		} else if (parameters->ec == AST_T38_EC_REDUNDANCY) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_UDP_EC_REDUNDANCY;
+		}
+
+		if (parameters->rate == AST_T38_RATE_14400) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+		} else if (parameters->rate == AST_T38_RATE_12000) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+		} else if (parameters->rate == AST_T38_RATE_9600) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+		} else if (parameters->rate == AST_T38_RATE_7200) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+		} else if (parameters->rate == AST_T38_RATE_4800) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_4800 | T38FAX_RATE_2400;
+		} else if (parameters->rate == AST_T38_RATE_2400) {
+			p->t38.capability = p->t38.jointcapability |= T38FAX_RATE_2400;
+		}
+	}
+
+	switch (request_response) {
+	case AST_T38_NEGOTIATED:
+	case AST_T38_REQUEST_NEGOTIATE:         /* Request T38 */
+		if (p->t38.state == T38_PEER_REINVITE) {
+			AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
+			change_t38_state(p, T38_ENABLED);
+			transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
+		} else if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT) && p->t38.state != T38_ENABLED) {
+			change_t38_state(p, T38_LOCAL_REINVITE);
+			if (!p->pendinginvite) {
+				transmit_reinvite_with_sdp(p, TRUE, FALSE);
+			} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
+				ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
+			}
+		}
+		break;
+	case AST_T38_TERMINATED:
+	case AST_T38_REFUSED:
+	case AST_T38_REQUEST_TERMINATE:         /* Shutdown T38 */
+		if (p->t38.state == T38_PEER_REINVITE) {
+			AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
+			change_t38_state(p, T38_DISABLED);
+			transmit_response_reliable(p, "488 Not acceptable here", &p->initreq);
+		} else if (p->t38.state == T38_ENABLED)
+			transmit_reinvite_with_sdp(p, FALSE, FALSE);
+		break;
+	default:
+		break;
+	}
+}
+
 /*! \brief Play indication to user 
  * With SIP a lot of indications is sent as messages, letting the device play
    the indication - busy signal, congestion etc 
@@ -6477,35 +6537,15 @@
 		if (datalen != sizeof(enum ast_control_t38)) {
 			ast_log(LOG_ERROR, "Invalid datalen for AST_CONTROL_T38. Expected %d, got %d\n", (int)sizeof(enum ast_control_t38), (int)datalen);
 		} else {
-			switch (*((enum ast_control_t38 *) data)) {
-			case AST_T38_NEGOTIATED:
-			case AST_T38_REQUEST_NEGOTIATE:		/* Request T38 */
-				if (p->t38.state == T38_PEER_REINVITE) {
-					AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
-					change_t38_state(p, T38_ENABLED);
-					transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
-				} else if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT) && p->t38.state != T38_ENABLED) {
-					change_t38_state(p, T38_LOCAL_REINVITE);
-					if (!p->pendinginvite) {
-						transmit_reinvite_with_sdp(p, TRUE, FALSE);
-					} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-						ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
-					}
-				}
-				break;
-			case AST_T38_TERMINATED:
-			case AST_T38_REFUSED:
-			case AST_T38_REQUEST_TERMINATE:		/* Shutdown T38 */
-				if (p->t38.state == T38_PEER_REINVITE) {
-					AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
-					change_t38_state(p, T38_DISABLED);
-					transmit_response_reliable(p, "488 Not acceptable here", &p->initreq);
-				} else if (p->t38.state == T38_ENABLED)
-					transmit_reinvite_with_sdp(p, FALSE, FALSE);
-				break;
-			default:
-				break;
-			}
+			interpret_t38_parameters(p, *((enum ast_control_t38 *) data), NULL);
+		}
+		break;
+	case AST_CONTROL_T38_PARAMETERS:
+		if (datalen != sizeof(struct ast_control_t38_parameters)) {
+			ast_log(LOG_ERROR, "Invalid datalen for AST_CONTROL_T38_PARAMETERS. Expected %d, got %d\n", (int)sizeof(struct ast_control_t38_parameters), (int)datalen);
+		} else {
+			const struct ast_control_t38_parameters *parameters = data;
+			interpret_t38_parameters(p, parameters->request_response, parameters);
 		}
 		break;
 	case AST_CONTROL_SRCUPDATE:




More information about the asterisk-commits mailing list