mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
Manager is now a singleton
This commit is contained in:
@ -3054,7 +3054,7 @@ AC_DEFUN([AC_CHECK_COMPILERS],
|
|||||||
|
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
|
|
||||||
KDE_CHECK_FOR_BAD_COMPILER
|
dnl KDE_CHECK_FOR_BAD_COMPILER
|
||||||
|
|
||||||
if test "$GXX" = "yes" || test "$CXX" = "KCC"; then
|
if test "$GXX" = "yes" || test "$CXX" = "KCC"; then
|
||||||
if test "$kde_use_debug_code" != "no"; then
|
if test "$kde_use_debug_code" != "no"; then
|
||||||
|
19
configure.ac
19
configure.ac
@ -35,7 +35,7 @@ AM_DISABLE_LIBRARIES
|
|||||||
AC_PROG_LIBTOOL
|
AC_PROG_LIBTOOL
|
||||||
AC_CHECK_COMPILERS
|
AC_CHECK_COMPILERS
|
||||||
|
|
||||||
CXXFLAGS="$CXXFLAGS $USE_EXCEPTIONS "
|
CXXFLAGS="$CXXFLAGS $USE_EXCEPTIONS"
|
||||||
|
|
||||||
SFLPHONE_CXXFLAGS=""
|
SFLPHONE_CXXFLAGS=""
|
||||||
|
|
||||||
@ -81,7 +81,10 @@ SFLPHONE_LIBS="$SFLPHONE_LIBS $libosip2_LIBS"
|
|||||||
if test $ac_cv_header_eXosip_eXosip_h = no; then
|
if test $ac_cv_header_eXosip_eXosip_h = no; then
|
||||||
AC_MSG_ERROR([*** missing eXipsip/eXosip.h. You need a working eXosip installation. See http://savannah.nongnu.org/projects/exosip/])
|
AC_MSG_ERROR([*** missing eXipsip/eXosip.h. You need a working eXosip installation. See http://savannah.nongnu.org/projects/exosip/])
|
||||||
fi
|
fi
|
||||||
SFLPHONE_LIBS="$SFLPHONE_LIBS -leXosip"
|
libexosip_LIBS="-leXosip "
|
||||||
|
SFLPHONE_LIBS="$SFLPHONE_LIBS $libexosip_LIBS"
|
||||||
|
|
||||||
|
AC_SUBST(LIBQT)
|
||||||
|
|
||||||
dnl if test $ac_cv_header_gsm_h = no; then
|
dnl if test $ac_cv_header_gsm_h = no; then
|
||||||
dnl AC_MSG_ERROR([*** missing gsm.h. You need a working GSM 06.10 lossy speech compression installation. See http://kbs.cs.tu-berlin.de/~jutta/toast.html])
|
dnl AC_MSG_ERROR([*** missing gsm.h. You need a working GSM 06.10 lossy speech compression installation. See http://kbs.cs.tu-berlin.de/~jutta/toast.html])
|
||||||
@ -109,17 +112,17 @@ AM_CONDITIONAL(MAINTENER_CODE, test x$maintener = xyes)
|
|||||||
if test $ac_cv_header_portaudio_h = no; then
|
if test $ac_cv_header_portaudio_h = no; then
|
||||||
AC_MSG_ERROR([*** missing portaudio.h. You need a working PortAudio installation. See http://www.portaudio.com])
|
AC_MSG_ERROR([*** missing portaudio.h. You need a working PortAudio installation. See http://www.portaudio.com])
|
||||||
fi
|
fi
|
||||||
SFLPHONE_LIBS="$SFLPHONE_LIBS -lportaudio"
|
portaudio_LIBS="-lportaudio "
|
||||||
CXXFLAGS="$CXXFLAGS -DAUDIO_PORTAUDIO"
|
portaudio_CFLAGS="-DAUDIO_PORTAUDIO "
|
||||||
|
SFLPHONE_LIBS="$SFLPHONE_LIBS $portaudio_LIBS"
|
||||||
|
SFLPHONE_CXXFLAGS=="$SFLPHONE_CXXFLAGS $portaudio_CFLAGS"
|
||||||
|
AC_SUBST(portaudio_CFLAGS)
|
||||||
|
AC_SUBST(portaudio_LIB)
|
||||||
|
|
||||||
AC_SUBST(SFLPHONE_CXXFLAGS)
|
AC_SUBST(SFLPHONE_CXXFLAGS)
|
||||||
AC_SUBST(SFLPHONE_LIBS)
|
AC_SUBST(SFLPHONE_LIBS)
|
||||||
CXXFLAGS="$CXXFLAGS $SFLPHONE_CXXFLAGS"
|
|
||||||
|
|
||||||
|
|
||||||
LIBS="$LIBS $SFLPHONE_LIBS $LIBQT"
|
|
||||||
|
|
||||||
dnl AC_CONFIG_FILES(
|
dnl AC_CONFIG_FILES(
|
||||||
AC_OUTPUT(
|
AC_OUTPUT(
|
||||||
sflphone.spec \
|
sflphone.spec \
|
||||||
|
@ -6,7 +6,6 @@ sflphone_SOURCES = \
|
|||||||
configitem.cpp \
|
configitem.cpp \
|
||||||
configuration.cpp \
|
configuration.cpp \
|
||||||
configurationtree.cpp \
|
configurationtree.cpp \
|
||||||
manager.cpp \
|
|
||||||
call.cpp \
|
call.cpp \
|
||||||
eventthread.cpp \
|
eventthread.cpp \
|
||||||
error.cpp \
|
error.cpp \
|
||||||
@ -15,6 +14,8 @@ sflphone_SOURCES = \
|
|||||||
voIPLink.cpp \
|
voIPLink.cpp \
|
||||||
sipcall.cpp \
|
sipcall.cpp \
|
||||||
skin.cpp \
|
skin.cpp \
|
||||||
|
managerimpl.cpp \
|
||||||
|
managerimpl.h \
|
||||||
manager.h \
|
manager.h \
|
||||||
global.h \
|
global.h \
|
||||||
configitem.h \
|
configitem.h \
|
||||||
@ -35,12 +36,10 @@ sflphone_SOURCES = \
|
|||||||
|
|
||||||
sflphone_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\"
|
sflphone_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\"
|
||||||
|
|
||||||
sflphone_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS)
|
sflphone_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS)
|
||||||
sflphone_LDADD = gui/libguiframework.la audio/libaudio.la ../stund/libstun.la -lpthread
|
sflphone_LDADD = gui/libguiframework.la audio/libaudio.la ../stund/libstun.la -lpthread $(LIBQT) $(SFLPHONE_LIBS)
|
||||||
|
KDE_CXXFLAGS = $(USE_EXCEPTIONS)
|
||||||
|
AM_CPPFLAGS = $(QT_INCLUDES) $(X_INCLUDES) -Iaudio/pacpp/include $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(portaudio_CFLAGS)
|
||||||
KDE_CXXFLAGS = $(USE_EXCEPTIONS)
|
|
||||||
AM_CPPFLAGS = $(QT_INCLUDES) $(X_INCLUDES) -Iaudio/pacpp/include
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,6 @@ libaudio_la_SOURCES = \
|
|||||||
tonegenerator.cpp tonegenerator.h \
|
tonegenerator.cpp tonegenerator.h \
|
||||||
ulaw.cpp ulaw.h
|
ulaw.cpp ulaw.h
|
||||||
|
|
||||||
AM_CXXFLAGS = -Ipacpp/include/
|
AM_CXXFLAGS = -Ipacpp/include/ $(libccext2_CFLAGS) $(libccrtp1_CFLAGS) $(portaudio_CFLAGS)
|
||||||
libaudio_la_LIBADD = gsm/libgsm.la pacpp/source/portaudiocpp/libportaudiocpp.la
|
libaudio_la_LIBADD = gsm/libgsm.la pacpp/source/portaudiocpp/libportaudiocpp.la
|
||||||
|
|
||||||
|
@ -27,12 +27,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#include "../global.h"
|
|
||||||
|
|
||||||
#include "audiocodec.h"
|
#include "audiocodec.h"
|
||||||
#include "../configuration.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -24,113 +24,113 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "audiolayer.h"
|
#include "audiolayer.h"
|
||||||
#include "ringbuffer.h"
|
|
||||||
#include "../error.h"
|
#include "../error.h"
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
#include "../manager.h"
|
#include "../manager.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
AudioLayer::AudioLayer (Manager* manager) {
|
AudioLayer::AudioLayer ()
|
||||||
_manager = manager;
|
: _urgentRingBuffer(SIZEBUF)
|
||||||
initDevice();
|
, _mainSndRingBuffer(SIZEBUF)
|
||||||
|
, _micRingBuffer(SIZEBUF)
|
||||||
_urgentRingBuffer = new RingBuffer(SIZEBUF);
|
, _stream(NULL)
|
||||||
_mainSndRingBuffer = new RingBuffer(SIZEBUF);
|
{}
|
||||||
_micRingBuffer = new RingBuffer(SIZEBUF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
AudioLayer::~AudioLayer (void)
|
AudioLayer::~AudioLayer (void)
|
||||||
{
|
{
|
||||||
closeStream();
|
closeStream();
|
||||||
autoSys->terminate();
|
|
||||||
|
|
||||||
delete autoSys;
|
|
||||||
delete _urgentRingBuffer;
|
|
||||||
delete _mainSndRingBuffer;
|
|
||||||
delete _micRingBuffer;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioLayer::initDevice (void) {
|
AudioLayer::closeStream (void)
|
||||||
autoSys = new portaudio::AutoSystem();
|
{
|
||||||
autoSys->initialize();
|
if(_stream) {
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AudioLayer::closeStream (void) {
|
|
||||||
_stream->close();
|
_stream->close();
|
||||||
|
delete _stream;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioLayer::openDevice (int index)
|
AudioLayer::openDevice (int index)
|
||||||
{
|
{
|
||||||
// Set up the System:
|
closeStream();
|
||||||
portaudio::System &sys = portaudio::System::instance();
|
// Set up the parameters required to open a (Callback)Stream:
|
||||||
|
portaudio::DirectionSpecificStreamParameters
|
||||||
// Set up the parameters required to open a (Callback)Stream:
|
outParams(portaudio::System::instance().deviceByIndex(index),
|
||||||
portaudio::DirectionSpecificStreamParameters outParams(
|
2, portaudio::INT16, true,
|
||||||
sys.deviceByIndex(index), 2, portaudio::INT16, true,
|
portaudio::System::instance().deviceByIndex(index).defaultLowOutputLatency(),
|
||||||
sys.deviceByIndex(index).defaultLowOutputLatency(), NULL);
|
NULL);
|
||||||
|
|
||||||
portaudio::DirectionSpecificStreamParameters inParams(
|
portaudio::DirectionSpecificStreamParameters
|
||||||
sys.deviceByIndex(index), 2, portaudio::INT16, true,
|
inParams(portaudio::System::instance().deviceByIndex(index),
|
||||||
sys.deviceByIndex(index).defaultLowInputLatency(), NULL);
|
2, portaudio::INT16, true,
|
||||||
|
portaudio::System::instance().deviceByIndex(index).defaultLowInputLatency(),
|
||||||
|
NULL);
|
||||||
|
|
||||||
portaudio::StreamParameters const params(inParams, outParams,
|
portaudio::StreamParameters const params(inParams, outParams,
|
||||||
SAMPLING_RATE, FRAME_PER_BUFFER, paNoFlag);
|
SAMPLING_RATE, FRAME_PER_BUFFER, paNoFlag);
|
||||||
|
|
||||||
// Create (and open) a new Stream, using the AudioLayer::audioCallback
|
// Create (and open) a new Stream, using the AudioLayer::audioCallback
|
||||||
_stream = new portaudio::MemFunCallbackStream<AudioLayer>(
|
_stream = new portaudio::MemFunCallbackStream<AudioLayer>(params,
|
||||||
params, *this, &AudioLayer::audioCallback);
|
*this,
|
||||||
|
&AudioLayer::audioCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioLayer::startStream(void)
|
AudioLayer::startStream(void)
|
||||||
{
|
{
|
||||||
if (_manager->isDriverLoaded()) {
|
if (Manager::instance().isDriverLoaded()) {
|
||||||
if (!_stream->isActive()) {
|
if (_stream && !_stream->isActive()) {
|
||||||
_stream->start();
|
_stream->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioLayer::stopStream(void)
|
AudioLayer::stopStream(void)
|
||||||
{
|
{
|
||||||
if (_manager->isDriverLoaded()) {
|
if (Manager::instance().isDriverLoaded()) {
|
||||||
if (!_stream->isStopped()) {
|
if (_stream && !_stream->isStopped()) {
|
||||||
_stream->stop();
|
_stream->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioLayer::sleep(int msec)
|
AudioLayer::sleep(int msec)
|
||||||
{
|
{
|
||||||
portaudio::System &sys = portaudio::System::instance();
|
portaudio::System::instance().sleep(msec);
|
||||||
sys.sleep(msec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
bool
|
||||||
AudioLayer::isStreamActive (void)
|
AudioLayer::isStreamActive (void)
|
||||||
{
|
{
|
||||||
return _stream->isActive();
|
if(_stream && _stream->isActive()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
bool
|
||||||
AudioLayer::isStreamStopped (void)
|
AudioLayer::isStreamStopped (void)
|
||||||
{
|
{
|
||||||
return _stream->isStopped();
|
if(_stream && _stream->isStopped()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer,
|
AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer,
|
||||||
unsigned long framesPerBuffer,
|
unsigned long framesPerBuffer,
|
||||||
const PaStreamCallbackTimeInfo *timeInfo,
|
const PaStreamCallbackTimeInfo *timeInfo,
|
||||||
PaStreamCallbackFlags statusFlags) {
|
PaStreamCallbackFlags statusFlags) {
|
||||||
(void) timeInfo;
|
(void) timeInfo;
|
||||||
(void) statusFlags;
|
(void) statusFlags;
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer,
|
|||||||
int16 *out = (int16 *) outputBuffer;
|
int16 *out = (int16 *) outputBuffer;
|
||||||
int toGet, toPut, urgentAvail, normalAvail, micAvailPut;
|
int toGet, toPut, urgentAvail, normalAvail, micAvailPut;
|
||||||
|
|
||||||
urgentAvail = _urgentRingBuffer->AvailForGet();
|
urgentAvail = _urgentRingBuffer.AvailForGet();
|
||||||
if (urgentAvail > 0) {
|
if (urgentAvail > 0) {
|
||||||
// Urgent data (dtmf, incoming call signal) come first.
|
// Urgent data (dtmf, incoming call signal) come first.
|
||||||
if (urgentAvail < (int)framesPerBuffer) {
|
if (urgentAvail < (int)framesPerBuffer) {
|
||||||
@ -146,24 +146,24 @@ AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer,
|
|||||||
} else {
|
} else {
|
||||||
toGet = framesPerBuffer;
|
toGet = framesPerBuffer;
|
||||||
}
|
}
|
||||||
_urgentRingBuffer->Get(out, SAMPLES_SIZE(toGet));
|
_urgentRingBuffer.Get(out, SAMPLES_SIZE(toGet));
|
||||||
|
|
||||||
// Consume the regular one as well
|
// Consume the regular one as well
|
||||||
_mainSndRingBuffer->Discard(SAMPLES_SIZE(toGet));
|
_mainSndRingBuffer.Discard(SAMPLES_SIZE(toGet));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If nothing urgent, play the regular sound samples
|
// If nothing urgent, play the regular sound samples
|
||||||
normalAvail = _mainSndRingBuffer->AvailForGet();
|
normalAvail = _mainSndRingBuffer.AvailForGet();
|
||||||
toGet = (normalAvail < (int)framesPerBuffer) ? normalAvail :
|
toGet = (normalAvail < (int)framesPerBuffer) ? normalAvail :
|
||||||
framesPerBuffer;
|
framesPerBuffer;
|
||||||
_mainSndRingBuffer->Get(out, SAMPLES_SIZE(toGet));
|
_mainSndRingBuffer.Get(out, SAMPLES_SIZE(toGet));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additionally handle the mike's audio stream
|
// Additionally handle the mike's audio stream
|
||||||
micAvailPut = _micRingBuffer->AvailForPut();
|
micAvailPut = _micRingBuffer.AvailForPut();
|
||||||
toPut = (micAvailPut <= (int)framesPerBuffer) ? micAvailPut :
|
toPut = (micAvailPut <= (int)framesPerBuffer) ? micAvailPut :
|
||||||
framesPerBuffer;
|
framesPerBuffer;
|
||||||
_micRingBuffer->Put(in, SAMPLES_SIZE(toPut));
|
_micRingBuffer.Put(in, SAMPLES_SIZE(toPut));
|
||||||
|
|
||||||
return paContinue;
|
return paContinue;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
|
#include "ringbuffer.h"
|
||||||
|
|
||||||
#define FRAME_PER_BUFFER 160
|
#define FRAME_PER_BUFFER 160
|
||||||
#define MIC_CHANNELS 2 // 1=mono 2=stereo
|
#define MIC_CHANNELS 2 // 1=mono 2=stereo
|
||||||
@ -34,37 +35,35 @@
|
|||||||
|
|
||||||
|
|
||||||
class RingBuffer;
|
class RingBuffer;
|
||||||
class Manager;
|
|
||||||
|
|
||||||
class AudioLayer {
|
class AudioLayer {
|
||||||
public:
|
public:
|
||||||
AudioLayer (Manager*);
|
AudioLayer();
|
||||||
~AudioLayer (void);
|
~AudioLayer (void);
|
||||||
|
|
||||||
void initDevice (void);
|
|
||||||
void openDevice (int);
|
void openDevice (int);
|
||||||
void startStream (void);
|
void startStream (void);
|
||||||
void stopStream (void);
|
void stopStream (void);
|
||||||
void sleep (int);
|
void sleep (int);
|
||||||
int isStreamActive (void);
|
bool isStreamActive (void);
|
||||||
int isStreamStopped (void);
|
bool isStreamStopped (void);
|
||||||
|
|
||||||
int audioCallback (const void *, void *, unsigned long,
|
int audioCallback (const void *, void *, unsigned long,
|
||||||
const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags);
|
const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags);
|
||||||
|
|
||||||
inline RingBuffer* urgentRingBuffer(void) { return _urgentRingBuffer; }
|
inline RingBuffer &urgentRingBuffer(void) { return _urgentRingBuffer; }
|
||||||
inline RingBuffer* mainSndRingBuffer(void) { return _mainSndRingBuffer; }
|
inline RingBuffer &mainSndRingBuffer(void) { return _mainSndRingBuffer; }
|
||||||
inline RingBuffer* micRingBuffer(void) { return _micRingBuffer; }
|
inline RingBuffer &micRingBuffer(void) { return _micRingBuffer; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void closeStream (void);
|
void closeStream (void);
|
||||||
Manager* _manager;
|
RingBuffer _urgentRingBuffer;
|
||||||
RingBuffer* _urgentRingBuffer;
|
RingBuffer _mainSndRingBuffer;
|
||||||
RingBuffer* _mainSndRingBuffer;
|
RingBuffer _micRingBuffer;
|
||||||
RingBuffer* _micRingBuffer;
|
|
||||||
|
|
||||||
portaudio::MemFunCallbackStream<AudioLayer> *_stream;
|
portaudio::MemFunCallbackStream<AudioLayer> *_stream;
|
||||||
portaudio::AutoSystem *autoSys;
|
portaudio::AutoSystem autoSys;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _AUDIO_LAYER_H_
|
#endif // _AUDIO_LAYER_H_
|
||||||
|
@ -24,14 +24,14 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "../global.h"
|
||||||
|
#include "../manager.h"
|
||||||
#include "audiocodec.h"
|
#include "audiocodec.h"
|
||||||
#include "audiortp.h"
|
#include "audiortp.h"
|
||||||
#include "audiolayer.h"
|
#include "audiolayer.h"
|
||||||
#include "codecDescriptor.h"
|
#include "codecDescriptor.h"
|
||||||
#include "ringbuffer.h"
|
#include "ringbuffer.h"
|
||||||
#include "../configuration.h"
|
#include "../configuration.h"
|
||||||
#include "../manager.h"
|
|
||||||
#include "../global.h"
|
|
||||||
#include "../user_cfg.h"
|
#include "../user_cfg.h"
|
||||||
#include "../sipcall.h"
|
#include "../sipcall.h"
|
||||||
#include "../../stund/stun.h"
|
#include "../../stund/stun.h"
|
||||||
@ -43,9 +43,17 @@ using namespace std;
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AudioRtp
|
// AudioRtp
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
AudioRtp::AudioRtp (Manager *manager) {
|
AudioRtp::AudioRtp () {
|
||||||
_manager = manager;
|
string svr;
|
||||||
|
|
||||||
_RTXThread = NULL;
|
_RTXThread = NULL;
|
||||||
|
|
||||||
|
if (!Manager::instance().useStun() &&
|
||||||
|
get_config_fields_str(SIGNALISATION, PROXY).empty()) {
|
||||||
|
svr = get_config_fields_str(SIGNALISATION, PROXY);
|
||||||
|
} else {
|
||||||
|
svr = get_config_fields_str(SIGNALISATION, HOST_PART);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioRtp::~AudioRtp (void) {
|
AudioRtp::~AudioRtp (void) {
|
||||||
@ -56,18 +64,19 @@ int
|
|||||||
AudioRtp::createNewSession (SipCall *ca) {
|
AudioRtp::createNewSession (SipCall *ca) {
|
||||||
// Start RTP Send/Receive threads
|
// Start RTP Send/Receive threads
|
||||||
ca->enable_audio = 1;
|
ca->enable_audio = 1;
|
||||||
if (!_manager->useStun()) {
|
if (!Manager::instance().useStun()) {
|
||||||
_symetric = false;
|
_symetric = false;
|
||||||
} else {
|
} else {
|
||||||
_symetric = true;
|
_symetric = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_RTXThread = new AudioRtpRTX (ca, _manager->getAudioDriver(),
|
_RTXThread = new AudioRtpRTX (ca,
|
||||||
_manager, _symetric);
|
Manager::instance().getAudioDriver(),
|
||||||
|
_symetric);
|
||||||
|
|
||||||
// Start PortAudio
|
// Start PortAudio
|
||||||
_manager->getAudioDriver()->micRingBuffer()->flush();
|
Manager::instance().getAudioDriver()->micRingBuffer().flush();
|
||||||
_manager->getAudioDriver()->startStream();
|
Manager::instance().getAudioDriver()->startStream();
|
||||||
|
|
||||||
if (_RTXThread->start() != 0) {
|
if (_RTXThread->start() != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -89,18 +98,18 @@ AudioRtp::closeRtpSession (SipCall *ca) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop portaudio and flush ringbuffer
|
// Stop portaudio and flush ringbuffer
|
||||||
_manager->getAudioDriver()->stopStream();
|
Manager::instance().getAudioDriver()->stopStream();
|
||||||
_manager->getAudioDriver()->mainSndRingBuffer()->flush();
|
Manager::instance().getAudioDriver()->mainSndRingBuffer().flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AudioRtpRTX Class //
|
// AudioRtpRTX Class //
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
AudioRtpRTX::AudioRtpRTX (SipCall *sipcall, AudioLayer* driver,
|
AudioRtpRTX::AudioRtpRTX (SipCall *sipcall,
|
||||||
Manager *mngr, bool sym) {
|
AudioLayer* driver,
|
||||||
|
bool sym) {
|
||||||
time = new Time();
|
time = new Time();
|
||||||
_manager = mngr;
|
|
||||||
_ca = sipcall;
|
_ca = sipcall;
|
||||||
_sym =sym;
|
_sym =sym;
|
||||||
_audioDevice = driver;
|
_audioDevice = driver;
|
||||||
@ -197,14 +206,14 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m
|
|||||||
int k;
|
int k;
|
||||||
int compSize;
|
int compSize;
|
||||||
|
|
||||||
if (_manager->getCall(_ca->getId())->isOnMute() or
|
if (Manager::instance().getCall(_ca->getId())->isOnMute() or
|
||||||
!_manager->isCurrentId(_ca->getId())) {
|
!Manager::instance().isCurrentId(_ca->getId())) {
|
||||||
// Mute :send 0's over the network.
|
// Mute :send 0's over the network.
|
||||||
_manager->getAudioDriver()->micRingBuffer()->Get(data_from_mic,
|
Manager::instance().getAudioDriver()->micRingBuffer().Get(data_from_mic,
|
||||||
RTP_FRAMES2SEND*2*sizeof(int16));
|
RTP_FRAMES2SEND*2*sizeof(int16));
|
||||||
} else {
|
} else {
|
||||||
// Control volume for micro
|
// Control volume for micro
|
||||||
int availFromMic = _manager->getAudioDriver()->micRingBuffer()->AvailForGet();
|
int availFromMic = Manager::instance().getAudioDriver()->micRingBuffer().AvailForGet();
|
||||||
int bytesAvail;
|
int bytesAvail;
|
||||||
if (availFromMic < (int)RTP_FRAMES2SEND) {
|
if (availFromMic < (int)RTP_FRAMES2SEND) {
|
||||||
bytesAvail = availFromMic;
|
bytesAvail = availFromMic;
|
||||||
@ -213,7 +222,7 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get bytes from micRingBuffer to data_from_mic
|
// Get bytes from micRingBuffer to data_from_mic
|
||||||
_manager->getAudioDriver()->micRingBuffer()->Get(data_from_mic,
|
Manager::instance().getAudioDriver()->micRingBuffer().Get(data_from_mic,
|
||||||
SAMPLES_SIZE(bytesAvail));
|
SAMPLES_SIZE(bytesAvail));
|
||||||
// control volume and stereo->mono
|
// control volume and stereo->mono
|
||||||
for (int j = 0; j < RTP_FRAMES2SEND; j++) {
|
for (int j = 0; j < RTP_FRAMES2SEND; j++) {
|
||||||
@ -272,20 +281,20 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the current call is the call which is answered
|
// If the current call is the call which is answered
|
||||||
if (_manager->isCurrentId(_ca->getId())) {
|
if (Manager::instance().isCurrentId(_ca->getId())) {
|
||||||
// Set decoded data to sound device
|
// Set decoded data to sound device
|
||||||
_manager->getAudioDriver()->mainSndRingBuffer()->Put(data_for_speakers_tmp, SAMPLES_SIZE(RTP_FRAMES2SEND));
|
Manager::instance().getAudioDriver()->mainSndRingBuffer().Put(data_for_speakers_tmp, SAMPLES_SIZE(RTP_FRAMES2SEND));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify (with a bip) an incoming call when there is already a call
|
// Notify (with a bip) an incoming call when there is already a call
|
||||||
countTime += time->getSecond();
|
countTime += time->getSecond();
|
||||||
if (_manager->getNumberOfCalls() > 0 and _manager->getbRingtone()) {
|
if (Manager::instance().getNumberOfCalls() > 0 and Manager::instance().getbRingtone()) {
|
||||||
countTime = countTime % 2000;
|
countTime = countTime % 2000;
|
||||||
if (countTime < 10 and countTime > 0) {
|
if (countTime < 10 and countTime > 0) {
|
||||||
_manager->notificationIncomingCall();
|
Manager::instance().notificationIncomingCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_manager->getAudioDriver()->startStream();
|
Manager::instance().getAudioDriver()->startStream();
|
||||||
|
|
||||||
delete cd;
|
delete cd;
|
||||||
delete adu;
|
delete adu;
|
||||||
@ -326,9 +335,8 @@ AudioRtpRTX::run (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (_ca->enable_audio != -1) {
|
while (_ca->enable_audio != -1) {
|
||||||
// Store volume values
|
micVolume = Manager::instance().getMicroVolume();
|
||||||
micVolume = _manager->getMicroVolume();
|
spkrVolume = Manager::instance().getSpkrVolume();
|
||||||
spkrVolume = _manager->getSpkrVolume();
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Send session
|
// Send session
|
||||||
|
@ -32,7 +32,6 @@ using namespace ost;
|
|||||||
#define SIZEDATA SAMPLES_SIZE(RTP_FRAMES2SEND)
|
#define SIZEDATA SAMPLES_SIZE(RTP_FRAMES2SEND)
|
||||||
|
|
||||||
class AudioLayer;
|
class AudioLayer;
|
||||||
class Manager;
|
|
||||||
class SipCall;
|
class SipCall;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -40,7 +39,7 @@ class SipCall;
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class AudioRtpRTX : public Thread, public TimerPort {
|
class AudioRtpRTX : public Thread, public TimerPort {
|
||||||
public:
|
public:
|
||||||
AudioRtpRTX (SipCall *, AudioLayer*, Manager *, bool);
|
AudioRtpRTX (SipCall *, AudioLayer*, bool);
|
||||||
~AudioRtpRTX();
|
~AudioRtpRTX();
|
||||||
|
|
||||||
Time *time; // For incoming call notification
|
Time *time; // For incoming call notification
|
||||||
@ -52,7 +51,6 @@ private:
|
|||||||
RTPSession* _sessionSend;
|
RTPSession* _sessionSend;
|
||||||
RTPSession* _sessionRecv;
|
RTPSession* _sessionRecv;
|
||||||
SymmetricRTPSession* _session;
|
SymmetricRTPSession* _session;
|
||||||
Manager* _manager;
|
|
||||||
bool _sym;
|
bool _sym;
|
||||||
|
|
||||||
void initAudioRtpSession (void);
|
void initAudioRtpSession (void);
|
||||||
@ -65,15 +63,14 @@ private:
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class AudioRtp {
|
class AudioRtp {
|
||||||
public:
|
public:
|
||||||
AudioRtp (Manager *);
|
AudioRtp();
|
||||||
~AudioRtp (void);
|
~AudioRtp();
|
||||||
|
|
||||||
int createNewSession (SipCall *);
|
int createNewSession (SipCall *);
|
||||||
void closeRtpSession (SipCall *);
|
void closeRtpSession (SipCall *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioRtpRTX* _RTXThread;
|
AudioRtpRTX* _RTXThread;
|
||||||
Manager* _manager;
|
|
||||||
bool _symetric;
|
bool _symetric;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ DTMFGenerator::~DTMFGenerator() {
|
|||||||
void DTMFGenerator::getSamples(int16* buffer, size_t n, unsigned char code) throw(DTMFException) {
|
void DTMFGenerator::getSamples(int16* buffer, size_t n, unsigned char code) throw(DTMFException) {
|
||||||
size_t i;
|
size_t i;
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
throw DTMFException("Invalid parameter value");
|
throw DTMFException("Invalid parameter value");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(code) {
|
switch(code) {
|
||||||
@ -142,17 +142,15 @@ void DTMFGenerator::getNextSamples(int16* buffer, size_t n) throw(DTMFException)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
throw DTMFException("Invalid parameter");
|
throw DTMFException("Invalid parameter");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.sample == 0) {
|
if (state.sample == 0) {
|
||||||
throw DTMFException("DTMF generator not initialized");
|
throw DTMFException("DTMF generator not initialized");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
buffer[i] = state.sample[(state.offset + i) % SAMPLING_RATE];
|
buffer[i] = state.sample[(state.offset + i) % SAMPLING_RATE];
|
||||||
}
|
}
|
||||||
|
|
||||||
state.offset = (state.offset + i) % SAMPLING_RATE;
|
state.offset = (state.offset + i) % SAMPLING_RATE;
|
||||||
|
@ -41,8 +41,7 @@ int AMPLITUDE = 8192;
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ToneThread implementation
|
// ToneThread implementation
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
ToneThread::ToneThread (Manager *mngr, int16 *buf, int size) : Thread () {
|
ToneThread::ToneThread (int16 *buf, int size) : Thread () {
|
||||||
this->mngr = mngr;
|
|
||||||
this->buffer = buf;
|
this->buffer = buf;
|
||||||
this->size = size;
|
this->size = size;
|
||||||
this->buf_ctrl_vol = new int16[size*CHANNELS];
|
this->buf_ctrl_vol = new int16[size*CHANNELS];
|
||||||
@ -56,19 +55,19 @@ void
|
|||||||
ToneThread::run (void) {
|
ToneThread::run (void) {
|
||||||
int k;
|
int k;
|
||||||
int spkrVolume;
|
int spkrVolume;
|
||||||
while (mngr->getZonetone()) {
|
while (Manager::instance().getZonetone()) {
|
||||||
spkrVolume = mngr->getSpkrVolume();
|
spkrVolume = Manager::instance().getSpkrVolume();
|
||||||
// control volume + mono->stereo
|
// control volume + mono->stereo
|
||||||
for (int j = 0; j < size; j++) {
|
for (int j = 0; j < size; j++) {
|
||||||
k = j*2;
|
k = j*2;
|
||||||
buf_ctrl_vol[k] = buf_ctrl_vol[k+1] = buffer[j] * spkrVolume/100;
|
buf_ctrl_vol[k] = buf_ctrl_vol[k+1] = buffer[j] * spkrVolume/100;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mngr->getAudioDriver()->mainSndRingBuffer()->Len() == 0) {
|
if (Manager::instance().getAudioDriver()->mainSndRingBuffer().Len() == 0) {
|
||||||
mngr->getAudioDriver()->mainSndRingBuffer()->Put(buf_ctrl_vol,
|
Manager::instance().getAudioDriver()->mainSndRingBuffer().Put(buf_ctrl_vol,
|
||||||
SAMPLES_SIZE(size));
|
SAMPLES_SIZE(size));
|
||||||
}
|
}
|
||||||
mngr->getAudioDriver()->startStream();
|
Manager::instance().getAudioDriver()->startStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,20 +75,12 @@ ToneThread::run (void) {
|
|||||||
// ToneGenerator implementation
|
// ToneGenerator implementation
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ToneGenerator::ToneGenerator (Manager *mngr) {
|
|
||||||
this->initTone();
|
|
||||||
this->manager = mngr;
|
|
||||||
buf = new int16[SIZEBUF];
|
|
||||||
tonethread = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ToneGenerator::ToneGenerator () {
|
ToneGenerator::ToneGenerator () {
|
||||||
this->initTone();
|
this->initTone();
|
||||||
tonethread = NULL;
|
tonethread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToneGenerator::~ToneGenerator (void) {
|
ToneGenerator::~ToneGenerator (void) {
|
||||||
delete[] buf;
|
|
||||||
delete tonethread;
|
delete tonethread;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,13 +247,13 @@ ToneGenerator::toneHandle (int idr) {
|
|||||||
|
|
||||||
// New thread for the tone
|
// New thread for the tone
|
||||||
if (tonethread == NULL) {
|
if (tonethread == NULL) {
|
||||||
tonethread = new ToneThread (manager, buf, totalbytes);
|
tonethread = new ToneThread (buf, totalbytes);
|
||||||
tonethread->start();
|
tonethread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!manager->getZonetone()) {
|
if (!Manager::instance().getZonetone()) {
|
||||||
manager->getAudioDriver()->stopStream();
|
Manager::instance().getAudioDriver()->stopStream();
|
||||||
manager->getAudioDriver()->mainSndRingBuffer()->flush();
|
Manager::instance().getAudioDriver()->mainSndRingBuffer().flush();
|
||||||
if (tonethread != NULL) {
|
if (tonethread != NULL) {
|
||||||
delete tonethread;
|
delete tonethread;
|
||||||
tonethread = NULL;
|
tonethread = NULL;
|
||||||
@ -305,12 +296,12 @@ ToneGenerator::playRingtone (const char *fileName) {
|
|||||||
expandedsize = ulaw->codecDecode (dst, (unsigned char *)src, length);
|
expandedsize = ulaw->codecDecode (dst, (unsigned char *)src, length);
|
||||||
|
|
||||||
if (tonethread == NULL) {
|
if (tonethread == NULL) {
|
||||||
tonethread = new ToneThread (manager, (int16*)dst, expandedsize);
|
tonethread = new ToneThread ((int16*)dst, expandedsize);
|
||||||
tonethread->start();
|
tonethread->start();
|
||||||
}
|
}
|
||||||
if (!manager->getZonetone()) {
|
if (!Manager::instance().getZonetone()) {
|
||||||
manager->getAudioDriver()->stopStream();
|
Manager::instance().getAudioDriver()->stopStream();
|
||||||
manager->getAudioDriver()->mainSndRingBuffer()->flush();
|
Manager::instance().getAudioDriver()->mainSndRingBuffer().flush();
|
||||||
if (tonethread != NULL) {
|
if (tonethread != NULL) {
|
||||||
delete tonethread;
|
delete tonethread;
|
||||||
tonethread = NULL;
|
tonethread = NULL;
|
||||||
|
@ -51,12 +51,11 @@ using namespace ost;
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class ToneThread : public Thread {
|
class ToneThread : public Thread {
|
||||||
public:
|
public:
|
||||||
ToneThread (Manager *, int16 *, int);
|
ToneThread (int16 *, int);
|
||||||
~ToneThread (void);
|
virtual ~ToneThread (void);
|
||||||
|
|
||||||
virtual void run ();
|
virtual void run ();
|
||||||
private:
|
private:
|
||||||
Manager* mngr;
|
|
||||||
int16* buffer;
|
int16* buffer;
|
||||||
int16* buf_ctrl_vol;
|
int16* buf_ctrl_vol;
|
||||||
int size;
|
int size;
|
||||||
@ -67,7 +66,6 @@ private:
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class ToneGenerator {
|
class ToneGenerator {
|
||||||
public:
|
public:
|
||||||
ToneGenerator (Manager *);
|
|
||||||
ToneGenerator ();
|
ToneGenerator ();
|
||||||
~ToneGenerator (void);
|
~ToneGenerator (void);
|
||||||
|
|
||||||
@ -86,7 +84,7 @@ public:
|
|||||||
int time;
|
int time;
|
||||||
int totalbytes;
|
int totalbytes;
|
||||||
|
|
||||||
int16 *buf;
|
int16 buf[SIZEBUF];
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
* Initialisation of the supported tones according to the countries.
|
* Initialisation of the supported tones according to the countries.
|
||||||
@ -102,7 +100,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
int contains(const string& str, char c);
|
int contains(const string& str, char c);
|
||||||
|
|
||||||
Manager* manager;
|
|
||||||
ToneThread* tonethread;
|
ToneThread* tonethread;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -25,12 +25,11 @@
|
|||||||
#include "voIPLink.h"
|
#include "voIPLink.h"
|
||||||
|
|
||||||
|
|
||||||
Call::Call (Manager* manager, short id, CallType type, VoIPLink* voiplink)
|
Call::Call (short id, CallType type, VoIPLink* voiplink)
|
||||||
{
|
{
|
||||||
initConstructor();
|
initConstructor();
|
||||||
_id = id;
|
_id = id;
|
||||||
_type = type;
|
_type = type;
|
||||||
_manager = manager;
|
|
||||||
_voIPLink = voiplink;
|
_voIPLink = voiplink;
|
||||||
|
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
|
@ -48,12 +48,11 @@ enum CallType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Manager;
|
|
||||||
class VoIPLink;
|
class VoIPLink;
|
||||||
|
|
||||||
class Call {
|
class Call {
|
||||||
public:
|
public:
|
||||||
Call(Manager* manager, short id, CallType type, VoIPLink* voiplink);
|
Call(short id, CallType type, VoIPLink* voiplink);
|
||||||
|
|
||||||
~Call(void);
|
~Call(void);
|
||||||
|
|
||||||
@ -111,7 +110,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void initConstructor (void);
|
void initConstructor (void);
|
||||||
|
|
||||||
Manager* _manager;
|
|
||||||
VoIPLink* _voIPLink;
|
VoIPLink* _voIPLink;
|
||||||
|
|
||||||
short _id;
|
short _id;
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Error::Error (Manager *mngr){
|
Error::Error (){
|
||||||
_mngr = mngr;
|
|
||||||
issetError = 0;
|
issetError = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,31 +35,31 @@ Error::errorName (Error_enum num_name) {
|
|||||||
switch (num_name){
|
switch (num_name){
|
||||||
// Handle opening device errors
|
// Handle opening device errors
|
||||||
case OPEN_FAILED_DEVICE:
|
case OPEN_FAILED_DEVICE:
|
||||||
_mngr->displayErrorText("Open device failed ");
|
Manager::instance().displayErrorText("Open device failed ");
|
||||||
issetError = 2;
|
issetError = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Handle setup errors
|
// Handle setup errors
|
||||||
case HOST_PART_FIELD_EMPTY:
|
case HOST_PART_FIELD_EMPTY:
|
||||||
_mngr->displayError("Fill host part field");
|
Manager::instance().displayError("Fill host part field");
|
||||||
issetError = 2;
|
issetError = 2;
|
||||||
break;
|
break;
|
||||||
case USER_PART_FIELD_EMPTY:
|
case USER_PART_FIELD_EMPTY:
|
||||||
_mngr->displayError("Fill user part field");
|
Manager::instance().displayError("Fill user part field");
|
||||||
issetError = 2;
|
issetError = 2;
|
||||||
break;
|
break;
|
||||||
case PASSWD_FIELD_EMPTY:
|
case PASSWD_FIELD_EMPTY:
|
||||||
_mngr->displayError("Fill password field");
|
Manager::instance().displayError("Fill password field");
|
||||||
issetError = 2;
|
issetError = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Handle sip uri
|
// Handle sip uri
|
||||||
case FROM_ERROR:
|
case FROM_ERROR:
|
||||||
_mngr->displayError("Error for 'From' header");
|
Manager::instance().displayError("Error for 'From' header");
|
||||||
issetError = 1;
|
issetError = 1;
|
||||||
break;
|
break;
|
||||||
case TO_ERROR:
|
case TO_ERROR:
|
||||||
_mngr->displayError("Error for 'To' header");
|
Manager::instance().displayError("Error for 'To' header");
|
||||||
issetError = 1;
|
issetError = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -35,10 +35,9 @@ typedef enum {
|
|||||||
|
|
||||||
} Error_enum;
|
} Error_enum;
|
||||||
|
|
||||||
class Manager;
|
|
||||||
class Error {
|
class Error {
|
||||||
public:
|
public:
|
||||||
Error (Manager *mngr);
|
Error ();
|
||||||
~Error (void) {};
|
~Error (void) {};
|
||||||
|
|
||||||
int errorName (Error_enum);
|
int errorName (Error_enum);
|
||||||
@ -46,7 +45,6 @@ public:
|
|||||||
inline void setError(int err) { issetError = err; }
|
inline void setError(int err) { issetError = err; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Manager *_mngr;
|
|
||||||
int issetError;
|
int issetError;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -5,4 +5,5 @@ noinst_LTLIBRARIES = libguiframework.la
|
|||||||
libguiframework_la_SOURCES = \
|
libguiframework_la_SOURCES = \
|
||||||
guiframework.cpp guiframework.h
|
guiframework.cpp guiframework.h
|
||||||
|
|
||||||
|
libguiframework_la_CXXFLAGS = $(libccext2_CFLAGS)
|
||||||
libguiframework_la_LIBADD = qt/libsflphoneqt.la
|
libguiframework_la_LIBADD = qt/libsflphoneqt.la
|
@ -23,23 +23,21 @@ using namespace std;
|
|||||||
#include "guiframework.h"
|
#include "guiframework.h"
|
||||||
#include "../manager.h"
|
#include "../manager.h"
|
||||||
|
|
||||||
GuiFramework::GuiFramework (Manager* manager)
|
GuiFramework::GuiFramework ()
|
||||||
{
|
{}
|
||||||
_manager = manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiFramework::~GuiFramework (void) {}
|
GuiFramework::~GuiFramework (void) {}
|
||||||
|
|
||||||
int
|
int
|
||||||
GuiFramework::outgoingCall (const string& to)
|
GuiFramework::outgoingCall (const string& to)
|
||||||
{
|
{
|
||||||
return _manager->outgoingCall(to);
|
return Manager::instance().outgoingCall(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
GuiFramework::hangupCall (short id)
|
GuiFramework::hangupCall (short id)
|
||||||
{
|
{
|
||||||
if (_manager->hangupCall(id) == 0) {
|
if (Manager::instance().hangupCall(id) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -49,7 +47,7 @@ GuiFramework::hangupCall (short id)
|
|||||||
int
|
int
|
||||||
GuiFramework::cancelCall (short id)
|
GuiFramework::cancelCall (short id)
|
||||||
{
|
{
|
||||||
if (_manager->cancelCall(id) == 0) {
|
if (Manager::instance().cancelCall(id) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -59,7 +57,7 @@ GuiFramework::cancelCall (short id)
|
|||||||
int
|
int
|
||||||
GuiFramework::answerCall (short id)
|
GuiFramework::answerCall (short id)
|
||||||
{
|
{
|
||||||
if (_manager->answerCall(id) == 0) {
|
if (Manager::instance().answerCall(id)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -69,7 +67,7 @@ GuiFramework::answerCall (short id)
|
|||||||
int
|
int
|
||||||
GuiFramework::onHoldCall (short id)
|
GuiFramework::onHoldCall (short id)
|
||||||
{
|
{
|
||||||
if (_manager->onHoldCall(id) == 0) {
|
if (Manager::instance().onHoldCall(id) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -79,7 +77,7 @@ GuiFramework::onHoldCall (short id)
|
|||||||
int
|
int
|
||||||
GuiFramework::offHoldCall (short id)
|
GuiFramework::offHoldCall (short id)
|
||||||
{
|
{
|
||||||
if (_manager->offHoldCall(id) == 0) {
|
if (Manager::instance().offHoldCall(id) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -89,7 +87,7 @@ GuiFramework::offHoldCall (short id)
|
|||||||
int
|
int
|
||||||
GuiFramework::transferCall (short id, const string& to)
|
GuiFramework::transferCall (short id, const string& to)
|
||||||
{
|
{
|
||||||
if (_manager->transferCall(id, to) == 1) {
|
if (Manager::instance().transferCall(id, to) == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -99,19 +97,19 @@ GuiFramework::transferCall (short id, const string& to)
|
|||||||
void
|
void
|
||||||
GuiFramework::muteOn (short id)
|
GuiFramework::muteOn (short id)
|
||||||
{
|
{
|
||||||
_manager->muteOn(id);
|
Manager::instance().muteOn(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GuiFramework::muteOff (short id)
|
GuiFramework::muteOff (short id)
|
||||||
{
|
{
|
||||||
_manager->muteOff(id);
|
Manager::instance().muteOff(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
GuiFramework::refuseCall (short id)
|
GuiFramework::refuseCall (short id)
|
||||||
{
|
{
|
||||||
if (_manager->refuseCall(id) == 0) {
|
if (Manager::instance().refuseCall(id) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -121,7 +119,7 @@ GuiFramework::refuseCall (short id)
|
|||||||
int
|
int
|
||||||
GuiFramework::saveConfig (void)
|
GuiFramework::saveConfig (void)
|
||||||
{
|
{
|
||||||
if (_manager->saveConfig()) {
|
if (Manager::instance().saveConfig()) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -131,7 +129,7 @@ GuiFramework::saveConfig (void)
|
|||||||
int
|
int
|
||||||
GuiFramework::registerVoIPLink (void)
|
GuiFramework::registerVoIPLink (void)
|
||||||
{
|
{
|
||||||
if (_manager->registerVoIPLink()) {
|
if (Manager::instance().registerVoIPLink()) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -141,26 +139,26 @@ GuiFramework::registerVoIPLink (void)
|
|||||||
void
|
void
|
||||||
GuiFramework::sendDtmf (short id, char code)
|
GuiFramework::sendDtmf (short id, char code)
|
||||||
{
|
{
|
||||||
_manager->sendDtmf(id, code);
|
Manager::instance().sendDtmf(id, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
GuiFramework::quitApplication (void)
|
GuiFramework::quitApplication (void)
|
||||||
{
|
{
|
||||||
return (_manager->quitApplication() ? 1 : 0);
|
return (Manager::instance().quitApplication() ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
GuiFramework::sendTextMessage (short id, const string& message)
|
GuiFramework::sendTextMessage (short id, const string& message)
|
||||||
{
|
{
|
||||||
_manager->sendTextMessage(id, message);
|
Manager::instance().sendTextMessage(id, message);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
GuiFramework::accessToDirectory (void)
|
GuiFramework::accessToDirectory (void)
|
||||||
{
|
{
|
||||||
_manager->accessToDirectory();
|
Manager::instance().accessToDirectory();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Manager;
|
|
||||||
class GuiFramework {
|
class GuiFramework {
|
||||||
public:
|
public:
|
||||||
GuiFramework (Manager* manager);
|
GuiFramework ();
|
||||||
virtual ~GuiFramework (void);
|
virtual ~GuiFramework (void);
|
||||||
|
|
||||||
/* Parent class to child class */
|
/* Parent class to child class */
|
||||||
@ -69,8 +68,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
string _message;
|
string _message;
|
||||||
|
|
||||||
private:
|
|
||||||
Manager* _manager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GUI_FRAMEWORK_H__
|
#endif // __GUI_FRAMEWORK_H__
|
||||||
|
@ -33,10 +33,11 @@ libsflphoneqt_la_SOURCES = \
|
|||||||
CLEANFILES = \
|
CLEANFILES = \
|
||||||
$(BUILT_SOURCES)
|
$(BUILT_SOURCES)
|
||||||
|
|
||||||
libsflphoneqt_la_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\"
|
libsflphoneqt_la_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(portaudio_CFLAGS)
|
||||||
|
libsflphoneqt_la_LIBADD = $(portaudio_LIBS)
|
||||||
|
|
||||||
KDE_CXXFLAGS = $(USE_EXCEPTIONS)
|
KDE_CXXFLAGS = $(USE_EXCEPTIONS)
|
||||||
AM_CPPFLAGS = -I../../audio/pacpp/include/ $(QT_INCLUDES) $(X_INCLUDES)
|
AM_CPPFLAGS = -I../../audio/pacpp/include/ $(QT_INCLUDES) $(X_INCLUDES) $(libccext2_CFLAGS) $(portaudio_CFLAGS)
|
||||||
|
|
||||||
|
|
||||||
%.h: %.ui
|
%.h: %.ui
|
||||||
|
@ -65,13 +65,13 @@ void ConfigurationPanel::init()
|
|||||||
const char* hostapiname;
|
const char* hostapiname;
|
||||||
|
|
||||||
int top = 0;
|
int top = 0;
|
||||||
device_t devStruct;
|
AudioDevice devStruct;
|
||||||
|
|
||||||
portaudio::AutoSystem autoSys;
|
portaudio::AutoSystem autoSys;
|
||||||
// For each device
|
// For each device
|
||||||
for (int i = 0; i < Manager::deviceCount(); i++) {
|
for (int i = 0; i < Manager::instance().deviceCount(); i++) {
|
||||||
// Fill the device structure
|
// Fill the device structure
|
||||||
devStruct = Manager::deviceList(i);
|
devStruct = Manager::instance().deviceList(i);
|
||||||
hostapiname = devStruct.hostApiName;
|
hostapiname = devStruct.hostApiName;
|
||||||
devicename = devStruct.deviceName;
|
devicename = devStruct.deviceName;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ void ConfigurationPanel::init()
|
|||||||
QToolTip::add(device , devicename );
|
QToolTip::add(device , devicename );
|
||||||
|
|
||||||
top += 30;
|
top += 30;
|
||||||
if (Manager::defaultDevice(i)) {
|
if (Manager::instance().defaultDevice(i)) {
|
||||||
device->setChecked(true);
|
device->setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,12 +96,12 @@ MyTrayIcon::mousePressEvent (QMouseEvent *e)
|
|||||||
* Default Constructor
|
* Default Constructor
|
||||||
* Init, Connections
|
* Init, Connections
|
||||||
*/
|
*/
|
||||||
QtGUIMainWindow::QtGUIMainWindow (QWidget *parent, const char *name, WFlags f,
|
QtGUIMainWindow::QtGUIMainWindow (QWidget *parent,
|
||||||
Manager *mngr)
|
const char *name,
|
||||||
: TransQWidget (parent, name, f),
|
WFlags f)
|
||||||
GuiFramework(mngr) {
|
: TransQWidget (parent, name, f),
|
||||||
|
GuiFramework() {
|
||||||
for (int i = 0; i < NUMBER_OF_LINES; i++) {
|
for (int i = 0; i < NUMBER_OF_LINES; i++) {
|
||||||
phLines[i] = new PhoneLine();
|
phLines[i] = new PhoneLine();
|
||||||
phLines[i]->setState(FREE);
|
phLines[i]->setState(FREE);
|
||||||
_TabIncomingCalls[i] = -1;
|
_TabIncomingCalls[i] = -1;
|
||||||
@ -113,8 +113,6 @@ QtGUIMainWindow::QtGUIMainWindow (QWidget *parent, const char *name, WFlags f,
|
|||||||
// URL input dialog
|
// URL input dialog
|
||||||
_urlinput = new URL_Input (this);
|
_urlinput = new URL_Input (this);
|
||||||
|
|
||||||
// For managing
|
|
||||||
_callmanager = mngr;
|
|
||||||
|
|
||||||
// For DTMF
|
// For DTMF
|
||||||
_key = new DTMF ();
|
_key = new DTMF ();
|
||||||
@ -190,7 +188,6 @@ QtGUIMainWindow::~QtGUIMainWindow(void) {
|
|||||||
delete _keypad;
|
delete _keypad;
|
||||||
delete _lcd;
|
delete _lcd;
|
||||||
delete _urlinput;
|
delete _urlinput;
|
||||||
delete _callmanager;
|
|
||||||
delete _mypop;
|
delete _mypop;
|
||||||
delete _trayicon;
|
delete _trayicon;
|
||||||
delete pt;
|
delete pt;
|
||||||
@ -343,8 +340,8 @@ QtGUIMainWindow::initMicVolumePosition (void) {
|
|||||||
void
|
void
|
||||||
QtGUIMainWindow::initVolume (void)
|
QtGUIMainWindow::initVolume (void)
|
||||||
{
|
{
|
||||||
_callmanager->setSpkrVolume(spkrVolVector->Y() - vol_spkr_y);
|
Manager::instance().setSpkrVolume(spkrVolVector->Y() - vol_spkr_y);
|
||||||
_callmanager->setMicroVolume(micVolVector->Y() - vol_mic_y);
|
Manager::instance().setMicroVolume(micVolVector->Y() - vol_mic_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -618,14 +615,14 @@ QtGUIMainWindow::putOnHoldBusyLine (int line)
|
|||||||
|
|
||||||
void
|
void
|
||||||
QtGUIMainWindow::dialtone (bool var) {
|
QtGUIMainWindow::dialtone (bool var) {
|
||||||
if (_callmanager->isDriverLoaded()) {
|
if (Manager::instance().isDriverLoaded()) {
|
||||||
if (_dialtone != var) {
|
if (_dialtone != var) {
|
||||||
_dialtone = var;
|
_dialtone = var;
|
||||||
}
|
}
|
||||||
_callmanager->setZonetone(var);
|
Manager::instance().setZonetone(var);
|
||||||
_callmanager->getTonegenerator()->toneHandle(ZT_TONE_DIALTONE);
|
Manager::instance().getTonegenerator()->toneHandle(ZT_TONE_DIALTONE);
|
||||||
} else {
|
} else {
|
||||||
_callmanager->error()->errorName(OPEN_FAILED_DEVICE);
|
Manager::instance().error()->errorName(OPEN_FAILED_DEVICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,8 +668,8 @@ QtGUIMainWindow::callIsBusy (Call* call, int id, int line, int busyLine)
|
|||||||
changeLineStatePixmap(line, ONHOLD);
|
changeLineStatePixmap(line, ONHOLD);
|
||||||
displayStatus(ONHOLD_STATUS);
|
displayStatus(ONHOLD_STATUS);
|
||||||
if (qt_onHoldCall(id) != 1) {
|
if (qt_onHoldCall(id) != 1) {
|
||||||
_callmanager->displayErrorText("On-hold call failed !\n");
|
Manager::instance().displayErrorText("On-hold call failed !\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -691,7 +688,7 @@ QtGUIMainWindow::callIsOnHold(int id, int line, int busyLine)
|
|||||||
}
|
}
|
||||||
_lcd->setInFunction(true);
|
_lcd->setInFunction(true);
|
||||||
if (qt_offHoldCall(id) != 1) {
|
if (qt_offHoldCall(id) != 1) {
|
||||||
_callmanager->displayErrorText("Off-hold call failed !\n");
|
Manager::instance().displayErrorText("Off-hold call failed !\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
displayContext(id);
|
displayContext(id);
|
||||||
@ -704,7 +701,7 @@ QtGUIMainWindow::callIsIncoming (int id, int line, int busyLine)
|
|||||||
changeLineStatePixmap(line, BUSY);
|
changeLineStatePixmap(line, BUSY);
|
||||||
putOnHoldBusyLine(busyLine);
|
putOnHoldBusyLine(busyLine);
|
||||||
if (qt_answerCall(id) != 1) {
|
if (qt_answerCall(id) != 1) {
|
||||||
_callmanager->displayErrorText("Answered call failed !\n");
|
Manager::instance().displayErrorText("Answered call failed !\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -737,7 +734,7 @@ QtGUIMainWindow::clickOnFreeLine(int line, int busyLine)
|
|||||||
Call*
|
Call*
|
||||||
QtGUIMainWindow::getCall (short id)
|
QtGUIMainWindow::getCall (short id)
|
||||||
{
|
{
|
||||||
return _callmanager->getCall(id);
|
return Manager::instance().getCall(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -842,7 +839,7 @@ QtGUIMainWindow::peerAnsweredCall (short id)
|
|||||||
getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));
|
getPhoneLine(id)->setStatus(QString(getCall(id)->getStatus()));
|
||||||
// Afficher call-timer
|
// Afficher call-timer
|
||||||
startCallTimer(id);
|
startCallTimer(id);
|
||||||
_callmanager->displayStatus(CONNECTED_STATUS);
|
Manager::instance().displayStatus(CONNECTED_STATUS);
|
||||||
setChooseLine(false);
|
setChooseLine(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,7 +858,7 @@ QtGUIMainWindow::peerHungupCall (short id)
|
|||||||
|
|
||||||
if (line == getCurrentLine() or getCurrentLine() == -1) {
|
if (line == getCurrentLine() or getCurrentLine() == -1) {
|
||||||
stopCallTimer(id);
|
stopCallTimer(id);
|
||||||
_callmanager->displayStatus(HUNGUP_STATUS);
|
Manager::instance().displayStatus(HUNGUP_STATUS);
|
||||||
setCurrentLine(-1);
|
setCurrentLine(-1);
|
||||||
} else {
|
} else {
|
||||||
// Stop the call timer when hang up
|
// Stop the call timer when hang up
|
||||||
@ -951,12 +948,12 @@ QtGUIMainWindow::qt_outgoingCall (void)
|
|||||||
int id;
|
int id;
|
||||||
int line = -1;
|
int line = -1;
|
||||||
if (_lcd->getTextBuffer() == NULL) {
|
if (_lcd->getTextBuffer() == NULL) {
|
||||||
_callmanager->displayStatus(ENTER_NUMBER_STATUS);
|
Manager::instance().displayStatus(ENTER_NUMBER_STATUS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const string to(_lcd->getTextBuffer().ascii());
|
const string to(_lcd->getTextBuffer().ascii());
|
||||||
if (to.empty()) {
|
if (to.empty()) {
|
||||||
_callmanager->displayStatus(ENTER_NUMBER_STATUS);
|
Manager::instance().displayStatus(ENTER_NUMBER_STATUS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,7 +964,7 @@ QtGUIMainWindow::qt_outgoingCall (void)
|
|||||||
|
|
||||||
setCurrentLine(line);
|
setCurrentLine(line);
|
||||||
displayStatus(TRYING_STATUS);
|
displayStatus(TRYING_STATUS);
|
||||||
_callmanager->getCall(id)->setCallerIdNumber(to);
|
Manager::instance().getCall(id)->setCallerIdNumber(to);
|
||||||
changeLineStatePixmap(line, BUSY);
|
changeLineStatePixmap(line, BUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1156,7 +1153,7 @@ QtGUIMainWindow::dial (void)
|
|||||||
} else if (getTransfer()){
|
} else if (getTransfer()){
|
||||||
// If call transfer
|
// If call transfer
|
||||||
if(qt_transferCall (line2id(getCurrentLine()) != 1)) {
|
if(qt_transferCall (line2id(getCurrentLine()) != 1)) {
|
||||||
_callmanager->displayErrorText("Transfer failed !\n");
|
Manager::instance().displayErrorText("Transfer failed !\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If new outgoing call
|
// If new outgoing call
|
||||||
@ -1181,15 +1178,15 @@ QtGUIMainWindow::hangupLine (void)
|
|||||||
int line = getCurrentLine();
|
int line = getCurrentLine();
|
||||||
int id = phLines[line]->getCallId();
|
int id = phLines[line]->getCallId();
|
||||||
|
|
||||||
if (_callmanager->getbCongestion()) {
|
if (Manager::instance().getbCongestion()) {
|
||||||
// If congestion tone
|
// If congestion tone
|
||||||
if (qt_hangupCall(id)) {
|
if (qt_hangupCall(id)) {
|
||||||
changeLineStatePixmap(line, FREE);
|
changeLineStatePixmap(line, FREE);
|
||||||
_lcd->clear(QString(ENTER_NUMBER_STATUS));
|
_lcd->clear(QString(ENTER_NUMBER_STATUS));
|
||||||
_callmanager->congestion(false);
|
Manager::instance().congestion(false);
|
||||||
phLines[line]->setCallId(0);
|
phLines[line]->setCallId(0);
|
||||||
} else {
|
} else {
|
||||||
_callmanager->displayErrorText("Hangup call failed !\n");
|
Manager::instance().displayErrorText("Hangup call failed !\n");
|
||||||
}
|
}
|
||||||
} else if (line >= 0 and id > 0 and getCall(id)->isProgressing()) {
|
} else if (line >= 0 and id > 0 and getCall(id)->isProgressing()) {
|
||||||
// If I want to cancel a call before ringing.
|
// If I want to cancel a call before ringing.
|
||||||
@ -1198,7 +1195,7 @@ QtGUIMainWindow::hangupLine (void)
|
|||||||
phLines[line]->setCallId(0);
|
phLines[line]->setCallId(0);
|
||||||
setChooseLine(false);
|
setChooseLine(false);
|
||||||
} else {
|
} else {
|
||||||
_callmanager->displayErrorText("Cancelled call failed !\n");
|
Manager::instance().displayErrorText("Cancelled call failed !\n");
|
||||||
}
|
}
|
||||||
} else if (line >= 0 and id > 0) {
|
} else if (line >= 0 and id > 0) {
|
||||||
// If hangup current line normally
|
// If hangup current line normally
|
||||||
@ -1208,7 +1205,7 @@ QtGUIMainWindow::hangupLine (void)
|
|||||||
phLines[line]->setCallId(0);
|
phLines[line]->setCallId(0);
|
||||||
setChooseLine(false);
|
setChooseLine(false);
|
||||||
} else {
|
} else {
|
||||||
_callmanager->displayErrorText("Hangup call failed !\n");
|
Manager::instance().displayErrorText("Hangup call failed !\n");
|
||||||
}
|
}
|
||||||
} else if ((i = isThereIncomingCall()) > 0){
|
} else if ((i = isThereIncomingCall()) > 0){
|
||||||
// To refuse new incoming call
|
// To refuse new incoming call
|
||||||
@ -1216,7 +1213,7 @@ QtGUIMainWindow::hangupLine (void)
|
|||||||
if (qt_refuseCall(i)) {
|
if (qt_refuseCall(i)) {
|
||||||
changeLineStatePixmap(id2line(i), FREE);
|
changeLineStatePixmap(id2line(i), FREE);
|
||||||
} else {
|
} else {
|
||||||
_callmanager->displayErrorText("Refused call failed !\n");
|
Manager::instance().displayErrorText("Refused call failed !\n");
|
||||||
}
|
}
|
||||||
} else if (line >= 0) {
|
} else if (line >= 0) {
|
||||||
_debug("Just load free pixmap for the line %d\n", line);
|
_debug("Just load free pixmap for the line %d\n", line);
|
||||||
@ -1274,12 +1271,12 @@ QtGUIMainWindow::startCallTimer (short id) {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void
|
void
|
||||||
QtGUIMainWindow::volumeSpkrChanged (int val) {
|
QtGUIMainWindow::volumeSpkrChanged (int val) {
|
||||||
_callmanager->setSpkrVolume(val);
|
Manager::instance().setSpkrVolume(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QtGUIMainWindow::volumeMicChanged (int val) {
|
QtGUIMainWindow::volumeMicChanged (int val) {
|
||||||
_callmanager->setMicroVolume(val);
|
Manager::instance().setMicroVolume(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1375,7 +1372,7 @@ QtGUIMainWindow::button_mute(void)
|
|||||||
|
|
||||||
int id = line2id(getCurrentLine());
|
int id = line2id(getCurrentLine());
|
||||||
|
|
||||||
if (_callmanager->getNumberOfCalls() > 0) {
|
if (Manager::instance().getNumberOfCalls() > 0) {
|
||||||
// If there is at least a pending call
|
// If there is at least a pending call
|
||||||
if(!isOn) {
|
if(!isOn) {
|
||||||
qt_muteOff(id);
|
qt_muteOff(id);
|
||||||
@ -1588,7 +1585,7 @@ QtGUIMainWindow::pressedKeySlot (int id) {
|
|||||||
callid = line2id(getCurrentLine());
|
callid = line2id(getCurrentLine());
|
||||||
if (callid != -1 and getCall(callid)->isBusy()) {
|
if (callid != -1 and getCall(callid)->isBusy()) {
|
||||||
sendDtmf(callid, code); // pour envoyer DTMF
|
sendDtmf(callid, code); // pour envoyer DTMF
|
||||||
} else if (_callmanager->isDriverLoaded()) {
|
} else if (Manager::instance().isDriverLoaded()) {
|
||||||
_lcd->appendText (code);
|
_lcd->appendText (code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1601,7 +1598,7 @@ QtGUIMainWindow::pressedKeySlot (int id) {
|
|||||||
int size = pulselen * (OCTETS /1000);
|
int size = pulselen * (OCTETS /1000);
|
||||||
|
|
||||||
buf_ctrl_vol = new int16[size*CHANNELS];
|
buf_ctrl_vol = new int16[size*CHANNELS];
|
||||||
spkrVolume = _callmanager->getSpkrVolume();
|
spkrVolume = Manager::instance().getSpkrVolume();
|
||||||
|
|
||||||
// Control volume and format mono->stereo
|
// Control volume and format mono->stereo
|
||||||
for (int j = 0; j < size; j++) {
|
for (int j = 0; j < size; j++) {
|
||||||
@ -1610,13 +1607,13 @@ QtGUIMainWindow::pressedKeySlot (int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Counters reset
|
// Counters reset
|
||||||
_callmanager->getAudioDriver()->urgentRingBuffer()->flush();
|
Manager::instance().getAudioDriver()->urgentRingBuffer().flush();
|
||||||
// Put buffer to urgentRingBuffer
|
// Put buffer to urgentRingBuffer
|
||||||
_callmanager->getAudioDriver()->urgentRingBuffer()->Put(buf_ctrl_vol,
|
Manager::instance().getAudioDriver()->urgentRingBuffer().Put(buf_ctrl_vol,
|
||||||
size * CHANNELS);
|
size * CHANNELS);
|
||||||
_callmanager->getAudioDriver()->startStream();
|
Manager::instance().getAudioDriver()->startStream();
|
||||||
_callmanager->getAudioDriver()->sleep(pulselen);
|
Manager::instance().getAudioDriver()->sleep(pulselen);
|
||||||
_callmanager->getAudioDriver()->stopStream();
|
Manager::instance().getAudioDriver()->stopStream();
|
||||||
|
|
||||||
delete[] buf_ctrl_vol;
|
delete[] buf_ctrl_vol;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ class Call;
|
|||||||
class DTMF;
|
class DTMF;
|
||||||
class JPushButton;
|
class JPushButton;
|
||||||
class MyDisplay;
|
class MyDisplay;
|
||||||
class Manager;
|
|
||||||
class MyTrayIcon;
|
class MyTrayIcon;
|
||||||
class NumericKeypad;
|
class NumericKeypad;
|
||||||
class PhoneLine;
|
class PhoneLine;
|
||||||
@ -77,7 +76,7 @@ class QtGUIMainWindow : public TransQWidget, public GuiFramework {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
// Default Constructor and destructor
|
// Default Constructor and destructor
|
||||||
QtGUIMainWindow (QWidget* = 0, const char* = 0,WFlags = 0,Manager * = NULL);
|
QtGUIMainWindow (QWidget* = 0, const char* = 0,WFlags = 0);
|
||||||
~QtGUIMainWindow(void);
|
~QtGUIMainWindow(void);
|
||||||
|
|
||||||
QPixmap TabLinePixmap[NUMBER_OF_LINES][NUMBER_OF_STATES];
|
QPixmap TabLinePixmap[NUMBER_OF_LINES][NUMBER_OF_STATES];
|
||||||
@ -229,7 +228,6 @@ private:
|
|||||||
QTimer* _blinkTimer;
|
QTimer* _blinkTimer;
|
||||||
URL_Input* _urlinput;
|
URL_Input* _urlinput;
|
||||||
ConfigurationPanel* _panel;
|
ConfigurationPanel* _panel;
|
||||||
Manager* _callmanager;
|
|
||||||
QPopupMenu* _mypop;
|
QPopupMenu* _mypop;
|
||||||
MyTrayIcon* _trayicon;
|
MyTrayIcon* _trayicon;
|
||||||
DTMF* _key;
|
DTMF* _key;
|
||||||
|
25
src/main.cpp
25
src/main.cpp
@ -38,23 +38,20 @@
|
|||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv) {
|
main (int argc, char **argv) {
|
||||||
Manager* manager;
|
Config::setTree(new ConfigurationTree());
|
||||||
Config::setTree(new ConfigurationTree());
|
GuiFramework *GUI;
|
||||||
manager = new Manager();
|
|
||||||
GuiFramework *GUI;
|
|
||||||
|
|
||||||
#if defined(GUI_QT)
|
#if defined(GUI_QT)
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
GUI = new QtGUIMainWindow (0, 0 ,
|
GUI = new QtGUIMainWindow (0, 0 ,
|
||||||
Qt::WDestructiveClose |
|
Qt::WDestructiveClose |
|
||||||
Qt::WStyle_Customize |
|
Qt::WStyle_Customize |
|
||||||
Qt::WStyle_NoBorder,
|
Qt::WStyle_NoBorder);
|
||||||
manager);
|
Manager::instance().setGui(GUI);
|
||||||
manager->setGui(GUI);
|
Manager::instance().init();
|
||||||
manager->init();
|
|
||||||
|
|
||||||
a.setMainWidget((QtGUIMainWindow*)GUI);
|
a.setMainWidget((QtGUIMainWindow*)GUI);
|
||||||
return a.exec();
|
return a.exec();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
285
src/manager.h
285
src/manager.h
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
|
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
|
||||||
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
|
* Author : Jean-Philippe Barrette-LaPierre
|
||||||
|
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,285 +18,15 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MANAGER_H__
|
#ifndef SFLPHONE_MANAGER_H
|
||||||
#define __MANAGER_H__
|
#define SFLPHONE_MANAGER_H
|
||||||
|
|
||||||
#include <cc++/thread.h>
|
#include "utilspp/singleton_holder.hpp"
|
||||||
|
#include "managerimpl.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "../stund/stun.h"
|
typedef utilspp::singleton_holder< ManagerImpl > Manager;
|
||||||
#include "call.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace ost;
|
|
||||||
|
|
||||||
class AudioLayer;
|
#endif
|
||||||
class CodecDescriptor;
|
|
||||||
class Error;
|
|
||||||
class GuiFramework;
|
|
||||||
class ToneGenerator;
|
|
||||||
class VoIPLink;
|
|
||||||
|
|
||||||
#define NOTIFICATION_LEN 250
|
|
||||||
// Status
|
|
||||||
#define CONNECTED_STATUS "Connected"
|
|
||||||
#define LOGGED_IN_STATUS "Logged in"
|
|
||||||
#define RINGING_STATUS "Ringing"
|
|
||||||
#define TRYING_STATUS "Trying ..."
|
|
||||||
#define HUNGUP_STATUS "Hung up"
|
|
||||||
#define ONHOLD_STATUS "On hold ..."
|
|
||||||
#define TRANSFER_STATUS "Transfer to:"
|
|
||||||
#define MUTE_ON_STATUS "Mute on"
|
|
||||||
#define ENTER_NUMBER_STATUS "Enter Phone Number:"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define a type for a list of call
|
|
||||||
*/
|
|
||||||
typedef vector<Call*, allocator<Call*> > CallVector;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define a type for a list of VoIPLink
|
|
||||||
*/
|
|
||||||
typedef vector<VoIPLink*, allocator<VoIPLink*> > VoIPLinkVector;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define a type for a list of CodecDescriptor
|
|
||||||
*/
|
|
||||||
typedef vector<CodecDescriptor*, allocator<CodecDescriptor*> > CodecDescriptorVector;
|
|
||||||
|
|
||||||
struct device_t{
|
|
||||||
const char* hostApiName;
|
|
||||||
const char* deviceName;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Manager {
|
|
||||||
public:
|
|
||||||
Manager (void);
|
|
||||||
~Manager (void);
|
|
||||||
|
|
||||||
static device_t deviceParam;
|
|
||||||
|
|
||||||
void init (void);
|
|
||||||
void setGui (GuiFramework* gui);
|
|
||||||
ToneGenerator* getTonegenerator(void);
|
|
||||||
Error* error(void);
|
|
||||||
AudioLayer* getAudioDriver(void);
|
|
||||||
|
|
||||||
// Accessor to number of calls
|
|
||||||
unsigned int getNumberOfCalls (void);
|
|
||||||
// Modifior of number of calls
|
|
||||||
void setNumberOfCalls (unsigned int nCalls);
|
|
||||||
|
|
||||||
// Accessor to current call id
|
|
||||||
short getCurrentCallId (void);
|
|
||||||
// Modifior of current call id
|
|
||||||
void setCurrentCallId (short currentCallId);
|
|
||||||
|
|
||||||
// Accessor to the Call vector
|
|
||||||
CallVector* getCallVector (void);
|
|
||||||
// Accessor to the Call with the id 'id'
|
|
||||||
Call* getCall (short id);
|
|
||||||
|
|
||||||
unsigned int getNumberOfCodecs (void);
|
|
||||||
void setNumberOfCodecs (unsigned int nb_codec);
|
|
||||||
|
|
||||||
VoIPLinkVector* getVoIPLinkVector (void);
|
|
||||||
|
|
||||||
CodecDescriptorVector* getCodecDescVector(void);
|
|
||||||
|
|
||||||
inline bool getZonetone (void) { return _zonetone; }
|
|
||||||
inline void setZonetone (bool b) { _zonetone = b; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Attribute a new random id for a new call
|
|
||||||
* and check if it's already attributed to existing calls.
|
|
||||||
* If not exists, returns 'id' otherwise return 0
|
|
||||||
*/
|
|
||||||
short generateNewCallId (void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add a new call at the end of the CallVector with identifiant 'id'
|
|
||||||
*/
|
|
||||||
void pushBackNewCall (short id, enum CallType type);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Erase the Call(id) from the CallVector
|
|
||||||
*/
|
|
||||||
void deleteCall (short id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions which occur with a user's action
|
|
||||||
*/
|
|
||||||
int outgoingCall (const string& to);
|
|
||||||
int hangupCall (short id);
|
|
||||||
int cancelCall (short id);
|
|
||||||
int answerCall (short id);
|
|
||||||
int onHoldCall (short id);
|
|
||||||
int offHoldCall (short id);
|
|
||||||
int transferCall (short id, const string& to);
|
|
||||||
void muteOn (short id);
|
|
||||||
void muteOff (short id);
|
|
||||||
int refuseCall (short id);
|
|
||||||
|
|
||||||
int saveConfig (void);
|
|
||||||
int registerVoIPLink (void);
|
|
||||||
int quitApplication (void);
|
|
||||||
int sendTextMessage (short id, const string& message);
|
|
||||||
int accessToDirectory (void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle choice of the DTMF-send-way
|
|
||||||
*
|
|
||||||
* @param id: callid of the line.
|
|
||||||
* @param code: pressed key.
|
|
||||||
*/
|
|
||||||
int sendDtmf (short id, char code);
|
|
||||||
|
|
||||||
|
|
||||||
int incomingCall (short id);
|
|
||||||
void peerAnsweredCall (short id);
|
|
||||||
int peerRingingCall (short id);
|
|
||||||
int peerHungupCall (short id);
|
|
||||||
void displayTextMessage (short id, const string& message);
|
|
||||||
void displayErrorText (const string& message);
|
|
||||||
void displayError (const string& error);
|
|
||||||
void displayStatus (const string& status);
|
|
||||||
int selectedCall (void);
|
|
||||||
bool isCurrentId (short id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle audio sounds heard by a caller while they wait for their
|
|
||||||
* connection to a called party to be completed.
|
|
||||||
*/
|
|
||||||
void ringback (bool var);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle played music when an incoming call occurs
|
|
||||||
*/
|
|
||||||
void ringtone (bool var);
|
|
||||||
|
|
||||||
void congestion (bool var);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Notification of incoming call when you are already busy
|
|
||||||
*/
|
|
||||||
void notificationIncomingCall (void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get information about firewall
|
|
||||||
* @param stunSvrAddr: stun server
|
|
||||||
*/
|
|
||||||
void getStunInfo (StunAddress4& stunSvrAddr);
|
|
||||||
bool useStun (void);
|
|
||||||
|
|
||||||
inline bool getbCongestion (void) { return _congestion; }
|
|
||||||
inline bool getbRingback (void) { return _ringback; }
|
|
||||||
inline bool getbRingtone (void) { return _ringtone; }
|
|
||||||
|
|
||||||
inline int getSpkrVolume (void) { return _spkr_volume; }
|
|
||||||
inline void setSpkrVolume (int spkr_vol) { _spkr_volume = spkr_vol; }
|
|
||||||
inline int getMicroVolume (void) { return _mic_volume; }
|
|
||||||
inline void setMicroVolume (int mic_vol) { _mic_volume = mic_vol; }
|
|
||||||
|
|
||||||
inline int getFirewallPort (void) { return _firewallPort; }
|
|
||||||
inline void setFirewallPort (int port) { _firewallPort = port; }
|
|
||||||
inline string getFirewallAddress (void) { return _firewallAddr; }
|
|
||||||
|
|
||||||
inline bool isDriverLoaded (void) { return _loaded; }
|
|
||||||
inline void loaded (bool l) { _loaded = l; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions about audio device
|
|
||||||
*/
|
|
||||||
static device_t deviceList (int);
|
|
||||||
static int deviceCount (void);
|
|
||||||
static bool defaultDevice (int);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the number of calls in the vector
|
|
||||||
*/
|
|
||||||
unsigned int callVectorSize (void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create .PROGNAME directory in home user and create
|
|
||||||
* configuration tree from the settings file if this file exists.
|
|
||||||
*
|
|
||||||
* @return 0 if creating file failed
|
|
||||||
* 1 if config-file exists
|
|
||||||
* 2 if file doesn't exist yet.
|
|
||||||
*/
|
|
||||||
int createSettingsPath (void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Init default values for the different fields
|
|
||||||
*/
|
|
||||||
void initConfigFile (void);
|
|
||||||
|
|
||||||
void initAudioCodec(void);
|
|
||||||
void selectAudioDriver (void);
|
|
||||||
|
|
||||||
/////////////////////
|
|
||||||
// Private variables
|
|
||||||
/////////////////////
|
|
||||||
ToneGenerator* _tone;
|
|
||||||
Error* _error;
|
|
||||||
GuiFramework* _gui;
|
|
||||||
AudioLayer* _audiodriverPA;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Vector of VoIPLink
|
|
||||||
*/
|
|
||||||
VoIPLinkVector* _voIPLinkVector;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Vector of calls
|
|
||||||
*/
|
|
||||||
CallVector* _callVector;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Vector of CodecDescriptor
|
|
||||||
*/
|
|
||||||
CodecDescriptorVector* _codecDescVector;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mutex to protect access to code section
|
|
||||||
*/
|
|
||||||
Mutex _mutex;
|
|
||||||
|
|
||||||
unsigned int _nCalls;
|
|
||||||
short _currentCallId;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For the call timer
|
|
||||||
*/
|
|
||||||
unsigned int _startTime;
|
|
||||||
unsigned int _endTime;
|
|
||||||
|
|
||||||
/* Path of the ConfigFile
|
|
||||||
*/
|
|
||||||
string _path;
|
|
||||||
int _exist;
|
|
||||||
|
|
||||||
unsigned int _nCodecs;
|
|
||||||
bool _zonetone;
|
|
||||||
bool _congestion;
|
|
||||||
bool _ringback;
|
|
||||||
bool _ringtone;
|
|
||||||
|
|
||||||
// To handle volume control
|
|
||||||
int _spkr_volume;
|
|
||||||
int _mic_volume;
|
|
||||||
|
|
||||||
// To handle firewall
|
|
||||||
int _firewallPort;
|
|
||||||
string _firewallAddr;
|
|
||||||
|
|
||||||
// Variables used in exception
|
|
||||||
bool _loaded;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __MANAGER_H__
|
|
||||||
|
@ -51,15 +51,14 @@ using namespace std;
|
|||||||
#define RANDOM_LOCAL_PORT ((rand() % 27250) + 5250)*2
|
#define RANDOM_LOCAL_PORT ((rand() % 27250) + 5250)*2
|
||||||
|
|
||||||
|
|
||||||
SipVoIPLink::SipVoIPLink (short id, Manager* manager) : VoIPLink (id, manager)
|
SipVoIPLink::SipVoIPLink (short id) : VoIPLink (id)
|
||||||
{
|
{
|
||||||
setId(id);
|
setId(id);
|
||||||
_localPort = 0;
|
_localPort = 0;
|
||||||
_cid = 0;
|
_cid = 0;
|
||||||
_manager = manager;
|
|
||||||
_evThread = new EventThread (this);
|
_evThread = new EventThread (this);
|
||||||
_sipcallVector = new SipCallVector();
|
_sipcallVector = new SipCallVector();
|
||||||
_audiortp = new AudioRtp(_manager);
|
_audiortp = new AudioRtp();
|
||||||
}
|
}
|
||||||
|
|
||||||
SipVoIPLink::~SipVoIPLink (void)
|
SipVoIPLink::~SipVoIPLink (void)
|
||||||
@ -99,13 +98,13 @@ SipVoIPLink::init (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If use STUN server, firewall address setup
|
// If use STUN server, firewall address setup
|
||||||
if (_manager->useStun()) {
|
if (Manager::instance().useStun()) {
|
||||||
eXosip_set_user_agent(tmp.data());
|
eXosip_set_user_agent(tmp.data());
|
||||||
if (behindNat() != 1) {
|
if (behindNat() != 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
eXosip_set_firewallip((_manager->getFirewallAddress()).data());
|
eXosip_set_firewallip((Manager::instance().getFirewallAddress()).data());
|
||||||
}
|
}
|
||||||
|
|
||||||
eXosip_set_user_agent(tmp.data());
|
eXosip_set_user_agent(tmp.data());
|
||||||
@ -139,14 +138,14 @@ SipVoIPLink::initRtpmapCodec (void)
|
|||||||
eXosip_sdp_negotiation_remove_audio_payloads();
|
eXosip_sdp_negotiation_remove_audio_payloads();
|
||||||
|
|
||||||
// Set rtpmap according to the supported codec order
|
// Set rtpmap according to the supported codec order
|
||||||
nb = _manager->getNumberOfCodecs();
|
nb = Manager::instance().getNumberOfCodecs();
|
||||||
for (unsigned int i = 0; i < nb; i++) {
|
for (unsigned int i = 0; i < nb; i++) {
|
||||||
payload = _manager->getCodecDescVector()->at(i)->getPayload();
|
payload = Manager::instance().getCodecDescVector()->at(i)->getPayload();
|
||||||
|
|
||||||
// Add payload to rtpmap if it is not already added
|
// Add payload to rtpmap if it is not already added
|
||||||
if (!isInRtpmap(i, payload, _manager->getCodecDescVector())) {
|
if (!isInRtpmap(i, payload, Manager::instance().getCodecDescVector())) {
|
||||||
snprintf(rtpmap, 127, "%d %s/%d", payload,
|
snprintf(rtpmap, 127, "%d %s/%d", payload,
|
||||||
_manager->getCodecDescVector()->at(i)->rtpmapPayload(payload).data(), SAMPLING_RATE);
|
Manager::instance().getCodecDescVector()->at(i)->rtpmapPayload(payload).data(), SAMPLING_RATE);
|
||||||
snprintf(tmp, 63, "%d", payload);
|
snprintf(tmp, 63, "%d", payload);
|
||||||
|
|
||||||
eXosip_sdp_negotiation_add_codec( osip_strdup(tmp), NULL,
|
eXosip_sdp_negotiation_add_codec( osip_strdup(tmp), NULL,
|
||||||
@ -175,11 +174,11 @@ SipVoIPLink::setRegister (void)
|
|||||||
get_config_fields_str(SIGNALISATION, HOST_PART));
|
get_config_fields_str(SIGNALISATION, HOST_PART));
|
||||||
|
|
||||||
if (get_config_fields_str(SIGNALISATION, HOST_PART).empty()) {
|
if (get_config_fields_str(SIGNALISATION, HOST_PART).empty()) {
|
||||||
_manager->error()->errorName(HOST_PART_FIELD_EMPTY);
|
Manager::instance().error()->errorName(HOST_PART_FIELD_EMPTY);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (get_config_fields_str(SIGNALISATION, USER_PART).empty()) {
|
if (get_config_fields_str(SIGNALISATION, USER_PART).empty()) {
|
||||||
_manager->error()->errorName(USER_PART_FIELD_EMPTY);
|
Manager::instance().error()->errorName(USER_PART_FIELD_EMPTY);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +286,7 @@ int
|
|||||||
SipVoIPLink::hangup (short id)
|
SipVoIPLink::hangup (short id)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
if (!_manager->getbCongestion()) {
|
if (!Manager::instance().getbCongestion()) {
|
||||||
_debug("Hang up call [id = %d, cid = %d, did = %d]\n",
|
_debug("Hang up call [id = %d, cid = %d, did = %d]\n",
|
||||||
id, getSipCall(id)->getCid(), getSipCall(id)->getDid());
|
id, getSipCall(id)->getCid(), getSipCall(id)->getDid());
|
||||||
// Release SIP stack.
|
// Release SIP stack.
|
||||||
@ -308,7 +307,7 @@ int
|
|||||||
SipVoIPLink::cancel (short id)
|
SipVoIPLink::cancel (short id)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
if (!_manager->getbCongestion()) {
|
if (!Manager::instance().getbCongestion()) {
|
||||||
_debug("Cancel call [id = %d, cid = %d]\n", id, getCid());
|
_debug("Cancel call [id = %d, cid = %d]\n", id, getCid());
|
||||||
// Release SIP stack.
|
// Release SIP stack.
|
||||||
eXosip_lock();
|
eXosip_lock();
|
||||||
@ -398,20 +397,19 @@ SipVoIPLink::getEvent (void)
|
|||||||
// IP-Phone user receives a new call
|
// IP-Phone user receives a new call
|
||||||
case EXOSIP_CALL_NEW: //
|
case EXOSIP_CALL_NEW: //
|
||||||
// Set local random port for incoming call
|
// Set local random port for incoming call
|
||||||
if (!_manager->useStun()) {
|
if (!Manager::instance().useStun()) {
|
||||||
// If no firewall
|
|
||||||
setLocalPort(RANDOM_LOCAL_PORT);
|
setLocalPort(RANDOM_LOCAL_PORT);
|
||||||
} else {
|
} else {
|
||||||
// If there is a firewall
|
// If there is a firewall
|
||||||
if (behindNat() != 0) {
|
if (behindNat() != 0) {
|
||||||
setLocalPort(_manager->getFirewallPort());
|
setLocalPort(Manager::instance().getFirewallPort());
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
id = _manager->generateNewCallId();
|
id = Manager::instance().generateNewCallId();
|
||||||
_manager->pushBackNewCall(id, Incoming);
|
Manager::instance().pushBackNewCall(id, Incoming);
|
||||||
_debug("Incoming Call with identifiant %d [cid = %d, did = %d]\n",
|
_debug("Incoming Call with identifiant %d [cid = %d, did = %d]\n",
|
||||||
id, event->cid, event->did);
|
id, event->cid, event->did);
|
||||||
_debug("Local audio port: %d\n", _localPort);
|
_debug("Local audio port: %d\n", _localPort);
|
||||||
@ -421,9 +419,9 @@ SipVoIPLink::getEvent (void)
|
|||||||
osip_from_init(&from);
|
osip_from_init(&from);
|
||||||
osip_from_parse(from, event->remote_uri);
|
osip_from_parse(from, event->remote_uri);
|
||||||
name = osip_from_get_displayname(from);
|
name = osip_from_get_displayname(from);
|
||||||
_manager->displayTextMessage(id, name);
|
Manager::instance().displayTextMessage(id, name);
|
||||||
if (_manager->getCall(id) != NULL) {
|
if (Manager::instance().getCall(id) != NULL) {
|
||||||
_manager->getCall(id)->setCallerIdName(name);
|
Manager::instance().getCall(id)->setCallerIdName(name);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -431,8 +429,8 @@ SipVoIPLink::getEvent (void)
|
|||||||
osip_from_free(from);
|
osip_from_free(from);
|
||||||
|
|
||||||
getSipCall(id)->newIncomingCall(event);
|
getSipCall(id)->newIncomingCall(event);
|
||||||
if (_manager->incomingCall(id) < 0) {
|
if (Manager::instance().incomingCall(id) < 0) {
|
||||||
_manager->displayErrorText("Incoming call failed");
|
Manager::instance().displayErrorText("Incoming call failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,11 +449,11 @@ SipVoIPLink::getEvent (void)
|
|||||||
id, event->cid, event->did,getSipCall(id)->getLocalAudioPort());
|
id, event->cid, event->did,getSipCall(id)->getLocalAudioPort());
|
||||||
|
|
||||||
// Answer
|
// Answer
|
||||||
if (id > 0 and !_manager->getCall(id)->isOnHold()
|
if (id > 0 and !Manager::instance().getCall(id)->isOnHold()
|
||||||
and !_manager->getCall(id)->isOffHold()) {
|
and !Manager::instance().getCall(id)->isOffHold()) {
|
||||||
getSipCall(id)->setStandBy(false);
|
getSipCall(id)->setStandBy(false);
|
||||||
if (getSipCall(id)->answeredCall(event) != -1) {
|
if (getSipCall(id)->answeredCall(event) != -1) {
|
||||||
_manager->peerAnsweredCall(id);
|
Manager::instance().peerAnsweredCall(id);
|
||||||
|
|
||||||
// Outgoing call is answered, start the sound channel.
|
// Outgoing call is answered, start the sound channel.
|
||||||
if (_audiortp->createNewSession (getSipCall(id)) < 0) {
|
if (_audiortp->createNewSession (getSipCall(id)) < 0) {
|
||||||
@ -475,7 +473,7 @@ SipVoIPLink::getEvent (void)
|
|||||||
|
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
getSipCall(id)->ringingCall(event);
|
getSipCall(id)->ringingCall(event);
|
||||||
_manager->peerRingingCall(id);
|
Manager::instance().peerRingingCall(id);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -491,10 +489,10 @@ SipVoIPLink::getEvent (void)
|
|||||||
id, event->cid, event->did);
|
id, event->cid, event->did);
|
||||||
|
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
if (!_manager->getCall(id)->isProgressing()) {
|
if (!Manager::instance().getCall(id)->isProgressing()) {
|
||||||
_audiortp->closeRtpSession(getSipCall(id));
|
_audiortp->closeRtpSession(getSipCall(id));
|
||||||
}
|
}
|
||||||
_manager->peerHungupCall(id);
|
Manager::instance().peerHungupCall(id);
|
||||||
deleteSipCall(id);
|
deleteSipCall(id);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@ -543,8 +541,8 @@ SipVoIPLink::getEvent (void)
|
|||||||
case ADDR_INCOMPLETE:
|
case ADDR_INCOMPLETE:
|
||||||
case BUSY_HERE:
|
case BUSY_HERE:
|
||||||
// Display error on the screen phone
|
// Display error on the screen phone
|
||||||
_manager->displayError(event->reason_phrase);
|
Manager::instance().displayError(event->reason_phrase);
|
||||||
_manager->congestion(true);
|
Manager::instance().congestion(true);
|
||||||
break;
|
break;
|
||||||
case REQ_TERMINATED:
|
case REQ_TERMINATED:
|
||||||
break;
|
break;
|
||||||
@ -557,8 +555,8 @@ SipVoIPLink::getEvent (void)
|
|||||||
// Handle 5XX errors
|
// Handle 5XX errors
|
||||||
switch (event->status_code) {
|
switch (event->status_code) {
|
||||||
case SERVICE_UNAVAILABLE:
|
case SERVICE_UNAVAILABLE:
|
||||||
_manager->ringback(false);
|
Manager::instance().ringback(false);
|
||||||
_manager->congestion(true);
|
Manager::instance().congestion(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -570,8 +568,8 @@ SipVoIPLink::getEvent (void)
|
|||||||
switch (event->status_code) {
|
switch (event->status_code) {
|
||||||
case BUSY_EVERYWHERE:
|
case BUSY_EVERYWHERE:
|
||||||
case DECLINE:
|
case DECLINE:
|
||||||
_manager->ringback(false);
|
Manager::instance().ringback(false);
|
||||||
_manager->congestion(true);
|
Manager::instance().congestion(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -580,7 +578,7 @@ SipVoIPLink::getEvent (void)
|
|||||||
|
|
||||||
case EXOSIP_REGISTRATION_SUCCESS:
|
case EXOSIP_REGISTRATION_SUCCESS:
|
||||||
_debug("-- Registration succeeded --\n");
|
_debug("-- Registration succeeded --\n");
|
||||||
_manager->displayStatus(LOGGED_IN_STATUS);
|
Manager::instance().displayStatus(LOGGED_IN_STATUS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXOSIP_REGISTRATION_FAILURE:
|
case EXOSIP_REGISTRATION_FAILURE:
|
||||||
@ -682,7 +680,7 @@ void
|
|||||||
SipVoIPLink::newOutgoingCall (short callid)
|
SipVoIPLink::newOutgoingCall (short callid)
|
||||||
{
|
{
|
||||||
_sipcallVector->push_back(new SipCall(callid,
|
_sipcallVector->push_back(new SipCall(callid,
|
||||||
_manager->getCodecDescVector()));
|
Manager::instance().getCodecDescVector()));
|
||||||
if (getSipCall(callid) != NULL) {
|
if (getSipCall(callid) != NULL) {
|
||||||
getSipCall(callid)->setStandBy(true);
|
getSipCall(callid)->setStandBy(true);
|
||||||
}
|
}
|
||||||
@ -691,7 +689,7 @@ SipVoIPLink::newOutgoingCall (short callid)
|
|||||||
void
|
void
|
||||||
SipVoIPLink::newIncomingCall (short callid)
|
SipVoIPLink::newIncomingCall (short callid)
|
||||||
{
|
{
|
||||||
SipCall* sipcall = new SipCall(callid, _manager->getCodecDescVector());
|
SipCall* sipcall = new SipCall(callid, Manager::instance().getCodecDescVector());
|
||||||
_sipcallVector->push_back(sipcall);
|
_sipcallVector->push_back(sipcall);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -751,7 +749,7 @@ SipVoIPLink::behindNat (void)
|
|||||||
|
|
||||||
// Firewall address
|
// Firewall address
|
||||||
_debug("STUN server: %s\n", svr.data());
|
_debug("STUN server: %s\n", svr.data());
|
||||||
_manager->getStunInfo(stunSvrAddr);
|
Manager::instance().getStunInfo(stunSvrAddr);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -799,7 +797,7 @@ SipVoIPLink::setAuthentication (void)
|
|||||||
}
|
}
|
||||||
pass = get_config_fields_str(SIGNALISATION, PASSWORD);
|
pass = get_config_fields_str(SIGNALISATION, PASSWORD);
|
||||||
if (pass.empty()) {
|
if (pass.empty()) {
|
||||||
_manager->error()->errorName(PASSWD_FIELD_EMPTY);
|
Manager::instance().error()->errorName(PASSWD_FIELD_EMPTY);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,11 +834,11 @@ SipVoIPLink::startCall (short id, const string& from, const string& to,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (checkUrl(from) != 0) {
|
if (checkUrl(from) != 0) {
|
||||||
_manager->error()->errorName(FROM_ERROR);
|
Manager::instance().error()->errorName(FROM_ERROR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (checkUrl(to) != 0) {
|
if (checkUrl(to) != 0) {
|
||||||
_manager->error()->errorName(TO_ERROR);
|
Manager::instance().error()->errorName(TO_ERROR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,15 +851,15 @@ SipVoIPLink::startCall (short id, const string& from, const string& to,
|
|||||||
eXosip_lock();
|
eXosip_lock();
|
||||||
|
|
||||||
char port[64];
|
char port[64];
|
||||||
if (!_manager->useStun()) {
|
if (!Manager::instance().useStun()) {
|
||||||
// Set random port for outgoing call
|
// Set random port for outgoing call
|
||||||
setLocalPort(RANDOM_LOCAL_PORT);
|
setLocalPort(RANDOM_LOCAL_PORT);
|
||||||
_debug("Local audio port: %d\n",_localPort);
|
_debug("Local audio port: %d\n",_localPort);
|
||||||
} else {
|
} else {
|
||||||
// If use Stun server
|
// If use Stun server
|
||||||
if (behindNat() != 0) {
|
if (behindNat() != 0) {
|
||||||
_debug("sip invite: firewall port = %d\n",_manager->getFirewallPort());
|
_debug("sip invite: firewall port = %d\n",Manager::instance().getFirewallPort());
|
||||||
setLocalPort(_manager->getFirewallPort());
|
setLocalPort(Manager::instance().getFirewallPort());
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -909,7 +907,7 @@ short
|
|||||||
SipVoIPLink::findCallIdWhenRinging (void)
|
SipVoIPLink::findCallIdWhenRinging (void)
|
||||||
{
|
{
|
||||||
unsigned int k;
|
unsigned int k;
|
||||||
int i = _manager->selectedCall();
|
int i = Manager::instance().selectedCall();
|
||||||
|
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
return i;
|
return i;
|
||||||
|
@ -55,7 +55,6 @@ class AudioCodec;
|
|||||||
class AudioRtp;
|
class AudioRtp;
|
||||||
class CodecDescriptor;
|
class CodecDescriptor;
|
||||||
class EventThread;
|
class EventThread;
|
||||||
class Manager;
|
|
||||||
class SipCall;
|
class SipCall;
|
||||||
|
|
||||||
typedef vector<SipCall*, allocator<SipCall*> > SipCallVector;
|
typedef vector<SipCall*, allocator<SipCall*> > SipCallVector;
|
||||||
@ -63,7 +62,7 @@ typedef vector<CodecDescriptor*, allocator<CodecDescriptor*> > CodecDescriptorVe
|
|||||||
|
|
||||||
class SipVoIPLink : public VoIPLink {
|
class SipVoIPLink : public VoIPLink {
|
||||||
public:
|
public:
|
||||||
SipVoIPLink (short id, Manager* manager);
|
SipVoIPLink (short id);
|
||||||
virtual ~SipVoIPLink (void);
|
virtual ~SipVoIPLink (void);
|
||||||
|
|
||||||
virtual int init (void);
|
virtual int init (void);
|
||||||
@ -124,7 +123,6 @@ private:
|
|||||||
short findCallIdWhenRinging (void);
|
short findCallIdWhenRinging (void);
|
||||||
bool isInRtpmap (int index, int payload, CodecDescriptorVector* cdv);
|
bool isInRtpmap (int index, int payload, CodecDescriptorVector* cdv);
|
||||||
|
|
||||||
Manager* _manager;
|
|
||||||
EventThread* _evThread;
|
EventThread* _evThread;
|
||||||
SipCallVector* _sipcallVector;
|
SipCallVector* _sipcallVector;
|
||||||
AudioRtp* _audiortp;
|
AudioRtp* _audiortp;
|
||||||
|
@ -26,10 +26,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
VoIPLink::VoIPLink (short id, Manager* manager)
|
VoIPLink::VoIPLink (short id)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_manager = manager;
|
|
||||||
initConstructor();
|
initConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +31,9 @@ enum VoIPLinkType {
|
|||||||
|
|
||||||
class AudioCodec;
|
class AudioCodec;
|
||||||
class Call;
|
class Call;
|
||||||
class Manager;
|
|
||||||
class VoIPLink {
|
class VoIPLink {
|
||||||
public:
|
public:
|
||||||
VoIPLink (short id, Manager* manager);
|
VoIPLink (short id);
|
||||||
virtual ~VoIPLink (void);
|
virtual ~VoIPLink (void);
|
||||||
|
|
||||||
virtual int getEvent (void) = 0;
|
virtual int getEvent (void) = 0;
|
||||||
@ -75,7 +74,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void initConstructor(void);
|
void initConstructor(void);
|
||||||
|
|
||||||
Manager* _manager;
|
|
||||||
short _id;
|
short _id;
|
||||||
VoIPLinkType _type;
|
VoIPLinkType _type;
|
||||||
string _fullname;
|
string _fullname;
|
||||||
|
Reference in New Issue
Block a user