From c0da142e56b93e572f8a1c468e8af7d740761c22 Mon Sep 17 00:00:00 2001 From: yanmorin <yanmorin> Date: Fri, 21 Oct 2005 23:29:03 +0000 Subject: [PATCH] Forget to commit --- configure.ac | 3 +- sflphone.spec.in | 8 ++-- src/Makefile.am | 4 +- src/audio/audiortp.cpp | 80 ++++++++++++++++---------------- src/audio/tonegenerator.cpp | 13 +++--- src/global.h | 2 +- src/gui/server/tcpstreampool.cpp | 4 +- src/main.cpp | 2 +- src/sipvoiplink.cpp | 42 +++++++++++------ 9 files changed, 87 insertions(+), 71 deletions(-) diff --git a/configure.ac b/configure.ac index a9acc371f4..d1cc4515db 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ LIBS="$LIBS -lstdc++" dnl dnl Solaris pkgadd support definitions PKGADD_PKG="SFLPhoned" -PKGADD_NAME="SFLPhone - a SIP client and deamon" +PKGADD_NAME="SFLPhone - a SIP client and daemon" PKGADD_VENDOR="http://www.sflphone.org/" AC_SUBST(PKGADD_PKG) AC_SUBST(PKGADD_NAME) @@ -146,6 +146,7 @@ AM_CONDITIONAL(USE_ZEROCONF, test "$have_libdns_sd" = "yes") dnl AC_CONFIG_FILES( AC_OUTPUT( sflphone.spec \ +sflphoned-fedora.spec \ Makefile \ src/Makefile \ src/audio/Makefile \ diff --git a/sflphone.spec.in b/sflphone.spec.in index 80937125ec..ecdd21b047 100644 --- a/sflphone.spec.in +++ b/sflphone.spec.in @@ -1,22 +1,22 @@ -%define name sflphone +%define name sflphoned %define version 0.5 %define release 1 %define prefix /usr Autoreq: 0 Name: %name -Summary: An other VoIP client +Summary: A VoIP daemon with SIP protocol Version: %version Release: %release License: GPL Group: Networking/Utilities URL: http://www.sflphone.org/ Packager: Cyrille Béraud <cyrille.beraud@savoirfairelinux.com> -Source: http://www.sflphone.org/sflphone-0.5.tar.gz +Source: http://www.sflphone.org/releases/sflphone-0.5.tar.gz BuildRoot: /tmp/sflphone-%{version}-%{release} %description -SFLPhone is a VoIP client for a X11 environment. +SFLPhoned is a VoIP daemon with SIP protocol. %prep %setup CXXFLAGS="$RPM_OPT_FLAGS" ./configure --prefix %{prefix} diff --git a/src/Makefile.am b/src/Makefile.am index 9438d91446..8ef5961182 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,9 +20,9 @@ sflphoned_SOURCES = call.cpp eventthread.cpp error.cpp main.cpp sipvoiplink. sflphoned_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(ZEROCONFFLAGS) -sflphoned_LDFLAGS = -static +#sflphoned_LDFLAGS = -static sflphoned_LDADD = gui/libguiframework.la audio/libaudio.la ../stund/libstun.la ../utilspp/libutilspp.la -lpthread $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) config/libconfig.la -KDE_CXXFLAGS = $(USE_EXCEPTIONS) +#KDE_CXXFLAGS = $(USE_EXCEPTIONS) AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)/audio/pacpp/include $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(portaudio_CFLAGS) noinst_HEADERS = observer.h diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index 54d2f1b928..82453849e3 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -59,10 +59,10 @@ AudioRtp::createNewSession (SipCall *ca) { _symmetric); // Start PortAudio - Manager::instance().getAudioDriver()->micRingBuffer().flush(); - Manager::instance().getAudioDriver()->startStream(); + //Manager::instance().getAudioDriver()->flushMic(); + //Manager::instance().getAudioDriver()->startStream(); - _debug("AudioRtp::createNewSession: starting RTX thread\n"); + //_debug("AudioRtp::createNewSession: starting RTX thread\n"); if (_RTXThread->start() != 0) { return -1; } @@ -80,27 +80,27 @@ AudioRtp::closeRtpSession () { //////////////////////////////////////////////////////////////////////////////// // AudioRtpRTX Class // //////////////////////////////////////////////////////////////////////////////// -AudioRtpRTX::AudioRtpRTX (SipCall *sipcall, AudioLayer* driver, - bool sym) : _codecBuilder(0) { - time = new ost::Time(); - _ca = sipcall; - _sym = sym; - _audioDevice = driver; - - // TODO: Change bind address according to user settings. +AudioRtpRTX::AudioRtpRTX (SipCall *sipcall, AudioLayer* driver, bool sym) : _codecBuilder(0) { + + time = new ost::Time(); + _ca = sipcall; + _sym = sym; + _audioDevice = driver; + + // TODO: Change bind address according to user settings. std::string localipConfig = _ca->getLocalIp(); - ost::InetHostAddress local_ip(localipConfig.c_str()); + ost::InetHostAddress local_ip(localipConfig.c_str()); - _debug("RTP: listening on IP %s local port : %d\n", localipConfig.c_str(), _ca->getLocalAudioPort()); - if (!_sym) { - _sessionRecv = new ost::RTPSession (local_ip, _ca->getLocalAudioPort()); - _sessionSend = new ost::RTPSession (local_ip); + if (!_sym) { + _sessionRecv = new ost::RTPSession (local_ip, _ca->getLocalAudioPort()); + _sessionSend = new ost::RTPSession (local_ip); _session = NULL; - } else { - _session = new ost::SymmetricRTPSession (local_ip, _ca->getLocalAudioPort()); + } else { + _debug("Symmetric RTP Session on local: %s:%d\n", localipConfig.c_str(), _ca->getLocalAudioPort()); + _session = new ost::SymmetricRTPSession (local_ip, _ca->getLocalAudioPort()); _sessionRecv = NULL; _sessionSend = NULL; - } + } } AudioRtpRTX::~AudioRtpRTX () { @@ -110,13 +110,14 @@ AudioRtpRTX::~AudioRtpRTX () { _debug("AudioRtpRTX: try to terminate, but catch an exception...\n"); } _ca = NULL; - _debug("Thread: AudioRtpRTX stop session\n"); + if (!_sym) { delete _sessionRecv; _sessionRecv = NULL; delete _sessionSend; _sessionSend = NULL; } else { delete _session; _session = NULL; } + delete time; time = NULL; } @@ -128,8 +129,6 @@ AudioRtpRTX::initAudioRtpSession (void) if (!remote_ip) { _debug("RTP: Target IP address [%s] is not correct!\n", _ca->getRemoteSdpAudioIp()); return; - } else { - _debug("RTP: Sending to %s : %d\n", _ca->getRemoteSdpAudioIp(), _ca->getRemoteSdpAudioPort()); } // Initialization @@ -150,31 +149,34 @@ AudioRtpRTX::initAudioRtpSession (void) _debug("RTX send: could not connect to port %d\n", _ca->getRemoteSdpAudioPort()); return; - } else { - _debug("RTP(Send): Added destination %s : %d\n", - remote_ip.getHostname(), - (unsigned short) _ca->getRemoteSdpAudioPort()); } + _debug("RTP(Send): Added sessionSend destination %s:%d\n", + remote_ip.getHostname(), (unsigned short) _ca->getRemoteSdpAudioPort()); //setPayloadFormat(StaticPayloadFormat(sptPCMU)); - _debug("Payload Format: %d\n", _ca->payload); + //_debug("Payload Format: %d\n", _ca->payload); _sessionRecv->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) _ca->payload)); _sessionSend->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) _ca->payload)); - setCancel(cancelImmediate); - _sessionSend->setMark(true); + setCancel(cancelImmediate); + _sessionSend->setMark(true); + + } else { + + _debug("RTP(Send): Added session destination %s:%d\n", + remote_ip.getHostname(), (unsigned short) _ca->getRemoteSdpAudioPort()); + + if (!_session->addDestination (remote_ip, (unsigned short) _ca->getRemoteSdpAudioPort())) { + return; + } + + _session->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) _ca->payload)); + setCancel(cancelImmediate); + } - } else { - if (!_session->addDestination (remote_ip, (unsigned short) _ca->getRemoteSdpAudioPort())) { - return; - } else { - _session->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) _ca->payload)); - setCancel(cancelImmediate); - } - } Manager::instance().getAudioDriver()->flushMic(); Manager::instance().getAudioDriver()->flushMain(); - _debug("-----------------------\n"); + _debug("== AudioRtpRTX::initAudioRtpSession end == \n"); } void @@ -306,7 +308,7 @@ AudioRtpRTX::run (void) { audiolayer->urgentRingBuffer().flush(); // start running the packet queue scheduler. - _debug("Thread: start session of AudioRtpRTX\n"); + //_debug("Thread: start session of AudioRtpRTX\n"); if (!_sym) { _sessionRecv->startRunning(); _sessionSend->startRunning(); diff --git a/src/audio/tonegenerator.cpp b/src/audio/tonegenerator.cpp index 4864a7ea18..7852741e6f 100644 --- a/src/audio/tonegenerator.cpp +++ b/src/audio/tonegenerator.cpp @@ -18,7 +18,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <iostream> #include <fstream> #include <math.h> #include <stdlib.h> @@ -331,7 +330,7 @@ ToneGenerator::toneHandle (unsigned int idr, const std::string& zone) { } buildTone(idz, idr, _buf); tonethread = new ToneThread(_buf, totalbytes); - _debug("Thread: start tonethread\n"); + //_debug("Thread: start tonethread\n"); tonethread->start(); } @@ -339,10 +338,10 @@ void ToneGenerator::stopTone() { _currentTone = ZT_TONE_NULL; - _debug("Thread: delete tonethread\n"); + //_debug("Thread: delete tonethread\n"); delete tonethread; tonethread = NULL; // we end the last thread - _debug("Thread: tonethread deleted\n"); + //_debug("Thread: tonethread deleted\n"); } /** @@ -385,11 +384,11 @@ ToneGenerator::playRingtone (const char *fileName) { // expandedsize is the number of bytes, not the number of int expandedsize = _ulaw->codecDecode (_dst, (unsigned char *)_src, length); - _debug("length (pre-ulaw) : %d\n", length); - _debug("expandedsize (post-ulaw) : %d\n", expandedsize); + //_debug("length (pre-ulaw) : %d\n", length); + //_debug("expandedsize (post-ulaw) : %d\n", expandedsize); if (tonethread == NULL) { - _debug("Thread: start tonethread\n"); + //_debug("Thread: start tonethread\n"); // send the number of int16, so device by two tonethread = new ToneThread ((int16*)_dst, expandedsize>>1); tonethread->start(); diff --git a/src/global.h b/src/global.h index 57cd515b87..fc299d5647 100644 --- a/src/global.h +++ b/src/global.h @@ -27,7 +27,7 @@ typedef float float32; typedef short int16; -#define DEBUG +//#define DEBUG #ifdef DEBUG #define _debug(...) fprintf(stderr, "[sflphoned] " __VA_ARGS__) diff --git a/src/gui/server/tcpstreampool.cpp b/src/gui/server/tcpstreampool.cpp index 30f4de63dd..e66ae2b4cb 100644 --- a/src/gui/server/tcpstreampool.cpp +++ b/src/gui/server/tcpstreampool.cpp @@ -29,7 +29,7 @@ TCPStreamPool::run() { while(!testCancel() && good()) { while (isPending(ost::TCPSocket::pendingInput, 2LU)) { std::getline(*this, input); - _debug("TCPStreamPool getline %s\n", input.c_str()); + //_debug("TCPStreamPool getline %s\n", input.c_str()); if (input != null && input[0]!=cr13) { _inputPool.push(input); } @@ -37,7 +37,7 @@ TCPStreamPool::run() { if (testCancel() || !good()) {break;} } if (_outputPool.pop(output, 2LU)) { - _debug("TCPStreamPool send %s\n", output.c_str()); + //_debug("TCPStreamPool send %s\n", output.c_str()); *this << output << std::endl; } } diff --git a/src/main.cpp b/src/main.cpp index ab113d0500..a0339fef23 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ main (int argc, char **argv) { if (argc == 2 && strcmp(argv[1], "--help") == 0) { - std::cout << PROGNAME << " Deamon " << SFLPHONED_VERSION << ", by Savoir-Faire Linux 2004-2005" << std::endl << std::endl; + std::cout << PROGNAME << " Daemon " << SFLPHONED_VERSION << ", by Savoir-Faire Linux 2004-2005" << std::endl << std::endl; std::cout << "USAGE: sflphoned [--help]" << std::endl; std::cout << "Parameters: " << std::endl; std::cout << " --help for this message" << std::endl << std::endl; diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 49b7f35426..249cd9aa80 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -613,7 +613,7 @@ SipVoIPLink::getEvent (void) CALLID id = 0; int returnValue = 0; - //_debug("GetEvent : %d ", event->type); + _debug("GetEvent : %d ", event->type); switch (event->type) { // IP-Phone user receives a new call case EXOSIP_CALL_INVITE: // @@ -635,9 +635,7 @@ SipVoIPLink::getEvent (void) // Generate id id = Manager::instance().generateNewCallId(); Manager::instance().pushBackNewCall(id, Incoming); - _debug("Incoming call with id %d [cid = %d, did = %d]\n", - id, event->cid, event->did); - _debug("Local audio port: %d\n", _localPort); + _debug("New INVITE Event: call with id %d [cid = %d, did = %d]\n",id, event->cid, event->did); // Display the callerId-name osip_from_t *from; @@ -662,7 +660,7 @@ SipVoIPLink::getEvent (void) urlUsername = url->username; } Manager::instance().callSetInfo(id, name, urlUsername); - _debug("From: %s\n", name.c_str()); + _debug("New INVITE Event: From: %s\n", name.c_str()); } //Don't need this display text message now that we send the name //inside the Manager to the gui @@ -672,15 +670,31 @@ SipVoIPLink::getEvent (void) // Associate an audio port with a call sipcall->setLocalAudioPort(_localPort); sipcall->setLocalIp(getLocalIpAddress()); + _debug("New INVITE Event: we set the local audio to: %s:%d\n", getLocalIpAddress().c_str(), _localPort); sipcall->newIncomingCall(event); if (Manager::instance().incomingCall(id) < 0) { - Manager::instance().displayErrorText(id, "Incoming call failed"); + Manager::instance().displayErrorText(id, "New INVITE Event: Incoming call failed"); } break; case EXOSIP_CALL_REINVITE: - eXosip_call_send_answer(event->tid, 403, NULL); + _debug("!!! EXOSIP_CALL_REINVITE: Should reinvite? !!!\n"); + //eXosip_call_send_answer(event->tid, 403, NULL); + //488 as http://www.atosc.org/pipermail/public/osip/2005-June/005385.html + id = findCallId(event); + if (id != 0) { + sipcall = getSipCall(id); + if (sipcall != NULL) { + _debug("Call reinvite : [id = %d, cid = %d, did = %d], localport=%d\n", id, event->cid, event->did,sipcall->getLocalAudioPort()); + + _audiortp.closeRtpSession(); + sipcall->newIncomingCall(event); + _audiortp.createNewSession(sipcall); + } + } else { + eXosip_call_send_answer(event->tid, 488, NULL); + } break; case EXOSIP_CALL_PROCEEDING: // 8 @@ -770,14 +784,14 @@ SipVoIPLink::getEvent (void) // Handle 4XX errors switch (event->response->status_code) { case AUTH_REQUIRED: - _debug("EXOSIP_CALL_REQUESTFAILURE :: AUTH_REQUIRED\n"); + _debug("SIP Server ask required authentification: loging...\n"); setAuthentication(); eXosip_lock(); eXosip_automatic_action(); eXosip_unlock(); break; case UNAUTHORIZED: - _debug("EXOSIP_CALL_REQUESTFAILURE :: UNAUTHORIZED\n"); + _debug("Request is unauthorized. SIP Server ask authentification: loging...\n"); setAuthentication(); break; @@ -852,7 +866,7 @@ SipVoIPLink::getEvent (void) break; } } - + // TODO: Que faire si rien trouve?? eXosip_lock(); if (k == _sipcallVector.size()) { @@ -879,7 +893,7 @@ SipVoIPLink::getEvent (void) // Get the message body ii = osip_message_get_body(event->request, 0, &body); if (ii != 0) { - _debug("Cannot get body\n"); + _debug("Cannot get body in a new EXOSIP_MESSAGE_NEW event\n"); returnValue = -1; break; } @@ -1244,7 +1258,7 @@ SipVoIPLink::behindNat (void) } // Firewall address - _debug("STUN server: %s\n", svr.data()); + //_debug("STUN server: %s\n", svr.data()); Manager::instance().getStunInfo(stunSvrAddr); return 1; @@ -1354,11 +1368,11 @@ SipVoIPLink::startCall (CALLID id, const std::string& from, const std::string& t if (!Manager::instance().useStun()) { // Set random port for outgoing call if no firewall setLocalPort(RANDOM_LOCAL_PORT); - _debug("Local audio port: %d\n",_localPort); + _debug("SipVoIPLink::startCall: Local audio port: %d\n",_localPort); } else { // If use Stun server if (behindNat() != 0) { - _debug("sip invite: firewall port = %d\n",Manager::instance().getFirewallPort()); + _debug("SipVoIPLink::startCall: sip invite: firewall port = %d\n",Manager::instance().getFirewallPort()); setLocalPort(Manager::instance().getFirewallPort()); } else { return -1; -- GitLab