diff --git a/sflphone-client-gnome/src/codeclist.c b/sflphone-client-gnome/src/codeclist.c index 8887452247081200ed34155ca701900b38e6e205..88136547d4430a69c324425b91b2968826e1a768 100644 --- a/sflphone-client-gnome/src/codeclist.c +++ b/sflphone-client-gnome/src/codeclist.c @@ -290,8 +290,6 @@ void codec_list_update_to_daemon (account_t *acc) { int c = 0; unsigned int i = 0; - g_print ("List of active codecs :\n"); - for(i = 0; i < length; i++) { codec_t* currentCodec = codec_list_get_nth (i, acc->codecs); @@ -301,7 +299,6 @@ void codec_list_update_to_daemon (account_t *acc) { // Save only if active if(currentCodec->is_active) { - g_print ("Codec %s\n", currentCodec->name); // Reallocate memory each time more than one active codec is found if(c!=0) codecList = (void*)realloc(codecList, (c+1)*sizeof(void*)); @@ -311,7 +308,6 @@ void codec_list_update_to_daemon (account_t *acc) { // Put payload string in char array sprintf(payload, "%d", currentCodec->_payload); strcpy((char*)*(codecList+c), payload); - g_print(" %s", *(codecList+c)); c++; } } diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c index 1042bf0c13682a5aef2eee6a5d1a4bfc8c174bab..26b35661b5ae22367fe6d355df1360cbd3d79cf4 100644 --- a/sflphone-client-gnome/src/uimanager.c +++ b/sflphone-client-gnome/src/uimanager.c @@ -115,6 +115,7 @@ update_actions() gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), FALSE); gtk_widget_set_sensitive(GTK_WIDGET (offHoldToolbar), FALSE); gtk_action_set_sensitive(GTK_ACTION (recordAction), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET (recordWidget), FALSE); gtk_action_set_sensitive(GTK_ACTION (copyAction), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(contactButton), FALSE); gtk_widget_set_tooltip_text(GTK_WIDGET (contactButton), @@ -145,9 +146,9 @@ update_actions() } } - // g_signal_handler_block (GTK_OBJECT (transferToolbar), transfertButtonConnId); - // gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (transferToolbar), FALSE); - // g_signal_handler_unblock ( GTK_OBJECT (transferToolbar), transfertButtonConnId); + // g_signal_handler_block (GTK_OBJECT (recordWidget), recordButtonConnId); + // gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (recordWidget), FALSE); + // g_signal_handler_unblock ( GTK_OBJECT (recordWidget), recordButtonConnId); callable_obj_t * selectedCall = calltab_get_selected_call(active_calltree); conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree); @@ -211,9 +212,7 @@ update_actions() 1); gtk_widget_set_sensitive(GTK_WIDGET (holdMenu), TRUE); gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), TRUE); - //gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (holdMenu), gtk_image_new_from_stock (GTK_STOCK_ONHOLD, GTK_ICON_SIZE_MENU)); gtk_widget_set_sensitive(GTK_WIDGET (transferToolbar), TRUE); - //gtk_action_set_sensitive( GTK_ACTION(newCallMenu),TRUE); gtk_action_set_sensitive(GTK_ACTION (recordAction), TRUE); gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); @@ -225,6 +224,7 @@ update_actions() gtk_toggle_tool_button_set_active( GTK_TOGGLE_TOOL_BUTTON (transferToolbar), FALSE); gtk_signal_handler_unblock (transferToolbar, transfertButtonConnId); + break; case CALL_STATE_BUSY: case CALL_STATE_FAILURE: @@ -546,7 +546,14 @@ call_pick_up(void * foo UNUSED) static void call_hang_up(void) { - sflphone_hang_up(); + /* + * [#3020] Restore the record toggle button + * We set it to FALSE, as when we hang up a call, the recording is stopped. + */ + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (recordWidget), FALSE); + + sflphone_hang_up(); + } static void diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index 7a1664ec90a38cb9d78c41d2e96ee9a22a2ef787..3f754c8df169c1bbb9fe49e3b79bab666e71c4fc 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -357,12 +357,17 @@ PulseLayer::stopStream (void) { _info("Audio: Stop audio stream"); + + pa_threaded_mainloop_lock (m); + if(playback) pa_stream_flush (playback->pulseStream(), NULL, NULL); if(record) pa_stream_flush (record->pulseStream(), NULL, NULL); + pa_threaded_mainloop_unlock (m); + disconnectAudioStream(); } diff --git a/sflphone-common/src/audio/sound/Makefile.am b/sflphone-common/src/audio/sound/Makefile.am index 37d7ddc61eb82225f25c86da9c270da8da0dc208..10e9960b7a14c29d2c66d7fb1447f2e18e2bdc1f 100644 --- a/sflphone-common/src/audio/sound/Makefile.am +++ b/sflphone-common/src/audio/sound/Makefile.am @@ -5,14 +5,12 @@ noinst_LTLIBRARIES = libsound.la libsound_la_SOURCES = \ audiofile.cpp \ tone.cpp \ - tonegenerator.cpp \ tonelist.cpp \ dtmf.cpp \ dtmfgenerator.cpp noinst_HEADERS = \ audiofile.h \ - tonegenerator.h \ tone.h \ tonelist.h \ dtmfgenerator.h \ diff --git a/sflphone-common/src/audio/sound/tone.cpp b/sflphone-common/src/audio/sound/tone.cpp index d8849cbf3235ffe1db8b1c0b9daa64f41238b55e..7f60f1ecca749103c8e42fe94f92231f9675677d 100644 --- a/sflphone-common/src/audio/sound/tone.cpp +++ b/sflphone-common/src/audio/sound/tone.cpp @@ -28,8 +28,12 @@ #include <cstdlib> #include <strings.h> -Tone::Tone (const std::string& definition, unsigned int sampleRate) : AudioLoop(), _sampleRate (sampleRate) +#define TABLE_LENGTH 4096 +double TWOPI = 2 * M_PI; + +Tone::Tone (const std::string& definition, unsigned int sampleRate) : AudioLoop(), _sampleRate (sampleRate), _xhigher(0.0), _xlower(0.0) { + fillWavetable(); genBuffer (definition); // allocate memory with definition parameter } @@ -101,6 +105,7 @@ Tone::genBuffer (const std::string& definition) } // Generate SAMPLING_RATE samples of sinus, buffer is the result + _debug("genSin(%d, %d)", freq1, freq2); genSin (bufferPos, freq1, freq2, count); // To concatenate the different buffers for each section. @@ -124,20 +129,70 @@ Tone::genBuffer (const std::string& definition) bufferPos=0; } +void +Tone::fillWavetable() +{ + double tableSize = (double)TABLE_LENGTH; + + for(int i = 0; i < TABLE_LENGTH; i++) { + _wavetable[i] = sin( ((double)i / (tableSize - 1.0)) * TWOPI ); + } +} + +double +Tone::interpolate(double x) +{ + int xi_0, xi_1; + double yi_0, yi_1, A, B; + + xi_0 = (int)x; + xi_1 = xi_0+1; + + yi_0 =_wavetable[xi_0]; + yi_1 = _wavetable[xi_1]; + + A = (x - xi_0); + B = 1.0 - A; + + return A*yi_0 + B*yi_1; +} + void Tone::genSin (SFLDataFormat* buffer, int frequency1, int frequency2, int nb) { + _xhigher = 0.0; + _xlower = 0.0; - double pi2 = 6.28318520; - double var1 = pi2 * (double) frequency1 / (double) _sampleRate; - double var2 = pi2 * (double) frequency2 / (double) _sampleRate; + double sr = (double)_sampleRate; + double tableSize = (double)TABLE_LENGTH; - // softer - double amp = (double) SFLDataAmplitude; + double N_h = sr / (double) (frequency1); + double N_l = sr / (double) (frequency2); - for (int t = 0; t < nb; t++) { - buffer[t] = (SFLDataFormat) (amp * ( (sin (var1 * t) + sin (var2 * t)))); - } + double dx_h = tableSize / N_h; + double dx_l = tableSize / N_l; + + double x_h = _xhigher; + double x_l = _xlower; + + double amp = (double)SFLDataAmplitude; + + for (int t = 0; t < nb; t ++) { + buffer[t] = (int16)(amp*(interpolate(x_h) + interpolate(x_l))); + x_h += dx_h; + x_l += dx_l; + + if(x_h > tableSize) { + x_h -= tableSize; + } + + if(x_l > tableSize) { + x_l -= tableSize; + } + } + + _xhigher = x_h; + _xlower = x_l; } diff --git a/sflphone-common/src/audio/sound/tone.h b/sflphone-common/src/audio/sound/tone.h index a725059dcf20a6d5ca509ffa8d0bc07c4187de28..94be60a0b8ecbe4a9b23465dfeec310231d2eedc 100644 --- a/sflphone-common/src/audio/sound/tone.h +++ b/sflphone-common/src/audio/sound/tone.h @@ -28,6 +28,8 @@ #define TONE_NBTONE 4 #define TONE_NBCOUNTRY 7 +#define TABLE_LENGTH 4096 + /** * @file tone.h * @brief Tone sample (dial, busy, ring, congestion) @@ -65,6 +67,17 @@ public: */ void genSin(SFLDataFormat* buffer, int frequency1, int frequency2, int nb); + /** + * + */ + void fillWavetable(void); + + /** + * + */ + double interpolate(double x); + + private: /** @@ -75,6 +88,11 @@ private: /** Sample rate */ unsigned int _sampleRate; + + double _wavetable[TABLE_LENGTH]; + + double _xhigher; + double _xlower; }; #endif // __TONE_H__ diff --git a/sflphone-common/src/audio/sound/tonegenerator.cpp b/sflphone-common/src/audio/sound/tonegenerator.cpp deleted file mode 100644 index dcdbb6be078724e8792321fb8cebfb829476c016..0000000000000000000000000000000000000000 --- a/sflphone-common/src/audio/sound/tonegenerator.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (C) 2004-2005 Savoir-Faire Linux inc. - * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <fstream> -#include <math.h> -#include <stdlib.h> - -#include "tonegenerator.h" -#include "global.h" - -int AMPLITUDE = 32767; - -/////////////////////////////////////////////////////////////////////////////// -// ToneGenerator implementation -/////////////////////////////////////////////////////////////////////////////// - -ToneGenerator::ToneGenerator (unsigned int sampleRate) : sample (NULL), freq1(), freq2(), time(), totalbytes(), _sampleRate (sampleRate) -{ -} - -ToneGenerator::~ToneGenerator (void) -{ -} - -/** - * Calculate superposition of 2 sinus - * - */ -void -ToneGenerator::generateSin (int lowerfreq, int higherfreq, int16* ptr, int len) const -{ - double var1, var2; - - var1 = (double) 2 * (double) M_PI * (double) higherfreq / (double) _sampleRate; - var2 = (double) 2 * (double) M_PI * (double) lowerfreq / (double) _sampleRate; - - double amp = (double) (AMPLITUDE >> 2); - - for (int t = 0; t < len; t++) { - ptr[t] = (int16) (amp * ( (sin (var1 * t) + sin (var2 * t)))); - } -} - diff --git a/sflphone-common/src/audio/sound/tonegenerator.h b/sflphone-common/src/audio/sound/tonegenerator.h deleted file mode 100644 index ce1ad56e618ebce339448607027f7b694e686ba1..0000000000000000000000000000000000000000 --- a/sflphone-common/src/audio/sound/tonegenerator.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2004-2006 Savoir-Faire Linux inc. - * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __TONE_GENERATOR_H__ -#define __TONE_GENERATOR_H__ - -#include <string> -#include <cc++/thread.h> - -#include "global.h" - -/** - * @file tonegenerator.h - * @brief Sine generator to create tone with string definition - */ - -class ToneGenerator { - public: - /** - * Constructor - * @param sampleRate The sample rate of the generated samples - */ - ToneGenerator (unsigned int sampleRate); - - /** - * Destructor - */ - ~ToneGenerator (void); - - /** - * Calculate sinus with superposition of 2 frequencies - * @param lowerfreq Lower frequency - * @param higherfreq Higher frequency - * @param ptr For result buffer - * @param len The length of the data to be generated - */ - void generateSin (int, int, int16 *, int len) const; - - - /////////////////////////// - // Public members variable - ////////////////////////// - int16 *sample; - int freq1, freq2; - int time; - int totalbytes; - - private: - // Copy Constructor - ToneGenerator(const ToneGenerator& rh); - - // Assignment Operator - ToneGenerator& operator=( const ToneGenerator& rh); - - /* - * Initialisation of the supported tones according to the countries. - */ - void initTone (void); - - int16 _buf[SIZEBUF]; - int _sampleRate; -}; - -#endif // __TONE_GENRATOR_H__ diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index af885c9964af77e6a9000d2fc603fe00e906cb21..34b6ab9700cd2cf026aa629b08974b9382fb7bcc 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 a7058bbb7bed2735fae67677c1a973fa6ff74cc6..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,10 +931,12 @@ SIPVoIPLink::peerHungup (const CallID& id) pjsip_tx_data *tdata = NULL; SIPCall* call; + _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; } @@ -947,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(); } @@ -1107,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; } @@ -1126,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)); @@ -1135,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); @@ -1152,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; } @@ -1169,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; } @@ -1490,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; } @@ -1498,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 @@ -1518,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(); @@ -3313,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) { @@ -3330,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); @@ -3476,7 +3505,7 @@ mod_on_rx_request (pjsip_rx_data *rdata) // No need to go any further on incoming ACK if (rdata->msg_info.msg->line.req.method.id == PJSIP_ACK_METHOD) { _info("UserAgent: received an ACK"); - return true; + return true; } // Handle the incoming call invite in this function @@ -3815,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; @@ -4002,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. "); } @@ -4014,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; @@ -4021,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)); @@ -4041,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_uac_send_hangup.xml b/sippxml/account_uac_send_hangup.xml index b07251cb2193abf14a4d70dd5351b790976c5dbf..8971769c591c52bbfd1c89cc1e96e46c71fe3860 100644 --- a/sippxml/account_uac_send_hangup.xml +++ b/sippxml/account_uac_send_hangup.xml @@ -19,47 +19,6 @@ <scenario name="accountcall_client"> - <send retrans="500"> - <![CDATA[ - - REGISTER sip:[remote_ip] SIP/2.0 - Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] - Max-Forward: 70 - From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number] - To: <sip:27182@[remote_ip]:[remote_port]> - Call-ID: REG///[call_id] - CSeq: 1 REGISTER - Contact: <sip:27182@[remote_ip]:[remote_port]> - Content-Length: 0 - Expires: 300 - - ]]> - </send> - - <recv response="401" auth="true"> - </recv> - - <send retrans="500"> - <![CDATA[ - - REGISTER sip:[remote_ip] SIP/2.0 - Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] - Max-Forwards: 70 - From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number] - To: <sip:27182@[remote_ip]:[remote_port]> - Call-ID: REG///[call_id] - CSeq: 2 REGISTER - Contact: <sip:27182@[remote_ip]:[remote_port]> - Content-Length: 0 - Expires: 300 - [authentication username=27182 password=1234] - - ]]> - </send> - - <recv response="200"> - </recv> - <pause milliseconds="200"/> <send retrans="500"> diff --git a/sippxml/account_uac_send_peer_hungup.xml b/sippxml/account_uac_send_peer_hungup.xml new file mode 100644 index 0000000000000000000000000000000000000000..716da9dd6de55534e79d29e2efa54ad6248ccc5c --- /dev/null +++ b/sippxml/account_uac_send_peer_hungup.xml @@ -0,0 +1,155 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE scenario SYSTEM "sipp.dtd"> + +<!-- This program is free software; you can redistribute it and/or --> +<!-- modify it under the terms of the GNU General Public License as --> +<!-- published by the Free Software Foundation; either version 2 of the --> +<!-- License, or (at your option) any later version. --> +<!-- --> +<!-- This program is distributed in the hope that it will be useful, --> +<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> +<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> +<!-- GNU General Public License for more details. --> +<!-- --> +<!-- You should have received a copy of the GNU General Public License --> +<!-- along with this program; if not, write to the --> +<!-- Free Software Foundation, Inc., --> +<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> + + +<scenario name="accountcall_client"> + + <pause milliseconds="200"/> + + <send retrans="500"> + <![CDATA[ + + INVITE sip:2000@[remote_ip] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] + From: <sip:27182@[remote_ip]>;tag=[call_number] + To: <sip:2000@[remote_ip]> + Call-ID: [call_id] + CSeq: 3 INVITE + Contact: sip:27182@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Functional Test + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv response="401" auth="true"> + </recv> + + <pause milliseconds="200"/> + + <send> + <![CDATA[ + + ACK sip:27182@[remote_ip] SIP/2.0 + Max-Forwards: 70 + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] + From: <sip:27182@[remote_ip]>;tag=[call_number] + To: <sip:2000@[remote_ip]> + Call-ID: [call_id] + CSeq: 4 ACK + Subject: Functional Test + Content-Length: 0 + + ]]> + </send> + + <send retrans="500"> + <![CDATA[ + + INVITE sip:2000@[remote_ip] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] + From: <sip:27182@:[remote_ip]>;tag=[call_number] + To: <sip:2000@[remote_ip]> + Call-ID: [call_id] + CSeq: 5 INVITE + Contact: sip:27182@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Functional Test + Content-Type: application/sdp + Content-Length: [len] + [authentication username=27182 password=1234] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv response="100"> + </recv> + + <recv response="180"> + </recv> + + + <recv response="200"> + </recv> + + <send> + <![CDATA[ + + ACK sip:2000@192.168.50.79 SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] + From: <sip:27182@[remote_ip]>;tag=[call_number] + To: <sip:2000@[remote_ip]> + Call-ID: [call_id] + CSeq: 5 ACK + Contact: sip:27182@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Functional Test + Content-Length: 0 + + ]]> + </send> + + <recv request="BYE"> + </recv> + + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <pause milliseconds="1000"/> + +</scenario> diff --git a/sippxml/account_uas_receive_transfer.xml b/sippxml/account_uas_receive_transfer.xml new file mode 100644 index 0000000000000000000000000000000000000000..80a875fbf707be6c6f3c03c2484be68c7c255ce4 --- /dev/null +++ b/sippxml/account_uas_receive_transfer.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE scenario SYSTEM "sipp.dtd"> + +<!-- This program is free software; you can redistribute it and/or --> +<!-- modify it under the terms of the GNU General Public License as --> +<!-- published by the Free Software Foundation; either version 2 of the --> +<!-- License, or (at your option) any later version. --> +<!-- --> +<!-- This program is distributed in the hope that it will be useful, --> +<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> +<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> +<!-- GNU General Public License for more details. --> +<!-- --> +<!-- You should have received a copy of the GNU General Public License --> +<!-- along with this program; if not, write to the --> +<!-- Free Software Foundation, Inc., --> +<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> + + +<scenario name="accountcall_client"> + + <recv request="INVITE"> + </recv> + + <send> + <![CDATA[ + + SIP/2.0 180 Ringing + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Length: 0 + + ]]> + </send> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK"> + </recv> + + <recv request="INVITE"> + </recv> + + <pause milliseconds="200"> + </recv> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK"> + </recv> + + +</scenario> diff --git a/sippxml/account_uas_recv_hangup.xml b/sippxml/account_uas_recv_hangup.xml new file mode 100644 index 0000000000000000000000000000000000000000..94bea4704232386a5518de7995c3138bc3007850 --- /dev/null +++ b/sippxml/account_uas_recv_hangup.xml @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE scenario SYSTEM "sipp.dtd"> + +<!-- This program is free software; you can redistribute it and/or --> +<!-- modify it under the terms of the GNU General Public License as --> +<!-- published by the Free Software Foundation; either version 2 of the --> +<!-- License, or (at your option) any later version. --> +<!-- --> +<!-- This program is distributed in the hope that it will be useful, --> +<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> +<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> +<!-- GNU General Public License for more details. --> +<!-- --> +<!-- You should have received a copy of the GNU General Public License --> +<!-- along with this program; if not, write to the --> +<!-- Free Software Foundation, Inc., --> +<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> + + +<scenario name="accountcall_client"> + + <recv request="INVITE"> + </recv> + + <send> + <![CDATA[ + + SIP/2.0 180 Ringing + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Length: 0 + + ]]> + </send> + + <pause milliseconds="200"/> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK"> + </recv> + + <recv request="INVITE"> + </recv> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK"> + </recv> + + <send retrans="500"> + <![CDATA[ + + BYE sip:2000@192.168.50.79 SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] + From: <sip:27182@[local_ip]:[local_port]>;tag=[call_number] + To: <sip:2000@192.168.50.79:[remote_port]> + Call-ID: [call_id] + CSeq: 6 BYE + Contact: sip:27182@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Functional Test + Content-Length: 0 + + ]]> + </send> + + <recv response="200"> + </recv> + +</scenario> diff --git a/sippxml/account_uas_recv_peer_hungup.xml b/sippxml/account_uas_recv_peer_hungup.xml index cfa9acb151e23f8234f3daf4a35ae21eca05c8dd..c91230c7fc32e2c853d934ec5dbc3f499060d958 100644 --- a/sippxml/account_uas_recv_peer_hungup.xml +++ b/sippxml/account_uas_recv_peer_hungup.xml @@ -19,54 +19,9 @@ <scenario name="accountcall_client"> - <send retrans="500"> - <![CDATA[ - - REGISTER sip:[remote_ip] SIP/2.0 - Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] - Max-Forward: 70 - From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number] - To: <sip:27182@[remote_ip]:[remote_port]> - Call-ID: REG///[call_id] - CSeq: 1 REGISTER - Contact: <sip:27182@[remote_ip]:[remote_port]> - Content-Length: 0 - Expires: 300 - - ]]> - </send> - - <recv response="401" auth="true"> - </recv> - - <send retrans="500"> - <![CDATA[ - - REGISTER sip:[remote_ip] SIP/2.0 - Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] - Max-Forwards: 70 - From: <sip:27182@[remote_ip]:[remote_port]>;tag=[call_number] - To: <sip:27182@[remote_ip]:[remote_port]> - Call-ID: REG///[call_id] - CSeq: 2 REGISTER - Contact: <sip:27182@[remote_ip]:[remote_port]> - Content-Length: 0 - Expires: 300 - [authentication username=27182 password=1234] - - ]]> - </send> - - <recv response="200"> - </recv> - - <recv request="INVITE"> </recv> - <recv response="401" auth="true"> - </recv> - <send> <![CDATA[ @@ -82,7 +37,38 @@ ]]> </send> - <pause milliseconds="200"/> + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK"> + </recv> + + <recv request="INVITE"> + </recv> + + <pause milliseconds="200"> + </recv> <send retrans="500"> <![CDATA[ diff --git a/sippxml/account_uas_recv_transfered.xml b/sippxml/account_uas_recv_transfered.xml new file mode 100644 index 0000000000000000000000000000000000000000..210f5621b4b5a002adcbbd0a1880756c49b33088 --- /dev/null +++ b/sippxml/account_uas_recv_transfered.xml @@ -0,0 +1,132 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE scenario SYSTEM "sipp.dtd"> + +<!-- This program is free software; you can redistribute it and/or --> +<!-- modify it under the terms of the GNU General Public License as --> +<!-- published by the Free Software Foundation; either version 2 of the --> +<!-- License, or (at your option) any later version. --> +<!-- --> +<!-- This program is distributed in the hope that it will be useful, --> +<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> +<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> +<!-- GNU General Public License for more details. --> +<!-- --> +<!-- You should have received a copy of the GNU General Public License --> +<!-- along with this program; if not, write to the --> +<!-- Free Software Foundation, Inc., --> +<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> + + +<scenario name="accountcall_client"> + + <recv request="INVITE"> + </recv> + + <send> + <![CDATA[ + + SIP/2.0 180 Ringing + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Length: 0 + + ]]> + </send> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK"> + </recv> + + <recv request="INVITE"> + </recv> + + <pause milliseconds="200"> + </recv> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK"> + </recv> + + + <!-- + + <recv request="BYE"> + </recv> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + --> + +</scenario> diff --git a/sippxml/account_uas_register.xml b/sippxml/account_uas_register.xml new file mode 100644 index 0000000000000000000000000000000000000000..e4ebb812276270bd5a3334ecd61a4b4c2825900c --- /dev/null +++ b/sippxml/account_uas_register.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE scenario SYSTEM "sipp.dtd"> + +<!-- This program is free software; you can redistribute it and/or --> +<!-- modify it under the terms of the GNU General Public License as --> +<!-- published by the Free Software Foundation; either version 2 of the --> +<!-- License, or (at your option) any later version. --> +<!-- --> +<!-- This program is distributed in the hope that it will be useful, --> +<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> +<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> +<!-- GNU General Public License for more details. --> +<!-- --> +<!-- You should have received a copy of the GNU General Public License --> +<!-- along with this program; if not, write to the --> +<!-- Free Software Foundation, Inc., --> +<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> + + +<scenario name="accountcall_client"> + + <send retrans="500"> + <![CDATA[ + + REGISTER sip:[remote_ip] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] + Max-Forwards: 70 + From: <sip:27182@[remote_ip]>;tag=[call_number] + To: <sip:27182@[remote_ip]> + Call-ID: REG///[call_id] + CSeq: 1 REGISTER + Contact: <sip:27182@[local_ip]:[local_port]> + Content-Length: 0 + Expires: 300 + + ]]> + </send> + + <recv response="401" auth="true"> + </recv> + + <send retrans="500"> + <![CDATA[ + + REGISTER sip:[remote_ip] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] + Max-Forwards: 70 + From: <sip:27182@[remote_ip]>;tag=[call_number] + To: <sip:27182@[remote_ip]> + Call-ID: REG///[call_id] + CSeq: 2 REGISTER + Contact: <sip:27182@[local_ip]:[local_port]> + Content-Length: 0 + Expires: 300 + [authentication username=27182 password=1234] + + ]]> + </send> + + <recv response="200"> + </recv> + +</scenario> diff --git a/sippxml/ip2ip_uac_send_hangup.xml b/sippxml/ip2ip_uac_send_hangup.xml index b38cf17361a568261f5441bd8b651639e759c4e2..49cc63fca06e2cd1f2a40f1f65929de436da7d6b 100644 --- a/sippxml/ip2ip_uac_send_hangup.xml +++ b/sippxml/ip2ip_uac_send_hangup.xml @@ -53,15 +53,18 @@ <recv response="200"> + <action> + <ereg regexp="tag=.*" search_in="hdr" header="To:" check_it="true" assign_to="1" /> + </action> </recv> <send> <![CDATA[ - ACK sip:192.168.50.79 SIP/2.0 + ACK sip:[remote_ip] SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] From: <sip:[local_ip]:[local_port]>;tag=[call_number] - To: <sip:192.168.50.79:[remote_port]> + To: <sip:[remote_ip]:[remote_port]>;tag=[$1] Call-ID: [call_id] CSeq: 2 ACK Contact: sip:[local_ip]:[local_port] @@ -78,7 +81,7 @@ BYE sip:192.168.50.79 SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] From: <sip:[local_ip]:[local_port]>;tag=[call_number] - To: <sip:192.168.50.79:[remote_port]> + To: <sip:[remote_ip]:[remote_port]>;tag=[$1] Call-ID: [call_id] CSeq: 3 BYE Contact: sip:[local_ip]:[local_port] diff --git a/sippxml/ip2ip_uac_send_peer_hungup.xml b/sippxml/ip2ip_uac_send_peer_hungup.xml index 3ffd02a3723285a72ce25cd4b026585b96e4dcef..4e811e38262f10680417f9415e960e33585b26ee 100644 --- a/sippxml/ip2ip_uac_send_peer_hungup.xml +++ b/sippxml/ip2ip_uac_send_peer_hungup.xml @@ -60,7 +60,7 @@ ACK sip:192.168.50.79 SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] From: <sip:[local_ip]:[local_port]>;tag=[call_number] - To: <sip:192.168.50.79:[remote_port]> + To: <sip:[remote_ip]:[remote_port]> Call-ID: [call_id] CSeq: 2 ACK Contact: sip:[local_ip]:[local_port] diff --git a/sippxml/ip2ip_uas_recv_hangup.xml b/sippxml/ip2ip_uas_recv_hangup.xml index 571dda97ccc73d9200591f795d2c3ed08458c91e..4e86b47480bd761e3d4ccdf071dcbe5738f5c5f9 100644 --- a/sippxml/ip2ip_uas_recv_hangup.xml +++ b/sippxml/ip2ip_uas_recv_hangup.xml @@ -16,7 +16,7 @@ [last_To:];tag=[call_number] [last_Call-ID:] [last_CSeq:] - Contact: <sip:127.0.1.1:5062;transport=[transport]> + Contact: <sip:[local_ip]:[local_port];transport=[transport]> Content-Length: 0 ]]> @@ -46,22 +46,27 @@ ]]> </send> + <!-- tag from From: header is required to build the To: header in + -- Bye request. --> - <recv request="ACK"> + <recv request="ACK"> + <action> + <ereg regexp="tag=.*" search_in="hdr" header="From:" check_it="true" assign_to="1" /> + </action> </recv> <pause milliseconds="500"/> - + <send retrans="500"> <![CDATA[ - BYE sip:127.0.0.1:5060;transport=[transport] SIP/2.0 - [last_Via:] - [last_From:] - [last_To:] + BYE sip:[service] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch] + From: <sip:[local_ip]:[local_port]>;tag=[call_number] + To: <sip:[remote_ip]:[remote_port]>;[$1] [last_Call-ID:] CSeq: [cseq] BYE - Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Contact: <sip:test@[local_ip]:[local_port]> Max-Forwards: 70 Subject: Functional Test Content-Length: 0 diff --git a/sippxml/ip2ip_uas_recv_hold_offhold.xml b/sippxml/ip2ip_uas_recv_hold_offhold.xml new file mode 100644 index 0000000000000000000000000000000000000000..568a97a9e62ddf5bd4a323b920f425f300104273 --- /dev/null +++ b/sippxml/ip2ip_uas_recv_hold_offhold.xml @@ -0,0 +1,187 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE scenario SYSTEM "sipp.dtd"> + + +<scenario name="UAS HOLD/OFFHOLD"> + + <!-- Receive a new call --> + + <recv request="INVITE" crlf="true"> + <action> + <ereg regexp="sendrecv" search_in="body" check_it="true" assign_to="1"/> + <log message="Media is [$1]"/> + </action> + </recv> + + <send> + <![CDATA[ + + SIP/2.0 180 Ringing + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Length: 0 + + ]]> + </send> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> +</send> + + <recv request="ACK" optional="true" rtd="true" crlf="true"> + </recv> + + <!-- This call is now on HOLD: sendonly tell to PBX to send music on hold--> + + <recv request="INVITE" crlf="true"> + <action> + <ereg regexp="sendonly" search_in="body" check_it="true" assign_to="2"/> + <log message="Media is [$2]"/> + </action> + </recv> + + <send> + <![CDATA[ + + SIP/2.0 180 Ringing + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Length: 0 + + ]]> + </send> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK" optional="true" rtd="true" crlf="true"> + </recv> + + <!-- OFFHOLD this call --> + + <recv request="INVITE" crlf="true"> + <action> + <ereg regexp="sendrecv" search_in="body" check_it="true" assign_to="3"/> + <log message="Media is [$3]"/> + </action> + </recv> + + + <send> + <![CDATA[ + + SIP/2.0 180 Ringing + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Length: 0 + + ]]> + </send> + + <send retrans="500"> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:];tag=[call_number] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv request="ACK" optional="true" rtd="true" crlf="true"> + </recv> + + <!-- Hangup this call --> + + <recv request="BYE"> + </recv> + + <send> + <![CDATA[ + + SIP/2.0 200 OK + [last_Via:] + [last_From:] + [last_To:] + [last_Call-ID:] + [last_CSeq:] + Contact: <sip:[local_ip]:[local_port];transport=[transport]> + Content-Length: 0 + + ]]> + </send> + + <pause milliseconds="4000"/> + + + <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/> + + <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/> + +</scenario> diff --git a/sippxml/ip2ip_uas_recv_peer_hungup.xml b/sippxml/ip2ip_uas_recv_peer_hungup.xml index 4b615f216cf96daf1ecfb35cfcf78f2d2f1daade..9f2721f5dc71742819d4d39003fc1279b0cd18db 100644 --- a/sippxml/ip2ip_uas_recv_peer_hungup.xml +++ b/sippxml/ip2ip_uas_recv_peer_hungup.xml @@ -46,10 +46,7 @@ ]]> </send> - <recv request="ACK" - optional="true" - rtd="true" - crlf="true"> + <recv request="ACK" optional="true" rtd="true" crlf="true"> </recv> <recv request="BYE"> diff --git a/sippxml/tempscript.sh b/sippxml/tempscript.sh new file mode 100644 index 0000000000000000000000000000000000000000..090a058ed8491511f8ef33551e260d56237be826 --- /dev/null +++ b/sippxml/tempscript.sh @@ -0,0 +1,5 @@ +SERVERPORT=5064 + +sipp -sf account_uas_register_bis.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 -m 1 + +sipp -sf account_uas_receive_transfer.xml 192.168.50.79 -i 192.168.50.182 -p ${SERVERPORT} -l 1 \ No newline at end of file diff --git a/sippxml/testsuiteuac.sh b/sippxml/testsuiteuac.sh index c63983c1e0319464254c924542d06b7472860126..1ed0db416504d9abc8288a3a56e8b848d0e46263 100644 --- a/sippxml/testsuiteuac.sh +++ b/sippxml/testsuiteuac.sh @@ -1,16 +1,22 @@ #!/bin/bash -# sleep 5; -SERVERPORT=5062 -function test_ip2ip_send_hangup { +LOCALPORT=5062 +LOCALIP_lo=127.0.0.1 +LOCALIP_eth0=192.168.50.182 - # start sipp server to receive calls from sflphone - sipp -sf ip2ip_uas_recv_peer_hungup.xml -p ${SERVERPORT} +REMOTEADDR_lo=127.0.0.1:5060 +REMOTEADDR_ast=192.168.50.79 + +# SCENARIO 1 Test 1 +function test_ip2ip_send_hangup { # 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; @@ -21,14 +27,15 @@ function test_ip2ip_send_hangup { # bashtrap } +# 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 -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; @@ -40,6 +47,7 @@ function test_ip2ip_send_peer_hungup { } +# SCENARIO 1 Test 3 function test_ip2ip_recv_hangup { # start sflphoned @@ -54,12 +62,14 @@ 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 } + +# SCENARIO 1 Test 4 function test_ip2ip_recv_peer_hungup { # start sflphoned @@ -74,12 +84,13 @@ 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 } +# SCENARIO 2 Test 1 function test_account_send_hangup { # start sflphoned @@ -93,13 +104,64 @@ function test_account_send_hangup { # wait some time to make sure client is bound # sleep 1; + # process only one registration + 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 ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 + + # kill every one + # bashtrap +} + +# SCENARIO 2 Test 2 +function test_account_send_peer_hungup { + + # start sflphoned + # /usr/lib/sflphone/sflphoned& + + # wait some time to make sure sflphoned is started + # sleep 1; + + # python ../tools/pysflphone/pysflphone_testdbus.py & + + # wait some time to make sure client is bound + # sleep 1; + + # process only one registration + 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_hangup.xml ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 # kill every one # bashtrap } +# SCENARIO 2 Test 3 +function test_account_recv_hangup { + + # start sflphoned + # /usr/lib/sflphone/sflphoned& + + # wait some time to make sure sflphoned is started + # sleep 1; + + # python ../tools/pysflphone/pysflphone_testdbus.py & + + # wait some time to make sure client is bound + # sleep 1; + + # process only one registration + 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 ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 -m 10 + # kill every one + # bashtrap +} + +# SCENARIO 2 Test 4 function test_account_recv_peer_hungup { # start sflphoned @@ -113,13 +175,61 @@ function test_account_recv_peer_hungup { # wait some time to make sure client is bound # sleep 1; + # process only one registration + 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 } +# SCENARIO 3 Test 1 +function test_ip2ip_send_hold_offhold { + + # start sflphoned + # /usr/lib/sflphone/sflphoned& + + # wait some time to make sure sflphoned is started + # sleep 1; + + # python ../tools/pysflphone/pysflphone_testdbus.py & + + # wait some time to make sure client is bound + # sleep 1; + + # start sipp client and send calls + sipp -sf ip2ip_uas_recv_hold_offhold.xml ${REMOTEADDR_lo} -i ${LOCALIP_lo} -p ${LOCALPORT} + # kill every one + # bashtrap +} + +# SCENARIO 4 Test 1 +function test_account_send_transfer { + + # start sflphoned + # /usr/lib/sflphone/sflphoned& + + # wait some time to make sure sflphoned is started + # sleep 1; + + # python ../tools/pysflphone/pysflphone_testdbus.py & + + # wait some time to make sure client is bound + # sleep 1; + + # process only one registration + 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 ${REMOTEADDR_ast} -i ${LOCALIP_eth0} -p ${LOCALPORT} -l 1 + + # kill every one + # bashtrap +} + + # function called if CTRL-C detected bashtrap() { @@ -130,12 +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 X: Normal flow calls (Account) -test_account_send_hangup -# test_account_recv_peer_hungup \ No newline at end of file + + +# 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 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 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 563b683456ec16685896a661109eba094da578ca..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""" @@ -113,6 +124,8 @@ class SflPhoneTests(): # Start Glib mainloop 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 @@ -121,24 +134,53 @@ class SflPhoneTests(): # Start Glib mainloop self.sflphone.start() + + # SCENARIO 2 Test 1 def test_account_send_hangup(self): """Send new account call, hangup once peer answered""" - print "test account send hangup" + i = 0 while(i < 10): - callid = self.sflphone.Call("27182") - time.sleep(0.5) + callid = self.sflphone.Call(PHONE1) + time.sleep(0.2) self.sflphone.HangUp(callid) - time.sleep(0.5) + 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(PHONE1) + time.sleep(1.0) i = i+1 - print "account hangup done" del self.sflphone - def test_account_recv_call_peer_hungup(self): + + # SCENARIO 2 Test 3 + def test_account_recv_hangup(self): + """Register an account and wait for incoming calls""" + + # Add callback for this test + self.sflphone.onIncomingCall_cb = acceptOnIncomingCallHangup + + # Start Glib mainloop + self.sflphone.start() + + + # SCENARIO 2 Test 4 + def test_account_recv_peer_hungup(self): """Register an account and wait for incoming calls""" # Add callback for this test @@ -147,24 +189,45 @@ class SflPhoneTests(): # Start Glib mainloop self.sflphone.start() - -# def test_account_send_call_peer_hungup(self): -# """Register an account on a remote server and make several calls""" -# -# self.setAccount("Account:1258495784"); -# time.sleep(3) -# -# i = 0 -# while(i < 50): -# -# callid = self.Call("5000") -# time.sleep(0.4) -# -# self.HangUp(callid) -# time.sleep(0.4) -# -# i = i+1 + # 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@" + REMOTEADDR_lo) + time.sleep(0.5) + + self.sflphone.Hold(callid) + time.sleep(0.5) + + self.sflphone.UnHold(callid) + time.sleep(0.5) + + self.sflphone.HangUp(callid) + time.sleep(0.5) + + i = i+1 + + 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(PHONE1) + time.sleep(1.0) + + self.sflphone.Transfer(callid,PHONE3) + # self.sflphone.HangUp(callid) + # time.sleep(1.0) + + i = i+1 @@ -178,23 +241,63 @@ testsuite = SflPhoneTests(sflphone) sflphone.setFirstRegisteredAccount(); +# ============================ Test Suite ============================ + + + # SCENARIO 1: IP2IP Normal flow calls # Test 1: - Send an IP2IP call # - Hangup # testsuite.test_ip2ip_send_hangup() + +# Test 2: - Send an IP2IP call +# - Peer Hangup # testsuite.test_ip2ip_send_peer_hungup() + +# Test 3: - Receive an IP2IP call +# - Hangup # testsuite.test_ip2ip_recv_hangup() + +# Test 4: - Receive an IP2IP call +# - Peer Hangup # testsuite.test_ip2ip_recv_peer_hungup() -# SCENARIO 2: IP2IP Normal flow calls +# SCENARIO 2: ACCOUNT Normal flow calls + +# Test 1: - Send an ACCOUNT call +# - Hangup +# testsuite.test_account_send_hangup() + +# Test 2: - Send an ACCOUNT call +# - Peer Hangup +# testsuite.test_account_send_peer_hungup() + +# Test 3: - Receive an ACCOUNT call +# - Hangup +# testsuite.test_account_recv_hangup() + +# Test 4: - Receive an ACCOUNT call +# - Peer Hangup +# 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() + + -# Test 1: - Create an account on Asterisk -# - Wait for incoming calls -# - Answer -# - Call is hanged up by calle -testsuite.test_account_send_hangup() -# testsuite.test_account_recv_call_peer_hungup() +# SCENARIO 4: IP2IP Call, HOLD/OFFHOLD +# Test 1: - Send an IP2IP call +# - Transfer this call to another sipp instance +# - Hangup +# testsuite.test_account_send_transfer() diff --git a/tools/pysflphone/sflphonectrlsimple.py b/tools/pysflphone/sflphonectrlsimple.py index a073e6ca04372fe09f1b74203a2ce1251ddb5624..a19d4ab0901f4b28fb2081d3f68fc58a5419b2e1 100755 --- a/tools/pysflphone/sflphonectrlsimple.py +++ b/tools/pysflphone/sflphonectrlsimple.py @@ -518,13 +518,13 @@ class SflPhoneCtrlSimple(Thread): self.callmanager.hangUp(callid) - def Transfert(self, callid, to): + def Transfer(self, callid, to): """Transfert a call identified by a CallID""" - if not self.account: - self.setFirstRegisteredAccount() + # if not self.account: + # self.setFirstRegisteredAccount() - if not self.isAccountRegistered(): - raise SflPhoneError("Can't transfert a call without a registered account") + # if not self.isAccountRegistered(): + # raise SflPhoneError("Can't transfert a call without a registered account") if callid is None or callid == "": raise SflPhoneError("Invalid callID") @@ -562,11 +562,11 @@ class SflPhoneCtrlSimple(Thread): def Hold(self, callid): """Hold a call identified by a CallID""" - if not self.account: - self.setFirstRegisteredAccount() + # if not self.account: + # self.setFirstRegisteredAccount() - if not self.isAccountRegistered(): - raise SflPhoneError("Can't hold a call without a registered account") + # if not self.isAccountRegistered(): + # raise SflPhoneError("Can't hold a call without a registered account") if callid is None or callid == "": raise SflPhoneError("Invalid callID") @@ -576,11 +576,11 @@ class SflPhoneCtrlSimple(Thread): def UnHold(self, callid): """Unhold an incoming call identified by a CallID""" - if not self.account: - self.setFirstRegisteredAccount() + # if not self.account: + # self.setFirstRegisteredAccount() - if not self.isAccountRegistered(): - raise SflPhoneError("Can't unhold a call without a registered account") + # if not self.isAccountRegistered(): + # raise SflPhoneError("Can't unhold a call without a registered account") if callid is None or callid == "": raise SflPhoneError("Invalid callID")