[asterisk-commits] may: branch may/chan_ooh323_rework r207483 - in /team/may/chan_ooh323_rework/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 20 15:43:50 CDT 2009


Author: may
Date: Mon Jul 20 15:43:46 2009
New Revision: 207483

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=207483
Log:
Full t.38 with t30 audio to t.38 transparent conversion

Modified:
    team/may/chan_ooh323_rework/addons/Makefile
    team/may/chan_ooh323_rework/addons/chan_ooh323.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCmdChannel.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.h
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ootypes.h

Modified: team/may/chan_ooh323_rework/addons/Makefile
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/Makefile?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/Makefile (original)
+++ team/may/chan_ooh323_rework/addons/Makefile Mon Jul 20 15:43:46 2009
@@ -44,9 +44,9 @@
 
 $(if $(filter format_mp3,$(EMBEDDED_MODS)),modules.link,format_mp3.so): mp3/common.o mp3/dct64_i386.o mp3/decode_ntom.o mp3/layer3.o mp3/tabinit.o mp3/interface.o
 
-chan_ooh323.o: ASTCFLAGS+=$(H323CFLAGS)
+chan_ooh323.o: ASTCFLAGS+=$(H323CFLAGS) $(SPANDSP_INCLUDE)
 
-chan_ooh323.so: ASTLDFLAGS+=-lrt
+chan_ooh323.so: ASTLDFLAGS+=-lrt $(SPANDSP_LIBS)
 
 $(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): ASTCFLAGS+=$(H323CFLAGS)
 $(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): $(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o

Modified: team/may/chan_ooh323_rework/addons/chan_ooh323.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/chan_ooh323.c?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/chan_ooh323.c (original)
+++ team/may/chan_ooh323_rework/addons/chan_ooh323.c Mon Jul 20 15:43:46 2009
@@ -17,7 +17,22 @@
 
 #include "chan_ooh323.h"
 #include <math.h>
-#include <spandsp.h>
+#include "spandsp.h"
+#include "spandsp/private/logging.h"
+#include "spandsp/private/fsk.h"
+#include "spandsp/private/modem_connect_tones.h"
+#include "spandsp/private/v17rx.h"
+#include "spandsp/private/v17tx.h"
+#include "spandsp/private/v29rx.h"
+#include "spandsp/private/v29tx.h"
+#include "spandsp/private/v27ter_rx.h"
+#include "spandsp/private/v27ter_tx.h"
+#include "spandsp/private/hdlc.h"
+#include "spandsp/private/fax_modems.h"
+#include "spandsp/private/t38_core.h"
+#include "spandsp/private/t38_non_ecm_buffer.h"
+#include "spandsp/private/t38_gateway.h"
+
 
 /* Defaults */
 #define DEFAULT_CONTEXT "default"
@@ -35,6 +50,9 @@
 #define H323_NEEDDESTROY        (1<<6)
 #define H323_DISABLEGK          (1<<7)
 #define H323_NEEDSTART		(1<<8)
+
+#define MAXT30	240
+#define T38TOAUDIOTIMEOUT 30
 
 /* Channel description */
 static const char type[] = "OOH323";
@@ -114,8 +132,10 @@
 	int t38_tx_enable;
 	int t38_init;
 	t38_gateway_state_t t38r_state;
+	t38_gateway_state_t t38t_state;
 	struct sockaddr_in udptlredirip;
 	time_t lastTxT38;
+	int chmodepend;
 
 	struct ast_channel *owner;	/* Master Channel */
    	union {
@@ -334,6 +354,11 @@
 		if (i->dtmfmode & H323_DTMF_INBAND) {
 			i->vad = ast_dsp_new();
 			ast_dsp_set_features(i->vad, DSP_FEATURE_DIGIT_DETECT);
+       			ast_dsp_set_features(i->vad,
+						DSP_FEATURE_DIGIT_DETECT | DSP_FEATURE_FAX_DETECT);
+        		ast_dsp_set_faxmode(i->vad,
+						DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED);
+
 			if (i->dtmfmode & H323_DTMF_INBANDRELAX)
 				ast_dsp_set_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
 		}
@@ -758,7 +783,18 @@
 		return -1;
 	}
 	ast_mutex_lock(&p->lock);
-	if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
+
+
+	if (digit == 'e' && !p->faxmode)  {
+		if (!p->chmodepend) {
+			if (gH323Debug)
+				ast_verbose("request to change %s to t.38 because fax cng\n",
+						p->callToken);
+			p->chmodepend = 1;
+			ooRequestChangeMode(p->callToken, 1);
+		}
+
+	} else if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
 		ast_rtp_instance_dtmf_begin(p->rtp, digit);
 	} else if (((p->dtmfmode & H323_DTMF_Q931) ||
 						 (p->dtmfmode & H323_DTMF_H245ALPHANUMERIC) ||
@@ -1062,13 +1098,16 @@
 					if (gH323Debug)
 						ast_debug(4, "t38gw_rx %d\n", t38samples);
 				}
+
                         	res = f->samples;
                 		time_t ct = time(NULL);
-                		/* if (ct - pvt->lastTxT38 > T38TOAUDIOTIMEOUT && !p->chmodepend) {
-                        		ast_debug(1,"request to change %s to audio because t38 timeout\n", ast->name);
-                        		h323_mode_change(token,0);
-                        			pvt->chmodepend = 1;
-                        	} */
+                		if (ct - p->lastTxT38 > T38TOAUDIOTIMEOUT && !p->chmodepend) {
+					if (gH323Debug)
+                        			ast_verbose("request to change %s to audio because"
+							 "t38 timeout\n", ast->name);
+					ooRequestChangeMode(p->callToken, 0);
+                        		p->chmodepend = 1;
+                        	} 
 				ast_mutex_unlock(&p->lock);
 				return res;
 			}
