[asterisk-addons-commits] objsys: branch 1.2 r268 - in /branches/1.2/asterisk-ooh323c: ./ ooh323c/src/ ...

asterisk-addons-commits at lists.digium.com asterisk-addons-commits at lists.digium.com
Fri Aug 4 09:36:49 MST 2006


Author: objsys
Date: Fri Aug  4 11:36:48 2006
New Revision: 268

URL: http://svn.digium.com/view/asterisk-addons?rev=268&view=rev
Log:
1.2 branch update for media wait for connect, fast start reply in ALERTING

Modified:
    branches/1.2/asterisk-ooh323c/README
    branches/1.2/asterisk-ooh323c/config.h
    branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.c
    branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.h
    branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.c
    branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.h
    branches/1.2/asterisk-ooh323c/ooh323c/src/ooq931.c
    branches/1.2/asterisk-ooh323c/ooh323c/src/ootypes.h
    branches/1.2/asterisk-ooh323c/src/chan_h323.c

Modified: branches/1.2/asterisk-ooh323c/README
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/README?rev=268&r1=267&r2=268&view=diff
==============================================================================
--- branches/1.2/asterisk-ooh323c/README (original)
+++ branches/1.2/asterisk-ooh323c/README Fri Aug  4 11:36:48 2006
@@ -25,10 +25,10 @@
     you have to have latest version of asterisk installed on your system. 
     You can skip to step 2, if you have already installed the asterisk.
 
-      Following precedure help you download and install asterisk
+      Following precedure help you download and install asterisk 1.2.x
 
-      To get latest asterisk sources from svn:
-      >svn checkout http://svn.digium.com/svn/asterisk/trunk asterisk
+      To get latest asterisk sources from svn branch 1.2:
+      >svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2
 
       To install asterisk.(You will have to be in 'super user' mode for this)
       >cd asterisk
@@ -39,18 +39,18 @@
 
       To update or if you hadn't downloaded the asterisk-ooh323c channel driver
       code, you can do so using following command (To get the latest 
-      asterisk-addons source from svn):
-      >svn checkout http://svn.digium.com/svn/asterisk-addons/trunk asterisk-addons
+      asterisk-addons 1.2 branch source from svn):
+      >svn checkout http://svn.digium.com/svn/asterisk-addons/branches/1.2 asterisk-addons-1.2
 
       To build & install:
-      >cd asterisk-addons/asterisk-ooh323c
+      >cd asterisk-addons-1.2/asterisk-ooh323c
       >./configure
       >make
 
       For debugging purpose, instead of "make", run "make debug"
 
       The library will be generated at 
-      asterisk-addons/asterisk-ooh323c/.libs/libchan_h323.so.1.0.1 
+      asterisk-addons-1.2/asterisk-ooh323c/.libs/libchan_h323.so.1.0.1 
  
       To install libchan_h323.so in /usr/libs/modules/ directory, change to 
       'super user' mode and then run:

Modified: branches/1.2/asterisk-ooh323c/config.h
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/config.h?rev=268&r1=267&r2=268&view=diff
==============================================================================
--- branches/1.2/asterisk-ooh323c/config.h (original)
+++ branches/1.2/asterisk-ooh323c/config.h Fri Aug  4 11:36:48 2006
@@ -108,13 +108,13 @@
 #define PACKAGE_NAME "ASTERISK-OOH323C"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ASTERISK-OOH323C 0.4"
+#define PACKAGE_STRING "ASTERISK-OOH323C 0.5"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "asterisk-ooh323c"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "0.4"
+#define PACKAGE_VERSION "0.5"
 
 /* Define to the type of arg 1 for `select'. */
 #define SELECT_TYPE_ARG1 int
@@ -135,7 +135,7 @@
 /* #undef TM_IN_SYS_TIME */
 
 /* Version number of package */
-#define VERSION "0.4"
+#define VERSION "0.5"
 
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */

Modified: branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.c?rev=268&r1=267&r2=268&view=diff
==============================================================================
--- branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.c (original)
+++ branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.c Fri Aug  4 11:36:48 2006
@@ -78,6 +78,8 @@
    if (OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART))
       OO_SETFLAG (call->flags, OO_M_FASTSTART);
 
+   if (OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN))
+      OO_SETFLAG (call->flags, OO_M_MEDIAWAITFORCONN);
    
    call->callState = OO_CALL_CREATED;
    call->callEndReason = OO_REASON_UNKNOWN;
@@ -143,6 +145,7 @@
    call->nextSessionID = 4; /* 1,2,3 are reserved for audio, video and data */
    dListInit(&call->timerList);
    call->msdRetries = 0;
