📄 cppeercall.cpp
字号:
#endif connection->forceHangUp(); /** SIPXTAPI: TBD **/ } mLocalConnectionState = PtEvent::CONNECTION_DISCONNECTED; mLocalTermConnectionState = PtTerminalConnection::DROPPED; } // Check if call is dead and drop it if it is dropIfDead(); return TRUE;}// Handles the processing of a CallManager::CP_GET_CALLED_ADDRESSES and// CallManager::CP_GET_CALLING_ADDRESSES messagesUtlBoolean CpPeerCall::handleGetAddresses(OsMsg* pEventMessage){ int msgSubType = pEventMessage->getMsgSubType(); int numConnections = 0; UtlBoolean localAdded = FALSE; UtlSList* connectionList; OsProtectedEvent* getConnEvent = (OsProtectedEvent*) ((CpMultiStringMessage*)pEventMessage)->getInt1Data(); getConnEvent->getIntData((int&)connectionList); if(getConnEvent) { // 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())) { if((msgSubType == CallManager::CP_GET_CALLED_ADDRESSES && connection->isRemoteCallee() ) || (msgSubType == CallManager::CP_GET_CALLING_ADDRESSES && !connection->isRemoteCallee())) { connection->getRemoteAddress(&address); connectionList->append(new UtlString(address)); numConnections++; } else if(!localAdded) { // Add the local connection/address localAdded = TRUE; connectionList->append(new UtlString(mLocalAddress)); 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); } } return TRUE ;}// Handles the processing of a CallManager::CP_ACCEPT_CONNECTION // messageUtlBoolean CpPeerCall::handleAcceptConnection(OsMsg* pEventMessage){ UtlString remoteAddress; UtlBoolean connectionFound = FALSE; ((CpMultiStringMessage*)pEventMessage)->getString2Data(remoteAddress); CONTACT_TYPE eType = (CONTACT_TYPE) ((CpMultiStringMessage*)pEventMessage)->getInt1Data(); void* hWnd = (void*) ((CpMultiStringMessage*)pEventMessage)->getInt2Data(); if (hWnd && mpMediaInterface) { mpMediaInterface->setVideoWindowDisplay(hWnd); } // This is a bit of a hack/short cut. // Find the first remote connection which is in the OFFERING // state and assume that it is the connection on // which the accept operation is to occur. The difficulty // is that the operation is being called on the local connection // but the action must be invoked on the remote connection. This // will need to be fixed for the general case to better support // conference calls. The weird thing from the JTAPI perspective // is that the local connection may be ESTABLISHED and an // incoming call (new connection) to join an existing conference // call will make the local connection go to the OFFERING state. SipConnection* connection = NULL; UtlString address; int connectState; OsReadLock lock(mConnectionMutex); UtlDListIterator iterator(mConnections); while ((connection = (SipConnection*) iterator())) { connectState = connection->getState();#ifdef TEST_PRINT UtlString remoteAddr; UtlString stateString; connection->getRemoteAddress(&remoteAddr); connection->getStateString(connectState, &stateString); osPrintf("%s-CallManager::CP_ACCEPT_CONNECTION connection: %s state: %s\n", mName.data(), remoteAddr.data(), stateString.data());#endif if(connectState == Connection::CONNECTION_OFFERING) { connection->setContactType(eType) ; connection->accept(noAnswerTimeout); connectionFound = TRUE; break; } } if(connectionFound) { //connection }#ifdef TEST_PRINT else { osPrintf("%s-ERROR: acceptConnection cannot find connectionId: %s\n", mName.data(), remoteAddress.data()); }#endif return TRUE ;}// Handles the processing of a CallManager::CP_REJECT_CONNECTION // messageUtlBoolean CpPeerCall::handleRejectConnection(OsMsg* pEventMessage){ UtlString remoteAddress; UtlBoolean connectionFound = FALSE; ((CpMultiStringMessage*)pEventMessage)->getString2Data(remoteAddress); // This is a bit of a hack/short cut. // Find the first remote connection which is in the OFFERING // state and assume that it is the connection on // which the reject operation is to occur. The difficulty // is that the operation is being called on the local connection // but the action must be invoked on the remote connection. This // will need to be fixed for the general case to better support // conference calls. The weird thing from the JTAPI perspective // is that the local connection may be ESTABLISHED and an // incoming call (new connection) to join an existing conference // call will make the local connection go to the OFFERING state. Connection* connection = NULL; UtlString address; int connectState; { OsReadLock lock(mConnectionMutex); UtlDListIterator iterator(mConnections); while ((connection = (Connection*) iterator())) { connectState = connection->getState();#ifdef TEST_PRINT UtlString remoteAddr; UtlString stateString; connection->getRemoteAddress(&remoteAddr); connection->getStateString(connectState, &stateString); osPrintf("%s-CallManager::CP_REJECT_CONNECTION connection: %s state: %s\n", mName.data(), remoteAddr.data(), stateString.data());#endif if(connectState == Connection::CONNECTION_OFFERING) { connection->reject(); connectionFound = TRUE; break; } } }#ifdef TEST_PRINT if(connectionFound) { // } else { osPrintf("%s-ERROR: CpPeerCall::CP_REJECT_CONNECTION cannot find connectionId: %s\n", mName.data(), remoteAddress.data()); }#endif // Check if call is dead and drop it if it is dropIfDead(); return TRUE ;}// Handles the processing of a CallManager::CP_REDIRECT_CONNECTION // messageUtlBoolean CpPeerCall::handleRedirectConnection(OsMsg* pEventMessage){ UtlString remoteAddress; UtlString forwardAddress; UtlBoolean connectionFound = FALSE; ((CpMultiStringMessage*)pEventMessage)->getString2Data(remoteAddress); ((CpMultiStringMessage*)pEventMessage)->getString3Data(forwardAddress); // This is a bit of a hack/short cut. // Find the first remote connection which is in the OFFERING // or ALERTING state and assume that it is the connection on // which the redirect operation is to occur. The difficulty // is that the operation is being called on the local connection // but the action must be invoked on the remote connection. This // will need to be fixed for the general case to better support // conference calls. The weird thing from the JTAPI perspective // is that the local connection may be ESTABLISHED and an // incoming call (new connection) to join an existing conference // call will make the local connection go to the OFFERING state. Connection* connection = NULL; UtlString address; int connectState; { OsReadLock lock(mConnectionMutex); UtlDListIterator iterator(mConnections); while ((connection = (Connection*) iterator())) { connectState = connection->getState();#ifdef TEST_PRINT UtlString remoteAddr; UtlString stateString; connection->getRemoteAddress(&remoteAddr); connection->getStateString(connectState, &stateString); osPrintf("%s-CallManager::CP_REDIRECT_CONNECTION connection: %s state: %s\n", mName.data(), remoteAddr.data(), stateString.data());#endif if(connectState == Connection::CONNECTION_OFFERING || connectState == Connection::CONNECTION_ALERTING) { connection->redirect(forwardAddress.data()); connectionFound = TRUE; break; } } }#ifdef TEST_PRINT if(connectionFound) { // } else { osPrintf("%s-ERROR: CpPeerCall::CP_REDIRECT_CONNECTION cannot find connectionId: %s\n", mName.data(), remoteAddress.data()); }#endif // Check if call is dead and drop it if it is dropIfDead(); return TRUE ;} // Handles the processing of a CallManager::CP_HOLD_TERM_CONNECTION // messageUtlBoolean CpPeerCall::handleHoldTermConnection(OsMsg* pEventMessage){ UtlString address; UtlString terminalId; UtlString callId; ((CpMultiStringMessage*)pEventMessage)->getString1Data(callId); ((CpMultiStringMessage*)pEventMessage)->getString2Data(address); ((CpMultiStringMessage*)pEventMessage)->getString3Data(terminalId); setTargetCallId(callId.data()); if(isLocalTerminal(terminalId.data())) { localHold(); } else { OsReadLock lock(mConnectionMutex); Connection* connection = findHandlingConnection(address); if(connection) { connection->hold(); if (mLocalHeld) { connection->fireSipXEvent(CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_INACTIVE) ; } else { connection->fireSipXEvent(CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE_HELD) ; } } else {#ifdef TEST_PRINT osPrintf("%s-ERROR: CpPeerCall::CP_HOLD_TERM_CONNECTION cannot find connectionId: %s terminalId: %s\n", mName.data(), address.data(), terminalId.data());#endif } } return TRUE ;}// Handles the processing of a CallManager::CP_HOLD_ALL_TERM_CONNECTIONS // messageUtlBoolean CpPeerCall::handleHoldAllTermConnection(OsMsg* pEventMessage){ // put all the connections on hold // The local connection: localHold(); // All of the remote connections OsReadLock lock(mConnectionMutex); UtlDListIterator iterator(mConnections); Connection* connection = NULL; while ((connection = (Connection*) iterator())) { connection->hold(); } return TRUE ;}// Handles the processing of a CallManager::CP_UNHOLD_TERM_CONNECTION // messageUtlBoolean CpPeerCall::handleUnholdTermConnection(OsMsg* pEventMessage){ UtlString address; UtlString terminalId; ((CpMultiStringMessage*)pEventMessage)->getString2Data(address); ((CpMultiStringMessage*)pEventMessage)->getString3Data(terminalId); if(isLocalTerminal(terminalId.data())) { // Post a message to the callManager to change focus CpIntMessage localHoldMessage(CallManager::CP_GET_FOCUS, (int)this); mpManager->postMessage(localHoldMessage); mLocalHeld = FALSE; } else { OsReadLock lock(mConnectionMutex); Connection* connection = findHandlingConnection(address); if(connection) { connection->offHold(); UtlString remoteAddress; connection->getRemoteAddress(&remoteAddress); if (mLocalTermConnectionState != PtTerminalConnection::TALKING && mLocalTermConnectionState != PtTerminalConnection::IDLE) { UtlString responseText; connection->getResponseText(responseText); postTaoListenerMessage(connection->getResponseCode(),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -