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

📄 protocalapi.c

📁 内容正如其名
💻 C
📖 第 1 页 / 共 4 页
字号:
 * * Output parameters :  * * Return value      : Return OK if the stack is configured successfully, *                     otherwise return FAIL. * * Comments          :  * * History           : *  2005/12/16       : Creation * * Date              : Dec 16 2005, Frank ZHANG ******************************************************************************/LONG MgcpStackSetDisconnectMinDelay(H_STACK pStack, DWORD dwDelayValue){  H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;    Assert(pStack);    pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);  Assert(pEndpntCtrl);    if (pEndpntCtrl)  {    pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);        pEndpntCtrl->dwTdmin = dwDelayValue;    pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);    return OK;  }  return FAIL;}/****************************************************************************** * Function          : MgcpStackSetDisconnectMaxDelay * * Description       : Set the disconnect max dealy value of the stack. * * Input parameters  : pStack - Handle of the stack *                     dwDelayValue - Disconnect max  dealy value * * Output parameters :  * * Return value      : Return OK if the stack is configured successfully, *                     otherwise return FAIL. * * Comments          :  * * History           : *  2005/12/16       : Creation * * Date              : Dec 16 2005, Frank ZHANG ******************************************************************************/LONG MgcpStackSetDisconnectMaxDelay(H_STACK pStack, DWORD dwDelayValue){  H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;    Assert(pStack);    pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);  Assert(pEndpntCtrl);    if (pEndpntCtrl)  {    pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);        pEndpntCtrl->dwTdmax = dwDelayValue;    pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);    return OK;  }  return FAIL;}/****************************************************************************** * Function          : MgcpStackSetRetureUnsupportPackages * * Description       : Set whether need to return the unsupported mgcp packages *                     in the outgoing mgcp response if the response code need * * Input parameters  : pStack - Handle of the stack *                     bOnOff - Flag to indicate return the unsupported mgcp *                              packages * * Output parameters :  * * Return value      : Return OK if the stack is configured successfully, *                     otherwise return FAIL. * * Comments          :  * * History           : *  2005/12/16       : Creation * * Date              : Dec 16 2005, Frank ZHANG ******************************************************************************/LONG MgcpStackSetRetureUnsupportPackages(H_STACK pStack, BOOL bOnOff){  H_MGCP_ENDPOINT_CONTROL pEndpntCtrl;    Assert(pStack);    pEndpntCtrl = (H_MGCP_ENDPOINT_CONTROL)(((MGCP_STACK*)pStack)->pEndpointCtl);  Assert(pEndpntCtrl);  if (pEndpntCtrl)  {    pthread_mutex_lock(&pEndpntCtrl->pEndpoinCtrltMutex);    pEndpntCtrl->bReturnPackageList = bOnOff;    pthread_mutex_unlock(&pEndpntCtrl->pEndpoinCtrltMutex);    return OK;  }  return FAIL;}/****************************************************************************** * Function          : MgcpEndpointSetCallAgent * * Description       : Set the Call Agent of the endpoint. If the CA name is *                     dot-decimal format, directly use this address, otherwise *                     resolve the domain name into ip addresses. *                      * Input parameters  : pEndpoint - Handle of the Endpoint *                     pcCaName - Call Agent name *                     wPort - Call Agent port * * Output parameters :  * * Return value      : Return OK if the CA is set successfully, otherwise *                     return FAIL. * * Comments          :  * * History           : *  2005/12/13       : Creation * * Date              : Dec 13 2005, Frank ZHANG ******************************************************************************/LONG MgcpEndpointSetCallAgent(H_ENDPOINT pEndpoint, char *pcCaName, WORD wPort){  char *p;  H_MGCP_ENDPOINT pEndpnt = (H_MGCP_ENDPOINT)pEndpoint;  Assert(pEndpoint);  Assert(pcCaName);  if ((p = strchr(pcCaName, '@')) != NULL)  {    /* Call Agent local name */    pEndpnt->NotifiedEntity.pcLocalName      = (char*)calloc((WORD)((p-pcCaName)+1), sizeof(char));    Assert(pEndpnt->NotifiedEntity.pcLocalName);    strncpy(pEndpnt->NotifiedEntity.pcLocalName, pcCaName, (size_t)(p-pcCaName));    /* Domain name */    StrClone(&pEndpnt->NotifiedEntity.pcDomainName, p+1);  }  else  {    /* Only domain name */    StrClone(&pEndpnt->NotifiedEntity.pcDomainName, pcCaName);  }  /* Call Agent port */  pEndpnt->NotifiedEntity.wPort = wPort;    Assert(pEndpnt->NotifiedEntity.pcDomainName);    /* Resolve the domain name to get IP addresses */  if (IsDotDecimalAddress(pEndpnt->NotifiedEntity.pcDomainName))  {    /* Dot decimal format IP address */    ConvertIpAddress(pEndpnt->NotifiedEntity.pIPAddrList,                     pEndpnt->NotifiedEntity.pcDomainName);    pEndpnt->NotifiedEntity.wCurAddrIndex = 0;    pEndpnt->NotifiedEntity.wAddrNum = 1;    return OK;  }  else  {    /* Domain Name format address */    WORD i = 0;    struct hostent *pHostList;    if ((pHostList = gethostbyname(pEndpnt->NotifiedEntity.pcDomainName)) != NULL)    {      /* Copy the new resolved address into the NE address list */      while ((pHostList->h_addr_list[i]) != NULL)      {        pEndpnt->NotifiedEntity.pIPAddrList[i]          = ntohl(*((DWORD*)pHostList->h_addr_list[i]));        i++;      }      pEndpnt->NotifiedEntity.wAddrNum = i;      pEndpnt->NotifiedEntity.wCurAddrIndex = 0;      return OK;    }  }  return FAIL;}/****************************************************************************** * Function          : MgcpEndpointAddSupportedPackage * * Description       : Set the supported MGCP packages of the endpoint, if the *                     package has set, ignore it, otherwise add it into the *                     package list. *                      * Input parameters  : pEndpoint - Handle of the Endpoint *                     ePackage - MGCP package tytpe * * Output parameters :  * * Return value      : Return FAIL if the packaeg has been in the package list, *                     otherwise return OK. * * Comments          :  * * History           : *  2005/12/13       : Creation * * Date              : Dec 13 2005, Frank ZHANG ******************************************************************************/LONG MgcpEndpointAddSupportedPackage(H_ENDPOINT pEndpoint, E_MGCP_PACKAGE ePackage){  E_MGCP_PACKAGE *pPkg;  H_MGCP_ENDPOINT pEndpnt = (H_MGCP_ENDPOINT)pEndpoint;  Assert(pEndpnt);  SListReset(&pEndpnt->CapabilityList.SupportedPackages);  /* Check if the package has been in the package list */  while((pPkg = SListGetCurData(&pEndpnt->CapabilityList.SupportedPackages))!= NULL)  {    if (ePackage == *pPkg)      return FAIL;    SListNextNode(&pEndpnt->CapabilityList.SupportedPackages);  }  pPkg = (E_MGCP_PACKAGE*)calloc(1, sizeof(E_MGCP_PACKAGE));  Assert(pPkg);  *pPkg = ePackage;  SListAppend(&pEndpnt->CapabilityList.SupportedPackages, pPkg);    return OK;}/****************************************************************************** * Function          : MgcpEndpointRemoveSupportedPackage * * Description       : Remove the supported MGCP packages of the endpoint, if *                     package is not in the package list, ignore it, otherwise *                     remove it from the package list. *                      * Input parameters  : pEndpoint - Handle of the Endpoint *                     ePackage - MGCP package tytpe * * Output parameters :  * * Return value      : Return FAIL if the packaeg is not in the package list, *                     otherwise remove it from the list and return OK. * * Comments          :  * * History           : *  2005/12/13       : Creation * * Date              : Dec 13 2005, Frank ZHANG ******************************************************************************/LONG MgcpEndpointRemoveSupportedPackage(H_ENDPOINT pEndpoint, E_MGCP_PACKAGE ePackage){  E_MGCP_PACKAGE *pPkg;  H_MGCP_ENDPOINT pEndpnt = (H_MGCP_ENDPOINT)pEndpoint;  Assert(pEndpnt);  SListReset(&pEndpnt->CapabilityList.SupportedPackages);  while((pPkg = SListGetCurData(&pEndpnt->CapabilityList.SupportedPackages))!= NULL)  {    if (ePackage == *pPkg)    {      free(pPkg);      SListDelCurNode(&pEndpnt->CapabilityList.SupportedPackages);      return OK;    }    SListNextNode(&pEndpnt->CapabilityList.SupportedPackages);  }  return FAIL;}/****************************************************************************** * Function          : MgcpEndpointClearSupportedPackages * * Description       : Remove all the supported MGCP packages of the endpoint *                      * Input parameters  : pEndpoint - Handle of the Endpoint * * Output parameters :  * * Return value      : None * * Comments          :  * * History           : *  2005/12/13       : Creation * * Date              : Dec 13 2005, Frank ZHANG ******************************************************************************/void MgcpEndpointClearSupportedPackages(H_ENDPOINT pEndpoint){  Assert(pEndpoint);  SListFreeAll(&((H_MGCP_ENDPOINT)pEndpoint)->CapabilityList.SupportedPackages);}/****************************************************************************** * Function          : MgcpEndpointSetDefaultPackage * * Description       : Set the default MGCP packages of the endpoint *                      * Input parameters  : pEndpoint - Handle of the Endpoint *                     ePackage - MGCP package tytpe * * Output parameters :  * * Return value      : Return OK if the default packaeg is set successfully, *                     otherwise return FAIL. * * Comments          :  * * History           : *  2005/12/13       : Creation * * Date              : Dec 13 2005, Frank ZHANG ******************************************************************************/LONG MgcpEndpointSetDefaultPackage(H_ENDPOINT pEndpoint, E_MGCP_PACKAGE ePackage){  E_MGCP_PACKAGE *pPkg = NULL;  H_MGCP_ENDPOINT pEndpnt = (H_MGCP_ENDPOINT)pEndpoint;  Assert(pEndpnt);  /* Ccheck if the default package has been in the supported package     list, if yes, free it firstly*/  SListReset(&pEndpnt->CapabilityList.SupportedPackages);  while((pPkg = SListGetCurData(&pEndpnt->CapabilityList.SupportedPackages))!= NULL)  {    if (ePackage == *pPkg)      SListDelCurNode(&pEndpnt->CapabilityList.SupportedPackages);        SListNextNode(&pEndpnt->CapabilityList.SupportedPackages);  }  /* Default package is not in the pakcage list, allocate a new */  if (pPkg == NULL)  {    pPkg = (E_MGCP_PACKAGE*)calloc(1, sizeof(E_MGCP_PACKAGE));    Assert(pPkg);    *pPkg = ePackage;  }    /* Add the default package into the head of the package list */  SListAdd(&pEndpnt->CapabilityList.SupportedPackages, pPkg);  return OK;}/****************************************************************************** * Function          : MgcpEndpointAddCodecCapability * * Description       : Set the supported compression algorithms of the endpoint *                      * Input parameters  : pEndpoint - Handle of the Endpoint *                     wCapNum - Algorithms number in the list *                     pCababilities - Algorithms list * * Output parameters :  * * Return value      : Return OK if the compression algorithms are set *                     successfully, otherwise return FAIL. * * Comments          :  * * History           : *  2005/12/15       : Creation * * Date              : Dec 15 2005, Frank ZHANG ******************************************************************************/LONG MgcpEndpointAddCodecCapability(H_ENDPOINT pEndpoint, MGCP_CODEC *pCabability){  MGCP_CODEC *pCodec;  H_MGCP_ENDPOINT pEndpnt = (H_MGCP_ENDPOINT)pEndpoint;  Assert(pEndpnt);  if (pCabability != NULL)  {    SListReset(&pEndpnt->CapabilityList.CompressAlgo);    while((pCodec = SListGetCurData(&pEndpnt->CapabilityList.CompressAlgo)) != NULL)    {      if (StrCaseCmp(pCodec->CodecName, pCabability->CodecName) == 0)        return FAIL;      SListNextNode(&pEndpnt->CapabilityList.CompressAlgo);    }        pCodec = (MGCP_CODEC*)calloc(1, sizeof(MGCP_CODEC));    Assert(pCodec);    memcpy(pCodec, pCabability, sizeof(MGCP_CODEC));    SListAppend(&pEndpnt->CapabilityList.CompressAlgo, pCodec);    return OK;  }  return FAIL;}/****************************************************************************** * Function          : MgcpEndpointClearCodecCapability * * Description       : Remove all the supported MGCP compression algorithms of *                     the endpoint *                      * Input parameters  : pEndpoint - Handle of the Endpoint * * Output parameters :  * * Return value      : None * * Comments          :  * * History           : *  2005/12/15       : Creation * * Date              : Dec 15 2005, Frank ZHANG ******************************************************************************/void MgcpEndpointClearCodecCapability(H_ENDPOINT pEndpoint){  Assert(pEndpoint);  SListFreeAll(&((H_MGCP_ENDPOINT)pEndpoint)->CapabilityList.CompressAlgo);}/****************************************************************************** * Function          : MgcpEndpointSetRestartDealy * * Description       : Set the restart delay of the endpoint *                      * Input parameters  : pEndpoint - Handle of the Endpoint *                     dwRestartDelay - Restart delay * * Output parameters :  * * Return value      : Return OK if the restart delay is set successfully, *                     otherwise return FAIL. * * Comments          :  * * History           : *  2005/12/13       : Creation * * Date              : Dec 13 2005, Frank ZHANG ******************************************************************************/LONG MgcpEndpointSetRestartDealy(H_ENDPOINT pEndpoint, DWORD dwRestartDelay){  Assert(pEndpoint);  ((H_MGCP_ENDPOINT)pEndpoint)->dwRestartDelay = dwRestartDelay;  return OK;}/****************************************************************************** * Function          : MgcpEndpointAddPersistentEvent * * Description       : Add a persitent event into list of the endpoint *                      * Input parameters  : pEndpoint - Handle of the Endpoint

⌨️ 快捷键说明

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