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

📄 cmconf.c

📁 基于h323协议的软phone
💻 C
字号:
#ifdef __cplusplus
extern "C" {
#endif



/*
***********************************************************************************

NOTICE:
This document contains information that is proprietary to RADVISION LTD..
No part of this publication may be reproduced in any form whatsoever without
written prior approval by RADVISION LTD..

RADVISION LTD. reserves the right to revise this publication and make changes
without obligation to notify any person of such revisions or changes.

***********************************************************************************
*/

/*
  conf.c

  Ron S.
  15 Sep. 1996

  */

#include "rvstdio.h"
#include "intutils.h"
#include "psyntree.h"
#include "cmConf.h"
#include "h245.h"


typedef struct {
  HPVT hVal; /* conf value tree */
  int rootId; /* configuration root id */
} ConfContext;


int /* terminal type or negative value on failure */
confGetTerminalType(
            /* in master/slave conf */
            IN  HPVT hVal,
            IN  int confRootId
            )
{
  RvInt32 termType=RV_ERROR_UNKNOWN;
  pvtGetChildValue2(hVal, confRootId, __h245(masterSlave), __h245(terminalType), &termType, NULL);
  return (int)termType;
}


int /* term cap set node id, or negative value on failure */
confGetCapSet(
          /* capabilities set */
          IN  HPVT hVal,
          IN  int confRootId
          )
{
  return pvtGetChild2(hVal, confRootId, __h245(capabilities), __h245(terminalCapabilitySet));
}


int /* RV_TRUE or negative value on failure */
confGetDataTypeName(
            /* Generate dataName using field name as in H.245 standard. */
            IN  HPVT hVal,
            IN  int dataTypeId, /* Data type node id */
            IN  int dataNameSize,
            OUT char *dataName, /* copied into user allocate space [128 chars] */
            OUT confDataType* type, /* of data */
            OUT RvInt32* typeId /* node id of media type */
            )
{
    HPST synConf = pvtGetSynTree(hVal, dataTypeId);
    int dataId = pvtChild(hVal, dataTypeId);
    int choice=-1;
    RvPstFieldId fieldId=-1;

    if( (synConf == NULL) || (dataId < 0) )
        return RV_ERROR_UNKNOWN;

    pvtGet(hVal, dataId, &fieldId, NULL, NULL, NULL);
    switch(fieldId)
    {
    case __h245(nonStandard):
        choice = confNonStandard;
        break;
    case __h245(nullData):
        choice = confNullData;
        break;
    case __h245(videoData):
        choice = confVideoData;
        dataId = pvtChild(hVal, dataId);
        break;
    case __h245(audioData):
        choice = confAudioData;
        dataId = pvtChild(hVal, dataId);
        break;
    case __h245(data):
        choice = confData;
        dataId = pvtChild(hVal, pvtChild(hVal, dataId));
        break;
    default:
        strncpy(dataName, "encryptionData - not supported", (RvSize_t)dataNameSize);
        break;
    }

    if (dataName)
    {
        pvtGet(hVal, dataId, &fieldId, NULL, NULL, NULL);
        pstGetFieldName(synConf, fieldId, dataNameSize, dataName);
    }

    if (type) *type=(confDataType)choice;
    if (typeId) *typeId = dataId;

    return RV_TRUE;
}



int
confGetDataType(
        /* Search channel name in channels conf. and create appropriate dataType tree */
        IN  HPVT hVal,
        IN  int confRootId,
        IN  char* channelName, /* in channels conf */
        OUT int dataTypeId, /* node id: user supplied */
        OUT RvBool* isDynamicPayload, /* true if dynamic */
        RvBool nonH235 /*If true means remove h235Media.mediaType level */
        )
{
  int pathId, dataId,ret;
  HPST synConf = pvtGetSynTree(hVal, confRootId);

  pathId = pvtAddRoot(hVal, synConf, 0, NULL);
  if (pathId<0)
      return pathId;
  __pvtBuildByFieldIds(dataId, hVal, pathId,
                    {_h245(channels) _nul(1) _h245(name) LAST_TOKEN},
                    (RvInt32)strlen(channelName), channelName);

  if (pvtSearchPath(hVal, confRootId, hVal, pathId, RV_TRUE) == RV_TRUE)  { /* found entry */
    int channelTableId = pvtParent(hVal, pvtParent(hVal, dataId));
    RvInt32 index;
    int tableEntryId, dtId, nonH235DtId;
    int confChanTableId;

    pvtGet(hVal, channelTableId, NULL, NULL, &index, NULL);
    confChanTableId = pvtGetChild(hVal, confRootId, __h245(channels), NULL);
    tableEntryId = pvtGetByIndex(hVal, confChanTableId, index, NULL);
    dtId = pvtGetChild(hVal, tableEntryId, __h245(dataType), NULL);
    if (isDynamicPayload)
      *isDynamicPayload =
    (pvtGetChild(hVal, tableEntryId, __h245(isDynamicPayloadType), NULL) >=0)?RV_TRUE:RV_FALSE;

    if (nonH235 && (nonH235DtId=pvtGetChild2(hVal,dtId,__h245(h235Media) , __h245(mediaType)))>=0)
        ret =pvtSetTree(hVal, dataTypeId, hVal, nonH235DtId);
    else
        ret =pvtSetTree(hVal, dataTypeId, hVal, dtId);
    pvtDelete(hVal, pathId);
    if(ret<0)
    return ret;
    return RV_TRUE;
  }


  pvtDelete(hVal, pathId);
  return RV_ERROR_UNKNOWN; /* not found */
}


int /* real number of channels or negative value on failure */
confGetChannelNames(
            /* build array of channels names as in configuration */
            IN  HPVT hVal,
            IN  int confRootId,
            IN  int nameArSize, /* number of elements in nameArray */
            IN  int nameLength, /* length of each name in array */
            OUT char** nameArray /* user allocated array of strings */
            )
{
  int chanSetId, chanEntryId;
  int i, len;

  if (!hVal || confRootId<0 || nameArSize<1 || !nameArray) return RV_ERROR_UNKNOWN;

  chanSetId = pvtGetChild(hVal, confRootId, __h245(channels), NULL);
  if (chanSetId <0) return RV_ERROR_UNKNOWN;


  for (i=1; i<=RvMin(nameArSize, pvtNumChilds(hVal, chanSetId)); i++) { /* loop all channels */
    chanEntryId = pvtGetByIndex(hVal, chanSetId, i, NULL); /* entry */
    len = pvtGetString(hVal, pvtGetChild(hVal, chanEntryId, __h245(name), NULL), nameLength, nameArray[i-1]);
    nameArray[i-1][len]=0;
  }
  nameArray[i-1]=NULL;

  return pvtNumChilds(hVal, chanSetId);
}





int /* RV_TRUE if found. negative value if not found */
confGetModeEntry(
         /* Search mode name in configuration. */
         IN  HPVT hVal,
         IN  int confRootId,
         IN  char *modeName, /* in conf. */
         OUT RvInt32 *entryId /* mode entry id */
         )
{
  int pathId, dataId;
  HPST synConf = pvtGetSynTree(hVal, confRootId);
  RvInt32 index=RV_ERROR_UNKNOWN;
  int ret = RV_ERROR_UNKNOWN;

  if (!hVal || !synConf || !entryId || !modeName) return RV_ERROR_UNKNOWN;

  pathId = pvtAddRoot(hVal, synConf, 0, NULL);
  if (pathId<0)
      return pathId;
  __pvtBuildByFieldIds(dataId, hVal, pathId,
                       {_h245(modes) _nul(1) _h245(name) LAST_TOKEN},
                       (RvInt32)strlen(modeName), modeName);

  if (pvtSearchPath(hVal, confRootId, hVal, pathId, RV_TRUE) == RV_TRUE)  { /* found entry */
    pvtGet(hVal, pvtParent(hVal, pvtParent(hVal, dataId)), NULL, NULL, &index, NULL);
    ret = RV_TRUE;
  }

  if (entryId) {
    int modesId = pvtGetChild(hVal, confRootId, __h245(modes), NULL);
    *entryId=pvtGetByIndex(hVal, pvtGetByIndex(hVal, modesId, index, NULL), 2, NULL);
  }

  pvtDelete(hVal, pathId);
  return ret;
}



#ifdef __cplusplus
}
#endif



⌨️ 快捷键说明

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