oocapability.c

来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C语言 代码 · 共 2,030 行 · 第 1/5 页

C
2,030
字号
/* * Copyright (C) 2004-2005 by Objective Systems, Inc. * * This software is furnished under an open source license and may be  * used and copied only in accordance with the terms of this license.  * The text of the license may generally be found in the root  * directory of this installation in the COPYING file.  It  * can also be viewed online at the following URL: * *   http://www.obj-sys.com/open/license.html * * Any redistributions of this file including modified versions must  * maintain this copyright notice. * *****************************************************************************/#include "ooCapability.h"#include "ootrace.h"#include "ooCalls.h"#include "ooh323ep.h"#include "ooUtils.h"/** Global endpoint structure */extern OOH323EndPoint gH323ep;static int giDynamicRTPPayloadType = 101;int ooCapabilityEnableDTMFRFC2833   (OOH323CallData *call, int dynamicRTPPayloadType){   if(!call)   {      gH323ep.dtmfmode |= OO_CAP_DTMF_RFC2833;      OOTRACEINFO1("Enabled RFC2833 DTMF capability for end-point\n");   }else{      call->dtmfmode |= OO_CAP_DTMF_RFC2833;      OOTRACEINFO3("Enabled RFC2833 DTMF capability for (%s, %s) \n",                    call->callType, call->callToken);   }   /*Dynamic RTP payload type range is from 96 - 127 */   if(dynamicRTPPayloadType >= 96 && dynamicRTPPayloadType <= 127)      giDynamicRTPPayloadType = dynamicRTPPayloadType;   return OO_OK;}int ooCapabilityDisableDTMFRFC2833(OOH323CallData *call){   if(!call){      gH323ep.dtmfmode ^= OO_CAP_DTMF_RFC2833;      OOTRACEINFO1("Disabled RFC2833 DTMF capability for end-point\n");   }else{      call->dtmfmode ^= OO_CAP_DTMF_RFC2833;      OOTRACEINFO3("Disabled RFC2833 DTMF capability for (%s, %s)\n",                     call->callType, call->callToken);   }   return OO_OK;}int ooCapabilityEnableDTMFH245Alphanumeric(OOH323CallData *call){   if(!call){      gH323ep.dtmfmode |= OO_CAP_DTMF_H245_alphanumeric;      OOTRACEINFO1("Dtmf mode set to H.245(alphanumeric) for endpoint\n");   }else {      call->dtmfmode |= OO_CAP_DTMF_H245_alphanumeric;      OOTRACEINFO3("Dtmf mode set to H.245(alphanumeric) for (%s, %s)\n",                     call->callType, call->callToken);   }   return OO_OK;}int ooCapabilityDisableDTMFH245Alphanumeric(OOH323CallData *call){   if(!call){      gH323ep.dtmfmode ^= OO_CAP_DTMF_H245_alphanumeric;      OOTRACEINFO1("Dtmf mode H.245(alphanumeric) disabled for endpoint\n");   }else {      call->dtmfmode ^= OO_CAP_DTMF_H245_alphanumeric;      OOTRACEINFO3("Dtmf mode H.245(alphanumeric) disabled for (%s, %s)\n",                     call->callType, call->callToken);   }   return OO_OK;}int ooCapabilityEnableDTMFH245Signal(OOH323CallData *call){   if(!call){      gH323ep.dtmfmode |= OO_CAP_DTMF_H245_signal;      OOTRACEINFO1("Dtmf mode set to H.245(signal) for endpoint\n");   }else {      call->dtmfmode |= OO_CAP_DTMF_H245_signal;      OOTRACEINFO3("Dtmf mode set to H.245(signal) for (%s, %s)\n",                     call->callType, call->callToken);   }   return OO_OK;}int ooCapabilityDisableDTMFH245Signal(OOH323CallData *call){   if(!call){      gH323ep.dtmfmode ^= OO_CAP_DTMF_H245_signal;      OOTRACEINFO1("Dtmf mode H.245(signal) disabled for endpoint\n");   }else {      call->dtmfmode ^= OO_CAP_DTMF_H245_signal;      OOTRACEINFO3("Dtmf mode H.245(signal) disabled for (%s, %s)\n",                     call->callType, call->callToken);   }   return OO_OK;}int ooCapabilityEnableDTMFQ931Keypad(struct OOH323CallData *call){   if(!call){      gH323ep.dtmfmode |= OO_CAP_DTMF_Q931;      OOTRACEINFO1("Dtmf mode set to Q.931(keypad) for the endpoint\n");   }else {      call->dtmfmode |= OO_CAP_DTMF_Q931;      OOTRACEINFO3("Dtmf mode set to Q.931(keypad) for the call (%s, %s)\n",                     call->callType, call->callToken);   }   return OO_OK;}int ooCapabilityDisableDTMFQ931Keypad(struct OOH323CallData *call){   if(!call){      gH323ep.dtmfmode ^= OO_CAP_DTMF_Q931;      OOTRACEINFO1("Dtmf mode Q.931(keypad) disabled for the endpoint\n");   }else {      call->dtmfmode ^= OO_CAP_DTMF_Q931;      OOTRACEINFO3("Dtmf mode Q.931(keypad) disabled for the call (%s, %s)\n",                     call->callType, call->callToken);   }   return OO_OK;}int ooCapabilityAddH263VideoCapability(ooCallData *call,                               unsigned sqcifMPI, unsigned qcifMPI,                               unsigned cifMPI, unsigned cif4MPI,                               unsigned cif16MPI, unsigned maxBitRate, int dir,                               cb_StartReceiveChannel startReceiveChannel,                              cb_StartTransmitChannel startTransmitChannel,                              cb_StopReceiveChannel stopReceiveChannel,                              cb_StopTransmitChannel stopTransmitChannel,                               OOBOOL remote){   int ret = OO_OK;   if(sqcifMPI>0)   {      ret = ooCapabilityAddH263VideoCapability_helper(call, sqcifMPI, 0,                                  0, 0, 0, maxBitRate, dir, startReceiveChannel,                                 startTransmitChannel, stopReceiveChannel,                                 stopTransmitChannel, remote);      if(ret != OO_OK)      {         OOTRACEERR1("Error: Failed to add H263 sqcifMPI capability\n");         return OO_FAILED;      }   }   if(qcifMPI>0)   {      ret = ooCapabilityAddH263VideoCapability_helper(call, 0, qcifMPI, 0,                                 0, 0, maxBitRate, dir, startReceiveChannel,                                 startTransmitChannel, stopReceiveChannel,                                 stopTransmitChannel, remote);      if(ret != OO_OK)      {         OOTRACEERR1("Error: Failed to add H263 qcifMPI capability\n");         return OO_FAILED;      }   }   if(cifMPI>0)   {      ret = ooCapabilityAddH263VideoCapability_helper(call, 0, 0, cifMPI,                                  0, 0, maxBitRate, dir, startReceiveChannel,                                 startTransmitChannel, stopReceiveChannel,                                 stopTransmitChannel, remote);      if(ret != OO_OK)      {         OOTRACEERR1("Error: Failed to add H263 cifMPI capability\n");         return OO_FAILED;      }   }   if(cif4MPI>0)   {      ret = ooCapabilityAddH263VideoCapability_helper(call, 0, 0, 0,                                  cif4MPI, 0, maxBitRate, dir,                                  startReceiveChannel,                                 startTransmitChannel, stopReceiveChannel,                                 stopTransmitChannel, remote);      if(ret != OO_OK)      {         OOTRACEERR1("Error: Failed to add H263 cif4MPI capability\n");         return OO_FAILED;      }   }   if(cif16MPI>0)   {      ret = ooCapabilityAddH263VideoCapability_helper(call, dir, 0, 0, 0, 0,                                  cif16MPI, maxBitRate, startReceiveChannel,                                 startTransmitChannel, stopReceiveChannel,                                 stopTransmitChannel, remote);      if(ret != OO_OK)      {         OOTRACEERR1("Error: Failed to add H263 cif16MPI capability\n");         return OO_FAILED;      }   }   return OO_OK;}int ooCapabilityAddH263VideoCapability_helper(ooCallData *call,                              unsigned sqcifMPI, unsigned qcifMPI,                               unsigned cifMPI, unsigned cif4MPI,                               unsigned cif16MPI, unsigned maxBitRate, int dir,                               cb_StartReceiveChannel startReceiveChannel,                              cb_StartTransmitChannel startTransmitChannel,                              cb_StopReceiveChannel stopReceiveChannel,                              cb_StopTransmitChannel stopTransmitChannel,                               OOBOOL remote){   ooH323EpCapability *epCap = NULL, *cur=NULL;   OOH263CapParams *params=NULL;      OOCTXT *pctxt=NULL;   char *pictureType = NULL;   int cap = OO_H263VIDEO;   if(!call) pctxt = &gH323ep.ctxt;   else pctxt = call->pctxt;   epCap = (ooH323EpCapability*)memAllocZ(pctxt, sizeof(ooH323EpCapability));   params = (OOH263CapParams*) memAllocZ(pctxt, sizeof(OOH263CapParams));   if(!epCap || !params)   {      OOTRACEERR1("Error:Memory - ooCapabilityAddH263Capability - epCap/params"                  ".\n");      return OO_FAILED;   }      if(sqcifMPI>0)   {      params->MPI = sqcifMPI;      params->picFormat = OO_PICFORMAT_SQCIF;      pictureType = "SQCIF";   }   if(qcifMPI>0)   {      params->MPI = qcifMPI;      params->picFormat =  OO_PICFORMAT_QCIF;      pictureType = "QCIF";   }   if(cifMPI>0)   {      params->MPI = cifMPI;      params->picFormat = OO_PICFORMAT_CIF;      pictureType = "CIF";   }   if(cif4MPI>0)   {      params->MPI = cif4MPI;      params->picFormat = OO_PICFORMAT_CIF4;      pictureType = "CIF4";   }   if(cif16MPI>0)   {      params->MPI = cif16MPI;      params->picFormat = OO_PICFORMAT_CIF16;      pictureType = "CIF16";   }   params->maxBitRate = maxBitRate;   if(dir & OORXANDTX)   {      epCap->dir = OORX;      epCap->dir |= OOTX;   }else      epCap->dir = dir;      epCap->cap = OO_H263VIDEO;   epCap->capType = OO_CAP_TYPE_VIDEO;   epCap->params = (void*)params;   epCap->startReceiveChannel = startReceiveChannel;   epCap->startTransmitChannel = startTransmitChannel;   epCap->stopReceiveChannel = stopReceiveChannel;   epCap->stopTransmitChannel = stopTransmitChannel;      epCap->next = NULL;   if(!call)   {/*Add as local capability */      OOTRACEDBGC2("Adding endpoint H263 video capability %s.\n", pictureType);      if(!gH323ep.myCaps)         gH323ep.myCaps = epCap;      else{         cur = gH323ep.myCaps;         while(cur->next) cur = cur->next;         cur->next = epCap;      }      ooAppendCapToCapPrefs(NULL, cap);      gH323ep.noOfCaps++;   }else{      if(remote)      {         /*Add as remote capability */         if(!call->remoteCaps)            call->remoteCaps = epCap;         else{	    cur = call->remoteCaps;            while(cur->next) cur = cur->next;            cur->next = epCap;         }     }else{        /*Add as our capability */        OOTRACEDBGC4("Adding call specific H263 video capability %s. "                     "(%s, %s)\n", pictureType, call->callType,                      call->callToken);        if(!call->ourCaps){           call->ourCaps = epCap;           ooResetCapPrefs(call);        }        else{	   cur = call->ourCaps;           while(cur->next) cur = cur->next;           cur->next = epCap;        }        ooAppendCapToCapPrefs(call, cap);     }   }   return OO_OK;}/* Used for g711 ulaw/alaw, g729 and g7231 */int ooCapabilityAddSimpleCapability   (OOH323CallData *call, int cap, int txframes,     int rxframes, OOBOOL silenceSuppression, int dir,     cb_StartReceiveChannel startReceiveChannel,    cb_StartTransmitChannel startTransmitChannel,    cb_StopReceiveChannel stopReceiveChannel,    cb_StopTransmitChannel stopTransmitChannel,    OOBOOL remote){   ooH323EpCapability *epCap = NULL, *cur=NULL;   OOCapParams *params=NULL;      OOCTXT *pctxt=NULL;   if(!call) pctxt = &gH323ep.ctxt;   else pctxt = call->pctxt;   epCap = (ooH323EpCapability*)memAlloc(pctxt, sizeof(ooH323EpCapability));   params = (OOCapParams*) memAlloc(pctxt, sizeof(OOCapParams));   if(!epCap || !params)   {      OOTRACEERR1("Error:Memory - ooCapabilityAddSimpleCapability - "                  "epCap/params\n");      return OO_FAILED;   }   params->txframes = txframes;   params->rxframes = rxframes;   /* Ignore silence suppression parameter unless cap is g7231 */   if(cap == OO_G7231)      params->silenceSuppression = silenceSuppression;   else      params->silenceSuppression = FALSE; /* Set to false for g711 and g729*/   if(dir & OORXANDTX)   {      epCap->dir = OORX;      epCap->dir |= OOTX;   }else      epCap->dir = dir;      epCap->cap = cap;   epCap->capType = OO_CAP_TYPE_AUDIO;   epCap->params = (void*)params;   epCap->startReceiveChannel = startReceiveChannel;   epCap->startTransmitChannel = startTransmitChannel;   epCap->stopReceiveChannel = stopReceiveChannel;   epCap->stopTransmitChannel = stopTransmitChannel;   epCap->next = NULL;   if(!call)   {/*Add as local capability */      OOTRACEDBGC2("Adding endpoint capability %s. \n",                      ooGetCapTypeText(epCap->cap));      if(!gH323ep.myCaps)         gH323ep.myCaps = epCap;      else{         cur = gH323ep.myCaps;         while(cur->next) cur = cur->next;         cur->next = epCap;      }      ooAppendCapToCapPrefs(NULL, cap);      gH323ep.noOfCaps++;   }else{      if(remote)      {         /*Add as remote capability */

⌨️ 快捷键说明

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