Commit a4525f8d authored by Alexandre Savard's avatar Alexandre Savard
parents 47ec8c98 0d661418
......@@ -119,13 +119,15 @@ LIBSAMPLERATE_MIN_VERSION=0.1.2
PKG_CHECK_MODULES(SAMPLERATE, samplerate >= ${LIBSAMPLERATE_MIN_VERSION},, AC_MSG_ERROR([Missing libsamplerate development package: libsamplerate0-dev]))
LIBCCGNU2_MIN_VERSION=1.3.1
PKG_CHECK_MODULES(CCGNU2, libccgnu2 >= ${LIBCCGNU2_MIN_VERSION},, AC_MSG_ERROR([Missing common cpp development package: libcommoncpp2-dev]))
LIBCCEXT2_MIN_VERSION=1.3.1
PKG_CHECK_MODULES(CCEXT2, libccext2 >= ${LIBCCEXT2_MIN_VERSION})
PKG_CHECK_MODULES([CCGNU2], [commoncpp] >= ${LIBCCGNU2_MIN_VERSION}, AC_DEFINE_UNQUOTED([COMMONCPP_PREFIX], [1], [Use commoncpp include prefix]), [
PKG_CHECK_MODULES([CCGNU2], [libccgnu2] >= ${LIBCCGNU2_MIN_VERSION}, AC_DEFINE_UNQUOTED([CCPP_PREFIX], [1], [Use cc++ include prefix]),
AC_MSG_ERROR([Missing common cpp development package: libcommoncpp2-dev]))
])
LIBCCRT_MIN_VERSION=1.3.0
PKG_CHECK_MODULES(CCRTP, libccrtp1 >= ${LIBCCRT_MIN_VERSION},, AC_MSG_ERROR([Missing ccrtp development package: libccrtp-dev]))
LIBCCRTP_MIN_VERSION=1.3.0
PKG_CHECK_MODULES([CCRTP], [libccrtp] >= ${LIBCCRTP_MIN_VERSION},, [
PKG_CHECK_MODULES([CCRTP], [libccrtp1] >= ${LIBCCRTP_MIN_VERSION},, AC_MSG_ERROR([Missing ccrtp development package: libccrtp-dev]))
])
dnl Check for OpenSSL to link against pjsip and provide SIPS TLS support
PKG_CHECK_MODULES([libssl], libssl,, AC_MSG_ERROR([Missing ssl development package: libssl-dev]))
......
......@@ -48,7 +48,9 @@ noinst_HEADERS = \
logger.h \
numbercleaner.h \
fileutils.h \
noncopyable.h
noncopyable.h \
cc_thread.h \
cc_config.h
libsflphone_la_LIBADD = \
$(top_builddir)/libs/iax2/libiax2.la \
......
......@@ -129,20 +129,20 @@ static const char *const CONFIG_REGISTRATION_STATE_CODE = "Registrat
static const char *const CONFIG_REGISTRATION_STATE_DESCRIPTION = "Registration.description";
// General configuration keys for accounts
static const char * const aliasKey = "alias";
static const char * const typeKey = "type";
static const char * const idKey = "id";
static const char * const usernameKey = "username";
static const char * const authenticationUsernameKey = "authenticationUsername";
static const char * const passwordKey = "password";
static const char * const hostnameKey = "hostname";
static const char * const accountEnableKey = "enable";
static const char * const mailboxKey = "mailbox";
static const char * const codecsKey = "codecs"; // 0/9/110/111/112/
static const char * const ringtonePathKey = "ringtonePath";
static const char * const ringtoneEnabledKey = "ringtoneEnabled";
static const char * const displayNameKey = "displayName";
static const char * const ALIAS_KEY = "alias";
static const char * const TYPE_KEY = "type";
static const char * const ID_KEY = "id";
static const char * const USERNAME_KEY = "username";
static const char * const AUTHENTICATION_USERNAME_KEY = "authenticationUsername";
static const char * const PASSWORD_KEY = "password";
static const char * const HOSTNAME_KEY = "hostname";
static const char * const ACCOUNT_ENABLE_KEY = "enable";
static const char * const MAILBOX_KEY = "mailbox";
static const char * const CODECS_KEY = "codecs"; // 0/9/110/111/112/
static const char * const RINGTONE_PATH_KEY = "ringtonePath";
static const char * const RINGTONE_ENABLED_KEY = "ringtoneEnabled";
static const char * const DISPLAY_NAME_KEY = "displayName";
class Account : public Serializable {
......
......@@ -41,9 +41,7 @@ class AlsaThread : public ost::Thread {
public:
AlsaThread(AlsaLayer *alsa);
~AlsaThread() {
terminate();
}
~AlsaThread() { terminate(); }
virtual void run();
......@@ -53,17 +51,15 @@ class AlsaThread : public ost::Thread {
};
AlsaThread::AlsaThread(AlsaLayer *alsa)
: Thread(), alsa_(alsa)
{
setCancel(cancelDeferred);
}
: ost::Thread(), alsa_(alsa)
{}
/**
* Reimplementation of run()
*/
void AlsaThread::run()
{
while (!testCancel()) {
while (alsa_->isStarted_) {
alsa_->audioCallback();
Thread::sleep(20);
}
......@@ -94,6 +90,7 @@ AlsaLayer::AlsaLayer()
// Destructor
AlsaLayer::~AlsaLayer()
{
isStarted_ = false;
delete audioThread_;
/* Then close the audio devices */
......@@ -679,19 +676,17 @@ void AlsaLayer::audioCallback()
if (ringtoneHandle_) {
AudioLoop *file_tone = Manager::instance().getTelephoneFile();
int ringtoneAvailSmpl = snd_pcm_avail_update(ringtoneHandle_);
int ringtoneAvailBytes = ringtoneAvailSmpl*sizeof(SFLDataFormat);
int ringtoneAvailBytes = ringtoneAvailSmpl * sizeof(SFLDataFormat);
SFLDataFormat *out = (SFLDataFormat *) malloc(ringtoneAvailBytes);
std::vector<SFLDataFormat> out(ringtoneAvailSmpl, 0);
if (file_tone) {
DEBUG("playback gain %d", getPlaybackGain());
file_tone->getNext(out, ringtoneAvailSmpl, getPlaybackGain());
file_tone->getNext(&(*out.begin()), ringtoneAvailSmpl,
getPlaybackGain());
}
else
memset(out, 0, ringtoneAvailBytes);
write(out, ringtoneAvailBytes, ringtoneHandle_);
free(out);
write(&(*out.begin()), ringtoneAvailBytes, ringtoneHandle_);
}
// Additionally handle the mic's audio stream
......
......@@ -149,7 +149,7 @@ class AlsaLayer : public AudioLayer {
}
private:
friend class AlsaThread;
/**
* Calls snd_pcm_open and retries if device is busy, since dmix plugin
......@@ -241,7 +241,7 @@ class AlsaLayer : public AudioLayer {
bool is_playback_open_;
bool is_capture_open_;
AlsaThread* audioThread_;
AlsaThread *audioThread_;
};
#endif // _ALSA_LAYER_H_
......@@ -34,7 +34,7 @@
#ifndef __AUDIO_LAYER_H__
#define __AUDIO_LAYER_H__
#include <cc++/thread.h> // for ost::Mutex
#include "cc_thread.h" // for ost::Mutex
#include <sys/time.h>
#include "ringbuffer.h"
......
......@@ -34,11 +34,10 @@
int AudioRecorder::count_ = 0;
AudioRecorder::AudioRecorder(AudioRecord *arec, MainBuffer *mb) : Thread(),
AudioRecorder::AudioRecorder(AudioRecord *arec, MainBuffer *mb) : ost::Thread(),
recorderId_(), mbuffer_(mb), arecord_(arec)
{
assert(mb);
setCancel(cancelDeferred);
++count_;
......@@ -61,7 +60,7 @@ void AudioRecorder::run()
int bufferLength = 10000;
SFLDataFormat buffer[bufferLength];
while (true) {
while (isRunning()) {
int availBytes = mbuffer_->availForGet(recorderId_);
int toGet = (availBytes < bufferLength) ? availBytes : bufferLength;
......
......@@ -28,11 +28,11 @@
* as that of the covered work.
*/
#ifndef __AUDIORECORDER_H_
#define __AUDIORECORDER_H_
#ifndef AUDIORECORDER_H_
#define AUDIORECORDER_H_
#include <string>
#include <cc++/thread.h>
#include "cc_thread.h"
#include "audiorecord.h"
#include "noncopyable.h"
......
......@@ -32,8 +32,8 @@
#define __AUDIO_RTP_FACTORY_H__
#include <stdexcept>
#include <cc++/thread.h>
#include <ccrtp/CryptoContext.h>
#include "cc_thread.h"
#include "audio_rtp_session.h"
#include "noncopyable.h"
......
......@@ -243,7 +243,8 @@ int AudioRtpSession::startRtpThread(AudioCodec &audiocodec)
initNoiseSuppress();
queue_.enableStack();
return thread_.start();
thread_.start();
return 0;
}
......
......@@ -66,7 +66,8 @@ class AudioSymmetricRtpSession : public ost::TimerPort, public ost::SymmetricRTP
}
int startSymmetricRtpThread() {
return rtpThread_.start();
rtpThread_.start();
return 0;
}
private:
......
......@@ -60,9 +60,6 @@ AudioZrtpSession::AudioZrtpSession(SIPCall &call, const std::string& zidFilename
{
DEBUG("AudioZrtpSession initialized");
initializeZid();
setCancel(cancelDefault);
DEBUG("AudioZrtpSession: Setting new RTP session with destination %s:%d",
call_.getLocalIp().c_str(), call_.getLocalAudioPort());
}
......@@ -73,14 +70,6 @@ AudioZrtpSession::~AudioZrtpSession()
Manager::instance().getMainBuffer()->unBindAll(call_.getCallId());
}
void AudioZrtpSession::final()
{
// tmatth:Oct 25 2011:FIXME:
// This was crashing...seems like it's not necessary. Double check
// with valgrind/helgrind
// delete this;
}
void AudioZrtpSession::initializeZid()
{
if (zidFilename_.empty())
......@@ -154,10 +143,8 @@ void AudioZrtpSession::run()
else
sendMicData();
setCancel(cancelDeferred);
controlReceptionService();
controlTransmissionService();
setCancel(cancelImmediate);
uint32 maxWait = timeval2microtimeout(getRTCPCheckInterval());
// make sure the scheduling timeout is
// <= the check interval for RTCP
......@@ -165,18 +152,13 @@ void AudioZrtpSession::run()
timeout = (timeout > maxWait) ? maxWait : timeout;
if (timeout < 1000) { // !(timeout/1000)
setCancel(cancelDeferred);
// dispatchDataPacket();
setCancel(cancelImmediate);
timerTick();
} else {
if (isPendingData(timeout / 1000)) {
setCancel(cancelDeferred);
if (isActive())
takeInDataPacket();
setCancel(cancelImmediate);
}
timeout = 0;
}
......
......@@ -40,7 +40,7 @@ using std::ptrdiff_t;
#include <libzrtpcpp/ZrtpUserCallback.h>
#include "audio_rtp_session.h"
#include <cc++/numbers.h> // OST::Time
// #include <commoncpp/numbers.h> // OST::Time
class SIPCall;
class AudioCodec;
......@@ -60,8 +60,6 @@ class AudioZrtpSession :
AudioZrtpSession(SIPCall &call, const std::string& zidFilename);
~AudioZrtpSession();
virtual void final();
// Thread associated method
virtual void run();
......
......@@ -34,9 +34,9 @@
#include <map>
#include <set>
#include <cc++/thread.h> // for ost::Mutex
#include <string>
#include "cc_thread.h" // for ost::Mutex
#include "global.h"
#include "call.h"
#include "ringbuffer.h"
......
......@@ -31,6 +31,7 @@
#include <algorithm> // for std::find
#include <stdexcept>
#include <cassert>
#include "audiostream.h"
#include "pulselayer.h"
#include "audio/samplerateconverter.h"
......@@ -39,24 +40,18 @@
namespace {
void playback_callback(pa_stream* s, size_t bytes, void* userdata)
void playback_callback(pa_stream * /*s*/, size_t /*bytes*/, void* userdata)
{
assert(s && bytes);
assert(bytes > 0);
static_cast<PulseLayer*>(userdata)->writeToSpeaker();
}
void capture_callback(pa_stream* s, size_t bytes, void* userdata)
void capture_callback(pa_stream * /*s*/, size_t /*bytes*/, void* userdata)
{
assert(s && bytes);
assert(bytes > 0);
static_cast<PulseLayer*>(userdata)->readFromMic();
}
void ringtone_callback(pa_stream* s, size_t bytes, void* userdata)
void ringtone_callback(pa_stream * /*s*/, size_t /*bytes*/, void* userdata)
{
assert(s && bytes);
assert(bytes > 0);
static_cast<PulseLayer*>(userdata)->ringtoneToSpeaker();
}
......@@ -124,7 +119,7 @@ PulseLayer::~PulseLayer()
if (mainloop_)
pa_threaded_mainloop_free(mainloop_);
delete[] mic_buffer_;
delete [] mic_buffer_;
}
void PulseLayer::context_state_callback(pa_context* c, void *user_data)
......@@ -422,7 +417,7 @@ void PulseLayer::readFromMic()
if (bytes > mic_buf_size_) {
mic_buf_size_ = bytes;
delete[] mic_buffer_;
delete [] mic_buffer_;
mic_buffer_ = new SFLDataFormat[samples];
}
......
......@@ -32,9 +32,8 @@
#ifndef CALL_H
#define CALL_H
#include <cc++/thread.h> // for mutex
#include <sstream>
#include "cc_thread.h"
#include "audio/recordable.h"
/*
......
/*
* Copyright (C) 2012 Savoir-Faire Linux Inc.
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef CC_CONFIG_H_
#define CC_CONFIG_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef CCPP_PREFIX
#include <cc++/config.h>
#elif defined COMMONCPP_PREFIX
#include <commoncpp/config.h>
#else
#error No CCGNU2 include directory found.
#endif
#endif // CC_CONFIG_H_
/*
* Copyright (C) 2012 Savoir-Faire Linux Inc.
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef CC_THREAD_H_
#define CC_THREAD_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef CCPP_PREFIX
#include <cc++/thread.h> // for mutex
#elif defined COMMONCPP_PREFIX
#include <commoncpp/thread.h> // for mutex
#else
#error No CCGNU2 include directory found.
#endif
#endif // CC_THREAD_H_
......@@ -27,10 +27,10 @@
* as that of the covered work.
*/
#ifndef __SFL_CODEC_H__
#define __SFL_CODEC_H__
#ifndef CODEC_H_
#define CODEC_H_
#include <cc++/config.h> // for types
#include "cc_config.h" // for types
/**
* Interface for both audio codecs as well as video codecs.
......@@ -65,4 +65,4 @@ typedef sfl::Codec* create_t();
typedef void destroy_t (sfl::Codec*);
#endif
#endif // CODEC_H_
......@@ -29,6 +29,7 @@ libdbus_la_CXXFLAGS = \
-DPROGSHAREDIR=\"${datadir}/sflphone\" \
$(NETWORKMANAGER)
noinst_HEADERS = \
callmanager.h \
configurationmanager.h \
......
......@@ -31,18 +31,13 @@
#include "eventthread.h"
#include "voiplink.h"
EventThread::EventThread(VoIPLink *link) : Thread(), link_(link)
{
setCancel(cancelDeferred);
}
EventThread::~EventThread() {
ost::Thread::terminate();
}
EventThread::EventThread(VoIPLink *link) : ost::Thread(), link_(link)
{}
void EventThread::run()
{
while (!testCancel())
link_->getEvent();
while (link_->getEvent())
; // noop
ost::Thread::exit();
}
......@@ -31,7 +31,7 @@
#ifndef EVENT_THREAD_H_
#define EVENT_THREAD_H_
#include <cc++/thread.h>
#include "cc_thread.h"
#include "noncopyable.h"
class VoIPLink;
......@@ -44,8 +44,7 @@ class VoIPLink;
class EventThread : public ost::Thread {
public:
EventThread(VoIPLink* link);
~EventThread();
virtual void run();
void run();
private:
NON_COPYABLE(EventThread);
......
......@@ -57,9 +57,9 @@ typedef signed int SINT32;
typedef short SFLDataFormat;
#define SIZEBUF 400000 /** About 12 sec of buffering at 8000 Hz*/
#define SIZEBUF 400000 /** About 12 sec of buffering at 8000 Hz*/
#define ALSA_DFT_CARD_ID 0 /** Index of the default soundcard */
#define ALSA_DFT_CARD_ID 0 /** Index of the default soundcard */
#define PCM_PLUGHW "plughw" /** Alsa plugin */
#define PCM_DEFAULT "default" /** Default ALSA plugin */
......
......@@ -71,17 +71,17 @@ void IAXAccount::serialize(Conf::YamlEmitter *emitter)
Conf::ScalarNode codecs(codecStr_);
Conf::ScalarNode displayName(displayName_);
accountmap.setKeyValue(aliasKey, &alias);
accountmap.setKeyValue(typeKey, &type);
accountmap.setKeyValue(idKey, &id);
accountmap.setKeyValue(usernameKey, &username);
accountmap.setKeyValue(passwordKey, &password);
accountmap.setKeyValue(hostnameKey, &hostname);
accountmap.setKeyValue(accountEnableKey, &enable);
accountmap.setKeyValue(mailboxKey, &mailbox);
accountmap.setKeyValue(displayNameKey, &displayName);
accountmap.setKeyValue(codecsKey, &codecs);
accountmap.setKeyValue(ALIAS_KEY, &alias);
accountmap.setKeyValue(TYPE_KEY, &type);
accountmap.setKeyValue(ID_KEY, &id);
accountmap.setKeyValue(USERNAME_KEY, &username);
accountmap.setKeyValue(PASSWORD_KEY, &password);
accountmap.setKeyValue(HOSTNAME_KEY, &hostname);
accountmap.setKeyValue(ACCOUNT_ENABLE_KEY, &enable);
accountmap.setKeyValue(MAILBOX_KEY, &mailbox);
accountmap.setKeyValue(DISPLAY_NAME_KEY, &displayName);
accountmap.setKeyValue(CODECS_KEY, &codecs);
try {
emitter->serializeAccount(&accountmap);
......@@ -97,18 +97,18 @@ void IAXAccount::unserialize(const Conf::MappingNode *map)
return;
}
map->getValue(aliasKey, &alias_);
map->getValue(typeKey, &type_);
map->getValue(usernameKey, &username_);
map->getValue(passwordKey, &password_);
map->getValue(hostnameKey, &hostname_);
map->getValue(accountEnableKey, &enabled_);
map->getValue(mailboxKey, &mailBox_);
map->getValue(codecsKey, &codecStr_);
map->getValue(ALIAS_KEY, &alias_);