+   call->pFastStartRes = NULL;
    call->usrData = NULL;
    OOTRACEINFO3("Created a new call (%s, %s)\n", call->callType, 
                  call->callToken);

Modified: branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.h
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.h?rev=268&r1=267&r2=268&view=diff
==============================================================================
--- branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.h (original)
+++ branches/1.2/asterisk-ooh323c/ooh323c/src/ooCalls.h Fri Aug  4 11:36:48 2006
@@ -49,6 +49,7 @@
 #define OO_M_AUTOANSWER         0x00100000
 #define OO_M_TUNNELING	        0x08000000
 #define OO_M_FASTSTARTANSWERED  0x04000000
+#define OO_M_MEDIAWAITFORCONN   0x03000000 
 #define OO_M_FASTSTART	        0x02000000 
 #define OO_M_DISABLEGK          0x01000000
 #define OO_M_MANUALRINGBACK     0x10000000
@@ -117,6 +118,16 @@
    int      port;      /*!< Port assigned to the channel */
    DList    outQueue;  /*!< Output message queue */
 } OOH323Channel;
+
+/**
+ * Structure to store information on fast start response (H.225) to 
+ * reply same answer in CALL PROCEEDING, ALERTING & CONNECT.
+ */
+typedef struct EXTERN FastStartResponse {
+   ASN1UINT n;
+   ASN1DynOctStr *elem;
+} FastStartResponse;
+
 
 /**
  * This structure is used to maintain all information on an active call. 
@@ -174,6 +185,7 @@
    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;
+   FastStartResponse    *pFastStartRes; /* fast start response */
    void                 *usrData; /*!<User can set this to user specific data*/
    struct OOH323CallData* next;
    struct OOH323CallData* prev;

Modified: branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.c?rev=268&r1=267&r2=268&view=diff
==============================================================================
--- branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.c (original)
+++ branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.c Fri Aug  4 11:36:48 2006
@@ -431,6 +431,18 @@
    return OO_OK;
 }
 
+int ooH323EpEnableMediaWaitForConnect(void)
+{
+   OO_SETFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN);
+   return OO_OK;
+}
+
+int ooH323EpDisableMediaWaitForConnect(void)
+{
+   OO_CLRFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN);
+   return OO_OK;
+}
+
 int ooH323EpEnableFastStart(void)
 {
    OO_SETFLAG(gH323ep.flags, OO_M_FASTSTART);
@@ -539,6 +551,14 @@
    }
    else{
       OOTRACEINFO1("\tH245 Tunneling - enabled\n");
+   }
+
+   if(!OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN))
+   {
+      OOTRACEINFO1("\tMediaWaitForConnect - disabled\n");
+   }
+   else{
+      OOTRACEINFO1("\tMediaWaitForConnect - enabled\n");
    }
 
    if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER))

Modified: branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.h
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.h?rev=268&r1=267&r2=268&view=diff
==============================================================================
--- branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.h (original)
+++ branches/1.2/asterisk-ooh323c/ooh323c/src/ooh323ep.h Fri Aug  4 11:36:48 2006
@@ -349,6 +349,20 @@
  * @return          OO_OK on success, OO_FAILED on failure
  */
 EXTERN int ooH323EpDisableManualRingback(void);
