bool basicCall_CallBack_Redirect(SIPX_EVENT_CATEGORY category, void* pInfo, void* pUserData) { if (category == EVENT_CATEGORY_CALLSTATE) { SIPX_CALLSTATE_INFO* pCallInfo = (SIPX_CALLSTATE_INFO*) pInfo; SIPX_CALL hCall = pCallInfo->hCall; switch(pCallInfo->event) { case CALLSTATE_OFFERING: sipxCallRedirect(hCall, "sip:[email protected]:10000"); sipxCallDestroy(hCall); break ; case CALLSTATE_ALERTING: break ; case CALLSTATE_DISCONNECTED: break ; default: break ; } } return true; }
int CallRedirectCommand::execute(int argc, char* argv[]) { int commandStatus = CommandProcessor::COMMAND_FAILED; if(argc == 3) { sipxCallRedirect(atoi(argv[1]), argv[2]); printf("Call with ID: %d has been redirected to %s.\n", atoi(argv[1]), argv[2]); } else { UtlString usage; getUsage(argv[0], &usage); printf("%s", usage.data()); commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX; } return commandStatus; }
bool SIPX_CALLING_CONVENTION AutoRedirectCallback(SIPX_EVENT_CATEGORY category, void* pInfo, void* pUserData) { if (category == EVENT_CATEGORY_CALLSTATE) { SIPX_CALLSTATE_INFO* pCallInfo = (SIPX_CALLSTATE_INFO*) pInfo; g_hAutoRedirectCallbackCall = pCallInfo->hCall; g_hAutoRedirectCallbackLine = pCallInfo->hLine; // If we have user data verify the line url against it if (pUserData) { char szBuffer[500] ; size_t nBuffer ; if (strlen((const char*) pUserData)) { if (g_hAutoRedirectCallbackLine) // hLine can be 0, and therefore, sipxLineGetURI should fail) { CPPUNIT_ASSERT_EQUAL(sipxLineGetURI(g_hAutoRedirectCallbackLine, szBuffer, sizeof(szBuffer), nBuffer), SIPX_RESULT_SUCCESS) ; } } } switch(pCallInfo->event) { case CALLSTATE_OFFERING: sipxCallRedirect(g_hAutoRedirectCallbackCall, "sip:[email protected]:10000"); break ; case CALLSTATE_DISCONNECTED: { SIPX_CALL hDestroy = g_hAutoRedirectCallbackCall ; sipxCallDestroy(hDestroy) ; } break ; default: break ; } } return true; }
void AutoRedirectCallbackProc(SIPX_CALL hCall, SIPX_LINE hLine, SIPX_CALLSTATE_MAJOR eMajor, SIPX_CALLSTATE_MINOR eMinor, void* pUser) { char szBuffer[128] ; char* szEventDesc = sipxCallEventToString(eMajor, eMinor, szBuffer, sizeof(szBuffer)) ; if(eMinor == OFFERING_ACTIVE) { if(sipxCallRedirect(hCall, ((const char*)pUser)) == SIPX_RESULT_SUCCESS) { printf("Call with ID %d has been redirected.\n", hCall); } else { printf("Call with ID %d failed to be redirected.\n", hCall); } } else if(eMajor == DISCONNECTED) { sipxCallDestroy(hCall); } }