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

📄 sipxtapi.cpp

📁 基于sipfoundy 公司开发的sipx协议API
💻 CPP
📖 第 1 页 / 共 5 页
字号:
SIPXTAPI_API SIPX_RESULT sipxCallGetID(const SIPX_CALL hCall,                                       char* szId,                                       const size_t iMaxLength){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallGetID hCall=%d",        hCall);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    UtlString callId ;    if (sipxCallGetCommonData(hCall, NULL, &callId, NULL, NULL))    {        if (iMaxLength)        {            strncpy(szId, callId.data(), iMaxLength) ;            szId[iMaxLength-1] = 0 ;        }        sr = SIPX_RESULT_SUCCESS ;    }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallGetLocalID(const SIPX_CALL hCall,                                            char* szId,                                            const size_t iMaxLength){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallGetLocalID hCall=%d",        hCall);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    UtlString callId ;    UtlString lineId ;    if (sipxCallGetCommonData(hCall, NULL, &callId, NULL, &lineId))    {        if (iMaxLength)        {            strncpy(szId, lineId.data(), iMaxLength) ;            szId[iMaxLength-1] = 0 ;        }        sr = SIPX_RESULT_SUCCESS ;    }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallGetRemoteID(const SIPX_CALL hCall,                                             char* szId,                                             const size_t iMaxLength){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallGetRemoteID hCall=%d",        hCall);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    UtlString callId ;    UtlString remoteId ;    if (sipxCallGetCommonData(hCall, NULL, &callId, &remoteId, NULL))    {        if (iMaxLength)        {            strncpy(szId, remoteId.data(), iMaxLength) ;            szId[iMaxLength-1] = 0 ;        }        sr = SIPX_RESULT_SUCCESS ;    }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallSetAssertedId(const SIPX_CALL hCall,                                                const char* szPAssertedId,                                               const bool bSignalNow){    SIPX_RESULT resultCode = SIPX_RESULT_FAILURE;    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallSetAssertedId hCall=%d szPAssertedId=\"%s\" bSignalNow=%s",        hCall, szPAssertedId, bSignalNow ? "true" : "false");    SIPX_INSTANCE_DATA* pInst ;    UtlString callId ;    UtlString remoteAddress;        if (sipxCallGetCommonData(hCall, &pInst, &callId, &remoteAddress, NULL))    {        if(pInst->pCallManager->setLocalPAssertedIdentity(callId,                                                          remoteAddress,                                                         szPAssertedId,                                                         bSignalNow ? TRUE : FALSE))        {            resultCode = SIPX_RESULT_SUCCESS;        }    }    return(resultCode);}SIPXTAPI_API SIPX_RESULT sipxCallGetConnectionId(const SIPX_CALL hCall,                                                 int& connectionId){    SIPX_RESULT sr = SIPX_RESULT_FAILURE;    connectionId = -1;        SIPX_CALL_DATA* pData = sipxCallLookup(hCall, SIPX_LOCK_READ);        assert(pData != 0) ;    assert(pData->pInst != 0) ;        if (pData)            {        if (pData->pInst && pData->pInst->pCallManager && pData->callId &&                 pData->remoteAddress)        {            CallManager* pCallManager = pData->pInst->pCallManager ;            UtlString callId(*pData->callId) ;            UtlString remoteAddress(*pData->remoteAddress) ;            sipxCallReleaseLock(pData, SIPX_LOCK_READ) ;            connectionId = pCallManager->getMediaConnectionId(callId, remoteAddress);            if (-1 != connectionId)            {                sr = SIPX_RESULT_SUCCESS;            }                   }        else        {            sipxCallReleaseLock(pData, SIPX_LOCK_READ) ;        }        }    return sr;}                                                 SIPXTAPI_API SIPX_RESULT sipxCallGetRequestURI(const SIPX_CALL hCall,                                               char* szUri,                                               const size_t iMaxLength){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallGetRequestURI hCall=%d",        hCall);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    SIPX_CALL_DATA* pData = sipxCallLookup(hCall, SIPX_LOCK_READ);        assert(pData != 0) ;    assert(pData->pInst != 0) ;        if (pData)            {        if (pData->pInst && pData->pInst->pCallManager && pData->callId &&            pData->remoteAddress)         {            CallManager* pCallManager = pData->pInst->pCallManager ;            UtlString callId(*pData->callId) ;            UtlString remoteAddress(*pData->remoteAddress) ;            sipxCallReleaseLock(pData, SIPX_LOCK_READ) ;            SipDialog sipDialog;            pCallManager->getSipDialog(callId, remoteAddress, sipDialog);                        UtlString uri;            sipDialog.getRemoteRequestUri(uri);            if (iMaxLength)            {                strncpy(szUri, uri.data(), iMaxLength) ;                szUri[iMaxLength-1] = 0 ;                sr = SIPX_RESULT_SUCCESS;            }        }        else        {            sipxCallReleaseLock(pData, SIPX_LOCK_READ) ;        }        }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallGetRemoteContact(const SIPX_CALL hCall,                                                  char* szContact,                                                  const size_t iMaxLength){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallGetRemoteContact hCall=%d",        hCall);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    SIPX_CALL_DATA* pData = sipxCallLookup(hCall, SIPX_LOCK_READ);        assert(pData != 0) ;    assert(pData->pInst != 0) ;        if (pData)            {        if (pData->pInst && pData->pInst->pCallManager && pData->callId &&                 pData->remoteAddress)        {            CallManager* pCallManager = pData->pInst->pCallManager ;            UtlString callId(*pData->callId) ;            UtlString remoteAddress(*pData->remoteAddress) ;            sipxCallReleaseLock(pData, SIPX_LOCK_READ) ;            SipDialog sipDialog;            pCallManager->getSipDialog(callId, remoteAddress, sipDialog);                        Url contact;            sipDialog.getRemoteContact(contact);            if (iMaxLength)            {                strncpy(szContact, contact.toString().data(), iMaxLength) ;                szContact[iMaxLength-1] = 0 ;                sr = SIPX_RESULT_SUCCESS;            }        }        else        {            sipxCallReleaseLock(pData, SIPX_LOCK_READ) ;        }        }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallStartTone(const SIPX_CALL hCall,                                           const TONE_ID toneId,                                           const bool bLocal,                                           const bool bRemote){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallStartTone hCall=%d ToneId=%d bLocal=%d bRemote=%d",        hCall, toneId, bLocal, bRemote);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    SIPX_INSTANCE_DATA *pInst ;    UtlString callId ;    TONE_ID xlateId;    if (sipxTranslateToneId(toneId, xlateId) == SIPX_RESULT_SUCCESS)    {        if (sipxCallGetCommonData(hCall, &pInst, &callId, NULL, NULL))        {#ifndef VOICE_ENGINE            if (!pInst->toneStates.tonePlaying)#endif            {                gpCallHandleMap->addHandleRef(hCall);  // Add a handle reference, so that                                                     // if the call ends before                                                     // the tone is stopped,                                                     // there is still a valid call handle                                                     // to use with stopTone                pInst->pCallManager->toneStart(callId.data(), xlateId, bLocal, bRemote) ;                sr = SIPX_RESULT_SUCCESS ;                if (!pInst->toneStates.bInitialized)                {                    pInst->toneStates.bInitialized = true;                }#ifndef VOICE_ENGINE                pInst->toneStates.tonePlaying = true;#endif                            }        }    }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallStopTone(const SIPX_CALL hCall){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallStopTone hCall=%d",        hCall);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    SIPX_INSTANCE_DATA *pInst ;    UtlString callId ;    if (sipxCallGetCommonData(hCall, &pInst, &callId, NULL, NULL))    {        if (pInst->toneStates.bInitialized && pInst->toneStates.tonePlaying)        {            pInst->pCallManager->toneStop(callId.data()) ;            sipxCallObjectFree(hCall);                    sr = SIPX_RESULT_SUCCESS ;            pInst->toneStates.tonePlaying = false;        }    }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallPlayFile(const SIPX_CALL hCall,                                          const char* szFile,                                          const bool bLocal,                                          const bool bRemote){    return sipxCallPlayFileStart(hCall, szFile, false, bLocal, bRemote);}SIPXTAPI_API SIPX_RESULT sipxCallPlayFileStart(const SIPX_CALL hCall,                                               const char* szFile,                                               const bool bRepeat,                                               const bool bLocal,                                               const bool bRemote){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallPlayFileStart hCall=%d File=%s bLocal=%d bRemote=%d bRepeat=%d",        hCall, szFile, bLocal, bRemote, bRepeat);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    SIPX_INSTANCE_DATA *pInst ;    UtlString callId ;    if (sipxCallGetCommonData(hCall, &pInst, &callId, NULL, NULL))    {        if (szFile)        {            pInst->pCallManager->audioPlay(callId.data(), szFile, bRepeat, bLocal, bRemote) ;            sr = SIPX_RESULT_SUCCESS ;        }        else        {            sr = SIPX_RESULT_INVALID_ARGS ;        }    }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallPlayFileStop(const SIPX_CALL hCall){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallPlayFileStop hCall=%d", hCall);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    SIPX_INSTANCE_DATA *pInst ;    UtlString callId ;    if (sipxCallGetCommonData(hCall, &pInst, &callId, NULL, NULL))    {        pInst->pCallManager->audioStop(callId.data()) ;        sr = SIPX_RESULT_SUCCESS ;    }    else    {        sr = SIPX_RESULT_INVALID_ARGS ;    }    return sr ;}SIPXTAPI_API SIPX_RESULT sipxCallPlayBufferStart(const SIPX_CALL hCall,                                                 const char* szBuffer,                                                 const int  bufSize,                                                 const int  bufType,                                                 const bool bRepeat,                                                 const bool bLocal,                                                 const bool bRemote){    OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,        "sipxCallPlayBufferStart hCall=%d Buffer=%p Size=%d Type=%d bLocal=%d bRemote=%d bRepeat=%d",        hCall, szBuffer, bufSize, bufType, bLocal, bRemote, bRepeat);    SIPX_RESULT sr = SIPX_RESULT_FAILURE ;    SIPX_INSTANCE_DATA *pInst ;    UtlString callId ;    if (sipxCallGetCommonData(hCall, &pInst, &callId, NULL, NULL))    {        if (szBuffer)        {            pInst->pCallManager->bufferPlay(callId.data(), (int)szBuffer, bufSize, bufType, bRepeat, bLocal, bRemote) ;            sr = SIPX_RESULT_SUCCESS ;        }        else        {            sr = SIPX_RESULT_INVALID_ARGS ;

⌨️ 快捷键说明

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