diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index 094ac14df50ea841b756d9e825a0d4a36cd1cc8b..bc83dcc6261d7fe3e9eb306a15f93c6c13483ba9 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -401,7 +401,7 @@ void PulseLayer::writeToSpeaker (void) _mainBuffer.getData (out, toGet, 100); pa_stream_write (playback->pulseStream(), out, toGet, NULL, 0, PA_SEEK_RELATIVE); - _urgentRingBuffer.Discard (toGet); + } else { bzero (out, framesPerBuffer * sizeof (SFLDataFormat)); diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index d2fc50d23dd2c00616f027ca4e93f888ee37a9d1..e55b69b34e0b7f4008a1a1166dc8a52dc2fc4059 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1492,7 +1492,7 @@ ManagerImpl::sendDtmf (const CallID& id, char code) AccountID accountid = getAccountFromCall (id); if (accountid == AccountNULL) { - //_debug("Send DTMF: call doesn't exists\n"); + _debug("Send DTMF: call doesn't exists\n"); playDtmf (code, false); return false; } @@ -1535,13 +1535,19 @@ ManagerImpl::playDtmf (char code, bool isTalking) bool hasToPlayTone = getConfigBool (SIGNALISATION, PLAY_DTMF); if (!hasToPlayTone) + { + _debug(" playDtmf: Do not have to play a tone...\n"); return false; + } // length in milliseconds pulselen = getConfigInt (SIGNALISATION, PULSE_LENGTH); if (!pulselen) + { + _debug(" playDtmf: Pulse length is not set...\n"); return false; + } // numbers of int = length in milliseconds / 1000 (number of seconds) // = number of seconds * SAMPLING_RATE by SECONDS @@ -1551,13 +1557,16 @@ ManagerImpl::playDtmf (char code, bool isTalking) // fast return, no sound, so no dtmf if (audiolayer==0 || _dtmfKey == 0) + { + _debug(" playDtmf: Error no audio layer...\n"); return false; + } // number of data sampling in one pulselen depends on samplerate // size (n sampling) = time_ms * sampling/s // --------------------- // ms/s - size = (int) (pulselen * ( (float) audiolayer->getSampleRate() /1000)); + size = (int) ((pulselen * (float) audiolayer->getSampleRate()) / 1000); // this buffer is for mono // TODO <-- this should be global and hide if same size @@ -1574,6 +1583,9 @@ ManagerImpl::playDtmf (char code, bool isTalking) audiolayer->startStream(); audiolayer->putUrgent (buf, size * sizeof (SFLDataFormat)); } + else { + _debug(" playDtmf: Error cannot play dtmf"); + } ret = true; diff --git a/sflphone-common/src/sipvoiplink.h b/sflphone-common/src/sipvoiplink.h deleted file mode 100644 index 204e8639031e69e626d61e80d685aa3b57517c0e..0000000000000000000000000000000000000000 --- a/sflphone-common/src/sipvoiplink.h +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright (C) 2004-2009 Savoir-Faire Linux inc. - * - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * Author: Yun Liu <yun.liu@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 SIPVOIPLINK_H -#define SIPVOIPLINK_H - -#include "voiplink.h" -#include "hooks/urlhook.h" - -////////////////////////////// -/* PJSIP imports */ -#include <pjsip.h> -#include <pjlib.h> -#include <pjsip_ua.h> -#include <pjlib-util.h> -#include <pjnath/stun_config.h> -/////////////////////////////// - -class EventThread; -class SIPCall; - -#define RANDOM_LOCAL_PORT ((rand() % 27250) + 5250)*2 -#define RANDOM_SIP_PORT rand() % 64000 + 1024 - -// To set the verbosity. From 0 (min) to 6 (max) -#define PJ_LOG_LEVEL 0 - -/** - * @file sipvoiplink.h - * @brief Specific VoIPLink for SIP (SIP core for incoming and outgoing events). - * This class is based on the singleton design pattern. - * One SIPVoIPLink can handle multiple SIP accounts, but all the SIP accounts have all the same SIPVoIPLink - */ - -class SIPVoIPLink : public VoIPLink -{ - public: - - /** - * Singleton method. Enable to retrieve the unique static instance - * @return SIPVoIPLink* A pointer on the object - */ - static SIPVoIPLink* instance( const AccountID& id ); - - /** - * Destructor - */ - ~SIPVoIPLink(); - - /* Copy Constructor */ - SIPVoIPLink(const SIPVoIPLink& rh); - - /* Assignment Operator */ - SIPVoIPLink& operator=( const SIPVoIPLink& rh); - - /** - * Try to initiate the pjsip engine/thread and set config - * @return bool True if OK - */ - bool init(void); - - /** - * Shut the library and clean up - */ - void terminate( void ); - - /** - * Event listener. Each event send by the call manager is received and handled from here - */ - void getEvent(void); - - /** - * Build and send SIP registration request - * @return bool True on success - * false otherwise - */ - int sendRegister(AccountID id); - - /** - * Build and send SIP unregistration request - * @return bool True on success - * false otherwise - */ - int sendUnregister(AccountID id); - - /** - * Place a new call - * @param id The call identifier - * @param toUrl The Sip address of the recipient of the call - * @return Call* The current call - */ - Call* newOutgoingCall(const CallID& id, const std::string& toUrl); - - /** - * Answer the call - * @param id The call identifier - * @return int True on success - */ - bool answer(const CallID& id); - - /** - * Hang up the call - * @param id The call identifier - * @return bool True on success - */ - bool hangup(const CallID& id); - - /** - * Hang up the call - * @param id The call identifier - * @return bool True on success - */ - bool peerHungup(const CallID& id); - - /** - * Cancel the call - * @param id The call identifier - * @return bool True on success - */ - bool cancel(const CallID& id); - - /** - * Put the call on hold - * @param id The call identifier - * @return bool True on success - */ - bool onhold(const CallID& id); - - /** - * Put the call off hold - * @param id The call identifier - * @return bool True on success - */ - bool offhold(const CallID& id); - - /** - * Transfer the call - * @param id The call identifier - * @param to The recipient of the transfer - * @return bool True on success - */ - bool transfer(const CallID& id, const std::string& to); - - /** Handle the incoming refer msg, not finished yet */ - bool transferStep2(SIPCall* call); - - /** - * Refuse the call - * @param id The call identifier - * @return bool True on success - */ - bool refuse (const CallID& id); - - /** - * Send DTMF - * @param id The call identifier - * @param code The char code - * @return bool True on success - */ - bool carryingDTMFdigits(const CallID& id, char code); - - /** - * If set to true, we check for a firewall - * @param use true if we use STUN - */ - inline void useStun(bool use) { _useStun=use; } - - inline bool useStun( void ) { return _useStun; } - - /** - * The name of the STUN server - * @param server Server FQDN/IP - */ - void setStunServer(const std::string& server); - - std::string getStunServer (void) { return _stunServer; } - - /** - * Terminate every call not hangup | brutal | Protected by mutex - */ - void terminateSIPCall(); - - /** - * Terminate only one call - */ - void terminateOneCall(const CallID& id); - - /** - * Build a sip address with the number that you want to call - * Example: sip:124@domain.com - * @param to The header of the recipient - * @return std::string Result as a string - */ - std::string SIPToHeader(const std::string& to); - - /** - * Check if an url is sip-valid - * @param url The url to check - * @return bool True if osip tell that is valid - */ - bool SIPCheckUrl(const std::string& url); - - - /** - * Send an outgoing call invite - * @param call The current call - * @return bool True if all is correct - */ - bool SIPOutgoingInvite(SIPCall* call); - - /** - * Start a SIP Call - * @param call The current call - * @param subject Undocumented - * @return true if all is correct - */ - bool SIPStartCall(SIPCall* call, const std::string& subject); - - /** - * Get the Sip TO url (add sip:, add @host, etc...) - * @param to_url The To url - * @return std::string The SIP to address - */ - std::string getSipTo(const std::string& to_url, std::string hostname); - - /** - * Tell the user that the call was answered - * @param - */ - void SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata); - - /** - * Handling 5XX/6XX error - * @param - */ - void SIPCallServerFailure(SIPCall *call); - - /** - * Peer close the connection - * @param - */ - void SIPCallClosed(SIPCall *call); - - /** - * The call pointer was released - * If the call was not cleared before, report an error - * @param - */ - void SIPCallReleased(SIPCall *call); - - /** - * Handle a re-invite request by the remote peer. - * A re-invite is an invite request inside a dialog. - * When receiving a re-invite, we close the current rtp session and create a new one with the updated information - */ - void handle_reinvite (SIPCall *call); - - /** - * SIPCall accessor - * @param id The call identifier - * @return SIPCall* A pointer on SIPCall object - */ - SIPCall* getSIPCall(const CallID& id); - - /** when we init the listener, how many times we try to bind a port? */ - int _nbTryListenAddr; - - /** Increment the number of SIP account connected to this link */ - void incrementClients (void) { _clients++; } - - /** Decrement the number of SIP account connected to this link */ - void decrementClients (void); - - - /** - * Set Recording - * @param id The call identifier - */ - // void setRecording(const CallID& id); - - /** - * Returning state (true recording) - * @param id The call identifier - */ - // bool isRecording(const CallID& id); - - - /** - * Return the codec protocol used for this call - * @param id The call identifier - */ - std::string getCurrentCodecName(); - - int inv_session_reinvite (SIPCall *call, std::string direction=""); - - bool new_ip_to_ip_call (const CallID& id, const std::string& to); - - std::string get_useragent_name (void); - - private: - /** - * Constructor - * @param accountID The account identifier - */ - SIPVoIPLink(const AccountID& accountID); - - /* The singleton instance */ - static SIPVoIPLink* _instance; - - /** - * Enable the SIP SRV resolver - * @param endpt The SIP endpoint - * @param p_resv Pointer to receive The DNS resolver instance - * - * @return pj_status_t PJ_SUCCESS on success - */ - pj_status_t enable_dns_srv_resolver (pjsip_endpoint *endpt, pj_dns_resolver ** p_resv); - - void busy_sleep(unsigned msec); - - /** - * Initialize the PJSIP library - * Must be called before any other calls to the SIP layer - * - * @return bool True on success - */ - bool pjsip_init(); - - /** - * Delete link-related stuuf like calls - */ - bool pjsip_shutdown(void); - - pj_status_t stunServerResolve(); - - /** Create SIP UDP Listener */ - int createUDPServer(); - - bool loadSIPLocalIP(); - - std::string getLocalIP() {return _localExternAddress;} - - /* Flag to check if the STUN server is valid or not */ - bool validStunServer; - - /** The current STUN server address */ - std::string _stunServer; - - /** Local Extern Address is the IP address seen by peers for SIP listener */ - std::string _localExternAddress; - - /** Local Extern Port is the port seen by peers for SIP listener */ - unsigned int _localExternPort; - - /** Starting sound */ - // AudioRtp* _audiortp; - - /** For registration use only */ - int _regPort; - - /** Do we use stun? */ - bool _useStun; - - /** Threading object */ - EventThread* _evThread; - ost::Mutex _mutexSIP; - - /* Number of SIP accounts connected to the link */ - int _clients; -}; - -#endif