Commit f38af512 authored by llea's avatar llea

Fix some bugs

parent d565fb90
......@@ -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
......
......@@ -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
......
......@@ -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.*
......@@ -24,9 +24,7 @@
#include "g711.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
AudioCodec::AudioCodec (void) {
// Init array handleCodecs
......
......@@ -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")
......
......@@ -35,10 +35,8 @@
#include "../stund/stun.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace ost;
using namespace std;
#endif
////////////////////////////////////////////////////////////////////////////////
// AudioRtp
......@@ -72,16 +70,7 @@ 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;
}
......@@ -92,37 +81,18 @@ AudioRtp::closeRtpSession (SipCall *ca) {
ca->enable_audio = -1;
if (RTXThread != NULL) {
// Wait for them...and delete.
RTXThread->join();
// 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
......@@ -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;
......
......@@ -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*);
......
/****************************************************************************
** 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!
......
/****************************************************************************
** 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!
......
......@@ -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 ;
......
......@@ -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
#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) {
......
......@@ -26,9 +26,7 @@
#include "../stund/stun.h"
#include <string>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
class AudioRtp;
class SIP;
......@@ -53,33 +51,33 @@ public:
std::string path;
inline
QtGUIMainWindow*gui (void) { return this->phonegui; }
bool ringing (void);
QtGUIMainWindow*gui (void) { return this->phonegui; }
bool ringing (void);
inline
void ring (void) { this->ring(true); }
void ring (bool);
void ring (void) { this->ring(true); }
void ring (bool);
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 *);
int startSound (SipCall *);
void closeSound (SipCall *);
void selectAudioDriver (void);
QString bufferTextRender (void);
bool isNotUsedLine (int);
bool isRingingLine (int);
int newCallLineNumber (void);
int newCallLineNumber (void);
void getInfoStun (StunAddress4 &);
int getFirewallPort (void);
int getFirewallPort (void);
void setFirewallPort (int);
QString getFirewallAddress (void);
bool otherLine (void);
bool otherLine (void);
bool isChosenLine (void);
int chosenLine (void);
void setChoose (bool, bool);
bool useStun (void);
void dtmf (int, char);
int chosenLine (void);
void setChoose (bool, bool);
bool useStun (void);
void dtmf (int, char);
bool getCallInProgress (void);
void setCallInProgress (bool);
bool transferedCall (void);
......@@ -92,8 +90,8 @@ private:
int firewallPort;
QString firewallAddr;
void sip_rtp_init (void);
void sip_init (void);
bool createSettingsPath (void);
};
......
......@@ -278,7 +278,7 @@ MyDisplay::renderTime (QPainter &painter, QFontMetrics &fm) {
}
time = new QString(minStr + ":" + secStr);
} else {
// If no conversation, display the current time
time = new QString(QDateTime::currentDateTime().toString("hh:mm"));
......
/****************************************************************************
** 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!
......
/****************************************************************************
** 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