@@ -3752,7 +3791,7 @@
 				f->frametype, f->subclass, f->datalen, ast->name);
 		if (!p->faxmode) p->faxmode = 1;
 		if (p->t38_init) {
-			t38_core_rx_ifp_packet(&p->t38r_state.t38, (uint8_t *)f->data.ptr,
+			t38_core_rx_ifp_packet(&p->t38r_state.t38x.t38, (uint8_t *)f->data.ptr,
                                          f->datalen, 0);
 			p->lastTxT38 = time(NULL);
                 }
@@ -3791,8 +3830,6 @@
 	return f;
 }
 
-#define MAXT30  240
-
 static int t30_read(const void *data) {
 
 	struct ast_channel *c = (struct ast_channel *) data;
@@ -3836,6 +3873,7 @@
 
 	if (p->faxmode && p->t38_init && p->t38_tx_enable) {
 
+
 		if ((len = t38_gateway_tx(&p->t38r_state, buf, MAXT30))) {
 
 			outf.samples = len;
@@ -3846,7 +3884,6 @@
 		}
 	}
 
-	ast_settimeout(c, 50, t30_read, c);
 	ast_channel_unlock(c);
 	ast_mutex_unlock(&p->lock);
 	return 0;
@@ -3932,24 +3969,61 @@
 
 	if (t38mode) {
 
-		if (t38_gateway_init(&p->t38r_state, t38_tx_packet_handler, p)) {
+		if (t38_gateway_init(&p->t38r_state, t38_tx_packet_handler, p) && 
+		    t38_gateway_init(&p->t38t_state, t38_tx_packet_handler, p)) {
 			p->t38_init = 1;
+
 			t38_gateway_set_transmit_on_idle(&p->t38r_state, FALSE);
+
 			span_log_set_tag(&p->t38r_state.logging, "T.38G");
-			span_log_set_tag(&p->t38r_state.t38.logging, "T.38");
+			span_log_set_tag(&p->t38r_state.t38x.t38.logging, "T.38");
+
 			span_log_set_message_handler(&p->t38r_state.logging, span_message);
-			span_log_set_message_handler(&p->t38r_state.t38.logging, span_message);
+			span_log_set_message_handler(&p->t38r_state.t38x.t38.logging, span_message);
+
 			span_log_set_level(&p->t38r_state.logging,
 				SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-			span_log_set_level(&p->t38r_state.t38.logging,
+			span_log_set_level(&p->t38r_state.t38x.t38.logging,
 				SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
 
-			t38_set_t38_version(&p->t38r_state.t38, 0);
-			t38_set_sequence_number_handling(&p->t38r_state.t38,0);
+
+			t38_set_t38_version(&p->t38r_state.t38x.t38, 0);
+
+			t38_set_sequence_number_handling(&p->t38r_state.t38x.t38,0);
+
 			t38_gateway_set_ecm_capability(&p->t38r_state, 1);
+
 			t38_gateway_set_tep_mode(&p->t38r_state, TRUE);
+
 			t38_gateway_set_supported_modems(&p->t38r_state,
 				T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER);
+
+
+			t38_gateway_set_transmit_on_idle(&p->t38t_state, FALSE);
+
+			span_log_set_tag(&p->t38t_state.logging, "T.38G");
+			span_log_set_tag(&p->t38t_state.t38x.t38.logging, "T.38");
+
+			span_log_set_message_handler(&p->t38t_state.logging, span_message);
+			span_log_set_message_handler(&p->t38t_state.t38x.t38.logging, span_message);
+
+			span_log_set_level(&p->t38t_state.logging,
+				SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+			span_log_set_level(&p->t38t_state.t38x.t38.logging,
+				SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
+
+
+			t38_set_t38_version(&p->t38t_state.t38x.t38, 0);
+
+			t38_set_sequence_number_handling(&p->t38t_state.t38x.t38,0);
+
+			t38_gateway_set_ecm_capability(&p->t38t_state, 1);
+
+			t38_gateway_set_tep_mode(&p->t38t_state, TRUE);
+
+			t38_gateway_set_supported_modems(&p->t38t_state,
+				T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER);
+
 			if (gH323Debug)
 				ast_debug(1,"Going to change native format for %s\n", call->callToken);
 			p->owner->nativeformats = AST_FORMAT_SLINEAR;
@@ -3959,16 +4033,16 @@
 			ast_set_write_format(p->owner, p->owner->rawwriteformat);
 			p->faxmode = 1;
 			ast_channel_unlock(p->owner);
-			ast_settimeout(p->owner, 50, t30_read, p->owner);
+			ast_settimeout(p->owner, 34, t30_read, p->owner);
 			ast_channel_lock(p->owner);
+			p->lastTxT38 = time(NULL);
 		}
 	} else {
 		p->faxmode = 0;
 		p->t38_init = 0;
-		/* p->chmodepending = 0; */
-	}
-
-
+	}
+
+	p->chmodepend = 0;
 	ast_channel_unlock(p->owner);
 	ast_mutex_unlock(&p->lock);
 }

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h Mon Jul 20 15:43:46 2009
@@ -200,6 +200,8 @@
    unsigned             nextSessionID; /* Note by default 1 is audio session, 2 is video and 3 is data, from 3 onwards master decides*/
    DList                timerList;
    ASN1UINT             msdRetries;
+   ASN1UINT8		requestSequence;
+   ASN1UINT		reqFlags;
    H235TimeStamp	alertingTime, connectTime, endTime; /* time data for gatekeeper */
    FastStartResponse    *pFastStartRes; /* fast start response */
    void                 *usrData; /*!<User can set this to user specific data*/

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c Mon Jul 20 15:43:46 2009
@@ -1081,6 +1081,37 @@
    return NULL;
 }
 
+/* Our t.38 params */
+
+struct H245DataMode_application* ooCreateT38ApplicationData
+				(OOCTXT* pctxt, H245DataMode_application *app)
+{
+      app->t = T_H245DataApplicationCapability_application_t38fax;
+      app->u.t38fax =
+	(H245DataApplicationCapability_application_t38fax *) memAlloc(pctxt, 
+	sizeof(H245DataApplicationCapability_application_t38fax));
+      if (!app->u.t38fax) {
+         OOTRACEERR1("Error:Memory - ooCreateT38AppData\n");
+         return NULL;
+      }
+      memset(app->u.t38fax, 0, sizeof(H245DataApplicationCapability_application_t38fax));
+      app->u.t38fax->t38FaxProtocol.t = T_H245DataProtocolCapability_udp;
+      app->u.t38fax->t38FaxProfile.m.versionPresent = TRUE;
+      app->u.t38fax->t38FaxProfile.version = 0;
+      app->u.t38fax->t38FaxProfile.m.t38FaxRateManagementPresent = TRUE;
+      app->u.t38fax->t38FaxProfile.t38FaxRateManagement.t =
+						T_H245T38FaxRateManagement_transferredTCF;
+      app->u.t38fax->t38FaxProfile.m.t38FaxUdpOptionsPresent = TRUE;
+      app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.m.t38FaxMaxBufferPresent = TRUE;
+      app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxMaxBuffer = 200;
+      app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.m.t38FaxMaxDatagramPresent = TRUE;
+      app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxMaxDatagram = 72;
+      app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxUdpEC.t =
+						T_H245T38FaxUdpOptions_t38FaxUdpEC_t38UDPFEC;
+
+      return app;
+}
+
 /* This is used for T.38 */
 struct H245DataApplicationCapability* ooCapabilityCreateT38Capability
    (ooH323EpCapability *epCap, OOCTXT* pctxt, int dir)
@@ -1108,30 +1139,11 @@
    {
    case OO_T38:
       pT38->maxBitRate = 144;
-      pT38->application.t = T_H245DataApplicationCapability_application_t38fax;
-      pT38->application.u.t38fax =
-	(H245DataApplicationCapability_application_t38fax *) memAlloc(pctxt, 
-	sizeof(H245DataApplicationCapability_application_t38fax));
-      if (!pT38->application.u.t38fax) {
+      if (!ooCreateT38ApplicationData(pctxt,&(pT38->application))) {
          OOTRACEERR2("Error:Memory - ooCapabilityCreateT38Capability - %d\n", epCap->cap);
          memFreePtr(pctxt, pT38);
          return NULL;
       }
-      memset(pT38->application.u.t38fax, 0, sizeof(H245DataApplicationCapability_application_t38fax));
-      pT38->application.u.t38fax->t38FaxProtocol.t = T_H245DataProtocolCapability_udp;
-      pT38->application.u.t38fax->t38FaxProfile.m.versionPresent = TRUE;
-      pT38->application.u.t38fax->t38FaxProfile.version = 0;
-      pT38->application.u.t38fax->t38FaxProfile.m.t38FaxRateManagementPresent = TRUE;
-      pT38->application.u.t38fax->t38FaxProfile.t38FaxRateManagement.t =
-						T_H245T38FaxRateManagement_transferredTCF;
-      pT38->application.u.t38fax->t38FaxProfile.m.t38FaxUdpOptionsPresent = TRUE;
-      pT38->application.u.t38fax->t38FaxProfile.t38FaxUdpOptions.m.t38FaxMaxBufferPresent = TRUE;
-      pT38->application.u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxMaxBuffer = 200;
-      pT38->application.u.t38fax->t38FaxProfile.t38FaxUdpOptions.m.t38FaxMaxDatagramPresent = TRUE;
-      pT38->application.u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxMaxDatagram = 72;
-      pT38->application.u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxUdpEC.t =
-						T_H245T38FaxUdpOptions_t38FaxUdpEC_t38UDPFEC;
-   
       return pT38;
 
    default:

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h Mon Jul 20 15:43:46 2009
@@ -660,6 +660,10 @@
 ooH323EpCapability* ooIsDataTypeSupported
 (struct OOH323CallData *call, H245DataType *data, int dir);
 
+/* fill t.38 application data */
+H245DataMode_application* ooCreateT38ApplicationData
+                                (OOCTXT* pctxt, H245DataMode_application *app);
+
 /**
  * This function is used to clear the capability preference order.
  * @param call      Handle to call, if capability preference order for call

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCmdChannel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCmdChannel.c?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCmdChannel.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCmdChannel.c Mon Jul 20 15:43:46 2009
@@ -397,6 +397,12 @@
 
                break;
 
+	    case OO_CMD_REQMODE:
+	       OOTRACEINFO3("Processing RequestMode command %s, requested mode is %d\n",
+				(char *)cmd.param1, *(int *)cmd.param2);
+	       ooSendRequestMode(call, *(int *)cmd.param2);
+	       break;
+
             default: OOTRACEERR1("ERROR:Unknown command\n");
          }
       }

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.c?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.c Mon Jul 20 15:43:46 2009
@@ -494,6 +494,54 @@
    return OO_STKCMD_SUCCESS;
 }
 
+OOStkCmdStat ooRequestChangeMode(const char *callToken, int isT38Mode)
+{
+   OOStackCommand cmd;
+   OOH323CallData *call;
+
+   if(!callToken)
+   {
+      return OO_STKCMD_INVALIDPARAM;
+   }
+
+   if(!(call = ooFindCallByToken(callToken))) {
+      return OO_STKCMD_INVALIDPARAM;
+   }
+
+   if(call->CmdChan == 0)
+   {
+      if(ooCreateCallCmdConnection(call) != OO_OK)
+         return OO_STKCMD_CONNECTIONERR;
+   }
+
+   memset(&cmd, 0, sizeof(OOStackCommand));
+   cmd.type = OO_CMD_REQMODE;
+
+   cmd.param1 = (void*) malloc(strlen(callToken)+1);
+   cmd.param2 = (void*) malloc(sizeof(int));
+   if(!cmd.param1 || !cmd.param2)
+   {
+      if(cmd.param1)   free(cmd.param1); /* Release memory */
+      if(cmd.param2)   free(cmd.param2);
+      return OO_STKCMD_MEMERR;
+   }
+   strcpy((char*)cmd.param1, callToken);
+   cmd.plen1 = strlen(callToken);
+   *((int *) cmd.param2) = isT38Mode;
+   cmd.plen2 = sizeof(int);
+   
+   if(ooWriteCallStackCommand(call,&cmd) != OO_OK)
+   {
+      free(cmd.param1);
+      free(cmd.param2);
+      return OO_STKCMD_WRITEERR;
+   }
+   free(cmd.param1);
+   free(cmd.param2);
+
+   return OO_STKCMD_SUCCESS;
+}
+
 
 const char* ooGetStkCmdStatusCodeTxt(OOStkCmdStat stat)
 {

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.h?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooStackCmds.h Mon Jul 20 15:43:46 2009
@@ -66,7 +66,8 @@
    OO_CMD_SENDDIGIT,         /*!< Send dtmf */
    OO_CMD_MANUALRINGBACK,    /*!< Send Alerting - ringback */
    OO_CMD_MANUALPROGRESS,    /*!< Send progress */
-   OO_CMD_STOPMONITOR        /*!< Stop the event monitor */
+   OO_CMD_STOPMONITOR,       /*!< Stop the event monitor */
+   OO_CMD_REQMODE	     /*!< Request new mode */
    
 } OOStackCmdID;
 

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c Mon Jul 20 15:43:46 2009
@@ -1212,6 +1212,7 @@
    ooFreeH245Message(call, ph245msg);
    return ret;
 }
+
 int ooSendRequestModeReject(OOH323CallData* call,
                                       H245SequenceNumber sequenceNumber)
 {
@@ -1254,6 +1255,113 @@
    
    ooFreeH245Message(call, ph245msg);
    return ret;
+}
+
+int ooSendRequestMode(OOH323CallData* call,
+                                      int isT38Mode)
+{
+   int ret=0;
+   H245RequestMessage *request;
+   H245Message *ph245msg=NULL;
+   OOCTXT *pctxt=call->msgctxt;
+
+
+   H245ModeDescription pModeDesc;
+   H245ModeElement pModeElem;
+   H245ModeElement* pModeElemRef = &pModeElem;
+
+   ret = ooCreateH245Message(call, &ph245msg, 
+                      T_H245MultimediaSystemControlMessage_request);
+   if(ret != OO_OK)
+   {
+      OOTRACEERR3("Error:H245 message creation failed for - RequstMode "
+                  "(%s, %s)\n",call->callType, 
+                  call->callToken);
+      return OO_FAILED;
+   }
+   ph245msg->msgType = OORequestMode;
+   request = ph245msg->h245Msg.u.request;
+   memset(request, 0, sizeof(H245RequestMessage));
+   request->t = T_H245RequestMessage_requestMode;
+
+   request->u.requestMode = (H245RequestMode *)
+                   ASN1MALLOC(pctxt, sizeof(H245RequestMode));
+   memset(request->u.requestMode, 0, 
+                             sizeof(H245RequestMode));
+
+   call->requestSequence++;
+   call->reqFlags = (isT38Mode) ? OO_M_DATASESSION : OO_M_AUDIOSESSION;
+
+   request->u.requestMode->sequenceNumber = call->requestSequence;
+   memset(&pModeElem, 0, sizeof(pModeElem));
+   memset(&pModeDesc, 0, sizeof(pModeDesc));
+   dListInit(&(request->u.requestMode->requestedModes));
+   dListInit(&pModeDesc);
+
+   if (isT38Mode) {
+
+   	pModeElem.type.t = T_H245ModeElementType_dataMode;
+   	pModeElem.type.u.dataMode = (H245DataMode *) memAllocZ(pctxt, sizeof(H245DataMode));
+   	pModeElem.type.u.dataMode->bitRate = 144;
+   	if (!ooCreateT38ApplicationData(pctxt,&(pModeElem.type.u.dataMode->application))) {
+       		OOTRACEERR3("Error:Memory - ooCapabilityCreateT38Capability - (%s, %s)\n",
+						call->callType, 
+						call->callToken);
+   	}
+   } else {
+	pModeElem.type.t = T_H245ModeElementType_audioMode;
+	pModeElem.type.u.audioMode = (H245AudioMode *) memAllocZ(pctxt, sizeof(H245AudioMode));
+	pModeElem.type.u.audioMode->t = T_H245AudioMode_genericAudioMode;
+	pModeElem.type.u.audioMode->u.genericAudioMode = (H245GenericCapability *)
+					memAllocZ(pctxt, sizeof(H245GenericCapability));
+        pModeElem.type.u.audioMode->u.genericAudioMode->capabilityIdentifier.t =
+					 T_H245CapabilityIdentifier_domainBased;
+	pModeElem.type.u.audioMode->u.genericAudioMode->capabilityIdentifier.u.domainBased =
+					 "H.323";
+        pModeElem.type.u.audioMode->u.genericAudioMode->m.maxBitRatePresent = TRUE;
+        pModeElem.type.u.audioMode->u.genericAudioMode->maxBitRate = 144;
+   }
+
+   dListAppend(pctxt, &pModeDesc, &pModeElem);
+   dListAppend(pctxt, &(request->u.requestMode->requestedModes), &pModeDesc);
+
+   ret = ooSendH245Msg(call, ph245msg);
+   if(ret != OO_OK)
+   {
+      OOTRACEERR3("Error:Failed to enqueue RequestMode message"
+                  " to outbound queue. (%s, %s)\n", call->callType, 
+                  call->callToken);
+   }
+   
+   ooFreeH245Message(call, ph245msg);
+   return ret;
+}
+
+void ooOnReceivedRequestModeAck(OOH323CallData* call, H245RequestModeAck * requestModeAck)
+{
+	int t38mode;
+
+	if (!call->reqFlags) return;
+
+	if (OO_TESTFLAG(call->reqFlags, OO_M_AUDIOSESSION)) {
+ 		OO_SETFLAG(call->flags, OO_M_AUDIOSESSION);
+		OO_CLRFLAG(call->flags, OO_M_DATASESSION);
+		t38mode = 0;
+	} else {
+ 		OO_CLRFLAG(call->flags, OO_M_AUDIOSESSION);
+		OO_SETFLAG(call->flags, OO_M_DATASESSION);
+		t38mode = 1;
+	}
+
+	call->reqFlags = 0; /* don't handle duplicate ack packet */
+
+	ooCloseAllLogicalChannels(call);
+	if(gH323ep.h323Callbacks.onModeChanged) {
+		OOTRACEDBGA3("Handle RequestModeAck: (%s, %s), calling "
+			"callback onModeChanged\n", call->callType, call->callToken);
+		gH323ep.h323Callbacks.onModeChanged(call, t38mode);
+	}
+	ooOpenLogicalChannels(call);
 }
 
 int ooHandleRequestMode(OOH323CallData* call,
@@ -1275,7 +1383,9 @@
   switch (pMode->t) {
 	case T_H245ModeElementType_dataMode:
 		if (pMode->u.dataMode->application.t == T_H245DataMode_application_t38fax) {
-			if (ooSendRequestModeAck(call, requestMode->sequenceNumber) == OO_OK) {
+			if (ooSendRequestModeAck(call, requestMode->sequenceNumber) == OO_OK &&
+				OO_TESTFLAG(call->flags, OO_M_AUDIOSESSION)) {
+
 				OO_CLRFLAG(call->flags, OO_M_AUDIOSESSION);
 				OO_SETFLAG(call->flags, OO_M_DATASESSION);
 				ooCloseAllLogicalChannels(call);
@@ -1286,10 +1396,24 @@
 				}
 				ooOpenLogicalChannels(call);
 			}
+		} else {
+			ooSendRequestModeReject(call, requestMode->sequenceNumber);
 		}
 		break;
 	case T_H245ModeElementType_audioMode:
-		ooSendRequestModeReject(call, requestMode->sequenceNumber);
+		if (ooSendRequestModeAck(call, requestMode->sequenceNumber) == OO_OK && 
+			OO_TESTFLAG(call->flags, OO_M_DATASESSION)) {
+
+			OO_CLRFLAG(call->flags, OO_M_DATASESSION);
+			OO_SETFLAG(call->flags, OO_M_AUDIOSESSION);
+			ooCloseAllLogicalChannels(call);
+			if(gH323ep.h323Callbacks.onModeChanged) {
+				OOTRACEDBGA3("Handle RequestMode: (%s, %s), calling "
+				"callback onModeChanged\n", call->callType, call->callToken);
+				gH323ep.h323Callbacks.onModeChanged(call, 0);
+			}
+			ooOpenLogicalChannels(call);
+		}
 		break;
 	default:
 		;
@@ -2533,6 +2657,21 @@
                   call->callEndReason = OO_REASON_NOCOMMON_CAPABILITIES;
                }
                break;
+            case T_H245ResponseMessage_requestModeAck:
+	       if (call->requestSequence == response->u.requestModeAck->sequenceNumber) {
+			/* response to our last request, process it */
+               		ooOnReceivedRequestModeAck(call, response->u.requestModeAck);
+	       }
+               break;
+            case T_H245ResponseMessage_requestModeReject:
+		OOTRACEDBGC3("Received requestModeReject, clearing call (%s, %s)\n",
+				 call->callType, call->callToken);
+               if(call->callState < OO_CALL_CLEAR)
+               {
+                  call->callState = OO_CALL_CLEAR;
+                  call->callEndReason = OO_REASON_REMOTE_REJECTED;
+               }
+               break;
             case T_H245ResponseMessage_openLogicalChannelAck:
                for(i = 0; i<call->timerList.count; i++)
                {

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c Mon Jul 20 15:43:46 2009
@@ -3606,7 +3606,11 @@
       "OORequestChannelCloseAck",
       "OORequestChannelCloseReject",
       "OORequestChannelCloseRelease",
-      "OOEndSessionCommand"
+      "OOEndSessionCommand",
+      "OOUserInputIndication",
+      "OORequestModeAck",
+      "OORequestModeReject",
+      "OORequestMode"
    };
    int idx = msgType - OO_MSGTYPE_MIN;
    return ooUtilsGetText (idx, msgTypeText, OONUMBEROF(msgTypeText));

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ootypes.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ootypes.h?view=diff&rev=207483&r1=207482&r2=207483
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ootypes.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ootypes.h Mon Jul 20 15:43:46 2009
@@ -187,8 +187,9 @@
 #define OOUserInputIndication              130
 #define OORequestModeAck		   131
 #define OORequestModeReject		   132
-
-#define OO_MSGTYPE_MAX                     132
+#define OORequestMode			   133
+
+#define OO_MSGTYPE_MAX                     133
 
 /* Timer types */
 #define OO_CALLESTB_TIMER  (1<<0)




More information about the asterisk-commits mailing list