⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dm3ntsch.c

📁 ipt网关源码
💻 C
📖 第 1 页 / 共 3 页
字号:
///////////////////////////////////////////////////////////////////////
// File Name: DM3NTSCH.C
//
//  This module contains a event handling functions for many TSC & NetTSc messages
//  using the DM3 C Application Framework.  These functions are nominally
//  implemented to show the user how TSP message processing can be done.
//
//  While many of these functions are immediately usable without mod-
//  ification, it is expected that many users will modify or enhance
//  the provided functionality to better fit their specific requirements,
//  and to link DM3 functionality to the operation of the overall application.
//
///////////////////////////////////////////////////////////////////////
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
//  ANY KIND EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED 
//  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
//  Copyright (c) 1997  Dialogic Corporation.  All Rights Reserved.
///////////////////////////////////////////////////////////////////////


#include "Dm3NTscH.h"
#include "gateStrc.h"
#include "statfp.h"
#include "main.h"
#include "gatedbg.h"
#include "gateDefs.h"
#include "pstndefs.h"

//数据库头文件
/*#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>*/
#include "database.h"



///////////////////////////////////////////////////////////////////////
//        NAME : Dm3NetTscEvtHndlr()
// DESCRIPTION : Entry point function for handling of all TSC & NetTSC messages
//             : the events coming back from the Firmware.  This function
//             : processes any event data maintained by the library, then
//             : routes all events and messages to lower level handlers.
//       INPUT : pComp     Pointer to the base component descriptor structure
//             : ulCmdType Command associated with this reply (if any)
//             : ulMgsType Reply Message type
//             : pReplyMsg Start of actual Reply Message.  
//      OUTPUT : Certain TSC instance data fields MAY be updated.
//     RETURNS : This function will return whatever the lower level handler
//             : returns in the form of an LPVOID.
//    CAUTIONS : The user should always check GetLastError to see if this
//             : function passed or failed.
///////////////////////////////////////////////////////////////////////
LPVOID Dm3NetTscEvtHndlr (LPDM3COMP    pComp,
                          ULONG        ulCmdType,
                          ULONG        ulReplyType,
                          QMsgRef      pReplyMsg)
{
   LPDM3NetTSC     pNetTsc;
   LPDM3TSC        pTsc;
   LPVOID          lpReturnCode = NULL;    // Return code from this function.
   UINT            unOffset = 0;
   Std_MsgError_t  ErrorData; 
   Std_MsgError_t  *pStdErr = NULL;
   GateSession     *lpCamelSession;
   gateStateFxn    stateFxn;

   
   /* First upcast the comp user info where we have cleverly stored the address
    * of the overall NetTSC component.  Note that since the framework controls the 
    * use of this pointer, we should never see this error.
    */
   if ((pNetTsc = (LPDM3NetTSC)(((LPDM3COMP)(pComp->lpUserInfo))->lpUserInfo)) == NULL)  {
      return (lpReturnCode);
   }

   pTsc =  NETTSC_GET_DM3TSC(pNetTsc);
	lpCamelSession = (GateSession *) (pNetTsc->lpUserInfo);
	stateFxn = lpCamelSession->stateFxn;


   /*
    * There are a few special case error and message scenarious that need to be 
    * checked for up front.   We start by checking for Std_MsgError by reply type
    * since this error type is used for errors on any command.
    */ 
   if (ulReplyType == Std_MsgError) {

      // Extract the error payload
      Std_MsgError_get(pReplyMsg, 
                       &ErrorData, 
                       unOffset);

      pStdErr = &ErrorData;   // Since this is no longer NULL, it also serves 
                              // as a flag indicating the presence of an error.
   }
   else if (ulReplyType == DM3_INVALID_MSGTYPE) {   
      /* This is how the base component methods tell us that there was an
       * Timeout condition on this command.   A good thing for an app to
       * do might be to wait and try the command again.  For now just call a
       * generic handler that the user can modify.
       */
      return (OnNetTscCmdTimedOut(pNetTsc, ulCmdType));
   }
      
   /*
    * Now switch on the command type that is associated with this reply message.  
    */
   switch(ulCmdType) {

      case TSC_MsgGetCallInfo:
         {

            /* The Get Call Info command can request several call info elements
             * at once.  To process this properly we need to pass the entire
             * raw message pointer to the handler.
             */
            lpReturnCode = OnNetTscGetCallInfoCmplt(pTsc, 
                                                 pReplyMsg, 
                                                 pStdErr);
         }
         break;

      case TSC_MsgGetCallState:
         {
            TSC_MsgGetCallStateCmplt_t ReplyData;
            
            if (pStdErr == NULL) {

               TSC_MsgGetCallStateCmplt_get( pReplyMsg, 
                                             &ReplyData, 
                                             unOffset);
            }

            lpReturnCode = OnNetTscGetCallStateCmplt(pTsc, 
                                                  &ReplyData, 
                                                  pStdErr);
         }
         break;

      case TSC_MsgMakeCall:
         {
            TSC_MsgMakeCallCmplt_t ReplyData;

            if (pStdErr == NULL) {

               TSC_MsgMakeCallCmplt_get(pReplyMsg, 
                                        &ReplyData, 
                                        unOffset);

               /*
                * Put the Call ID that was assigned to this call in the TSP
                * component Information structure.
                */
               pTsc->unCallId = ReplyData.CallId;
            }

            // Now call the application's event handler for this event.
            lpReturnCode = OnNetTscMakeCallCmplt(pTsc,
                                              &ReplyData, 
                                              pStdErr);

         }
         break;

      /* 
       * Lump all the Standard message completes into one handler.  This is done
       * because most applications will not be concerned with doing any specific
       * processing on individual Std_MsgxxxCmplt's.  
       */
      case Std_MsgCancelAllEvts:
      case Std_MsgCancelEvt:
      case Std_MsgCancelxEvts:
      case Std_MsgDetectEvt:
      case Std_MsgDetectxEvts:
      case Std_MsgGetParm:
      case Std_MsgGetxParms:

         lpReturnCode = OnNetTscStdMsgCmplt(pTsc, 
                                         ulCmdType, 
                                         ulReplyType, 
                                         pReplyMsg);
         break;

      case Std_MsgEvtDetected:
         {
            Std_MsgEvtDetected_t    ReplyData;  // Generic Std_MsgEvtDetected payload

            if(ulReplyType != Std_MsgEvtDetected) {
              gateALERT(lpCamelSession->sessionNumber,(lpCamelSession->LogFile,"Got unexpected reply on Std_MsgEvtDetected %d.\n",
				      ulReplyType));
			   }

            // Get the standard event message body
            Std_MsgEvtDetected_get(pReplyMsg, 
                                   &ReplyData, 
                                   unOffset);

            /* 
             * Any one of the following denote a valid tag for TSC events.  Perform 
             * event payload extraction based on the type of event being returned.
             */
            switch (ReplyData.Label) {

         			case NTSC_LABEL_H245_DATA:
                           {
                              NetTSC_EvtH245Data_t   EvtData;
                           
                              NetTSC_EvtH245Data_get(pReplyMsg, &EvtData, unOffset);
         
                              lpReturnCode = OnNetTscH245DataEvt(pNetTsc, &EvtData);
         
                           }
                           break;
         
         
        
         			case TSC_LABEL_CHAN_STATE:
                           {
                              TSC_EvtChanState_t   EvtData;
         
                              TSC_EvtChanState_get(pReplyMsg, &EvtData, unOffset);
         
                              lpReturnCode = OnNetTscChanStateEvt(pTsc, &EvtData);
         
                           }
                           break;
         
         			case TSC_LABEL_CALL_STATE:
                           {
                              TSC_EvtCallState_t   EvtData;
         
                              TSC_EvtCallState_get(pReplyMsg, &EvtData, unOffset);
         
                              // Update the Call State in the component
                              pTsc->unCallState = EvtData.CallState;
         
                              // Update the Reason in the component
                              pTsc->unCallStateReason = EvtData.Reason;
         
                              lpReturnCode = OnNetTscCallStateEvt(pTsc, &EvtData);
         
                           }
                           break;
         
         
                        default:    // An invalid label
         				      gateALERT(lpCamelSession->sessionNumber,(lpCamelSession->LogFile,"Unknown label for Std_MsgEvtDetected.\n"));
                           return (NULL);
         
               } // End Switch(ReplyData.Label)
            }
            break;   

      default:
         /*
          * Some unknown command type, perform error processing
          */
         gateALERT(lpCamelSession->sessionNumber,(lpCamelSession->LogFile,"Unknown command type.\n"));
         return (NULL);

   } // End switch(ulMsgType) 

   /* We are done with event processing, return the user defined pointer to whatever.
    * This pointer will be propagated all the way back to the point at which the
    * component methods initiated event processing.  Thus in the Async case, this 
    * pointer will ultimately be returned by Dm3CompProcIoCompletion().
    */
   return (lpReturnCode);
}


///////////////////////////////////////////////////////////////////////
//        NAME : OnNetTscCmdTimedOut
// DESCRIPTION : Application Event Handler for Timeout Error condition 
//       INPUT : LPDM3NetTSC  pNetTsc      Pointer to the NetTSC structure
//             : ULONG        ulCmdType     What Command Timed out
//      OUTPUT : None.
//     RETURNS : A User defineable pointer to VOID
//    CAUTIONS : None.
///////////////////////////////////////////////////////////////////////
LPVOID OnNetTscCmdTimedOut (LPDM3NetTSC pNetTsc, 
                            ULONG ulCmdType)
{
	GateSession   *pCamelSession;


	pCamelSession = (GateSession *)(pNetTsc->lpUserInfo);

   switch(ulCmdType) {

       case TSC_MsgMakeCall:
           IPTResetSession(pCamelSession->sessionNumber,FALSE);
		   break;

	   case TSC_MsgAnswerCall:
	   case TSC_MsgDropCall:
	   case TSC_MsgRejectCall:
	   case TSC_MsgReleaseCall:
	   case NetTSC_MsgSendUserInputIndication:
      case NetTSC_MsgSendNonStandardCmd:
		   break;

   }
   return (NULL);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -