Fix some bugs

This commit is contained in:
llea
2005-01-13 23:44:39 +00:00
parent d565fb903b
commit f38af512e1
24 changed files with 112 additions and 317 deletions

7
README
View File

@ -19,9 +19,7 @@ make install
How to use it ?
---------------
1. Lauch it and click on SETUP.
Go to Audio, choose OSS (if you don't it WILL crash, this is a small bug,
don't forget, it's alpha).
1. Lauch it, a setup window appears.
2. If you do have a SIP account, fill the SIP stuff where related. You can use
STUN too.
@ -40,9 +38,6 @@ Why does it not compile ?
some compilers). We are using gcc 3.3.3 on
Fedora Core 2 Linux. Someone reported it works on gcc 3.4.
- You don't have luck as we cannot help you before
January, 5th 2005 because we are on *holidays*.
Of course we love patches. And contribution. See http://www.sflphone.org/ .
We are setting up the project (CVS, bugtraqer, MLs) infrastructure.
Please be patient. The goal was to release an early alpha version before the

View File

@ -36,8 +36,6 @@ hangup_x=225
hangup_y=156
dial_x=225
dial_y=182
ring_x=87
ring_y=0
redial_x=212
redial_y=84
mute_x=225

View File

@ -20,7 +20,7 @@ INC_OTHERS = ../stund
INCPATH = -I. -I$(QTDIR)/include -I$(CCPPDIR)/include/cc++2 -I$(CCRTPDIR)/include -I$(OSIPDIR)/include -I$(EXOPSIP)/include -I/usr/include
CXXFLAGS = -pipe -Wall -W -O2 -g -pipe -march=i386 -mcpu=i686 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -fpermissive -Wno-deprecated $(INCPATH)
CXXFLAGS = -pipe -Wall -W -g -pipe -march=i386 -mcpu=i686 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -fpermissive -Wno-deprecated $(INCPATH)
LIBS = -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm -L/opt/lib -losip2 -leXosip -lccrtp1 `ccgnu2-config --flags --stdlibs`
@ -110,5 +110,5 @@ uninstall:
rm -rf $(SHARE_DIR)/$(PROGNAME)
clean:
rm -f $(PROGNAME) *.o *.a *~ *.moc.cpp *.bak core
rm -f $(PROGNAME) *.o *.a *~ *.moc.cpp *.bak core.*

View File

@ -24,9 +24,7 @@
#include "g711.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
AudioCodec::AudioCodec (void) {
// Init array handleCodecs

View File

@ -21,9 +21,7 @@
#define __CODEC_AUDIO_H__
#include <string.h>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
typedef enum {
PAYLOAD_CODEC_ULAW = 0,
@ -32,13 +30,7 @@ typedef enum {
PAYLOAD_CODEC_ILBC = 97,
PAYLOAD_CODEC_SPEEX = 110
} codecType;
/*
#define CODEC_ALAW QString("G711a")
#define CODEC_ULAW QString("G711u")
#define CODEC_GSM QString("GSM")
#define CODEC_ILBC QString("iLBC")
#define CODEC_SPEEX QString("SPEEX")
*/
#define CODEC_ALAW std::string("G711a")
#define CODEC_ULAW std::string("G711u")
#define CODEC_GSM std::string("GSM")

View File

@ -35,10 +35,8 @@
#include "../stund/stun.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace ost;
using namespace std;
#endif
////////////////////////////////////////////////////////////////////////////////
// AudioRtp
@ -73,15 +71,6 @@ AudioRtp::createNewSession (SipCall *ca) {
RTXThread = new AudioRtpRTX (ca, manager->audiodriver, manager, symetric);
RTXThread->start();
/* if (!manager->useStun()) {
RTXThread = new AudioRtpRTX (ca, manager->audiodriver, manager);
qDebug("new RTXThread = 0x%X", (int)RTXThread);
RTXThread->start();
} else {
symThread = new AudioRtpSymmetric (ca, manager->audiodriver, manager);
symThread->start();
}
*/
return 0;
}
@ -93,36 +82,17 @@ AudioRtp::closeRtpSession (SipCall *ca) {
if (RTXThread != NULL) {
// Wait for them...and delete.
qDebug ("Thread audio JOIN ...");
RTXThread->join();
qDebug ("Thread audio JOIN !!!");
delete RTXThread;
qDebug ("RTXThread deleted!");
RTXThread = NULL;
}
/* if (!manager->useStun()) {
RTXThread->join();
if (RTXThread != NULL) {
delete RTXThread;
qDebug ("RTXThread deleted!");
RTXThread = NULL;
}
} else {
symThread->join();
if (symThread != NULL) {
delete symThread;
symThread = NULL;
}
}
*/
// Flush audio read buffer
manager->audiodriver->resetDevice();
}
void
AudioRtp::rtpexit (void) {
}
////////////////////////////////////////////////////////////////////////////////
// AudioRtpRTX Class //
////////////////////////////////////////////////////////////////////////////////
@ -330,124 +300,5 @@ AudioRtpRTX::run (void) {
this->exit();
}
#if 0
////////////////////////////////////////////////////////////////////////////////
// AudioRtpSymmetric Class //
////////////////////////////////////////////////////////////////////////////////
AudioRtpSymmetric::AudioRtpSymmetric (SipCall *sipcall, AudioDrivers *driver,
Manager *mngr) {
this->ca = sipcall;
this->audioDevice = driver;
this->manager = mngr;
InetHostAddress local_ip("192.168.1.172");
int forcedPort = manager->getFirewallPort();
qDebug("port firewall = %d", forcedPort);
session = new SymmetricRTPSession (local_ip, forcedPort);
}
AudioRtpSymmetric::~AudioRtpSymmetric () {
delete session;
terminate();
}
void
AudioRtpSymmetric::run (void) {
AudioCodec ac;
unsigned char *data_to_send;
short *data_from_mic;
int i,
compSize,
timestamp;
int expandedSize;
short *data_for_speakers = NULL;
data_for_speakers = new short[2048];
data_from_mic = new short[1024];
data_to_send = new unsigned char[1024];
InetHostAddress remote_ip;
remote_ip = ca->remote_sdp_audio_ip;
int remote_port = ca->remote_sdp_audio_port;
if (!remote_ip) {
qDebug("Symmetric: IP address is not correct!");
exit();
}
// Initialization
session->setSchedulingTimeout(10000);
session->setExpireTimeout(1000000);
if (!session->addDestination (remote_ip, (unsigned short) remote_port)) {
qDebug("Symmetric: could not connect to port %d", remote_port);
this->exit();
} else {
qDebug("Symmetric: Connected to %s:%d",
ca->remote_sdp_audio_ip, remote_port);
}
session->setPayloadFormat(StaticPayloadFormat(
(enum StaticPayloadType) ca->payload));
setCancel(cancelImmediate);
timestamp = 0;
// TODO: get frameSize from user config
int frameSize = 20; // 20ms frames
TimerPort::setTimer(frameSize);
// start running the packet queue scheduler.
session->startRunning();
while (ca->enable_audio != -1) {
////////////////////////////
// Send session
////////////////////////////
i = audioDevice->readBuffer (data_from_mic, 320);
// Encode acquired audio sample
compSize = AudioCodec::codecEncode (
ac.handleCodecs[0],
data_to_send,
data_from_mic, i);
// Send encoded audio sample
session->putData(timestamp, data_to_send, compSize);
timestamp += compSize;
////////////////////////////
// Recv session
////////////////////////////
const AppDataUnit* adu = NULL;
do {
Thread::sleep(10);
adu = session->getData(session->getFirstTimestamp());
} while (adu == NULL);
// Decode data with relevant codec
expandedSize = AudioCodec::codecDecode (
adu->getType(),
data_for_speakers,
(unsigned char*) adu->getData(),
adu->getSize());
// Write decoded data to sound device
audioDevice->writeBuffer (data_for_speakers, expandedSize);
delete adu;
// Let's wait for the next cycle
Thread::sleep(TimerPort::getTimer());
TimerPort::incTimer(frameSize); // 'frameSize' ms
}
delete[] data_for_speakers;
delete[] data_from_mic;
delete[] data_to_send;
this->exit();
}
#endif
// EOF

View File

@ -24,9 +24,7 @@
#include <ccrtp/rtp.h>
#ifdef CCXX_NAMESPACES
using namespace ost;
#endif
#include "sipcall.h"
@ -54,23 +52,6 @@ private:
bool sym;
};
#if 0
///////////////////////////////////////////////////////////////////////////////
// One pair of sockets
///////////////////////////////////////////////////////////////////////////////
class AudioRtpSymmetric : public Thread, public TimerPort {
public:
AudioRtpSymmetric (SipCall *, AudioDrivers *, Manager *);
~AudioRtpSymmetric();
virtual void run ();
private:
SipCall *ca;
AudioDrivers *audioDevice;
Manager *manager;
SymmetricRTPSession *session;
};
#endif
///////////////////////////////////////////////////////////////////////////////
// Main class rtp
///////////////////////////////////////////////////////////////////////////////
@ -81,7 +62,6 @@ public:
int createNewSession (SipCall *);
void closeRtpSession (SipCall *);
void rtpexit (void);
private:
AudioRtpRTX *RTXThread;

View File

@ -25,11 +25,8 @@
#include "global.h"
#define CFG_PFX PROGNAME
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
class ConfigurationTree;
class Config {
@ -37,19 +34,6 @@ public:
Config (void) {};
~Config (void) {};
#if 0
static QString gets (QString);
static QString get (QString, QString);
static QString set (QString, QString);
static int geti (QString);
static int get (QString, int);
static int set (QString, int);
static bool getb (QString);
static bool get (QString, bool);
static bool set (QString, bool);
#endif
static std::string gets (const char*, const char*);
static char* getschar (const char*, const char*);
static int geti (const char*, const char*);

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form implementation generated from reading ui file 'configurationpanel.ui'
**
** Created: Tue Jan 11 12:49:32 2005
** Created: Thu Jan 13 18:34:00 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form interface generated from reading ui file 'configurationpanel.ui'
**
** Created: Tue Jan 11 12:49:32 2005
** Created: Thu Jan 13 18:34:00 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!

View File

@ -31,16 +31,6 @@
#include "skin.h"
#include "qtGUImainwindow.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
void OptionProcess (int argc,char **argv) ;
QString *pOption ;

View File

@ -43,35 +43,17 @@
#include "qtGUImainwindow.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
Manager::Manager (QString *Dc = NULL) {
DirectCall = Dc;
bool exist;
for (int i = 0; i < NUMBER_OF_LINES; i++) {
phLines[i] = new PhoneLine ();
}
// Create .sflphone directory in home user
bool exist = true;
char * buffer;
// Get variable $HOME
buffer = getenv ("HOME"); path = string(buffer);
path = path + "/." + PROGNAME;
if (mkdir (path.data(), 0755) != 0) {
// If directory creation failed
if (errno != EEXIST) {
printf ("Cannot create directory: %s\n", strerror(errno));
}
}
// Load user's config
path = path + "/" + PROGNAME + "rc";
if (Config::tree()->populateFromFile(path.data()) == 0){
exist = false;
}
exist = createSettingsPath();
phonegui = new QtGUIMainWindow (0, 0 ,
Qt::WDestructiveClose |
@ -82,7 +64,7 @@ Manager::Manager (QString *Dc = NULL) {
audioRTP = new AudioRtp(this->sip, this);
tone = new ToneGenerator(this);
sip_rtp_init();
sip_init();
selectAudioDriver();
@ -101,7 +83,6 @@ Manager::Manager (QString *Dc = NULL) {
// show configuration panel
gui()->configuration();
}
}
Manager::~Manager (void) {
@ -113,27 +94,64 @@ Manager::~Manager (void) {
delete[] phLines;
}
/**
* Create .PROGNAME directory in home user and create configuration tree from
* the settings file if this file exists.
*
* @return true if config-file exists or false if not.
*/
bool
Manager::createSettingsPath (void) {
//
bool exist = true;
char * buffer;
// Get variable $HOME
buffer = getenv ("HOME"); path = string(buffer);
path = path + "/." + PROGNAME;
if (mkdir (path.data(), 0755) != 0) {
// If directory creation failed
if (errno != EEXIST) {
printf ("Cannot create directory: %s\n", strerror(errno));
}
}
// Load user's config
path = path + "/" + PROGNAME + "rc";
if (Config::tree()->populateFromFile(path.data()) == 0){
exist = false;
}
return exist;
}
/**
* Call audio driver constructor according to the selected driver in setup
*/
void
Manager::selectAudioDriver (void) {
this->audiodriver = new AudioDriversOSS ();
/* if (Config::getb(QString("Audio/Drivers.driverOSS"))) {
// TODO remplacer par ce qui suit ad ALSA sera implement<6E>
#if 0
if (Config::getb("Audio", "Drivers.driverOSS")) {
this->audiodriver = new AudioDriversOSS ();
} else if (Config::get(QString("Audio/Drivers.driverALSA"), false)) {
audiodriver = new AudioDriversALSA ();
}*/
} else if (Config::getb("Audio", "Drivers.driverALSA")) {
this->audiodriver = new AudioDriversALSA ();
}
#endif
}
/**
* Init the SIP stack
*/
void
Manager::sip_rtp_init (void) {
// Init the SIP and RTP stacks.
Manager::sip_init (void) {
if ( sip->initSIP () != -1) {
sip->initRtpmapCodec ();
}
// if (Config::getb(QString("Preferences/Options.autoregister"))) {
if (Config::getb("Preferences", "Options.autoregister")) {
// Register to the known proxies if available
//if (Config::gets("Signalisations/SIP.password").length() > 0) {
if (Config::gets("Signalisations", "SIP.password").length() > 0) {
sip->setRegister ();
}
@ -143,7 +161,6 @@ Manager::sip_rtp_init (void) {
void
Manager::quitLibrary (void) {
sip->quitSIP();
audioRTP->rtpexit();
}
int
@ -441,7 +458,6 @@ Manager::setChoose (bool b, bool b2) {
bool
Manager::useStun () {
// if (Config::getb("Signalisations/STUN.useStunYes")) {
if (Config::getb("Signalisations", "STUN.useStunYes")) {
return true;
} else {
@ -449,10 +465,14 @@ Manager::useStun () {
}
}
// Handle choice of the DTMF-send-way
/**
* Handle choice of the DTMF-send-way
*
* @param line: number of the line.
* @param digit: pressed key.
*/
void
Manager::dtmf (int line, char digit) {
// int sendType = Config::geti ("Signalisations/DTMF.sendDTMFas");
int sendType = Config::geti ("Signalisations", "DTMF.sendDTMFas");
switch (sendType) {

View File

@ -26,9 +26,7 @@
#include "../stund/stun.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
class AudioRtp;
class SIP;
@ -61,7 +59,7 @@ public:
void quitLibrary (void);
int outgoingNewCall (void);
void actionHandle (int, int);
int findLineNumberNotUsedSIP (void);
int findLineNumberNotUsedSIP(void);
void handleRemoteEvent (int, char *, int);
int startSound (SipCall *);
void closeSound (SipCall *);
@ -92,8 +90,8 @@ private:
int firewallPort;
QString firewallAddr;
void sip_rtp_init (void);
void sip_init (void);
bool createSettingsPath (void);
};

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form implementation generated from reading ui file 'phonebook.ui'
**
** Created: Tue Jan 11 12:49:31 2005
** Created: Thu Jan 13 18:33:59 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form interface generated from reading ui file 'phonebook.ui'
**
** Created: Tue Jan 11 12:49:31 2005
** Created: Thu Jan 13 18:33:59 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!

View File

@ -27,10 +27,11 @@ PhoneLine::PhoneLine (void) {
setState (FREE);
setStateLine (FREE);
first = true;
timer = new QTime();
}
PhoneLine::~PhoneLine (void) {
if (timer) {
if (timer != NULL) {
delete timer;
}
}
@ -103,6 +104,7 @@ PhoneLine::button (void) {
void
PhoneLine::startTimer(void) {
if (timer == NULL)
timer = new QTime();
timer->start();
}

View File

@ -487,20 +487,6 @@ QtGUIMainWindow::numLineBusy(void) {
return temp;
}
void
QtGUIMainWindow::stopBlinkingRingPixmap (void) {
// Initialisation of red bar rectangle region
QRect rect(ExistingDF.GetInt("ring_x","Positions"),
ExistingDF.GetInt("ring_y","Positions"),
imageRing.width(), imageRing.height());
// Blit the no-ringing pixmap with update rectangle
bitBlt (this, ExistingDF.GetInt("ring_x","Positions"),
ExistingDF.GetInt("ring_y","Positions"),&imageNoRing, 0, 0,
imageRing.width(), imageRing.height(), Qt::CopyROP);
update(rect);
}
void
QtGUIMainWindow::dialTone (bool var) {
if (this->b_dialtone != var) {
@ -556,7 +542,7 @@ QtGUIMainWindow::toggleLine (int num_line) {
chosenLine = currentLineNumber;
if (!noChoose) {
choose = true;
this->dialTone(true);
//this->dialTone(true);
}
callmanager->phLines[currentLineNumber]->setStateLine(BUSY);
}
@ -593,7 +579,6 @@ QtGUIMainWindow::toggleLine (int num_line) {
callmanager->phLines[currentLineNumber]->getStateLine() != ONHOLD){
qDebug("GUI: -- Nouvel appel repondu %d --", currentLineNumber);
callmanager->actionHandle (currentLineNumber, ANSWER_CALL);
stopBlinkingRingPixmap ();
callmanager->phLines[currentLineNumber]->setState(BUSY);
callmanager->phLines[currentLineNumber]->setStateLine(BUSY);
}
@ -625,14 +610,19 @@ QtGUIMainWindow::dial (void) {
int i = 0;
if (transfer and callmanager->sip->call[currentLineNumber] != NULL
and currentLineNumber != -1) {
// If transfer button clicked, validate the number for transfer.
callmanager->actionHandle (currentLineNumber, TRANSFER_CALL);
transfer = false;
} else if (callmanager->phLines[currentLineNumber]->isOnHold() or
callmanager->phLines[currentLineNumber]->getStateLine() == OFFHOLD
or (callmanager->phLines[currentLineNumber]->isBusy() and
callmanager->sip->call[currentLineNumber] != NULL)){
// If line used
// NOTHING
} else {
qDebug("GUI: LINE CURRENT %d", currentLineNumber);
// If new incoming call
// Stop blinking ring pixmap and answer.
if (callmanager->ringing()) {
stopBlinkingRingPixmap();
// If new incoming call
currentLineNumber = callmanager->newCallLineNumber();
toggleLine (currentLineNumber);
} else {
@ -714,6 +704,7 @@ void
QtGUIMainWindow::setFreeStateLine (int line) {
// Set free-status for current line
callmanager->phLines[line]->setState (FREE);
callmanager->phLines[line]->setStateLine (FREE);
// Set free-pixmap
callmanager->phLines[line]->button()->setPixmap( TabLinePixmap[line][FREE]);
}

View File

@ -215,7 +215,6 @@ private:
void initBlinkTimer (void);
int numLineBusy (void);
void stopBlinkingRingPixmap (void);
int positionOffsetX (void);

View File

@ -36,9 +36,7 @@
#include "sipcall.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
// TODO : mettre dans config
#define DEFAULT_SIP_PORT 5060
@ -484,7 +482,12 @@ SIP::outgoingInvite (void) {
from = (char*)qfrom.data();
// Form the To header field
string qto = toHeader(string(callmanager->bufferTextRender().ascii()));
string qto;
if (callmanager->bufferTextRender().ascii() == NULL)
return -1;
else
qto = toHeader(string(callmanager->bufferTextRender().ascii()));
if (qto.find("@") == string::npos and
Config::getb("Preferences", "Options.autoregister")) {
qto = qto + "@" + Config::gets("Signalisations", "SIP.hostPart");
@ -546,7 +549,6 @@ SIP::carryingDTMFdigits (int line, char digit) {
int
SIP::manageActions (int usedLine, int action) {
int i;
// QString referTo;
string referTo;
char tmpbuf[64];
@ -732,7 +734,6 @@ SIP::getEvent (void) {
// TODO: stop the ringtone
callmanager->ringTone(false);
// Stop the call progress
callmanager->setCallInProgress(false);
@ -747,6 +748,7 @@ SIP::getEvent (void) {
if (callmanager->phLines[theline]->getStateLine() == BUSY or
callmanager->phLines[theline]->getStateLine() == OFFHOLD
or !call[theline]->usehold) {
if (!callmanager->transferedCall()) {
// Associate an audio port with a call
call[theline]->setLocalAudioPort(local_port);
@ -867,7 +869,6 @@ SIP::getEvent (void) {
// If callee closes call instead of answering
theline = notUsedLine;
}
assert (theline >= 0);
assert (theline < NUMBER_OF_LINES);

View File

@ -39,10 +39,8 @@
#include <cc++/thread.h>
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
using namespace ost;
#endif
// List of actions
#define ANSWER_CALL 0
@ -101,7 +99,7 @@ public:
char *myIPAddress;
SipCall *call[NUMBER_OF_LINES];
Manager *callmanager;
char displayName[64];
int notUsedLine;

View File

@ -22,9 +22,7 @@
#include <cc++/thread.h>
#ifdef CCXX_NAMESPACES
using namespace ost;
#endif
#include "manager.h"

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form implementation generated from reading ui file 'url_input.ui'
**
** Created: Tue Jan 11 12:49:31 2005
** Created: Thu Jan 13 18:34:00 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Form interface generated from reading ui file 'url_input.ui'
**
** Created: Tue Jan 11 12:49:31 2005
** Created: Thu Jan 13 18:34:00 2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!