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

📄 cppeercall.cpp

📁 基于sipfoundy 公司开发的sipx协议API
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                    responseText,                     PtEvent::TERMINAL_CONNECTION_TALKING,                     TERMINAL_CONNECTION_STATE,                     PtEvent::CAUSE_UNHOLD,                     connection->isRemoteCallee(),                     remoteAddress);                if (mLocalHeld)                {                    connection->fireSipXEvent(CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE_HELD) ;                }                else                {                    connection->fireSipXEvent(CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE) ;                }#ifdef TEST_PRINT                osPrintf("%s->>>> CpPeerCall::handleUnholdTermConnection: CallManager::CP_UNHOLD_TERM_CONNECTION:  TERMINAL_CONNECTION_CREATED >>>>\n", mName.data());#endif            }        }#ifdef TEST_PRINT        else        {            osPrintf("%s-ERROR: CpPeerCall::CP_OFFHOLD_TERM_CONNECTION cannot find connectionId: %s\n",                 mName.data(), address.data());        }#endif    }    return TRUE ;}// Handles the processing of a CallManager::CP_RENEGOTIATE_CODECS_CONNECTION // messageUtlBoolean CpPeerCall::handleRenegotiateCodecsConnection(OsMsg* pEventMessage){    UtlString address;    UtlString terminalId;    ((CpMultiStringMessage*)pEventMessage)->getString2Data(address);    ((CpMultiStringMessage*)pEventMessage)->getString3Data(terminalId);    if(isLocalTerminal(terminalId.data()))    {#ifdef TEST_PRINT        osPrintf("%s-ERROR: CpPeerCall::CP_RENEGOTIATE_CODECS_CONNECTION cannot renegotiate codecs for local connectionId: %s\n",             mName.data(), address.data());#endif    }    else    {        OsReadLock lock(mConnectionMutex);        Connection* connection = findHandlingConnection(address);        if(connection)        {            //UtlString remoteAddress;            //connection->getRemoteAddress(&remoteAddress);            if (mLocalTermConnectionState == PtTerminalConnection::TALKING)            {                connection->renegotiateCodecs();            }            else            {                // The may be needed for proper error handling                //UtlString responseText;                //connection->getResponseText(responseText);                //postTaoListenerMessage(connection->getResponseCode(),                 //    responseText,                 //    PtEvent::TERMINAL_CONNECTION_TALKING,                 //    TERMINAL_CONNECTION_STATE,                 //    PtEvent::CAUSE_UNHOLD,                 //    connection->isRemoteCallee(),                 //    remoteAddress);#ifdef TEST_PRINT                osPrintf("%s-ERROR: CpPeerCall::handleRenegotiateCodecsConnection: CallManager::CP_RENEGOTIATE_CODECS_CONNECTION\n", mName.data());#endif            }        }#ifdef TEST_PRINT        else        {            osPrintf("%s-ERROR: CpPeerCall::CP_RENEGOTIATE_CODECS_CONNECTION cannot find connectionId: %s\n",                 mName.data(), address.data());        }#endif    }    return TRUE ;}// Handles the processing of a CallManager::CP_RENEGOTIATE_CODECS_ALL_CONNECTIONS // messageUtlBoolean CpPeerCall::handleRenegotiateCodecsAllConnections(OsMsg* pEventMessage){    if (mLocalTermConnectionState == PtTerminalConnection::TALKING)    {            Connection* connection = NULL;            OsReadLock lock(mConnectionMutex);        UtlDListIterator iterator(mConnections);        while ((connection = (Connection*) iterator()))        {            connection->renegotiateCodecs() ;        }    }     return TRUE ;}// Handles the processing of a CallManager::CP_SET_CODEC_CPU_LIMIT messageUtlBoolean CpPeerCall::handleSetCodecCPULimit(OsMsg& eventMessage){    UtlBoolean bRC = FALSE ;    int iLevel = ((CpMultiStringMessage&)eventMessage).getInt1Data();    if (mpMediaInterface)    {        mpMediaInterface->setCodecCPULimit(iLevel) ;        bRC = TRUE ;    }    return bRC ;}// Handles the processing of a CallManager::CP_GET_CODEC_CPU_COST messageUtlBoolean CpPeerCall::handleGetCodecCPUCost(OsMsg& eventMessage){    UtlBoolean bRC = FALSE ;    int iCost = -1 ;     if (mpMediaInterface)    {        iCost = mpMediaInterface->getCodecCPUCost();        bRC = TRUE ;    }    OsProtectedEvent* getNumEvent = (OsProtectedEvent*) ((CpMultiStringMessage&)eventMessage).getInt1Data();    // If the event has already been signalled, clean up    if(OS_ALREADY_SIGNALED == getNumEvent->signal(iCost))    {        // The other end must have timed out on the wait        OsProtectEventMgr* eventMgr = OsProtectEventMgr::getEventMgr();        eventMgr->release(getNumEvent);    }    return bRC ;}// Handles the processing of a CallManager::CP_GET_CODEC_CPU_LIMIT messageUtlBoolean CpPeerCall::handleGetCodecCPULimit(OsMsg& eventMessage){    UtlBoolean bRC = FALSE  ;    int iCost = -1 ;    if (mpMediaInterface)    {        iCost = mpMediaInterface->getCodecCPULimit();        bRC = TRUE ;    }    OsProtectedEvent* getNumEvent = (OsProtectedEvent*) ((CpMultiStringMessage&)eventMessage).getInt1Data();    // If the event has already been signalled, clean up    if(OS_ALREADY_SIGNALED == getNumEvent->signal(iCost))    {        // The other end must have timed out on the wait        OsProtectEventMgr* eventMgr = OsProtectEventMgr::getEventMgr();        eventMgr->release(getNumEvent);    }    return bRC ;}// Handles the processing of a CallManager::CP_ADD_TONE_LISTENER // messageUtlBoolean CpPeerCall::handleAddToneListener(OsMsg* pEventMessage){    // add tone listener to all connecitons    Connection* connection = NULL;    int pListener = ((CpMultiStringMessage*)pEventMessage)->getInt1Data();    OsReadLock lock(mConnectionMutex);    UtlDListIterator iterator(mConnections);    while ((connection = (Connection*) iterator()))    {        addToneListenerToFlowGraph(pListener, connection);    }    // add tone listener to a local list    if (!mToneListeners.containsReference((UtlContainable*) pListener))        mToneListeners.append((UtlContainable*) pListener);    return TRUE ;}// Handles the processing of a CallManager::CP_REMOVE_TONE_LISTENER // messageUtlBoolean CpPeerCall::handleRemoveToneListener(OsMsg* pEventMessage){    // remove tone listener from all connecitons    Connection* connection = NULL;    int pListener = ((CpMultiStringMessage*)pEventMessage)->getInt1Data();    OsReadLock lock(mConnectionMutex);    UtlDListIterator iterator(mConnections);    while ((connection = (Connection*) iterator()))    {        removeToneListenerFromFlowGraph(pListener, connection);    }    // remove tone listener from local list    if (!mToneListeners.containsReference((UtlContainable*)  pListener))        mToneListeners.removeReference((UtlContainable*) pListener);    return TRUE ;}// Handles the processing of a CallManager::CP_TRANSFER_CONNECTION_STATUS // messageUtlBoolean CpPeerCall::handleTransferConnectionStatus(OsMsg* pEventMessage){    // This message is sent to the target call on the    // transfer controller    UtlString connectionAddress;    ((CpMultiStringMessage*)pEventMessage)->getString2Data(connectionAddress);    int connectionState = ((CpMultiStringMessage*)pEventMessage)->getInt1Data();    int cause = ((CpMultiStringMessage*)pEventMessage)->getInt2Data();#ifdef TEST_PRINT    UtlString connState;    Connection::getStateString(connectionState, &connState);    osPrintf("%s-CpPeerCall::CP_TRANSFER_CONNECTION_STATUS connectionAddress: %s state: %s cause: %d\n",        mName.data(), connectionAddress.data(), connState.data(), cause);#endif    {        // Find the connection and give it the status        OsReadLock lock(mConnectionMutex);        Connection* connection = findHandlingConnection(connectionAddress);        if(connection)        {            OsSysLog::add(FAC_CP, PRI_DEBUG, "transferControllerStatus");            connection->transferControllerStatus(connectionState, cause);        }#ifdef TEST_PRINT        else        {            UtlString defaultCallId;            getCallId(defaultCallId);            osPrintf("%s-CpPeerCall::CP_TRANSFER_CONNECTION_STATUS FAILED to find connection %s in call: %s\n",                mName.data(), connectionAddress.data(), defaultCallId.data());        }#endif    }    // Stop the meta event    stopMetaEvent();    // Check if call is dead and drop it if it is    dropIfDead();    return TRUE ;}// Handles the processing of a CallManager::CP_TRANSFEREE_CONNECTION_STATUS // messageUtlBoolean CpPeerCall::handleTransfereeConnectionStatus(OsMsg* pEventMessage){    // This message gets sent to the original call on the    // transferee    UtlString connectionAddress;    ((CpMultiStringMessage*)pEventMessage)->getString2Data(connectionAddress);    int connectionState = ((CpMultiStringMessage*)pEventMessage)->getInt1Data();    int responseCode = ((CpMultiStringMessage*)pEventMessage)->getInt2Data();#ifdef TEST_PRINT    UtlString connectionStateString;    Connection::getStateString(connectionState, &connectionStateString);    osPrintf("%s-CpPeerCall::CP_TRANSFEREE_CONNECTION_STATUS connectionAddress: \"%s\" state: %s response: %d\n",        mName.data(), connectionAddress.data(), connectionStateString.data(), responseCode);#endif    // Find the connection and give it the status    {        OsReadLock lock(mConnectionMutex);        Connection* connection = findHandlingConnection(connectionAddress);        if(connection)            connection->transfereeStatus(connectionState, responseCode);#ifdef TEST_PRINT        else        {            UtlString thisCallId;            getCallId(thisCallId);            osPrintf("%s-CpPeerCall::CP_TRANSFEREE_CONNECTION_STATUS connection not found in call: %s\n",                mName.data(), thisCallId.data());        }#endif    }    // Stop the meta event    stopMetaEvent();    // Check if call is dead and drop it if it is    dropIfDead();    return TRUE ;}// Handles the processing of CallManager::CP_GET_NUM_CONNECTIONS // and CallManager::CP_GET_NUM_TERM_CONNECTIONS messages       UtlBoolean CpPeerCall::handleGetNumConnections(OsMsg* pEventMessage){    int numConnections = mConnections.entries() + 1;    OsProtectedEvent* getNumEvent = (OsProtectedEvent*)         ((CpMultiStringMessage*)pEventMessage)->getInt1Data();    // If the event has already been signalled, clean up    if(OS_ALREADY_SIGNALED == getNumEvent->signal(numConnections))    {        // The other end must have timed out on the wait        OsProtectEventMgr* eventMgr = OsProtectEventMgr::getEventMgr();        eventMgr->release(getNumEvent);    }    return TRUE ;}// Handles the processing of a CallManager::CP_GET_CONNECTIONS // messageUtlBoolean CpPeerCall::handleGetConnections(OsMsg* pEventMessage){    int numConnections = 0;    UtlSList* connectionList = 0;    OsProtectedEvent* getConnEvent = (OsProtectedEvent*)         ((CpMultiStringMessage*)pEventMessage)->getInt1Data();    getConnEvent->getIntData((int&)connectionList);    if(getConnEvent && connectionList)    {        // Add the local connection/address        connectionList->append(new UtlString(mLocalAddress));        numConnections++;        // Get the remote connection(s)/address(es)        { // scope for lock            Connection* connection = NULL;            UtlString address;            OsReadLock lock(mConnectionMutex);            UtlDListIterator iterator(mConnections);            while ((connection = (Connection*) iterator()))            {                connection->getRemoteAddress(&address);                connectionList->append(new UtlString(address));                numConnections++;            }        }        // Signal the caller that we are done.        // If the event has already been signalled, clean up        if(OS_ALREADY_SIGNALED == getConnEvent->signal(numConnections))        {            // The other end must have timed out on the wait            connectionList->destroyAll();            delete connectionList;            OsProtectEventMgr* eventMgr = OsProtectEventMgr::getEventMgr();            eventMgr->release(getConnEvent);        }

⌨️ 快捷键说明

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