From b7bd64faa7da9a8370b5d019bc2142f6fa8e2fd8 Mon Sep 17 00:00:00 2001 From: yanmorin <yanmorin> Date: Fri, 14 Oct 2005 14:03:51 +0000 Subject: [PATCH] Namespace cleaning Remove exception bug on 'stop' --- src/audio/alaw.cpp | 2 +- src/audio/alaw.h | 4 ++-- src/audio/audiocodec.cpp | 9 +++------ src/audio/audiocodec.h | 13 +++++-------- src/audio/audiolayer.cpp | 9 +++------ src/audio/audiortp.cpp | 31 ++++++++++++++----------------- src/audio/codecDescriptor.cpp | 10 +++++----- src/audio/gsmcodec.cpp | 2 +- src/audio/gsmcodec.h | 4 ++-- src/audio/tonegenerator.cpp | 20 +++++++++----------- src/audio/ulaw.cpp | 2 +- src/audio/ulaw.h | 4 ++-- src/error.cpp | 3 --- src/eventthread.cpp | 4 ---- src/gui/guiframework.cpp | 6 ++---- src/managerimpl.cpp | 5 +---- src/sipcall.cpp | 6 +----- src/sipcall.h | 2 +- src/sipvoiplink.cpp | 6 +++--- src/voIPLink.cpp | 16 ++++++---------- 20 files changed, 62 insertions(+), 96 deletions(-) diff --git a/src/audio/alaw.cpp b/src/audio/alaw.cpp index 041ee3337f..3c3dc34fdb 100644 --- a/src/audio/alaw.cpp +++ b/src/audio/alaw.cpp @@ -20,7 +20,7 @@ #include "g711.h" #include "alaw.h" -Alaw::Alaw(int payload, const string& codec) : AudioCodec(payload, codec) +Alaw::Alaw(int payload, const std::string& codec) : AudioCodec(payload, codec) { _codecName = codec; _payload = payload; diff --git a/src/audio/alaw.h b/src/audio/alaw.h index 27a6038670..c75e0a550b 100644 --- a/src/audio/alaw.h +++ b/src/audio/alaw.h @@ -24,14 +24,14 @@ class Alaw : public AudioCodec { public: - Alaw (int payload, const string& codec); + Alaw (int payload, const std::string& codec); ~Alaw (void); int codecDecode (short *, unsigned char *, unsigned int); int codecEncode (unsigned char *, short *, unsigned int); private: - string _codecName; + std::string _codecName; int _payload; }; diff --git a/src/audio/audiocodec.cpp b/src/audio/audiocodec.cpp index 146b0cd137..358aeb616e 100644 --- a/src/audio/audiocodec.cpp +++ b/src/audio/audiocodec.cpp @@ -22,10 +22,7 @@ #include "audiocodec.h" -using namespace std; - - -AudioCodec::AudioCodec (int payload, const string& codec) { +AudioCodec::AudioCodec (int payload, const std::string& codec) { _codecName = codec; _payload = payload; } @@ -34,12 +31,12 @@ AudioCodec::~AudioCodec (void) { } void -AudioCodec::setCodecName (const string& codec) +AudioCodec::setCodecName (const std::string& codec) { _codecName = codec; } -string +std::string AudioCodec::getCodecName (void) { return _codecName; diff --git a/src/audio/audiocodec.h b/src/audio/audiocodec.h index a464ba76c3..cf682f89bf 100644 --- a/src/audio/audiocodec.h +++ b/src/audio/audiocodec.h @@ -1,5 +1,6 @@ /** * Copyright (C) 2004-2005 Savoir-Faire Linux inc. + * Author: Yan Morin <yan.morin@savoirfairelinux.com> * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify @@ -24,23 +25,19 @@ #include <string> #include "../global.h" -using namespace std; - - - class AudioCodec { public: - AudioCodec(int payload, const string& codec); + AudioCodec(int payload, const std::string& codec); virtual ~AudioCodec (void); virtual int codecDecode (short *, unsigned char *, unsigned int) = 0; virtual int codecEncode (unsigned char *, short *, unsigned int) = 0; - void setCodecName (const string& codec); - string getCodecName (void); + void setCodecName (const std::string& codec); + std::string getCodecName (void); private: - string _codecName; + std::string _codecName; int _payload; }; diff --git a/src/audio/audiolayer.cpp b/src/audio/audiolayer.cpp index 66811e2853..c5ba9570e5 100644 --- a/src/audio/audiolayer.cpp +++ b/src/audio/audiolayer.cpp @@ -19,18 +19,15 @@ */ #ifdef AUDIO_PORTAUDIO - + #include <stdio.h> #include <stdlib.h> -#include <string.h> #include "audiolayer.h" #include "../error.h" #include "../global.h" #include "../manager.h" -using namespace std; - AudioLayer::AudioLayer () : _urgentRingBuffer(SIZEBUF) , _mainSndRingBuffer(SIZEBUF) @@ -210,8 +207,8 @@ AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer, toPut = (micAvailPut <= (int)framesPerBuffer) ? micAvailPut : framesPerBuffer; _micRingBuffer.Put(in, SAMPLES_SIZE(toPut)); - - return paContinue; + + return paContinue; } #endif // defined(AUDIO_PORTAUDIO) diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index b22b7da308..b85805c167 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -21,8 +21,7 @@ #include <cstdio> #include <cstdlib> #include <ccrtp/rtp.h> -#include <assert.h> -#include <iostream> +#include <assert.h> #include <string> #include "../global.h" @@ -36,10 +35,6 @@ #include "../sipcall.h" #include "../../stund/stun.h" -using namespace ost; -using namespace std; - - //////////////////////////////////////////////////////////////////////////////// // AudioRtp //////////////////////////////////////////////////////////////////////////////// @@ -48,7 +43,6 @@ AudioRtp::AudioRtp () { } AudioRtp::~AudioRtp (void) { - terminate(); delete _RTXThread; _RTXThread = NULL; } @@ -102,21 +96,24 @@ AudioRtp::closeRtpSession (SipCall *ca) { AudioRtpRTX::AudioRtpRTX (SipCall *sipcall, AudioLayer* driver, bool sym) { - time = new Time(); + time = new ost::Time(); _ca = sipcall; _sym = sym; _audioDevice = driver; // TODO: Change bind address according to user settings. std::string localipConfig = _ca->getLocalIp(); - InetHostAddress local_ip(localipConfig.c_str()); + ost::InetHostAddress local_ip(localipConfig.c_str()); _debug("RTP: listening on IP %s local port : %d\n", localipConfig.c_str(), _ca->getLocalAudioPort()); if (!_sym) { - _sessionRecv = new RTPSession (local_ip, _ca->getLocalAudioPort()); - _sessionSend = new RTPSession (local_ip); + _sessionRecv = new ost::RTPSession (local_ip, _ca->getLocalAudioPort()); + _sessionSend = new ost::RTPSession (local_ip); + _session = NULL; } else { - _session = new SymmetricRTPSession (local_ip, _ca->getLocalAudioPort()); + _session = new ost::SymmetricRTPSession (local_ip, _ca->getLocalAudioPort()); + _sessionRecv = NULL; + _sessionSend = NULL; } } @@ -135,7 +132,7 @@ AudioRtpRTX::~AudioRtpRTX () { void AudioRtpRTX::initAudioRtpSession (void) { - InetHostAddress remote_ip(_ca->getRemoteSdpAudioIp()); + ost::InetHostAddress remote_ip(_ca->getRemoteSdpAudioIp()); if (!remote_ip) { _debug("RTP: Target IP address [%s] is not correct!\n", _ca->getRemoteSdpAudioIp()); @@ -170,8 +167,8 @@ AudioRtpRTX::initAudioRtpSession (void) //setPayloadFormat(StaticPayloadFormat(sptPCMU)); _debug("Payload Format: %d\n", _ca->payload); - _sessionRecv->setPayloadFormat(StaticPayloadFormat((StaticPayloadType) _ca->payload)); - _sessionSend->setPayloadFormat(StaticPayloadFormat((StaticPayloadType) _ca->payload)); + _sessionRecv->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) _ca->payload)); + _sessionSend->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) _ca->payload)); setCancel(cancelImmediate); _sessionSend->setMark(true); @@ -180,7 +177,7 @@ AudioRtpRTX::initAudioRtpSession (void) if (!_session->addDestination (remote_ip, (unsigned short) _ca->getRemoteSdpAudioPort())) { return; } else { - _session->setPayloadFormat(StaticPayloadFormat((StaticPayloadType) _ca->payload)); + _session->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) _ca->payload)); setCancel(cancelImmediate); } } @@ -232,7 +229,7 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers, { int expandedSize; int k; - const AppDataUnit* adu = NULL; + const ost::AppDataUnit* adu = NULL; // Get audio data stream if (!_sym) { diff --git a/src/audio/codecDescriptor.cpp b/src/audio/codecDescriptor.cpp index 1c6ed5261a..7c64f397a7 100644 --- a/src/audio/codecDescriptor.cpp +++ b/src/audio/codecDescriptor.cpp @@ -129,23 +129,23 @@ CodecDescriptor::rtpmapPayload (int payload) { // we create one, but in MainManager for the list switch (payload) { case PAYLOAD_CODEC_ALAW: - return string("PCMA"); + return std::string("PCMA"); break; case PAYLOAD_CODEC_ULAW: - return string("PCMU"); + return std::string("PCMU"); break; case PAYLOAD_CODEC_GSM: - return string("GSM"); + return std::string("GSM"); break; case PAYLOAD_CODEC_ILBC: - return string("iLBC"); + return std::string("iLBC"); break; case PAYLOAD_CODEC_SPEEX: - return string("speex"); + return std::string("speex"); break; default: diff --git a/src/audio/gsmcodec.cpp b/src/audio/gsmcodec.cpp index 9f18951de4..36767d1c41 100644 --- a/src/audio/gsmcodec.cpp +++ b/src/audio/gsmcodec.cpp @@ -21,7 +21,7 @@ #include "gsmcodec.h" #include "../global.h" -Gsm::Gsm(int payload, const string& codec) : AudioCodec(payload, codec) +Gsm::Gsm(int payload, const std::string& codec) : AudioCodec(payload, codec) { _codecName = codec; _payload = payload; diff --git a/src/audio/gsmcodec.h b/src/audio/gsmcodec.h index 03fcd35427..27073fbb32 100644 --- a/src/audio/gsmcodec.h +++ b/src/audio/gsmcodec.h @@ -27,14 +27,14 @@ extern "C" { class Gsm : public AudioCodec { public: - Gsm (int payload, const string& codec); + Gsm (int payload, const std::string& codec); ~Gsm (void); int codecDecode (short *, unsigned char *, unsigned int); int codecEncode (unsigned char *, short *, unsigned int); private: - string _codecName; + std::string _codecName; int _payload; gsm _decode_gsmhandle; gsm _encode_gsmhandle; diff --git a/src/audio/tonegenerator.cpp b/src/audio/tonegenerator.cpp index 1842f6f443..18508b92d7 100644 --- a/src/audio/tonegenerator.cpp +++ b/src/audio/tonegenerator.cpp @@ -31,8 +31,6 @@ #include "../manager.h" #include "../user_cfg.h" -using namespace std; - int AMPLITUDE = 8192; @@ -184,14 +182,14 @@ ToneGenerator::generateSin (int lowerfreq, int higherfreq, int16* ptr, int len) */ void ToneGenerator::buildTone (unsigned int idCountry, unsigned int idTones, int16* temp) { - string s; + std::string s; int count = 0; int byte = 0; int nbcomma = 0; int16 *buffer = new int16[SIZEBUF]; //1kb int pos; - string str(toneZone[idCountry][idTones]); + std::string str(toneZone[idCountry][idTones]); nbcomma = contains(toneZone[idCountry][idTones], ','); // Number of format sections @@ -271,7 +269,7 @@ ToneGenerator::buildTone (unsigned int idCountry, unsigned int idTones, int16* t * @return id of the zone */ int -ToneGenerator::idZoneName (const string& name) { +ToneGenerator::idZoneName (const std::string& name) { if (name.compare("North America") == 0) { return ID_NORTH_AMERICA; } else if (name.compare("France") == 0) { @@ -350,16 +348,16 @@ ToneGenerator::playRingtone (const char *fileName) { return 0; } - fstream file; - file.open(fileName, fstream::in); + std::fstream file; + file.open(fileName, std::fstream::in); if (!file.is_open()) { return 0; } // get length of file: - file.seekg (0, ios::end); + file.seekg (0, std::ios::end); length = file.tellg(); - file.seekg (0, ios::beg); + file.seekg (0, std::ios::beg); // allocate memory: _src = new char [length]; @@ -382,12 +380,12 @@ ToneGenerator::playRingtone (const char *fileName) { } int -ToneGenerator::contains (const string& str, char c) +ToneGenerator::contains (const std::string& str, char c) { static int nb = 0; unsigned int pos = str.find(c); - if (pos != string::npos) { + if (pos != std::string::npos) { nb = nb + 1; return contains(str.substr(pos + 1, str.length()), c); } else { diff --git a/src/audio/ulaw.cpp b/src/audio/ulaw.cpp index fd3cddd0c0..3830587d93 100644 --- a/src/audio/ulaw.cpp +++ b/src/audio/ulaw.cpp @@ -20,7 +20,7 @@ #include "g711.h" #include "ulaw.h" -Ulaw::Ulaw(int payload, const string& codec) : AudioCodec(payload, codec) +Ulaw::Ulaw(int payload, const std::string& codec) : AudioCodec(payload, codec) { _codecName = codec; _payload = payload; diff --git a/src/audio/ulaw.h b/src/audio/ulaw.h index 418f224804..eff25df253 100644 --- a/src/audio/ulaw.h +++ b/src/audio/ulaw.h @@ -24,14 +24,14 @@ class Ulaw : public AudioCodec { public: - Ulaw (int payload, const string& codec); + Ulaw (int payload, const std::string& codec); ~Ulaw (void); int codecDecode (short *, unsigned char *, unsigned int); int codecEncode (unsigned char *, short *, unsigned int); private: - string _codecName; + std::string _codecName; int _payload; }; diff --git a/src/error.cpp b/src/error.cpp index 57395a10c2..bcc3985a8d 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -22,8 +22,6 @@ #include "global.h" #include "error.h" #include "manager.h" - -using namespace std; Error::Error (){ issetError = 0; @@ -31,7 +29,6 @@ Error::Error (){ int Error::errorName (Error_enum num_name) { - string str; switch (num_name){ // Handle opening device errors case OPEN_FAILED_DEVICE: diff --git a/src/eventthread.cpp b/src/eventthread.cpp index fd25ed60e4..67cff80b73 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -17,13 +17,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <iostream> - #include "eventthread.h" #include "sipvoiplink.h" -using namespace std; - EventThread::EventThread (SipVoIPLink* sip) : Thread () { _sipthread = sip; diff --git a/src/gui/guiframework.cpp b/src/gui/guiframework.cpp index 00d013c679..c927faf083 100644 --- a/src/gui/guiframework.cpp +++ b/src/gui/guiframework.cpp @@ -19,8 +19,6 @@ */ #include <string> -using namespace std; - #include "guiframework.h" #include "../manager.h" @@ -30,7 +28,7 @@ GuiFramework::GuiFramework () GuiFramework::~GuiFramework (void) {} int -GuiFramework::outgoingCall (const string& to) +GuiFramework::outgoingCall (const std::string& to) { return Manager::instance().outgoingCall(to); } @@ -86,7 +84,7 @@ GuiFramework::offHoldCall (CALLID id) } int -GuiFramework::transferCall (CALLID id, const string& to) +GuiFramework::transferCall (CALLID id, const std::string& to) { if (Manager::instance().transferCall(id, to) == 0) { return 1; diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 6aa65dddf2..ada5d845ee 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -55,9 +55,6 @@ #define fill_config_int(name, value) \ (_config.addConfigTreeItem(section, Conf::ConfigTreeItem(std::string(name), std::string(value), type_int))) -//using namespace std; -//using namespace ost; - ManagerImpl::ManagerImpl (void) { // initialize random generator @@ -133,7 +130,7 @@ ManagerImpl::init (void) displayError(e.what()); throw e; } - catch (const exception &e) + catch (const std::exception &e) { displayError(e.what()); throw e; diff --git a/src/sipcall.cpp b/src/sipcall.cpp index 6917fbef1e..2028c1481f 100644 --- a/src/sipcall.cpp +++ b/src/sipcall.cpp @@ -21,10 +21,8 @@ */ #include <osipparser2/sdp_message.h> -#include <string.h> +#include <string.h> // strcpy -#include <iostream> - // For AF_INET #include <sys/socket.h> @@ -33,8 +31,6 @@ #include "audio/codecDescriptor.h" #include "sipcall.h" -using namespace std; - SipCall::SipCall (CALLID id, CodecDescriptorVector* cdv) : _localIp("127.0.0.1") { _id = id; // Same id of Call object diff --git a/src/sipcall.h b/src/sipcall.h index 0b3cf478cd..18cb3864ae 100644 --- a/src/sipcall.h +++ b/src/sipcall.h @@ -36,7 +36,7 @@ class AudioCodec; #define _RECVONLY 2 // Vector of CodecDescriptor -typedef std::vector<CodecDescriptor*, allocator<CodecDescriptor*> > CodecDescriptorVector; +typedef std::vector<CodecDescriptor*, std::allocator<CodecDescriptor*> > CodecDescriptorVector; class SipCall { public: diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 3936a1a7d0..e187dea772 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -53,8 +53,8 @@ SipVoIPLink::SipVoIPLink() SipVoIPLink::~SipVoIPLink(void) { endSipCalls(); - eXosip_quit(); delete _evThread; _evThread = NULL; + eXosip_quit(); } // for voIPLink interface @@ -1310,9 +1310,9 @@ FULL_NAME); std::string -SipVoIPLink::toHeader(const string& to) +SipVoIPLink::toHeader(const std::string& to) { - if (to.find("sip:") == string::npos) { + if (to.find("sip:") == std::string::npos) { return ("sip:" + to ); } else { return to; diff --git a/src/voIPLink.cpp b/src/voIPLink.cpp index b74cb20fe0..36ce64c744 100644 --- a/src/voIPLink.cpp +++ b/src/voIPLink.cpp @@ -24,10 +24,6 @@ #include "voIPLink.h" #include "manager.h" - -using namespace std; - - VoIPLink::VoIPLink () { initConstructor(); @@ -50,36 +46,36 @@ VoIPLink::getType (void) } void -VoIPLink::setFullName (const string& fullname) +VoIPLink::setFullName (const std::string& fullname) { _fullname = fullname; } -string +std::string VoIPLink::getFullName (void) { return _fullname; } void -VoIPLink::setHostName (const string& hostname) +VoIPLink::setHostName (const std::string& hostname) { _hostname = hostname; } -string +std::string VoIPLink::getHostName (void) { return _hostname; } void -VoIPLink::setLocalIpAddress (const string& ipAdress) +VoIPLink::setLocalIpAddress (const std::string& ipAdress) { _localIpAddress = ipAdress; } -string +std::string VoIPLink::getLocalIpAddress (void) { return _localIpAddress; -- GitLab