diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 2e0934d170be5f9c332214fe6d2acdb8d6a310ca..5fc21e09a700677d936f2996c0ddfda3288727f8 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -650,13 +650,15 @@ bool ManagerImpl::transferCall (const CallID& call_id, const std::string& to) { AccountID accountid; bool returnValue; + _info("Manager: Transfer Call\n"); + stopTone(); CallID current_call_id = getCurrentCallId(); if (participToConference(call_id)) { - _debug("Particip to a conference\n"); + _info("Manager: Particip to a conference\n"); Conference *conf = getConferenceFromCallID(call_id); @@ -668,8 +670,6 @@ bool ManagerImpl::transferCall (const CallID& call_id, const std::string& to) { } } else { - _debug("Do not Particip to a conference\n"); - // we are not participating to a conference, current call switched to "" if (!isConference(current_call_id)) switchCall(""); @@ -685,7 +685,7 @@ bool ManagerImpl::transferCall (const CallID& call_id, const std::string& to) { accountid = getAccountFromCall(call_id); if (accountid == AccountNULL) { - _debug ("! Manager Transfer Call: Call doesn't exists"); + _warn ("Manager: Call doesn't exists"); return false; } @@ -696,18 +696,21 @@ bool ManagerImpl::transferCall (const CallID& call_id, const std::string& to) { removeWaitingCall(call_id); - if (_dbus) - _dbus->getCallManager()->callStateChanged(call_id, "HUNGUP"); - return returnValue; } void ManagerImpl::transferFailed () { + + _debug("UserAgent: Transfer failed"); + if (_dbus) _dbus->getCallManager()->transferFailed(); } void ManagerImpl::transferSucceded () { + + _debug("UserAgent: Transfer succeded"); + if (_dbus) _dbus->getCallManager()->transferSucceded(); @@ -1713,7 +1716,7 @@ void ManagerImpl::peerHungupCall (const CallID& call_id) { AccountID account_id; bool returnValue; - _debug ("ManagerImpl::peerHungupCall(%s)", call_id.c_str()); + _debug ("Manager: Peer hungup call %s", call_id.c_str()); // store the current call id CallID current_call_id = getCurrentCallId(); @@ -1745,11 +1748,6 @@ void ManagerImpl::peerHungupCall (const CallID& call_id) { account_id = getAccountFromCall(call_id); - if (account_id == AccountNULL) { - _debug ("peerHungupCall: Call doesn't exists"); - return; - } - returnValue = getAccountLink(account_id)->peerHungup(call_id); } diff --git a/sflphone-common/src/sip/sipcall.h b/sflphone-common/src/sip/sipcall.h index f2d93259da6872000a51a3491da79e2d37eef3b4..7d14936729055c65cbd348263fcac35b6fe620f9 100644 --- a/sflphone-common/src/sip/sipcall.h +++ b/sflphone-common/src/sip/sipcall.h @@ -97,9 +97,11 @@ class SIPCall : public Call void setTid(int tid) { _tid = tid; } void setXferSub(pjsip_evsub* sub) {_xferSub = sub;} + pjsip_evsub *getXferSub() {return _xferSub;} void setInvSession(pjsip_inv_session* inv) {_invSession = inv;} + pjsip_inv_session *getInvSession() {return _invSession;} Sdp* getLocalSDP (void) { return _local_sdp; } diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 022cdcbe0c2dd16cc5b97e6115570756b9cb7bd6..2309c86923288825ba59aed8ce1b1ab8a04c50ff 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -50,6 +50,8 @@ #include <sys/ioctl.h> #include <linux/if.h> +#include <map> + #define CAN_REINVITE 1 static char * invitationStateMap[] = { @@ -79,9 +81,17 @@ struct result { pjsip_server_addresses servers; }; +/** The default transport (5060) */ pjsip_transport *_localUDPTransport = NULL; + +/** The local tls listener */ pjsip_tpfactory *_localTlsListener = NULL; +/** A map to retreive SFLphone internal call id + * Given a SIP call ID (usefull for transaction sucha as transfer)*/ +std::map<std::string, CallID> transferCallID; + + const pj_str_t STR_USER_AGENT = { (char*) "User-Agent", 10 }; /**************** EXTERN VARIABLES AND FUNCTIONS (callbacks) **************************/ @@ -921,12 +931,12 @@ SIPVoIPLink::peerHungup (const CallID& id) pjsip_tx_data *tdata = NULL; SIPCall* call; - _info("SIP: Peer hungup"); + _info("UserAgent: Peer hungup"); call = getSIPCall (id); if (call==0) { - _debug ("! SIP Error: Call doesn't exist"); + _warn ("UserAgent: Call doesn't exist"); return false; } @@ -949,7 +959,7 @@ SIPVoIPLink::peerHungup (const CallID& id) // Release RTP thread if (Manager::instance().isCurrentCall (id)) { - _debug ("* SIP Info: Stopping AudioRTP for hangup"); + _debug ("UserAgent: Stopping AudioRTP for hangup"); call->getAudioRtp()->stop(); } @@ -1109,13 +1119,13 @@ SIPVoIPLink::transfer (const CallID& id, const std::string& to) account_id = Manager::instance().getAccountFromCall (id); account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id)); - if (account == NULL) { - _debug ("SIPVoIPLink::transfer account is null. Returning."); + if (!account) { + _error("UserAgent: Error: Transfer account is null. Returning."); return false; } - if (call==0) { - _debug ("! SIP Failure: Call doesn't exist"); + if (!call) { + _error ("UserAgent: Error: Call doesn't exist"); return false; } @@ -1128,7 +1138,7 @@ SIPVoIPLink::transfer (const CallID& id, const std::string& to) pj_cstr (&pjDest, dest.c_str()); } - _debug ("Transfering to %s", dest.c_str()); + _info ("UserAgent: Transfering to %s", dest.c_str()); /* Create xfer client subscription. */ pj_bzero (&xfer_cb, sizeof (xfer_cb)); @@ -1137,13 +1147,13 @@ SIPVoIPLink::transfer (const CallID& id, const std::string& to) status = pjsip_xfer_create_uac (call->getInvSession()->dlg, &xfer_cb, &sub); if (status != PJ_SUCCESS) { - _debug ("UserAgent: Unable to create xfer -- %d", status); + _warn ("UserAgent: Unable to create xfer -- %d", status); return false; } /* Associate this voiplink of call with the client subscription * We can not just associate call with the client subscription - * because after this function, we can not find the cooresponding + * because after this function, we can no find the cooresponding * voiplink from the call any more. But the voiplink is useful! */ pjsip_evsub_set_mod_data (sub, getModId(), this); @@ -1154,15 +1164,21 @@ SIPVoIPLink::transfer (const CallID& id, const std::string& to) status = pjsip_xfer_initiate (sub, &pjDest, &tdata); if (status != PJ_SUCCESS) { - _debug ("UserAgent: Unable to create REFER request -- %d", status); + _error ("UserAgent: Unable to create REFER request -- %d", status); return false; } + // Put SIP call id in map in order to retrieve call during transfer callback + std::string callidtransfer(call->getInvSession()->dlg->call_id->id.ptr, call->getInvSession()->dlg->call_id->id.slen); + _debug("%s", callidtransfer.c_str()); + transferCallID.insert(std::pair<std::string, CallID>(callidtransfer, call->getCallId())); + + /* Send. */ status = pjsip_xfer_send_request (sub, tdata); if (status != PJ_SUCCESS) { - _debug ("UserAgent: Unable to send REFER request -- %d", status); + _error ("UserAgent: Unable to send REFER request -- %d", status); return false; } @@ -1171,7 +1187,12 @@ SIPVoIPLink::transfer (const CallID& id, const std::string& to) bool SIPVoIPLink::transferStep2 (SIPCall* call) { - call->getAudioRtp()->stop(); + + // TODO is this the best way to proceed? + Manager::instance().peerHungupCall(call->getCallId()); + + + return true; } @@ -1492,7 +1513,10 @@ SIPVoIPLink::SIPCallServerFailure (SIPCall *call) void SIPVoIPLink::SIPCallClosed (SIPCall *call) { + _info("UserAgent: Closing call"); + if (!call) { + _warn("UserAgent: Error: CAll pointer is NULL\n"); return; } @@ -1500,16 +1524,14 @@ SIPVoIPLink::SIPCallClosed (SIPCall *call) if (Manager::instance().isCurrentCall (id)) { call->setAudioStart (false); - _debug ("* SIP Info: Stopping AudioRTP when closing"); + _debug ("UserAgent: Stopping AudioRTP when closing"); call->getAudioRtp()->stop(); } - _debug ("After close RTP"); - Manager::instance().peerHungupCall (id); terminateOneCall (id); removeCall (id); - _debug ("After remove call ID"); + } void @@ -1520,7 +1542,7 @@ SIPVoIPLink::SIPCallReleased (SIPCall *call) } // if we are here.. something when wrong before... - _debug ("SIP call release"); + _debug ("UserAgent: SIP call release"); CallID id = call->getCallId(); @@ -3315,9 +3337,8 @@ void call_on_forked (pjsip_inv_session *inv, pjsip_event *e) void call_on_tsx_changed (pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e) { - _debug("call_on_tsx_changed to state %s", transactionStateMap[tsx->state]); + _debug("UserAgent: Transaction changed to state %s", transactionStateMap[tsx->state]); - if (tsx->role==PJSIP_ROLE_UAS && tsx->state==PJSIP_TSX_STATE_TRYING && pjsip_method_cmp (&tsx->method, &pjsip_refer_method) ==0) { @@ -3332,12 +3353,18 @@ void call_on_tsx_changed (pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_ if (r_data->msg_info.msg->line.req.method.id == PJSIP_OTHER_METHOD) { - std::string method_name = "INFO"; - std::string request = r_data->msg_info.msg->line.req.method.name.ptr; + std::string method_info = "INFO"; + std::string method_notify = "NOTIFY"; + + std::string request = pjsip_rx_data_get_info (r_data); + + _debug("UserAgent: %s", request.c_str()); - if (request.find (method_name) != (size_t)-1) { + if(request.find (method_notify) != (size_t)-1) { - _debug ("%s", pjsip_rx_data_get_info (r_data)); + } + // Must reply 200 OK on SIP INFO request + else if (request.find (method_info) != (size_t)-1) { pjsip_dlg_create_response (inv->dlg, r_data, PJSIP_SC_OK, NULL, &t_data); @@ -3817,8 +3844,7 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata) * request. */ ref_by_hdr = (pjsip_hdr*) - pjsip_msg_find_hdr_by_name (rdata->msg_info.msg, &str_ref_by, - NULL); + pjsip_msg_find_hdr_by_name (rdata->msg_info.msg, &str_ref_by, NULL); /* Notify callback */ code = PJSIP_SC_ACCEPTED; @@ -4004,10 +4030,9 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event) * When subscription is accepted (got 200/OK to REFER), check if * subscription suppressed. */ - if (pjsip_evsub_get_state (sub) == PJSIP_EVSUB_STATE_ACCEPTED) { - _debug ("Transfer accepted! Waiting for notifications. "); + _debug ("UserAgent: Transfer received, waiting for notifications. "); } @@ -4016,6 +4041,7 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event) */ else if (pjsip_evsub_get_state (sub) == PJSIP_EVSUB_STATE_ACTIVE || pjsip_evsub_get_state (sub) == PJSIP_EVSUB_STATE_TERMINATED) { + pjsip_msg *msg; pjsip_msg_body *body; pjsip_status_line status_line; @@ -4023,13 +4049,6 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event) pj_bool_t cont; pj_status_t status; - std::string noresource; - std::string ringing; - std::string request; - - noresource = "noresource"; - ringing = "Ringing"; - SIPVoIPLink *link = reinterpret_cast<SIPVoIPLink *> (pjsip_evsub_get_mod_data (sub, _mod_ua.id)); @@ -4043,101 +4062,73 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event) } + /* Application is not interested with call progress status */ if (!link || !event) { - /* Application is not interested with call progress status */ - _debug ("UserAgent: Either link or event is empty!"); + _warn ("UserAgent: Either link or event is empty in transfer callback"); return; } + pjsip_rx_data* r_data = event->body.rx_msg.rdata; - /* This better be a NOTIFY request */ - if (event->type == PJSIP_EVENT_TSX_STATE && - event->body.tsx_state.type == PJSIP_EVENT_RX_MSG) { - - pjsip_rx_data *rdata; - - rdata = event->body.tsx_state.src.rdata; + std::string method_notify = "NOTIFY"; + std::string request = pjsip_rx_data_get_info (r_data); + /* This better be a NOTIFY request */ + if (r_data->msg_info.msg->line.req.method.id == PJSIP_OTHER_METHOD && + request.find(method_notify) != (size_t)-1) { /* Check if there's body */ - msg = rdata->msg_info.msg; + msg = r_data->msg_info.msg; body = msg->body; if (!body) { - // if (call->getCallConfiguration () == Call::IPtoIP) { - // _debug("UserAgent: IptoIp NOTIFY without message body"); - // } - // else{ - _debug ("UserAgent: Warning! Received NOTIFY without message body"); + _warn ("UserAgent: Warning! Received NOTIFY without message body"); return; - // } } - - /* Check for appropriate content */ if (pj_stricmp2 (&body->content_type.type, "message") != 0 || pj_stricmp2 (&body->content_type.subtype, "sipfrag") != 0) { - _debug ("UserAgent: Warning! Received NOTIFY with non message/sipfrag content"); + _warn ("UserAgent: Warning! Received NOTIFY without message/sipfrag content"); return; } /* Try to parse the content */ - status = pjsip_parse_status_line ( (char*) body->data, body->len, - &status_line); + status = pjsip_parse_status_line ( (char*) body->data, body->len, &status_line); if (status != PJ_SUCCESS) { - _debug ("UserAgent: Warning! Received NOTIFY with invalid message/sipfrag content"); + _warn ("UserAgent: Warning! Received NOTIFY with invalid message/sipfrag content"); return; } } else { - _debug ("UserAgent: Set code to 500!"); + _error ("UserAgent: Error: Set code to 500 during transfer"); status_line.code = 500; status_line.reason = *pjsip_get_status_text (500); } - // Get current call - SIPCall *call = dynamic_cast<SIPCall *> (link->getCall (Manager::instance().getCurrentCallId())); + // Get call coresponding to this transaction + std::string transferID(r_data->msg_info.cid->id.ptr, r_data->msg_info.cid->id.slen); + std::map<std::string, CallID>::iterator it = transferCallID.find(transferID); + CallID cid = it->second; + SIPCall *call = dynamic_cast<SIPCall *> (link->getCall (cid)); if (!call) { - _debug ("UserAgent: Call doesn't exit!"); + _warn ("UserAgent: Call with id %s doesn't exit!", cid.c_str()); return; } - if (event->body.rx_msg.rdata->msg_info.msg_buf != NULL) { - request = event->body.rx_msg.rdata->msg_info.msg_buf; - - if ( (int) request.find (noresource) != -1) { - _debug ("UserAgent: NORESOURCE for transfer!"); - link->transferStep2 (call); - pjsip_evsub_terminate (sub, PJ_TRUE); - - Manager::instance().transferFailed(); - return; - } - - if ( (int) request.find (ringing) != -1) { - _debug ("UserAgent: transfered call RINGING!"); - link->transferStep2 (call); - pjsip_evsub_terminate (sub, PJ_TRUE); - - Manager::instance().transferSucceded(); - return; - } - } - - /* Notify application */ is_last = (pjsip_evsub_get_state (sub) ==PJSIP_EVSUB_STATE_TERMINATED); cont = !is_last; + _debug("UserAgent: Notification status line: %d", status_line.code); if (status_line.code/100 == 2) { - _debug ("UserAgent: Try to stop rtp!"); + _debug ("UserAgent: Received 200 OK on call transfered, stop call!"); pjsip_tx_data *tdata; status = pjsip_inv_end_session (call->getInvSession(), PJSIP_SC_GONE, NULL, &tdata); diff --git a/sippxml/account_uas_recv_hangup.xml b/sippxml/account_uas_recv_hangup.xml index 101e6f4c97442b091dc86fedc913078353126c63..94bea4704232386a5518de7995c3138bc3007850 100644 --- a/sippxml/account_uas_recv_hangup.xml +++ b/sippxml/account_uas_recv_hangup.xml @@ -96,8 +96,6 @@ <recv request="ACK"> </recv> - <pause milliseconds="500"/> - <send retrans="500"> <![CDATA[ diff --git a/sippxml/testsuiteuac.sh b/sippxml/testsuiteuac.sh index be9455244341e1074b25b4fbee1f8cbbf9c28391..1ed0db416504d9abc8288a3a56e8b848d0e46263 100644 --- a/sippxml/testsuiteuac.sh +++ b/sippxml/testsuiteuac.sh @@ -1,17 +1,22 @@ #!/bin/bash -# sleep 5; -SERVERPORT=5062 + +LOCALPORT=5062 +LOCALIP_lo=127.0.0.1 +LOCALIP_eth0=192.168.50.182 + +REMOTEADDR_lo=127.0.0.1:5060 +REMOTEADDR_ast=192.168.50.79 # SCENARIO 1 Test 1 function test_ip2ip_send_hangup { - # start sipp server to receive calls from sflphone - sipp -sf ip2ip_uas_recv_peer_hungup.xml 127.0.0.1:5060 -i 127.0.0.1 -p ${SERVERPORT} - # start sflphoned # /usr/lib/sflphone/sflphoned& + # start sipp server to receive calls from sflphone + sipp -sf ip2ip_uas_recv_peer_hungup.xml ${REMOTEADDR_lo} -i ${LOCALIP_lo} -p ${LOCALPORT} + # wait some time to make sure sflphoned is started # sleep 1; @@ -25,12 +30,12 @@ function test_ip2ip_send_hangup { # SCENARIO 1 Test 2 function test_ip2ip_send_peer_hungup { - # start sipp server to receive calls from sflphone and then hangup - sipp -sf ip2ip_uas_recv_hangup.xml 127.0.0.1:5060 -s 127.0.0.1:5060 -i 127.0.0.1 -p ${SERVERPORT} - # start sflphoned # /usr/lib/sflphone/sflphoned& + # start sipp server to receive calls from sflphone and then hangup + sipp -sf ip2ip_uas_recv_hangup.xml ${REMOTEADDR_lo} -s ${REMOTEADDR_lo} -i ${LOCALIP_lo} -p ${LOCALPORT} + # wait some time to make sure sflphoned is started # sleep 1; @@ -57,7 +62,7 @@ function test_ip2ip_recv_hangup { # sleep 1; # start sipp client and send calls - sipp -sf ip2ip_uac_send_peer_hungup.xml 127.0.0.1:5060 -i 127.0.0.1 -p ${SERVERPORT} -l 1 + sipp -sf ip2ip_uac_send_peer_hungup.xml ${REMOTEADDR_lo} -i ${LOCALIP_lo} -p ${LOCALPORT} -l 1 -m 10 # kill every one # bashtrap @@ -79,7 +84,7 @@ function test_ip2ip_recv_peer_hungup { # sleep 1; # start sipp client and send calls - sipp -sf ip2ip_uac_send_hangup.xml 127.0.0.1:5060 -i 127.0.0.1 -p ${SERVERPORT} -l 1 + sipp -sf ip2ip_uac_send_hangup.xml ${REMOTEADDR_lo} -i ${LOCALIP_lo} -p ${LOCALPORT} -l 1 -m 10 # kill every one # bashtrap @@ -100,10 +105,10 @@ function test_account_send_hangup { # sleep 1; # process only one registration - sipp -sf account_uas_register.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 -m 1 + sipp -sf account_uas_register.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 1 # start sipp client and send calls - sipp -sf account_uas_recv_peer_hungup.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 + sipp -sf account_uas_recv_peer_hungup.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 # kill every one # bashtrap @@ -124,10 +129,10 @@ function test_account_send_peer_hungup { # sleep 1; # process only one registration - sipp -sf account_uas_register.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 -m 1 + sipp -sf account_uas_register.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 1 # start sipp client and send calls - sipp -sf account_uas_recv_hangup.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 + sipp -sf account_uas_recv_hangup.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 # kill every one # bashtrap @@ -148,11 +153,10 @@ function test_account_recv_hangup { # sleep 1; # process only one registration - sipp -sf account_uas_register.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 -m 1 + sipp -sf account_uas_register.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 1 # start sipp client and send calls - sipp -sf account_uac_send_peer_hungup.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 - + sipp -sf account_uac_send_peer_hungup.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 10 # kill every one # bashtrap } @@ -172,10 +176,10 @@ function test_account_recv_peer_hungup { # sleep 1; # process only one registration - sipp -sf account_uas_register.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 -m 1 + sipp -sf account_uas_register.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 1 # start sipp client and send calls - sipp -sf account_uac_send_hangup.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 + sipp -sf account_uac_send_hangup.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 10 # kill every one # bashtrap @@ -196,7 +200,7 @@ function test_ip2ip_send_hold_offhold { # sleep 1; # start sipp client and send calls - sipp -sf ip2ip_uas_recv_hold_offhold.xml 127.0.0.1:5060 -i 127.0.0.1 -p ${SERVERPORT} + sipp -sf ip2ip_uas_recv_hold_offhold.xml ${REMOTEADDR_lo} -i ${LOCALIP_lo} -p ${LOCALPORT} # kill every one # bashtrap } @@ -216,10 +220,10 @@ function test_account_send_transfer { # sleep 1; # process only one registration - sipp -sf account_uas_register.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 -m 1 + sipp -sf account_uas_register.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 1 # start sipp client and send calls - sipp -sf account_uas_recv_transfered.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 + sipp -sf account_uas_recv_transfered.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 # kill every one # bashtrap @@ -236,20 +240,61 @@ bashtrap() # ============================ Test Suite ============================ -# SCENARIO 1: Normal flow calls (IP2IP) + + +# SCENARIO 1: (IP2IP) Normal flow calls + +# Test 1: - Send an IP2IP call +# - Hangup # test_ip2ip_send_hangup + +# Test 2: - Send an IP2IP call +# - Peer Hangup # test_ip2ip_send_peer_hungup + +# Test 3: - Receive an IP2IP call +# - Hangup # test_ip2ip_recv_hangup + +# Test 4: - Receive an IP2IP call +# - Peer Hangup # test_ip2ip_recv_peer_hungup -# SCENARIO 2: Normal flow calls (Account) + + +# SCENARIO 2: (ACCOUNT) Normal flow calls + +# Test 1: - Send an ACCOUNT call +# - Hangup # test_account_send_hangup + +# Test 2: - Send an ACCOUNT call +# - Peer Hangup # test_account_send_peer_hungup + +# Test 3: - Receive an ACCOUNT call +# - Hangup # test_account_recv_hangup + +# Test 4: - Receive an ACCOUNT call +# - Peer Hangup # test_account_recv_peer_hungup + + # SCENARIO 3: Hold/offHold calls (Account) -# test_ip2ip_send_hold_offhold + +# Test 1: - Send an IP2IP call +# - Put this call on HOLD +# - Off HOLD this call +# - Hangup +test_ip2ip_send_hold_offhold + + # SCENARIO 4: Transfer calls (Account) -test_account_send_transfer \ No newline at end of file + +# Test 1: - Send an IP2IP call +# - Transfer this call to another sipp instance +# - Hangup +# test_account_send_transfer \ No newline at end of file diff --git a/tools/pysflphone/pysflphone_testdbus.py b/tools/pysflphone/pysflphone_testdbus.py index 3e7c97f0b03dc2df97dc4f643275e11224d75ce2..a1c909c531fb3a2b73306c59466039e26bbcefb1 100644 --- a/tools/pysflphone/pysflphone_testdbus.py +++ b/tools/pysflphone/pysflphone_testdbus.py @@ -13,21 +13,29 @@ from threading import Event print "Import SFLphone" from sflphonectrlsimple import SflPhoneCtrlSimple -# def killhandler(signum, frame): -# raise IOError("Couldn't open device!") +# Define remote IP address constant +REMOTEADDR_lo="127.0.0.1:5062" -# signal.signal(signal.SIGKILL, killhandler) +# Defines phone numbers +PHONE1="27182" +PHONE2="31416" +PHONE3="14142" +# Define function callback to emulate UA behavior on +# recieving a call def acceptOnIncomingCall(sflphone): time.sleep(0.2) sflphone.Accept(sflphone.currentCallId) +# Define function callback to emulate UA behavior on +# receiving a call and hanging up def acceptOnIncomingCallHangup(sflphone): time.sleep(0.2) sflphone.Accept(sflphone.currentCallId) time.sleep(0.5) sflphone.HangUp(sflphone.currentCallId) + class SflPhoneTests(): def __init__(self, sfl): @@ -75,12 +83,13 @@ class SflPhoneTests(): print "Account with ID " + accountID + " removed" + # SCENARIO 1 Test 1 def test_ip2ip_send_hangup(self): """Make a call to a server (sipp) on port 5062""" i = 0 while(i < 10): - callid = self.sflphone.Call("sip:test@127.0.0.1:5062") + callid = self.sflphone.Call("sip:test@" + REMOTEADDR_lo) time.sleep(0.5) self.sflphone.HangUp(callid) @@ -91,19 +100,21 @@ class SflPhoneTests(): del self.sflphone + # SCENARIO 1 Test 2 def test_ip2ip_send_peer_hungup(self): """Make a call to a server (sipp) on port 5062""" i = 0 - while(i < 1): + while(i < 10): - callid = self.sflphone.Call("sip:test@127.0.0.1:5062") + callid = self.sflphone.Call("sip:test@" + REMOTEADDR_lo) time.sleep(1.0) i = i+1 del self.sflphone - + + # SCENARIO 1 Test 3 def test_ip2ip_recv_hangup(self): """Wait for calls, answer then hangup""" @@ -114,6 +125,7 @@ class SflPhoneTests(): self.sflphone.start() + # SCENARIO 1 Test 4 def test_ip2ip_recv_peer_hungup(self): """Wait for calls, answer, peer hangup""" # Add callback for this test @@ -123,30 +135,32 @@ class SflPhoneTests(): self.sflphone.start() + # SCENARIO 2 Test 1 def test_account_send_hangup(self): """Send new account call, hangup once peer answered""" i = 0 - while(i < 1): + while(i < 10): - callid = self.sflphone.Call("27182") - time.sleep(1.0) + callid = self.sflphone.Call(PHONE1) + time.sleep(0.2) self.sflphone.HangUp(callid) - time.sleep(1.0) + time.sleep(0.2) i = i+1 # del self.sflphone + # SCENARIO 2 Test 2 def test_account_send_peer_hungup(self): """Send new account call, hangup once peer answered""" i = 0 while(i < 10): - callid = self.sflphone.Call("27182") + callid = self.sflphone.Call(PHONE1) time.sleep(1.0) i = i+1 @@ -154,6 +168,7 @@ class SflPhoneTests(): del self.sflphone + # SCENARIO 2 Test 3 def test_account_recv_hangup(self): """Register an account and wait for incoming calls""" @@ -164,6 +179,7 @@ class SflPhoneTests(): self.sflphone.start() + # SCENARIO 2 Test 4 def test_account_recv_peer_hungup(self): """Register an account and wait for incoming calls""" @@ -174,12 +190,13 @@ class SflPhoneTests(): self.sflphone.start() + # SCENARIO 3 Test 1 def test_ip2ip_send_hold_offhold(self): """Send new call, hold this call, offhold, hangup""" i = 0 while(i < 10): - callid = self.sflphone.Call("sip:test@127.0.0.1:5062") + callid = self.sflphone.Call("sip:test@" + REMOTEADDR_lo) time.sleep(0.5) self.sflphone.Hold(callid) @@ -196,16 +213,17 @@ class SflPhoneTests(): del self.sflphone + # SCENARIO 4 Test 1 def test_account_send_transfer(self): """Send new calls, transfer it to a new instance""" i = 0 while(i < 1): - callid = self.sflphone.Call("27182") + callid = self.sflphone.Call(PHONE1) time.sleep(1.0) - self.sflphone.Transfer(callid,"14142") + self.sflphone.Transfer(callid,PHONE3) # self.sflphone.HangUp(callid) # time.sleep(1.0) @@ -223,6 +241,10 @@ testsuite = SflPhoneTests(sflphone) sflphone.setFirstRegisteredAccount(); +# ============================ Test Suite ============================ + + + # SCENARIO 1: IP2IP Normal flow calls # Test 1: - Send an IP2IP call @@ -262,13 +284,15 @@ sflphone.setFirstRegisteredAccount(); # testsuite.test_account_recv_peer_hungup() + # SCENARIO 3: IP2IP Call, HOLD/OFFHOLD # Test 1: - Send an IP2IP call # - Put this call on HOLD # - Off HOLD this call # - Hangup -# testsuite.test_ip2ip_send_hold_offhold() +testsuite.test_ip2ip_send_hold_offhold() + # SCENARIO 4: IP2IP Call, HOLD/OFFHOLD @@ -276,4 +300,4 @@ sflphone.setFirstRegisteredAccount(); # Test 1: - Send an IP2IP call # - Transfer this call to another sipp instance # - Hangup -testsuite.test_account_send_transfer() +# testsuite.test_account_send_transfer()