+
+/**
+ * This function is used to enable MediaWaitForConnect.
+ *
+ * @return            OO_OK, on success. OO_FAILED, on failure.
+ */
+EXTERN int ooH323EpDisableMediaWaitForConnect(void);
+
+/**
+ * This function is used to disable MediaWaitForConnect.
+ *
+ * @return            OO_OK, on success. OO_FAILED, on failure.
+ */
+EXTERN int ooH323EpDisableMediaWaitForConnect(void);
 
 /**
  * This function is used to enable faststart.

Modified: branches/1.2/asterisk-ooh323c/ooh323c/src/ooq931.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/ooh323c/src/ooq931.c?rev=268&r1=267&r2=268&view=diff
==============================================================================
--- branches/1.2/asterisk-ooh323c/ooh323c/src/ooq931.c (original)
+++ branches/1.2/asterisk-ooh323c/ooh323c/src/ooq931.c Fri Aug  4 11:36:48 2006
@@ -817,6 +817,371 @@
    return OO_OK;
 }
 
+int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg, 
+   ASN1UINT *fsCount, ASN1DynOctStr **fsElem)
+{
+   OOCTXT *pctxt = &gH323ep.msgctxt;   
+   int ret = 0, i=0, j=0, remoteMediaPort=0, remoteMediaControlPort = 0, dir=0;
+   char remoteMediaIP[20], remoteMediaControlIP[20];
+   DListNode *pNode = NULL;
+   H245OpenLogicalChannel *olc = NULL, printOlc;
+   ooH323EpCapability *epCap = NULL;
+   ASN1DynOctStr *pFS=NULL;
+   H245H2250LogicalChannelParameters *h2250lcp = NULL;  
+   ooLogicalChannel* pChannel;
+
+
+   if(pCall->pFastStartRes) {
+      ASN1UINT k = 0;
+      ASN1OCTET* pData;
+
+      /* copy the stored fast start response to structure */
+      *fsCount = pCall->pFastStartRes->n;
+      *fsElem = (ASN1DynOctStr*)
+         memAlloc(pctxt, pCall->pFastStartRes->n * sizeof(ASN1DynOctStr));
+
+      for(k = 0; k < pCall->pFastStartRes->n; k ++) {
+         (*fsElem)[k].numocts = pCall->pFastStartRes->elem[k].numocts;
+         pData = (ASN1OCTET*) memAlloc(
+            pctxt, (*fsElem)[k].numocts * sizeof(ASN1OCTET));
+         memcpy(pData, 
+            pCall->pFastStartRes->elem[k].data, 
+            pCall->pFastStartRes->elem[k].numocts);
+         (*fsElem)[k].data = pData;
+      }
+
+      /* free the stored fast start response */
+      if(pQ931msg->messageType == Q931ConnectMsg) {
+         for(k = 0; k < pCall->pFastStartRes->n; k ++) {
+            memFreePtr(pCall->pctxt, pCall->pFastStartRes->elem[k].data);
+         }
+         memFreePtr(pCall->pctxt, pCall->pFastStartRes->elem);
+         memFreePtr(pCall->pctxt, pCall->pFastStartRes);
+         pCall->pFastStartRes = NULL;
+      }
+
+      return ASN_OK;
+   }
+   
+      
+   /* If fast start supported and remote endpoint has sent faststart element */
+   if(OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART) && 
+      pCall->remoteFastStartOLCs.count>0)
+   {
+      pFS = (ASN1DynOctStr*)memAlloc(pctxt, 
+                        pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr));
+      if(!pFS)
+      {
+         OOTRACEERR3("Error:Memory - ooSetFastStartResponse - pFS (%s, %s)\n", 
+                      pCall->callType, pCall->callToken);    
+         return OO_FAILED;
+      }
+      memset(pFS, 0, pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr));
+
+      /* Go though all the proposed channels */
+      for(i=0, j=0; i<(int)pCall->remoteFastStartOLCs.count; i++)
+      {
+
+         pNode = dListFindByIndex(&pCall->remoteFastStartOLCs, i);
+         olc = (H245OpenLogicalChannel*)pNode->data;
+
+         /* Don't support both direction channel */
+         if(olc->forwardLogicalChannelParameters.dataType.t != 
+                                                   T_H245DataType_nullData &&
+            olc->m.reverseLogicalChannelParametersPresent)
+         {
+            OOTRACEINFO3("Ignoring bidirectional OLC as it is not supported."
+                         "(%s, %s)\n", pCall->callType, pCall->callToken);
+            continue;
+         }
+
+         /* Check forward logic channel */
+         if(olc->forwardLogicalChannelParameters.dataType.t != 
+                                                   T_H245DataType_nullData)
+         {
+            /* Forward Channel - remote transmits - local receives */
+            OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n", 
+                          olc->forwardLogicalChannelNumber, pCall->callType, 
+                          pCall->callToken);
+            dir = OORX;
+            epCap = ooIsDataTypeSupported(pCall, 
+                                &olc->forwardLogicalChannelParameters.dataType,
+                                OORX);
+            
+            if(!epCap) { continue; } /* Not Supported Channel */
+
+            OOTRACEINFO1("Receive Channel data type supported\n");
+            if(olc->forwardLogicalChannelParameters.multiplexParameters.t !=
+               T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
+            {
+               OOTRACEERR4("ERROR:Unknown multiplex parameter type for "
+                           "channel %d (%s, %s)\n", 
+                           olc->forwardLogicalChannelNumber, 
+                           pCall->callType, pCall->callToken);
+               memFreePtr(pCall->pctxt, epCap);
+               epCap = NULL;
+               continue;
+            }
+            h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
+
+            /* Check session is Not already established */
+            if(ooIsSessionEstablished(pCall, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive"))
+            {
+
+               OOTRACEINFO4("Receive channel with sessionID %d already "
+                            "established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, 
+                            pCall->callType, pCall->callToken);
+               memFreePtr(pCall->pctxt, epCap);
+               epCap = NULL;
+               continue;
+            }
+
+            /* Extract mediaControlChannel info, if supplied */
+            if(h2250lcp->m.mediaControlChannelPresent)
+            {
+               if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, 
+                                &h2250lcp->mediaControlChannel, 
+                                remoteMediaControlIP, &remoteMediaControlPort))
+               {
+                  OOTRACEERR3("Error: Invalid media control channel address "
+                              "(%s, %s)\n", pCall->callType, pCall->callToken);
+                  memFreePtr(pCall->pctxt, epCap);
+                  epCap = NULL;
+                  continue;
+               }
+            }
+         }
+         /* Check reverse logical channel */
+         else if(olc->m.reverseLogicalChannelParametersPresent)
+         {
+            /* Reverse channel - remote receives - local transmits */
+            OOTRACEDBGC4("Processing received reverse olc %d (%s, %s)\n", 
+                          olc->forwardLogicalChannelNumber, pCall->callType, 
+                          pCall->callToken);
+            dir = OOTX;
+            epCap = ooIsDataTypeSupported(pCall, 
+                                &olc->reverseLogicalChannelParameters.dataType,
+                                OOTX);
+
+            if(!epCap) { continue; } /* Capability not supported */
+
+            OOTRACEINFO1("Transmit Channel data type supported\n");
+
+            if(olc->reverseLogicalChannelParameters.multiplexParameters.t != 
+               T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
+            {
+               OOTRACEERR4("ERROR:Unknown multiplex parameter type for "
+                           "channel %d (%s, %s)\n", 
+                           olc->forwardLogicalChannelNumber, 
+                           pCall->callType, pCall->callToken);
+               memFreePtr(pCall->pctxt, epCap);
+               epCap = NULL;
+               continue;
+            }
+
+            /* Check session is not established */
+            if(ooIsSessionEstablished(pCall, olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "transmit"))
+            {
+
+               OOTRACEINFO4("Transmit session with sessionID %d already "
+                            "established.(%s, %s)\n", olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, pCall->callType, pCall->callToken);
+
+               memFreePtr(pCall->pctxt, epCap);
+               epCap = NULL;
+               continue;
+            }
+            
+            /* Extract the remote media endpoint address */
+            h2250lcp = olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
+            if(!h2250lcp)
+            {
+               OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
+                           "reverse Logical Channel Parameters found. "
+                           "(%s, %s)\n", pCall->callType, pCall->callToken);
+               memFreePtr(pCall->pctxt, epCap);
+               epCap = NULL;
+               return OO_FAILED;
+            }
+            
+            /* Reverse Channel info will be always present, crash proof */
+            if(!h2250lcp->m.mediaChannelPresent)
+            {
+               OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
+                           "reverse media channel information found. "
+                           "(%s, %s)\n", pCall->callType, pCall->callToken);
+               memFreePtr(pCall->pctxt, epCap);
+               epCap = NULL;
+               return OO_FAILED;
+            }
+
+            /* Get IP, PORT of reverse channel */
+            if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, 
+                                &h2250lcp->mediaChannel, 
+                                remoteMediaIP, &remoteMediaPort))
+            {
+               OOTRACEERR3("Error: Invalid media  channel address "
+                           "(%s, %s)\n", pCall->callType, pCall->callToken);
+               memFreePtr(pCall->pctxt, epCap);
+               epCap = NULL;
+               continue;
+            }
+
+            /* Extract mediaControlChannel info, if supplied */
+            if(h2250lcp->m.mediaControlChannelPresent)
+            {
+               if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, 
+                                &h2250lcp->mediaControlChannel, 
+                                remoteMediaControlIP, &remoteMediaControlPort))
+               {
+                  OOTRACEERR3("Error: Invalid media control channel address "
+                              "(%s, %s)\n", pCall->callType, pCall->callToken);
+                  memFreePtr(pCall->pctxt, epCap);
+                  epCap = NULL;
+                  continue;
+               }
+            }
+         }
+
+         if(dir & OOTX)
+         {  
+            /* According to the spec if we are accepting olc for transmission
+               from called endpoint to calling endpoint, called endpoint should
+               insert a unqiue forwardLogicalChannelNumber into olc
+            */
+            olc->forwardLogicalChannelNumber =  pCall->logicalChanNoCur++;
+            if(pCall->logicalChanNoCur > pCall->logicalChanNoMax)
+               pCall->logicalChanNoCur = pCall->logicalChanNoBase;
+         }
+
+         
+         ooPrepareFastStartResponseOLC(pCall, olc, epCap, pctxt, dir);
+         
+         pChannel = ooFindLogicalChannelByLogicalChannelNo
+                      (pCall, olc->forwardLogicalChannelNumber);
+   
+         /* start receive and tramsmit channel listening */
+         if(dir & OORX)
+         {
+            strcpy(pChannel->remoteIP, remoteMediaControlIP);
+            pChannel->remoteMediaControlPort = remoteMediaControlPort;
+            if(epCap->startReceiveChannel)
+            {   
+               epCap->startReceiveChannel(pCall, pChannel);      
+               OOTRACEINFO4("Receive channel of type %s started (%s, %s)\n", 
+                        (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video",
+                        pCall->callType, pCall->callToken);
+            }
+            else{
+               OOTRACEERR4("ERROR:No callback registered to start receive %s"
+                          " channel (%s, %s)\n", 
+                        (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", 
+                           pCall->callType, pCall->callToken);
+               return OO_FAILED;
+            }
+         }
+         if(dir & OOTX)
+         {
+            pChannel->remoteMediaPort = remoteMediaPort;
+            strcpy(pChannel->remoteIP, remoteMediaIP);
+            pChannel->remoteMediaControlPort = remoteMediaControlPort;
+
+            if(epCap->startTransmitChannel)
+            {   
+               epCap->startTransmitChannel(pCall, pChannel);      
+               OOTRACEINFO3("Transmit channel of type audio started "
+                            "(%s, %s)\n", pCall->callType, pCall->callToken);
+               /*OO_SETFLAG (pCall->flags, OO_M_AUDIO);*/
+            }
+            else{
+               OOTRACEERR3("ERROR:No callback registered to start transmit"
+                           " audio channel (%s, %s)\n", pCall->callType, 
+                           pCall->callToken);
+               return OO_FAILED;
+            }
+         }
+
+         /* Encode fast start element */
+         setPERBuffer(pctxt, NULL, 0, 1);
+         if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK)
+         {
+            OOTRACEERR3("ERROR:Encoding of olc failed for faststart "
+                        "(%s, %s)\n", pCall->callType, pCall->callToken);
+            ooFreeQ931Message(pQ931msg);
+            if(pCall->callState < OO_CALL_CLEAR)
+            {
+               pCall->callEndReason = OO_REASON_LOCAL_CLEARED;
+               pCall->callState = OO_CALL_CLEAR;
+            }
+            return OO_FAILED;
+         }
+         pFS[j].data = encodeGetMsgPtr(pctxt, &(pFS[j].numocts));
+
+
+         /* start print call */
+         setPERBuffer(pctxt,  (char*)pFS[j].data, pFS[j].numocts, 1);
+         initializePrintHandler(&printHandler, "FastStart Element");
+         setEventHandler (pctxt, &printHandler);
+         memset(&printOlc, 0, sizeof(printOlc));
+         ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc));
+         if(ret != ASN_OK)
+         {
+            OOTRACEERR3("Error: Failed decoding FastStart Element (%s, %s)\n", 
+                        pCall->callType, pCall->callToken);
+            ooFreeQ931Message(pQ931msg);
+            if(pCall->callState < OO_CALL_CLEAR)
+            {
+               pCall->callEndReason = OO_REASON_LOCAL_CLEARED;
+               pCall->callState = OO_CALL_CLEAR;
+            }
+            return OO_FAILED;
+         }
+         finishPrint();
+         removeEventHandler(pctxt); 
+         /* end print call */
+
+         olc = NULL;
+         j++;
+         epCap = NULL;
+      }
+      OOTRACEDBGA4("Added %d fast start elements to message "
+                   "(%s, %s)\n",  j, pCall->callType, pCall->callToken);
+      if(j != 0)
+      {
+         ASN1UINT k = 0;
+         ASN1OCTET* pData;
+         //*fsPresent = TRUE;
+         *fsCount = j;
+         *fsElem = pFS; 
+
+         /* save the fast start response for later use in ALERTING, CONNECT */
+         pCall->pFastStartRes = (FastStartResponse*)
+            memAlloc(pCall->pctxt, sizeof(FastStartResponse));
+         pCall->pFastStartRes->n = j;
+         pCall->pFastStartRes->elem = (ASN1DynOctStr*) memAlloc(pCall->pctxt, 
+            pCall->pFastStartRes->n * sizeof(ASN1DynOctStr));
+
+         for(k = 0; k < pCall->pFastStartRes->n; k ++) {
+            pCall->pFastStartRes->elem[k].numocts = (*fsElem)[k].numocts;
+            pData = (ASN1OCTET*) memAlloc(pCall->pctxt, 
+               pCall->pFastStartRes->elem[k].numocts * sizeof(ASN1OCTET));
+            memcpy(pData, (*fsElem)[k].data, (*fsElem)[k].numocts);
+            pCall->pFastStartRes->elem[k].data = pData;
+         }
+      }
+      else{
+         OOTRACEINFO3("None of the faststart elements received in setup can be"
+                      " supported, rejecting faststart.(%s, %s)\n", 
+                      pCall->callType, pCall->callToken);
+         //*fsPresent = FALSE;
+         OO_CLRFLAG(pCall->flags, OO_M_FASTSTART);
+         OOTRACEDBGC3("Faststart for pCall is disabled by local endpoint."
+                      "(%s, %s)\n", pCall->callType, pCall->callToken);
+      }
+   }
+   return ASN_OK;
+}
+
+
 /*
 
 */
