Commit b7286e03 authored by Julien Bonjean's avatar Julien Bonjean

[#2402] Code indent

parent 3298edc0
......@@ -5,7 +5,7 @@
# Savoir-faire Linux Inc
# http://www.sflphone.org
style=kr # Kernighan & Ritchie style formatting/indenting uses linux bracket
style=k&r # Kernighan & Ritchie style formatting/indenting uses linux bracket
indent=spaces=4 # Use spaces instead of tabs for indentation
indent-classes # Indent 'class' and 'struct' blocks so that the blocks 'public:', 'protected:' and 'private:' are indented
indent-switches # Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block
......
......@@ -34,81 +34,87 @@
#include "manager.h"
Account::Account (const AccountID& accountID, std::string type) :
_accountID (accountID)
, _link (NULL)
, _enabled (true)
, _type (type)
, _codecOrder ()
, _codecStr("")
, _ringtonePath("/usr/share/sflphone/ringtones/konga.ul")
, _ringtoneEnabled(true)
, _displayName("")
, _useragent("SFLphone")
_accountID (accountID)
, _link (NULL)
, _enabled (true)
, _type (type)
, _codecOrder ()
, _codecStr ("")
, _ringtonePath ("/usr/share/sflphone/ringtones/konga.ul")
, _ringtoneEnabled (true)
, _displayName ("")
, _useragent ("SFLphone")
{
setRegistrationState (Unregistered);
setRegistrationState (Unregistered);
}
Account::~Account()
{
}
void Account::loadConfig() {
void Account::loadConfig()
{
// If IAX is not supported, do not register this account
// If IAX is not supported, do not register this account
#ifndef USE_IAX
if (_type == "IAX")
_enabled = false;
if (_type == "IAX")
_enabled = false;
#endif
loadAudioCodecs ();
loadAudioCodecs ();
}
void Account::setRegistrationState (RegistrationState state) {
void Account::setRegistrationState (RegistrationState state)
{
if (state != _registrationState) {
_debug ("Account: set registration state");
_registrationState = state;
if (state != _registrationState) {
_debug ("Account: set registration state");
_registrationState = state;
// Notify the client
Manager::instance().connectionStatusNotification();
}
// Notify the client
Manager::instance().connectionStatusNotification();
}
}
void Account::loadAudioCodecs (void) {
// if the user never set the codec list, use the default configuration for this account
if(_codecStr == "") {
_info ("Account: use the default order");
Manager::instance ().getCodecDescriptorMap ().setDefaultOrder();
}
// else retrieve the one set in the user config file
else {
std::vector<std::string> active_list = Manager::instance ().retrieveActiveCodecs();
// This property is now set per account basis
// std::string s = Manager::instance ().getConfigString (_accountID, "ActiveCodecs");
setActiveCodecs (Manager::instance ().unserialize (_codecStr));
}
void Account::loadAudioCodecs (void)
{
// if the user never set the codec list, use the default configuration for this account
if (_codecStr == "") {
_info ("Account: use the default order");
Manager::instance ().getCodecDescriptorMap ().setDefaultOrder();
}
// else retrieve the one set in the user config file
else {
std::vector<std::string> active_list = Manager::instance ().retrieveActiveCodecs();
// This property is now set per account basis
// std::string s = Manager::instance ().getConfigString (_accountID, "ActiveCodecs");
setActiveCodecs (Manager::instance ().unserialize (_codecStr));
}
}
void Account::setActiveCodecs (const std::vector <std::string> &list) {
_codecOrder.clear();
// list contains the ordered payload of active codecs picked by the user for this account
// we used the CodecOrder vector to save the order.
int i=0;
int payload;
size_t size = list.size();
while ( (unsigned int) i < size) {
payload = std::atoi (list[i].data());
_info ("Account: Adding codec with RTP payload=%i", payload);
//if (Manager::instance ().getCodecDescriptorMap ().isCodecLoaded (payload)) {
_codecOrder.push_back ( (AudioCodecType) payload);
//}
i++;
}
// setConfig
_codecStr = Manager::instance ().serialize (list);
void Account::setActiveCodecs (const std::vector <std::string> &list)
{
_codecOrder.clear();
// list contains the ordered payload of active codecs picked by the user for this account
// we used the CodecOrder vector to save the order.
int i=0;
int payload;
size_t size = list.size();
while ( (unsigned int) i < size) {
payload = std::atoi (list[i].data());
_info ("Account: Adding codec with RTP payload=%i", payload);
//if (Manager::instance ().getCodecDescriptorMap ().isCodecLoaded (payload)) {
_codecOrder.push_back ( (AudioCodecType) payload);
//}
i++;
}
// setConfig
_codecStr = Manager::instance ().serialize (list);
}
......@@ -50,26 +50,26 @@ AccountCreator::createAccount (AccountType type, AccountID accountID)
{
switch (type) {
case SIP_ACCOUNT: {
_debug("AccountCreator: create account %s", accountID.c_str());
return new SIPAccount (accountID);
break;
}
case SIP_DIRECT_IP_ACCOUNT: {
_debug("AccountCreator: create account IP2IP_PROFILE");
return new SIPAccount (IP2IP_PROFILE);
break;
}
case SIP_ACCOUNT: {
_debug ("AccountCreator: create account %s", accountID.c_str());
return new SIPAccount (accountID);
break;
}
case SIP_DIRECT_IP_ACCOUNT: {
_debug ("AccountCreator: create account IP2IP_PROFILE");
return new SIPAccount (IP2IP_PROFILE);
break;
}
#ifdef USE_IAX
case IAX_ACCOUNT: {
_debug("AccountCreator: create account %s", accountID.c_str());
return new IAXAccount (accountID);
break;
}
case IAX_ACCOUNT: {
_debug ("AccountCreator: create account %s", accountID.c_str());
return new IAXAccount (accountID);
break;
}
#endif
default:
_error("AccountCreator: Error: unknown account type");
default:
_error ("AccountCreator: Error: unknown account type");
}
return 0;
......
......@@ -64,7 +64,7 @@ AudioLoop::getNext (SFLDataFormat* output, int nb, short volume)
bcopy (_buffer+pos, output, block*sizeof (SFLDataFormat)); // short>char conversion
if (volume!=100) {
for (int i=0;i<block;i++) {
for (int i=0; i<block; i++) {
*output = (*output * volume) /100;
output++;
}
......
......@@ -33,47 +33,48 @@
AudioProcessing::AudioProcessing(Algorithm *_algo) : _algorithm(_algo) {}
AudioProcessing::AudioProcessing (Algorithm *_algo) : _algorithm (_algo) {}
AudioProcessing::~AudioProcessing(void){}
AudioProcessing::~AudioProcessing (void) {}
void AudioProcessing::resetAlgorithm(void)
void AudioProcessing::resetAlgorithm (void)
{
if(_algorithm)
_algorithm->reset();
if (_algorithm)
_algorithm->reset();
}
int AudioProcessing::getData(SFLDataFormat *outputData)
int AudioProcessing::getData (SFLDataFormat *outputData)
{
if(_algorithm)
return _algorithm->getData(outputData);
else
return 0;
if (_algorithm)
return _algorithm->getData (outputData);
else
return 0;
}
void AudioProcessing::putData(SFLDataFormat *inputData, int nbBytes)
void AudioProcessing::putData (SFLDataFormat *inputData, int nbBytes)
{
if(_algorithm)
_algorithm->putData(inputData, nbBytes);
if (_algorithm)
_algorithm->putData (inputData, nbBytes);
}
void AudioProcessing::processAudio(SFLDataFormat *inputData, int nbBytes)
void AudioProcessing::processAudio (SFLDataFormat *inputData, int nbBytes)
{
if(_algorithm)
_algorithm->process(inputData, nbBytes);
if (_algorithm)
_algorithm->process (inputData, nbBytes);
}
int AudioProcessing::processAudio(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes)
int AudioProcessing::processAudio (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes)
{
if(_algorithm)
return _algorithm->process(inputData, outputData, nbBytes);
else
return 0;
if (_algorithm)
return _algorithm->process (inputData, outputData, nbBytes);
else
return 0;
}
void AudioProcessing::processAudio(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {
if(_algorithm)
_algorithm->process(micData, spkrData, outputData, nbBytes);
void AudioProcessing::processAudio (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes)
{
if (_algorithm)
_algorithm->process (micData, spkrData, outputData, nbBytes);
}
......@@ -104,12 +104,12 @@ void AudioRecord::initFileName (std::string peerNumber)
if (fileType_ == FILE_RAW) {
if (strstr (fileName_, ".raw") == NULL) {
_debug("AudioRecord: concatenate .raw file extension: name : %s", fileName_);
_debug ("AudioRecord: concatenate .raw file extension: name : %s", fileName_);
fName.append (".raw");
}
} else if (fileType_ == FILE_WAV) {
if (strstr (fileName_, ".wav") == NULL) {
_debug("AudioRecord: concatenate .wav file extension: name : %s", fileName_);
_debug ("AudioRecord: concatenate .wav file extension: name : %s", fileName_);
fName.append (".wav");
}
}
......@@ -196,18 +196,16 @@ bool AudioRecord::setRecording()
{
if (isOpenFile()) {
if (!recordingEnabled_) {
_info ("AudioRecording: Start recording");
recordingEnabled_ = true;
}
else {
recordingEnabled_ = false;
_info ("AudioRecording: Stop recording");
}
}
else {
if (!recordingEnabled_) {
_info ("AudioRecording: Start recording");
recordingEnabled_ = true;
} else {
recordingEnabled_ = false;
_info ("AudioRecording: Stop recording");
}
} else {
openFile();
recordingEnabled_ = true; // once opend file, start recording
}
......@@ -275,7 +273,7 @@ void AudioRecord::createFilename()
// fileName_ = out.str();
strncpy (fileName_, out.str().c_str(), 8192);
_info("AudioRecord: create filename for this call %s ", fileName_);
_info ("AudioRecord: create filename for this call %s ", fileName_);
}
bool AudioRecord::setRawFile()
......@@ -305,7 +303,7 @@ bool AudioRecord::setWavFile()
fp = fopen (savePath_.c_str(), "wb");
if (!fp) {
_warn("AudioRecord: Error: could not create WAV file.");
_warn ("AudioRecord: Error: could not create WAV file.");
return false;
}
......@@ -333,7 +331,7 @@ bool AudioRecord::setWavFile()
if (fwrite (&hdr, 4, 11, fp) != 11) {
_warn("AudioRecord: Error: could not write WAV header for file. ");
_warn ("AudioRecord: Error: could not write WAV header for file. ");
return false;
}
......@@ -363,7 +361,7 @@ bool AudioRecord::openExistingWavFile()
fp = fopen (fileName_, "rb+");
if (!fp) {
_warn("AudioRecord: Error: could not open WAV file!");
_warn ("AudioRecord: Error: could not open WAV file!");
return false;
}
......@@ -373,7 +371,7 @@ bool AudioRecord::openExistingWavFile()
_warn ("AudioRecord: Error: Couldn't seek offset 40 in the file ");
if (fread (&byteCounter_, 4, 1, fp))
_warn("AudioRecord: Error: bytecounter Read successfully ");
_warn ("AudioRecord: Error: bytecounter Read successfully ");
if (fseek (fp, 0 , SEEK_END) != 0)
_warn ("AudioRecord: Error: Couldn't seek at the en of the file ");
......@@ -406,29 +404,33 @@ void AudioRecord::closeWavFile()
return;
}
_debug("AudioRecord: Close wave file");
_debug ("AudioRecord: Close wave file");
SINT32 bytes = byteCounter_ * channels_;
fseek (fp, 40, SEEK_SET); // jump to data length
if (ferror (fp))
if (ferror (fp))
_warn ("AudioRecord: Error: can't reach offset 40 while closing");
fwrite (&bytes, sizeof (SINT32), 1, fp);
if (ferror (fp))
if (ferror (fp))
_warn ("AudioRecord: Error: can't write bytes for data length ");
bytes = byteCounter_ * channels_ + 44; // + 44 for the wave header
fseek (fp, 4, SEEK_SET); // jump to file size
if (ferror (fp))
if (ferror (fp))
_warn ("AudioRecord: Error: can't reach offset 4");
fwrite (&bytes, 4, 1, fp);
if (ferror (fp))
_warn("AudioRecord: Error: can't reach offset 4");
if (ferror (fp))
_warn ("AudioRecord: Error: can't reach offset 4");
if (fclose (fp) != 0)
......@@ -471,7 +473,7 @@ void AudioRecord::recMicData (SFLDataFormat* buffer, int nSamples)
void AudioRecord::recData (SFLDataFormat* buffer, int nSamples)
{
if (recordingEnabled_) {
if (recordingEnabled_) {
if (fp == 0) {
_debug ("AudioRecord: Can't record data, a file has not yet been opened!");
......@@ -499,7 +501,7 @@ void AudioRecord::recData (SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int
if (recordingEnabled_) {
_debug("Recording enabled");
_debug ("Recording enabled");
if (fp == 0) {
_debug ("AudioRecord: Can't record data, a file has not yet been opened!");
......
......@@ -39,7 +39,7 @@ AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) : Thread()
++count;
std::string id("processid_");
std::string id ("processid_");
// convert count into string
std::string s;
......@@ -47,10 +47,10 @@ AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) : Thread()
out << count;
s = out.str();
recorderId = id.append(s);
recorderId = id.append (s);
arecord = arec;
mbuffer = mb;
mbuffer = mb;
}
......@@ -61,19 +61,19 @@ void AudioRecorder::run (void)
{
SFLDataFormat buffer[10000];
while(true) {
while (true) {
if(!mbuffer)
_warn("AudioRecorder: Error: No instance of ringbuffer");
if (!mbuffer)
_warn ("AudioRecorder: Error: No instance of ringbuffer");
int availBytes = mbuffer->availForGet(recorderId);
int availBytes = mbuffer->availForGet (recorderId);
if(availBytes > 0) {
if (availBytes > 0) {
arecord->recData(buffer, availBytes/sizeof(SFLDataFormat));
}
arecord->recData (buffer, availBytes/sizeof (SFLDataFormat));
}
sleep(20);
sleep (20);
}
......
......@@ -64,7 +64,7 @@ AudioRtpFactory::~AudioRtpFactory()
stop();
}
void AudioRtpFactory::initAudioRtpConfig(SIPCall *ca)
void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca)
{
assert (ca);
......@@ -95,6 +95,7 @@ void AudioRtpFactory::initAudioRtpSession (SIPCall * ca)
ost::MutexLock m (_audioRtpThreadMutex);
_debug ("Srtp enable: %d ", _srtpEnabled);
if (_srtpEnabled) {
std::string zidFilename (Manager::instance().getConfigString (SIGNALISATION, ZRTP_ZIDFILE));
......@@ -115,14 +116,14 @@ void AudioRtpFactory::initAudioRtpSession (SIPCall * ca)
case Sdes:
_rtpSession = new AudioSrtpSession (&Manager::instance(), ca);
_rtpSession = new AudioSrtpSession (&Manager::instance(), ca);
_rtpSessionType = Sdes;
ca->getLocalSDP()->set_srtp_crypto(static_cast<AudioSrtpSession *> (_rtpSession)->getLocalCryptoInfo());
break;
ca->getLocalSDP()->set_srtp_crypto (static_cast<AudioSrtpSession *> (_rtpSession)->getLocalCryptoInfo());
break;
default:
_debug("Unsupported Rtp Session Exception Type!");
_debug ("Unsupported Rtp Session Exception Type!");
throw UnsupportedRtpSessionType();
}
} else {
......@@ -141,15 +142,17 @@ void AudioRtpFactory::start (AudioCodec* audiocodec)
switch (_rtpSessionType) {
case Sdes:
if (static_cast<AudioSrtpSession *> (_rtpSession)->startRtpThread(audiocodec) != 0) {
if (static_cast<AudioSrtpSession *> (_rtpSession)->startRtpThread (audiocodec) != 0) {
throw AudioRtpFactoryException ("RTP: Error: Failed to start AudioSRtpSession thread");
}
break;
break;
case Symmetric:
_debug ("Starting symmetric rtp thread");
if (static_cast<AudioSymmetricRtpSession *> (_rtpSession)->startRtpThread(audiocodec) != 0) {
if (static_cast<AudioSymmetricRtpSession *> (_rtpSession)->startRtpThread (audiocodec) != 0) {
throw AudioRtpFactoryException ("RTP: Error: Failed to start AudioSymmetricRtpSession thread");
}
......@@ -157,9 +160,10 @@ void AudioRtpFactory::start (AudioCodec* audiocodec)
case Zrtp:
if (static_cast<AudioZrtpSession *> (_rtpSession)->startRtpThread(audiocodec) != 0) {
if (static_cast<AudioZrtpSession *> (_rtpSession)->startRtpThread (audiocodec) != 0) {
throw AudioRtpFactoryException ("RTP: Error: Failed to start AudioZrtpSession thread");
}
break;
}
}
......@@ -167,7 +171,7 @@ void AudioRtpFactory::start (AudioCodec* audiocodec)
void AudioRtpFactory::stop (void)
{
ost::MutexLock mutex (_audioRtpThreadMutex);
_info("RTP: Stopping audio rtp session");
_info ("RTP: Stopping audio rtp session");
if (_rtpSession == NULL) {
_debugException ("RTP: Error: _rtpSession is null when trying to stop. Returning.");
......@@ -178,8 +182,8 @@ void AudioRtpFactory::stop (void)
switch (_rtpSessionType) {
case Sdes:
delete static_cast<AudioSrtpSession *> (_rtpSession);
break;
delete static_cast<AudioSrtpSession *> (_rtpSession);
break;
case Symmetric:
delete static_cast<AudioSymmetricRtpSession *> (_rtpSession);
......@@ -193,13 +197,14 @@ void AudioRtpFactory::stop (void)
_rtpSession = NULL;
} catch (...) {
_debugException ("RTP: Error: Exception caught when stopping the audio rtp session");
throw AudioRtpFactoryException("RTP: Error: caught exception in AudioRtpFactory::stop");
throw AudioRtpFactoryException ("RTP: Error: caught exception in AudioRtpFactory::stop");
}
}
void AudioRtpFactory::updateDestinationIpAddress (void)
{
_info ("RTP: Updating IP address");
if (_rtpSession == NULL) {
throw AudioRtpFactoryException ("RTP: Error: _rtpSession was null when trying to update IP address");
}
......@@ -207,26 +212,26 @@ void AudioRtpFactory::updateDestinationIpAddress (void)
switch (_rtpSessionType) {
case Sdes:
static_cast<AudioSrtpSession *> (_rtpSession)->updateDestinationIpAddress();
break;
static_cast<AudioSrtpSession *> (_rtpSession)->updateDestinationIpAddress();
break;
case Symmetric:
static_cast<AudioSymmetricRtpSession *> (_rtpSession)->updateDestinationIpAddress();
break;
case Zrtp:
static_cast<AudioZrtpSession *> (_rtpSession)->updateDestinationIpAddress();
static_cast<AudioZrtpSession *> (_rtpSession)->updateDestinationIpAddress();
break;
}
}
sfl::AudioSymmetricRtpSession * AudioRtpFactory::getAudioSymetricRtpSession()
{
if ( (_rtpSessionType == Symmetric) && (_rtpSessionType != NULL)) {
return static_cast<AudioSymmetricRtpSession *> (_rtpSession);
} else {
throw AudioRtpFactoryException("RTP: Error: _rtpSession is NULL in getAudioSymetricRtpSession");
}
if ( (_rtpSessionType == Symmetric) && (_rtpSessionType != NULL)) {
return static_cast<AudioSymmetricRtpSession *> (_rtpSession);
} else {
throw AudioRtpFactoryException ("RTP: Error: _rtpSession is NULL in getAudioSymetricRtpSession");
}
}
sfl::AudioZrtpSession * AudioRtpFactory::getAudioZrtpSession()
......@@ -234,35 +239,35 @@ sfl::AudioZrtpSession * AudioRtpFactory::getAudioZrtpSession()
if ( (_rtpSessionType == Zrtp) && (_rtpSessionType != NULL)) {
return static_cast<AudioZrtpSession *> (_rtpSession);
} else {
throw AudioRtpFactoryException("RTP: Error: _rtpSession is NULL in getAudioZrtpSession");
throw AudioRtpFactoryException ("RTP: Error: _rtpSession is NULL in getAudioZrtpSession");
}
}
void AudioRtpFactory::setRemoteCryptoInfo(sfl::SdesNegotiator& nego)
void AudioRtpFactory::setRemoteCryptoInfo (sfl::SdesNegotiator& nego)
{
if ( _rtpSession && _rtpSessionType && (_rtpSessionType == Sdes)) {
static_cast<AudioSrtpSession *> (_rtpSession)->setRemoteCryptoInfo(nego);
}
else {
throw AudioRtpFactoryException("RTP: Error: _rtpSession is NULL in setRemoteCryptoInfo");
if (_rtpSession && _rtpSessionType && (_rtpSessionType == Sdes)) {
static_cast<AudioSrtpSession *> (_rtpSession)->setRemoteCryptoInfo (nego);
} else {
throw AudioRtpFactoryException ("RTP: Error: _rtpSession is NULL in setRemoteCryptoInfo");
}
}
void AudioRtpFactory::sendDtmfDigit(int digit) {
switch(_rtpSessionType) {
void AudioRtpFactory::sendDtmfDigit (int digit)
{
switch (_rtpSessionType) {
case Sdes:
static_cast<AudioSrtpSession *> (_rtpSession)->putDtmfEvent(digit);
break;
case Sdes:
static_cast<AudioSrtpSession *> (_rtpSession)->putDtmfEvent (digit);
break;
case Symmetric:
static_cast<AudioSymmetricRtpSession *> (_rtpSession)->putDtmfEvent(digit);
break;
case Symmetric:
static_cast<AudioSymmetricRtpSession *> (_rtpSession)->putDtmfEvent (digit);
break;
case Zrtp:
static_cast<AudioZrtpSession *> (_rtpSession)->putDtmfEvent(digit);
break;
}
case Zrtp:
static_cast<AudioZrtpSession *> (_rtpSession)->putDtmfEvent (digit);
break;
}
}
}
......
......@@ -55,7 +55,7 @@ ZrtpSessionCallback::ZrtpSessionCallback (SIPCall *sipcall) :
return;
}
_info("Zrtp: Initialize callbacks");
_info ("Zrtp: Initialize callbacks");
/**
* Information Map
......
......@@ -58,32 +58,32 @@ class Celt : public AudioCodec
_mode = celt_mode_create (_clockRate, _frameSize, &error);
if(error != CELT_OK) {
switch(error) {