@@ -1024,6 +1389,15 @@
    vendor->vendor.t35Extension = gH323ep.t35Extension;
    vendor->vendor.manufacturerCode = gH323ep.manufacturerCode;
    
+   ret = ooSetFastStartResponse(call, q931msg, 
+      &alerting->fastStart.n, &alerting->fastStart.elem);
+   if(ret != ASN_OK) { return ret; }
+   if(alerting->fastStart.n > 0) {
+      alerting->m.fastStartPresent = TRUE;
+   }
+   else {
+      alerting->m.fastStartPresent = FALSE;
+   }
 
    OOTRACEDBGA3("Built Alerting (%s, %s)\n", call->callType, call->callToken);
    
@@ -1201,7 +1575,6 @@
    return ret;
 }
 
-
 int ooSendConnect(OOH323CallData *call)
 {
    ooAcceptCall(call);
@@ -1211,19 +1584,12 @@
 /*TODO: Need to clean logical channel in case of failure after creating one */
 int ooAcceptCall(OOH323CallData *call)
 {
-   int ret = 0, i=0, j=0, remoteMediaPort=0, remoteMediaControlPort = 0, dir=0;
-   char remoteMediaIP[20], remoteMediaControlIP[20];
+   int ret = 0, i=0;
    H225Connect_UUIE *connect;
    H225TransportAddress_ipAddress *h245IpAddr;
    H225VendorIdentifier *vendor;
    Q931Message *q931msg=NULL;
-   DListNode *pNode = NULL;
-   H245OpenLogicalChannel *olc = NULL, printOlc;
-   ooH323EpCapability *epCap = NULL;
-   ASN1DynOctStr *pFS=NULL;
    OOCTXT *pctxt = &gH323ep.msgctxt;   
-   H245H2250LogicalChannelParameters *h2250lcp = NULL;  
-   ooLogicalChannel* pChannel;
 
    ret = ooCreateQ931Message(&q931msg, Q931ConnectMsg);
    if(ret != OO_OK)
@@ -1344,287 +1710,15 @@
       strncpy(vendor->versionId.data, gH323ep.versionID, 
                                                    vendor->versionId.numocts); 
    }
-   /* If fast start supported and remote endpoint has sent faststart element */
-   if(OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART) && 
-      call->remoteFastStartOLCs.count>0)
-   {
-      pFS = (ASN1DynOctStr*)memAlloc(pctxt, 
-                        call->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr));
-      if(!pFS)
-      {
-         OOTRACEERR3("Error:Memory - ooAcceptCall - pFS (%s, %s)\n", 
-                      call->callType, call->callToken);    
-         return OO_FAILED;
-      }
-      memset(pFS, 0, call->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr));
-
-
-      for(i=0, j=0; i<(int)call->remoteFastStartOLCs.count; i++)
-      {
-
-         pNode = dListFindByIndex(&call->remoteFastStartOLCs, i);
-         olc = (H245OpenLogicalChannel*)pNode->data;
-
-         if(olc->forwardLogicalChannelParameters.dataType.t != 
-                                                   T_H245DataType_nullData &&
-            olc->m.reverseLogicalChannelParametersPresent)
-         {
-            OOTRACEINFO3("Ignoring bidirectional OLC as it is not supported."
-                         "(%s, %s)\n", call->callType, call->callToken);
-            continue;
-         }
-
-         if(olc->forwardLogicalChannelParameters.dataType.t != 
-                                                   T_H245DataType_nullData)
-         {
-            /* Forward Channel - remote transmits - local receives */
-            OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n", 
-                          olc->forwardLogicalChannelNumber, call->callType, 
-                          call->callToken);
-            dir = OORX;
-            epCap = ooIsDataTypeSupported(call, 
-                                &olc->forwardLogicalChannelParameters.dataType,
-                                OORX);
-            if(!epCap) 
-               continue;
-            OOTRACEINFO1("Receive Channel data type supported\n");
-            if(olc->forwardLogicalChannelParameters.multiplexParameters.t !=
-               T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
-            {
-               OOTRACEERR4("ERROR:Unknown multiplex parameter type for "
-                           "channel %d (%s, %s)\n", 
-                           olc->forwardLogicalChannelNumber, 
-                           call->callType, call->callToken);
-               memFreePtr(call->pctxt, epCap);
-               epCap = NULL;
-               continue;
-            }
-            h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
-
-            if(ooIsSessionEstablished(call, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive"))
-            {
-
-               OOTRACEINFO4("Receive channel with sessionID %d already "
-                            "established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, 
-                            call->callType, call->callToken);
-               memFreePtr(call->pctxt, epCap);
-               epCap = NULL;
-               continue;
-            }
-
-            /* Extract mediaControlChannel info, if supplied */
-            if(h2250lcp->m.mediaControlChannelPresent)
-            {
-               if(OO_OK != ooGetIpPortFromH245TransportAddress(call, 
-                                &h2250lcp->mediaControlChannel, 
-                                remoteMediaControlIP, &remoteMediaControlPort))
-               {
-                  OOTRACEERR3("Error: Invalid media control channel address "
-                              "(%s, %s)\n", call->callType, call->callToken);
-                  memFreePtr(call->pctxt, epCap);
-                  epCap = NULL;
-                  continue;
-               }
-            }
-         }
-         else if(olc->m.reverseLogicalChannelParametersPresent)
-         {
-            /* Reverse channel - remote receives - local transmits */
-            OOTRACEDBGC4("Processing received reverse olc %d (%s, %s)\n", 
-                          olc->forwardLogicalChannelNumber, call->callType, 
-                          call->callToken);
-            dir = OOTX;
-            epCap = ooIsDataTypeSupported(call, 
-                                &olc->reverseLogicalChannelParameters.dataType,
-                                OOTX);
-            if(!epCap) 
-               continue;
-
-            OOTRACEINFO1("Transmit Channel data type supported\n");
-
-            if(olc->reverseLogicalChannelParameters.multiplexParameters.t != 
-               T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
-            {
-               OOTRACEERR4("ERROR:Unknown multiplex parameter type for "
-                           "channel %d (%s, %s)\n", 
-                           olc->forwardLogicalChannelNumber, 
-                           call->callType, call->callToken);
-               memFreePtr(call->pctxt, epCap);
-               epCap = NULL;
-               continue;
-            }
-            if(ooIsSessionEstablished(call, olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "transmit"))
-            {
-
-               OOTRACEINFO4("Transmit session with sessionID %d already "
-                            "established.(%s, %s)\n", olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, call->callType, call->callToken);
-
-               memFreePtr(call->pctxt, epCap);
-               epCap = NULL;
-               continue;
-            }
-            
-            /* Extract the remote media endpoint address */
-            h2250lcp = olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
-            if(!h2250lcp)
-            {
-               OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
-                           "reverse Logical Channel Parameters found. "
-                           "(%s, %s)\n", call->callType, call->callToken);
-               memFreePtr(call->pctxt, epCap);
-               epCap = NULL;
-               return OO_FAILED;
-            }
-            if(!h2250lcp->m.mediaChannelPresent)
-            {
-               OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
-                           "reverse media channel information found. "
-                           "(%s, %s)\n", call->callType, call->callToken);
-               memFreePtr(call->pctxt, epCap);
-               epCap = NULL;
-               return OO_FAILED;
-            }
-            if(OO_OK != ooGetIpPortFromH245TransportAddress(call, 
-                                &h2250lcp->mediaChannel, 
-                                remoteMediaIP, &remoteMediaPort))
-            {
-               OOTRACEERR3("Error: Invalid media  channel address "
-                           "(%s, %s)\n", call->callType, call->callToken);
-               memFreePtr(call->pctxt, epCap);
-               epCap = NULL;
-               continue;
-            }
-
-            /* Extract mediaControlChannel info, if supplied */
-            if(h2250lcp->m.mediaControlChannelPresent)
-            {
-               if(OO_OK != ooGetIpPortFromH245TransportAddress(call, 
-                                &h2250lcp->mediaControlChannel, 
-                                remoteMediaControlIP, &remoteMediaControlPort))
-               {
-                  OOTRACEERR3("Error: Invalid media control channel address "
-                              "(%s, %s)\n", call->callType, call->callToken);
-                  memFreePtr(call->pctxt, epCap);
-                  epCap = NULL;
-                  continue;
-               }
-            }
-         }
-
-         if(dir & OOTX)
-         {  
-            /* According to the spec if we are accepting olc for transmission
-               from called endpoint to calling endpoint, called endpoint should
-               insert a unqiue forwardLogicalChannelNumber into olc
-            */
-            olc->forwardLogicalChannelNumber =  call->logicalChanNoCur++;
-            if(call->logicalChanNoCur > call->logicalChanNoMax)
-               call->logicalChanNoCur = call->logicalChanNoBase;
-         }
-
-         
-         ooPrepareFastStartResponseOLC(call, olc, epCap, pctxt, dir);
-         
-         pChannel = ooFindLogicalChannelByLogicalChannelNo
-                      (call, olc->forwardLogicalChannelNumber);
-   
-         if(dir & OORX)
-         {
-            strcpy(pChannel->remoteIP, remoteMediaControlIP);
-            pChannel->remoteMediaControlPort = remoteMediaControlPort;
-            if(epCap->startReceiveChannel)
-            {   
-               epCap->startReceiveChannel(call, pChannel);      
-               OOTRACEINFO4("Receive channel of type %s started (%s, %s)\n", 
-                        (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video",
-                        call->callType, call->callToken);
-            }
-            else{
-               OOTRACEERR4("ERROR:No callback registered to start receive %s"
-                          " channel (%s, %s)\n", 
-                        (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", 
-                           call->callType, call->callToken);
-               return OO_FAILED;
-            }
-         }
-         if(dir & OOTX)
-         {
-            pChannel->remoteMediaPort = remoteMediaPort;
-            strcpy(pChannel->remoteIP, remoteMediaIP);
-            pChannel->remoteMediaControlPort = remoteMediaControlPort;
-
-            if(epCap->startTransmitChannel)
-            {   
-               epCap->startTransmitChannel(call, pChannel);      
-               OOTRACEINFO3("Transmit channel of type audio started "
-                            "(%s, %s)\n", call->callType, call->callToken);
-               /*OO_SETFLAG (call->flags, OO_M_AUDIO);*/
-            }
-            else{
-               OOTRACEERR3("ERROR:No callback registered to start transmit"
-                           " audio channel (%s, %s)\n", call->callType, 
-                           call->callToken);
-               return OO_FAILED;
-            }
-         }
-         /* Do not specify msg buffer let automatic allocation work */
-         setPERBuffer(pctxt, NULL, 0, 1);
-         if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK)
-         {
-            OOTRACEERR3("ERROR:Encoding of olc failed for faststart "
-                        "(%s, %s)\n", call->callType, call->callToken);
-            ooFreeQ931Message(q931msg);
-            if(call->callState < OO_CALL_CLEAR)
-            {
-               call->callEndReason = OO_REASON_LOCAL_CLEARED;
-               call->callState = OO_CALL_CLEAR;
-            }
-            return OO_FAILED;
-         }
-         pFS[j].data = encodeGetMsgPtr(pctxt, &(pFS[j].numocts));
-
-         /* Dump faststart element in logfile for debugging purpose */
-         setPERBuffer(pctxt,  (char*)pFS[j].data, pFS[j].numocts, 1);
-         initializePrintHandler(&printHandler, "FastStart Element");
-         setEventHandler (pctxt, &printHandler);
-         memset(&printOlc, 0, sizeof(printOlc));
-         ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc));
-         if(ret != ASN_OK)
-         {
-            OOTRACEERR3("Error: Failed decoding FastStart Element (%s, %s)\n", 
-                        call->callType, call->callToken);
-            ooFreeQ931Message(q931msg);
-            if(call->callState < OO_CALL_CLEAR)
-            {
-               call->callEndReason = OO_REASON_LOCAL_CLEARED;
-               call->callState = OO_CALL_CLEAR;
-            }
-            return OO_FAILED;
-         }
-         finishPrint();
-         removeEventHandler(pctxt); 
-
-         olc = NULL;
-         j++;
-         epCap = NULL;
-      }
-      OOTRACEDBGA4("Added %d fast start elements to CONNECT message "
-                   "(%s, %s)\n",  j, call->callType, call->callToken);
-      if(j != 0)
-      {
-         connect->m.fastStartPresent = TRUE;
-         connect->fastStart.n = j;
-         connect->fastStart.elem = pFS; 
-      }
-      else{
-         OOTRACEINFO3("None of the faststart elements received in setup can be"
-                      " supported, rejecting faststart.(%s, %s)\n", 
-                      call->callType, call->callToken);
-         connect->m.fastStartPresent = FALSE;
-         OO_CLRFLAG(call->flags, OO_M_FASTSTART);
-         OOTRACEDBGC3("Faststart for call is disabled by local endpoint."
-                      "(%s, %s)\n", call->callType, call->callToken);
-      }
+
+   ret = ooSetFastStartResponse(call, q931msg, 
+      &connect->fastStart.n, &connect->fastStart.elem);
+   if(ret != ASN_OK) { return ret; }
+   if(connect->fastStart.n > 0) {
+      connect->m.fastStartPresent = TRUE;
+   }
+   else {
+      connect->m.fastStartPresent = FALSE;
    }
 
    /* Add h245 listener address. Do not add H245 listener address in case
@@ -2317,7 +2411,12 @@
                                call->callIdentifier.guid.numocts);
    

[... 115 lines stripped ...]


More information about the asterisk-addons-commits mailing list