diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 081391da703dc8c99db358e04bdbcb43a30c9ecd..b4a75d272c65753474e8d6689e5c5780857979e0 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -3,6 +3,7 @@ * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@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 @@ -106,6 +107,9 @@ GtkWidget * overrtp; GHashTable * directIpCallsProperties = NULL; +gchar *current_username; + + // Credentials enum { COLUMN_CREDENTIAL_REALM, @@ -193,12 +197,17 @@ static GPtrArray* getNewCredential (GHashTable * properties) { -1); g_hash_table_insert(properties, g_strdup(ACCOUNT_REALM), realm); - g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username); + + // better use the current_username as it is the account username in the + // g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username); + g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), current_username); // Do not change the password if nothing has been changed by the user if (g_strcasecmp (password, PW_HIDDEN) != 0) g_hash_table_insert(properties, g_strdup(ACCOUNT_PASSWORD), password); + + valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(credentialStore), &iter); while (valid) { @@ -1345,10 +1354,11 @@ void show_account_window (account_t * a) { gtk_widget_destroy (GTK_WIDGET(dialog)); return; } - + + gchar *key = g_strdup(ACCOUNT_USERNAME); + // If accept button is if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_ALIAS), @@ -1368,6 +1378,10 @@ void show_account_window (account_t * a) { g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox)))); + + // Variable used to update credentials + current_username = (gchar *)g_hash_table_lookup(currentAccount->properties, g_strdup(ACCOUNT_USERNAME)); + } if (proto && strcmp (proto, "SIP") == 0) { diff --git a/sflphone-common/configure.ac b/sflphone-common/configure.ac index 3e321067b154ead9ccf3772b39b6142910d5779c..c7b986863833c2a13c6b93bd5245b9e8e9898ce1 100644 --- a/sflphone-common/configure.ac +++ b/sflphone-common/configure.ac @@ -62,7 +62,6 @@ AC_CONFIG_FILES([Makefile]) src/audio/codecs/Makefile \ src/config/Makefile \ src/dbus/Makefile \ - src/plug-in/audiorecorder/Makefile \ src/plug-in/Makefile \ src/plug-in/test/Makefile \ src/hooks/Makefile \ diff --git a/sflphone-common/src/Makefile.am b/sflphone-common/src/Makefile.am index e0c90658f90f9a06cf46b60cddd15cf501c1b1d8..f41b7b87aeafd60e778948d7b5a6c8e4d07f6eb4 100644 --- a/sflphone-common/src/Makefile.am +++ b/sflphone-common/src/Makefile.am @@ -37,27 +37,8 @@ endif sflphoned_CXXFLAGS = \ -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(IAX_CXXFLAG) $(NETWORKMANAGER) \ - -DVERSION=\"$(VERSION)\" \ - @ZRTPCPP_CFLAGS@ \ - @libssl_CFLAGS@ - - -# Add here the dynamic libraries sflphoned should be linked against -sflphoned_LDADD = \ - ./libsflphone.la \ - @CCGNU2_LIBS@ \ - @CCEXT2_LIBS@ \ - @ZRTPCPP_LIBS@ \ - $(PJSIP_LIBS) \ - @CCRTP_LIBS@ \ - @ALSA_LIBS@ \ - @PULSEAUDIO_LIBS@ \ - @SAMPLERATE_LIBS@ \ - @libssl_LIBS@ - -# sflphoned_LDFLAGS= -pg -luuid -sflphoned_LDFLAGS= $(UUID_LIBS) -DVERSION=\"$(VERSION)\" + # libsflphone sflphoned_LDADD = ./libsflphone.la @@ -86,15 +67,9 @@ libsflphone_la_LIBADD = \ ./sip/libsiplink.la \ ./sip/im/libim.la \ ./audio/libaudio.la \ - ./audio/audiortp/libaudiortp.la \ - ./audio/sound/libsound.la \ - ./audio/codecs/libcodecdescriptor.la \ - ./audio/alsa/libalsalayer.la \ - ./audio/pulseaudio/libpulselayer.la \ ./dbus/libdbus.la \ ./config/libconfig.la \ ./plug-in/libplugin.la \ - ./plug-in/audiorecorder/libaudiorecorder.la \ ./hooks/libhooks.la \ ./history/libhistory.la @@ -102,9 +77,6 @@ libsflphone_la_LDFLAGS = \ @CCGNU2_LIBS@ \ @CCEXT2_LIBS@ \ @ZRTPCPP_LIBS@ \ - @GSTREAMER_LIBS@ \ - @LIBAVCODEC_LIBS@ \ - @LIBSWSCALE_LIBS@ \ $(PJSIP_LIBS) \ @CCRTP_LIBS@ \ @ALSA_LIBS@ \ @@ -117,9 +89,6 @@ libsflphone_la_CFLAGS = \ @CCGNU2_CFLAGS@ \ @CCEXT2_CFLAGS@ \ @ZRTPCPP_CFLAGS@ \ - @GSTREAMER_CFLAGS@ \ - @LIBAVCODEC_CFLAGS@ \ - @LIBSWSCALE_CFLAGS@ \ $(PJSIP_CFLAGS) \ @CCRTP_CFLAGS@ \ @ALSA_CFLAGS@ \ diff --git a/sflphone-common/src/audio/Makefile.am b/sflphone-common/src/audio/Makefile.am index fcf2c2e9b7c22d91d5f70402124026168fa8fdce..8f49c29cc547b096cd2a47d42a951fe4bbbc1c68 100644 --- a/sflphone-common/src/audio/Makefile.am +++ b/sflphone-common/src/audio/Makefile.am @@ -12,6 +12,8 @@ libaudio_la_SOURCES = \ audioloop.cpp \ ringbuffer.cpp \ mainbuffer.cpp \ + audiorecord.cpp \ + audiorecorder.cpp \ recordable.cpp \ audiolayer.cpp \ audiodevice.cpp \ @@ -28,9 +30,11 @@ noinst_HEADERS = \ audioloop.h \ common.h \ ringbuffer.h \ + mainbuffer.h \ + audiorecord.h \ + audiorecorder.h \ audiolayer.h \ audiodevice.h \ - mainbuffer.h \ recordable.h \ algorithm.h \ delaydetection.h \ diff --git a/sflphone-common/src/audio/alsa/Makefile.am b/sflphone-common/src/audio/alsa/Makefile.am index bcc584432ff498be653d216053a3b925f067b3c7..8f67710b33ea530dc6a44016121f6802d51276c7 100644 --- a/sflphone-common/src/audio/alsa/Makefile.am +++ b/sflphone-common/src/audio/alsa/Makefile.am @@ -4,5 +4,5 @@ noinst_LTLIBRARIES = libalsalayer.la libalsalayer_la_SOURCES = alsalayer.cpp -noinst_HEADERS = alsalayer.h +noinst_HEADERS = alsalayer.h diff --git a/sflphone-common/src/audio/audiolayer.h b/sflphone-common/src/audio/audiolayer.h index f9935e2bc76fc2e001bd7566830d9b951aee6b07..ab2a4559fa144d10278c53ba69c624ba6457eced 100644 --- a/sflphone-common/src/audio/audiolayer.h +++ b/sflphone-common/src/audio/audiolayer.h @@ -37,20 +37,17 @@ #include "audiodevice.h" #include "ringbuffer.h" #include "mainbuffer.h" - -#include <cc++/thread.h> // for ost::Mutex - #include "dcblocker.h" #include "speexechocancel.h" #include "echocancel.h" +#include <cc++/thread.h> // for ost::Mutex /** * @file audiolayer.h * @brief Main sound class. Manages the data transfers between the application and the hardware. */ -class Recordable; class ManagerImpl; class AudioLayer { diff --git a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp b/sflphone-common/src/audio/audiorecord.cpp similarity index 99% rename from sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp rename to sflphone-common/src/audio/audiorecord.cpp index 4cc6d1779432412c61772a0a785dc5bfda8c8fcb..06d97d0b30d0ee58919e957e3f243245a880ae1e 100644 --- a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp +++ b/sflphone-common/src/audio/audiorecord.cpp @@ -120,8 +120,6 @@ void AudioRecord::initFileName (std::string peerNumber) void AudioRecord::openFile() { - _info ("AudioRecord: Open file()"); - bool result = false; _debug ("AudioRecord: Open file()"); @@ -408,6 +406,8 @@ void AudioRecord::closeWavFile() return; } + _debug("AudioRecord: Close wave file"); + SINT32 bytes = byteCounter_ * channels_; @@ -471,7 +471,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,6 +499,8 @@ void AudioRecord::recData (SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int if (recordingEnabled_) { + _debug("Recording enabled"); + if (fp == 0) { _debug ("AudioRecord: Can't record data, a file has not yet been opened!"); return; diff --git a/sflphone-common/src/plug-in/audiorecorder/audiorecord.h b/sflphone-common/src/audio/audiorecord.h similarity index 98% rename from sflphone-common/src/plug-in/audiorecorder/audiorecord.h rename to sflphone-common/src/audio/audiorecord.h index de58f9535e86aa7efe31ad1ac98bcd876d01d781..8e42bd2a245f50c2874b8f313df28f98509510ce 100644 --- a/sflphone-common/src/plug-in/audiorecorder/audiorecord.h +++ b/sflphone-common/src/audio/audiorecord.h @@ -36,10 +36,7 @@ #include <stdlib.h> #include <sstream> -#include "plug-in/plugin.h" -// #include "audiodsp.h" - -// class AudioDSP; +#include "global.h" using namespace std; diff --git a/sflphone-common/src/plug-in/audiorecorder/audiorecorder.cpp b/sflphone-common/src/audio/audiorecorder.cpp similarity index 68% rename from sflphone-common/src/plug-in/audiorecorder/audiorecorder.cpp rename to sflphone-common/src/audio/audiorecorder.cpp index 77587a501171e11490761734024b370245058905..bb846e022b3a728c3bca022514583d0e84e30663 100644 --- a/sflphone-common/src/plug-in/audiorecorder/audiorecorder.cpp +++ b/sflphone-common/src/audio/audiorecorder.cpp @@ -29,13 +29,28 @@ */ #include "audiorecorder.h" +#include "mainbuffer.h" -AudioRecorder::AudioRecorder (AudioRecord *arec) - : Thread(), recorderId("recorder_id") +int AudioRecorder::count = 0; + +AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) : Thread() { setCancel (cancelDeferred); + ++count; + + std::string id("processid_"); + + // convert count into string + std::string s; + std::stringstream out; + out << count; + s = out.str(); + + recorderId = id.append(s); + arecord = arec; + mbuffer = mb; } @@ -44,13 +59,26 @@ AudioRecorder::AudioRecorder (AudioRecord *arec) */ void AudioRecorder::run (void) { - SFLDataFormat buffer[10000]; - // int availBytes = mbuffer->availForGet(recorderId); + while(true) { + + if(!mbuffer) + _warn("AudioRecorder: Error: No instance of ringbuffer"); + + int availBytes = mbuffer->availForGet(recorderId); + + if(availBytes > 0) { + + int got = mbuffer->getData(buffer, availBytes, 100, recorderId); + + int availBytesAfter = mbuffer->availForGet(recorderId); + + arecord->recData(buffer, availBytes/sizeof(SFLDataFormat)); + } - // mbuffer->getData(buffer, availBytes, 100, recorderId); + sleep(20); - // arecord->recData(buffer, availBytes/sizeof(SFLDataFormat)); + } } diff --git a/sflphone-common/src/plug-in/audiorecorder/audiorecorder.h b/sflphone-common/src/audio/audiorecorder.h similarity index 94% rename from sflphone-common/src/plug-in/audiorecorder/audiorecorder.h rename to sflphone-common/src/audio/audiorecorder.h index 9b3ef3d26ed9fd242732834a159cf850aeeae5af..b1c15f3a489a49fa058b320cb81caa8153e93208 100644 --- a/sflphone-common/src/plug-in/audiorecorder/audiorecorder.h +++ b/sflphone-common/src/audio/audiorecorder.h @@ -35,13 +35,17 @@ #include "audiorecord.h" #include <string> +class MainBuffer; + class AudioRecorder : public ost::Thread { public: - AudioRecorder(AudioRecord *arec); + AudioRecorder(AudioRecord *arec, MainBuffer *mb); ~AudioRecorder(void){ terminate(); } + static int count; + std::string getRecorderID() { return recorderId; } virtual void run(); @@ -50,10 +54,10 @@ class AudioRecorder : public ost::Thread { AudioRecorder (const AudioRecorder& ar); AudioRecorder& operator=(const AudioRecorder& ar); - // MainBuffer *mbuffer; - std::string recorderId; + MainBuffer *mbuffer; + AudioRecord *arecord; }; diff --git a/sflphone-common/src/audio/audiortp/AudioRtpSession.h b/sflphone-common/src/audio/audiortp/AudioRtpSession.h index b9eef5597162c49715c3b3232c0c004ab328ba4b..5144d3767989d019316a1837aaaa0c0c2f189e3b 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpSession.h @@ -736,10 +736,10 @@ namespace sfl { // DTMF over RTP, size must be over 4 in order to process it as voice data if(size > 4) { - // processDataDecode(spkrDataIn, size); - if(result == JB_OK) { - processDataDecode((unsigned char *)(frame.data), 160); - } + processDataDecode(spkrDataIn, size); + //if(result == JB_OK) { + // processDataDecode((unsigned char *)(frame.data), 160); + //} } delete adu; @@ -815,6 +815,8 @@ namespace sfl { // Recv session receiveSpeakerData (); + /* + // Let's wait for the next transmit cycle if (sessionWaiting == 1) { // Record mic and speaker during conversation @@ -823,6 +825,7 @@ namespace sfl { // Record mic only while leaving a message _ca->recAudio.recData (_micData,_nSamplesMic); } + */ _manager->getAudioLayerMutex()->leave(); diff --git a/sflphone-common/src/audio/dcblocker.cpp b/sflphone-common/src/audio/dcblocker.cpp index bef34f6a510d4064bbe8020800a4ee61c8dcabfb..b1a18eb1a2e6ddcf97568825cd057df55a8b42fc 100644 --- a/sflphone-common/src/audio/dcblocker.cpp +++ b/sflphone-common/src/audio/dcblocker.cpp @@ -54,7 +54,7 @@ void DcBlocker::process (SFLDataFormat *data, int nbBytes) for (int i = 0; i < nbSamples; i++) { _x = data[i]; - _y = (SFLDataFormat) ( (float) _x - (float) _xm1 + 0.9999 * (float) _ym1); + _y = (SFLDataFormat) ( (float) _x - (float) _xm1 + 0.995 * (float) _ym1); _xm1 = _x; _ym1 = _y; diff --git a/sflphone-common/src/audio/mainbuffer.cpp b/sflphone-common/src/audio/mainbuffer.cpp index 91e0d238d850ce61b14d3fe563156c084a498263..2ccc1f8d6e7ee6409bcb4a223e4a42f4f9bca1ab 100644 --- a/sflphone-common/src/audio/mainbuffer.cpp +++ b/sflphone-common/src/audio/mainbuffer.cpp @@ -255,23 +255,33 @@ void MainBuffer::unBindCallID (CallID call_id1, CallID call_id2) } } -void MainBuffer::unBindHalfDuplexOut(CallID call_id, CallID process_id) +void MainBuffer::unBindHalfDuplexOut(CallID process_id, CallID call_id) { removeCallIDfromSet(process_id, call_id); - RingBuffer* ringbuffer; - - ringbuffer = getRingBuffer(process_id); + RingBuffer* ringbuffer = getRingBuffer(call_id); if(ringbuffer) { - ringbuffer->removeReadPointer(call_id); + ringbuffer->removeReadPointer(process_id); if(ringbuffer->getNbReadPointer() == 0) { - removeCallIDSet(process_id); - removeRingBuffer(process_id); + removeCallIDSet(call_id); + removeRingBuffer(call_id); } } + else { + _debug("Error: did not found ringbuffer %s", process_id.c_str()); + removeCallIDSet(process_id); + } + + + CallIDSet* callid_set = getCallIDSet(process_id); + if(callid_set) { + if(callid_set->empty()) + removeCallIDSet(process_id); + } + } @@ -387,9 +397,7 @@ int MainBuffer::getData (void *buffer, int toCopy, unsigned short volume, CallID return 0; } else { - for (int k = 0; k < nbSmplToCopy; k++) { - ( (SFLDataFormat*) (buffer)) [k] = 0; - } + memset(buffer, 0, nbSmplToCopy*sizeof(SFLDataFormat*)); int size = 0; diff --git a/sflphone-common/src/audio/mainbuffer.h b/sflphone-common/src/audio/mainbuffer.h index 551cf8c0871d92f3fd3b686515505b9b94997c28..95dd787ea4c8aab914fcdb0307afd4f7e2b89de4 100644 --- a/sflphone-common/src/audio/mainbuffer.h +++ b/sflphone-common/src/audio/mainbuffer.h @@ -37,12 +37,10 @@ #include <cc++/thread.h> // for ost::Mutex #include <string> -#include "../global.h" -#include "../call.h" +#include "global.h" +#include "call.h" #include "ringbuffer.h" - - typedef std::map<CallID, RingBuffer*> RingBufferMap; typedef std::set<CallID> CallIDSet; diff --git a/sflphone-common/src/audio/recordable.cpp b/sflphone-common/src/audio/recordable.cpp index 7e3c37addf2db1648db1f1cf00ead48922502090..8371bf7ec8b52a82763e3b4ea90a51944eafd48b 100644 --- a/sflphone-common/src/audio/recordable.cpp +++ b/sflphone-common/src/audio/recordable.cpp @@ -29,9 +29,8 @@ #include "recordable.h" #include "manager.h" -#include "mainbuffer.h" -Recordable::Recordable() : recorder(&recAudio) +Recordable::Recordable() : recorder(&recAudio, Manager::instance().getMainBuffer()) { FILE_TYPE fileType = FILE_WAV; diff --git a/sflphone-common/src/audio/recordable.h b/sflphone-common/src/audio/recordable.h index 4cd83dcc5064efb43a664363a80272e367469009..6b08db919674c1529653c343c367c08a3b0f2201 100644 --- a/sflphone-common/src/audio/recordable.h +++ b/sflphone-common/src/audio/recordable.h @@ -30,8 +30,8 @@ #ifndef RECORDABLE_H #define RECORDABLE_H -#include "../plug-in/audiorecorder/audiorecord.h" -#include "../plug-in/audiorecorder/audiorecorder.h" +#include "audiorecord.h" +#include "audiorecorder.h" class Recordable { @@ -41,14 +41,30 @@ class Recordable { ~Recordable(); + /** + * Return recording state (true/false) + */ bool isRecording(){ return recAudio.isRecording(); } + /** + * This method must be implemented for this interface as calls and conferences + * have different behavior. + */ virtual bool setRecording() = 0; + /** + * Stop recording + */ void stopRecording(){ recAudio.stopRecording(); } + /** + * Init the recording file name according to path specified in configuration + */ void initRecFileName(); + /** + * Set recording sampling rate. + */ void setRecordingSmplRate(int smplRate); virtual std::string getRecFileId() = 0; @@ -64,11 +80,6 @@ class Recordable { AudioRecorder recorder; - private: - - /** File name for his call : time YY-MM-DD */ - // std::string _filename; - }; #endif diff --git a/sflphone-common/src/call.cpp b/sflphone-common/src/call.cpp index 65195f5f50c5230641298ea18dc79d59ffccec0b..c640ad77b80d9e49f999cf2d142a21e8aadb9433 100644 --- a/sflphone-common/src/call.cpp +++ b/sflphone-common/src/call.cpp @@ -189,18 +189,33 @@ Call::isAudioStarted() bool Call::setRecording() { - bool recordStatus = Recordable::recAudio.setRecording(); + bool recordStatus = Recordable::recAudio.isRecording(); - if(!recordStatus) - return false; + Recordable::recAudio.setRecording(); - MainBuffer *mbuffer = &(Manager::instance()._mainBuffer); + // Start recording + if(!recordStatus) { - CallID process_id = Recordable::recorder.getRecorderID(); + MainBuffer *mbuffer = Manager::instance().getMainBuffer(); + CallID process_id = Recordable::recorder.getRecorderID(); + + mbuffer->bindHalfDuplexOut(process_id, _id); + mbuffer->bindHalfDuplexOut(process_id); + + } + // Stop recording + else { + + MainBuffer *mbuffer = Manager::instance().getMainBuffer(); + CallID process_id = Recordable::recorder.getRecorderID(); + + mbuffer->unBindHalfDuplexOut(process_id, _id); + mbuffer->unBindHalfDuplexOut(process_id); + + } + + Manager::instance().getMainBuffer()->stateInfo(); - mbuffer->bindHalfDuplexOut(process_id, _id); - mbuffer->bindHalfDuplexOut(process_id); - Recordable::recorder.start(); return recordStatus; diff --git a/sflphone-common/src/call.h b/sflphone-common/src/call.h index 89c81c1f67b0c196243e5e2a678d8c213b151dba..713f23e5609637c9c292c84e7a6d7c453dea1da7 100644 --- a/sflphone-common/src/call.h +++ b/sflphone-common/src/call.h @@ -35,7 +35,6 @@ #include <cc++/thread.h> // for mutex #include <sstream> -// #include "plug-in/audiorecorder/audiorecord.h" #include "audio/recordable.h" #define SIP_SCHEME "sip:" diff --git a/sflphone-common/src/conference.cpp b/sflphone-common/src/conference.cpp index 17ee9a39b50cf1334f780e1c33c63a8694e795b4..20219fc5921f19a641dc3a6829dd57245eec68fb 100644 --- a/sflphone-common/src/conference.cpp +++ b/sflphone-common/src/conference.cpp @@ -162,23 +162,45 @@ ParticipantSet Conference::getParticipantList() bool Conference::setRecording() { - bool recordStatus = Recordable::recAudio.setRecording(); + bool recordStatus = Recordable::recAudio.isRecording(); - if(!recordStatus) - return false; + Recordable::recAudio.setRecording(); - MainBuffer *mbuffer = &(Manager::instance()._mainBuffer); + // start recording + if(!recordStatus){ - ParticipantSet::iterator iter = _participants.begin(); + MainBuffer *mbuffer = Manager::instance().getMainBuffer(); - CallID process_id = Recordable::recorder.getRecorderID(); + ParticipantSet::iterator iter = _participants.begin(); - while(iter != _participants.end()) { + CallID process_id = Recordable::recorder.getRecorderID(); + + while(iter != _participants.end()) { mbuffer->bindHalfDuplexOut(process_id, *iter); iter++; + } + + mbuffer->bindHalfDuplexOut(process_id); + + } + // stop recording + else { + + MainBuffer *mbuffer = Manager::instance().getMainBuffer(); + + ParticipantSet::iterator iter = _participants.begin(); + + CallID process_id = Recordable::recorder.getRecorderID(); + + while(iter != _participants.end()) { + mbuffer->unBindHalfDuplexOut(process_id, *iter); + iter++; + } + + mbuffer->unBindHalfDuplexOut(process_id); + } - mbuffer->bindHalfDuplexOut(process_id); Recordable::recorder.start(); diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 5a42426d440dbc7b5aa3b9d4200051841c5e38cf..b664f2a591830a0df528e3a5a8cc2cd994b822a8 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -1240,7 +1240,6 @@ class ManagerImpl { void unloadAccountMap(); - public: /** * Instance of the MainBuffer for the whole application * @@ -1251,6 +1250,14 @@ class ManagerImpl { MainBuffer _mainBuffer; + public: + + /** + * Return a pointer to the instance of the mainbuffer + */ + MainBuffer *getMainBuffer(void) { return &_mainBuffer; } + + /** * Tell if there is a current call processed * @return bool True if there is a current call diff --git a/sflphone-common/src/plug-in/Makefile.am b/sflphone-common/src/plug-in/Makefile.am index 35ea21e0390c242d1686bf722077cee6c60e9428..ec8d43800601c3b98c3b7a708b84bedacbfefbb9 100644 --- a/sflphone-common/src/plug-in/Makefile.am +++ b/sflphone-common/src/plug-in/Makefile.am @@ -1,6 +1,6 @@ include ../../globals.mak -SUBDIRS=audiorecorder test +SUBDIRS=test noinst_LTLIBRARIES = libplugin.la diff --git a/sflphone-common/src/plug-in/audiorecorder/Makefile.am b/sflphone-common/src/plug-in/audiorecorder/Makefile.am deleted file mode 100644 index 811f75102fd1d58b44a735ce14b7158340dd326a..0000000000000000000000000000000000000000 --- a/sflphone-common/src/plug-in/audiorecorder/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/globals.mak - -noinst_LTLIBRARIES = libaudiorecorder.la - -libaudiorecorder_la_SOURCES = \ - audiorecord.cpp \ - audiorecorder.cpp \ No newline at end of file diff --git a/sflphone-common/src/plug-in/audiorecorder/audiodsp.cpp b/sflphone-common/src/plug-in/audiorecorder/audiodsp.cpp deleted file mode 100644 index fb95d1a52cb4302c5daf89413921b9509b0e720b..0000000000000000000000000000000000000000 --- a/sflphone-common/src/plug-in/audiorecorder/audiodsp.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Alexandre Savard <alexandre.savard@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. - */ - -#include "audiodsp.h" - -AudioDSP::AudioDSP() -{ - - bufPointer_ = 0; - bufferLength_ = 1024; - circBuffer_ = new float[bufferLength_]; - -} - - -AudioDSP::~AudioDSP() -{ - - delete[] circBuffer_; - -} - - -float AudioDSP::getRMS (int data) -{ - // printf("AudioDSP::getRMS() : bufPointer_ %i ", bufPointer_); - printf ("AudioDSP::getRMS() : %i ", data); - circBuffer_[bufPointer_++] = (float) data; - - if (bufPointer_ >= bufferLength_) - bufPointer_ = 0; - - return computeRMS(); -} - - -float AudioDSP::computeRMS() -{ - - rms = 0.0; - - - for (int i = 0; i < bufferLength_; i++) { - // printf("AudioDSP::computeRMS() : i_ %i ", i); - rms += (float) (circBuffer_[i]*circBuffer_[i]); - } - - rms = sqrt (rms / (float) bufferLength_); - - // printf("AudioDSP::computeRMS() : RMS VALUE: %f ", rms); - return rms; - -} diff --git a/sflphone-common/src/plug-in/audiorecorder/audiodsp.h b/sflphone-common/src/plug-in/audiorecorder/audiodsp.h deleted file mode 100644 index bc2279494cb68f422ac02822bd6cb620d233ca77..0000000000000000000000000000000000000000 --- a/sflphone-common/src/plug-in/audiorecorder/audiodsp.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Alexandre Savard <alexandre.savard@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 _AUDIO_DSP_H -#define _AUDIO_DSP_H - -#include <math.h> -#include <iostream> -#include <string.h> -#include <stdlib.h> -#include <sstream> - -class AudioDSP -{ - -public: - - AudioDSP(); - - ~AudioDSP(); - - /** - * Return rms value - */ - float getRMS(int data); - -protected: - - /** - * Compute Rms value - */ - float computeRMS(); - - /** - * Internal buffer pointer - */ - int bufPointer_; - - /** - * Internal buffer length - */ - int bufferLength_; - - /** - * Internal buffer to compute RMS - */ - float* circBuffer_; - - /** - * Variable to compute RMS value - */ - float rms; - -}; - -#endif // _AUDIO_DSP_H diff --git a/sflphone-common/test/Makefile.am b/sflphone-common/test/Makefile.am index ddb4294c4746c6587543c28663aa355415ef774c..616dab24a0de76d573afd76561cfababe7c6e453 100644 --- a/sflphone-common/test/Makefile.am +++ b/sflphone-common/test/Makefile.am @@ -31,18 +31,17 @@ test_SOURCES = \ delaydetectiontest.cpp \ instantmessagingtest.cpp - - - LLIBS=$(CPPUNIT_LIBS) \ - @ALSA_LIBS@ \ - @PULSEAUDIO_LIBS@ \ - @CPPUNIT_LIBS@ \ - @CCEXT2_LIBS@ \ - @CCGNU2_LIBS@ \ - @CCRTP_LIBS@ \ - @ZRTPCPP_LIBS@ \ - @libssl_LIBS@ \ - @SAMPLERATE_LIBS@ \ - $(PJSIP_LIBS) \ + ../src/sflphoned-logger.o \ + ../src/sflphoned-managerimpl.o \ + ../src/sflphoned-account.o\ + ../src/sflphoned-accountcreator.o \ + ../src/sflphoned-call.o \ + ../src/sflphoned-conference.o \ + ../src/sflphoned-eventthread.o \ + ../src/sflphoned-managerimpl_registration.o \ + ../src/sflphoned-numbercleaner.o \ + ../src/sflphoned-observer.o \ + ../src/sflphoned-voiplink.o \ ../src/libsflphone.la + diff --git a/sflphone-common/test/main.cpp b/sflphone-common/test/main.cpp index 131630b33d46feb5d6e8f3a7ce7cb9caba5ff487..ada12320f8272f1247ae0f3c6e4b1743ed8da548 100644 --- a/sflphone-common/test/main.cpp +++ b/sflphone-common/test/main.cpp @@ -37,40 +37,21 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <cppunit/ui/text/TextTestRunner.h> -// TODO: Why some header cannot be included ? -#include "accounttest.h" -#include "audiolayertest.h" -#include "configurationtest.h" -//#include "historytest.h" -//#include "hookmanagertest.h" -#include "mainbuffertest.h" -#include "numbercleanertest.h" -//#include "pluginmanagertest.h" -//#include "rtptest.h" -#include "sdesnegotiatortest.h" - - int main(int argc, char* argv[]) { printf("\nSFLphone Daemon Test Suite, by Savoir-Faire Linux 2004-2010\n\n"); - Logger::setConsoleLog(true); - Logger::setDebugMode(true); - /* - Logger::setDebugMode(false); - + int argvIndex = 1; if (argc > 1) { if (strcmp("--help", argv[1]) == 0) { argvIndex++; - CPPUNIT_NS::Test - *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry( - "All Tests").makeTest(); + CPPUNIT_NS::Test* suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry("All Tests").makeTest(); + int testSuiteCount = suite->getChildTestCount(); - printf("Usage: test [OPTIONS] [TEST_SUITE]\n"); printf("\nOptions:\n"); printf(" --debug - Debug mode\n"); @@ -89,6 +70,7 @@ int main(int argc, char* argv[]) { } } + // Default test suite : all tests std::string testSuiteName = "All Tests"; if(argvIndex < argc) { @@ -100,34 +82,28 @@ int main(int argc, char* argv[]) { Manager::instance().initConfigFile(true, CONFIG_SAMPLE); Manager::instance().init(); - printf("\n\n=== Test Suite: %s ===\n\n", testSuiteName.c_str()); // Get the top level suite from the registry + printf("\n\n=== Test Suite: %s ===\n\n", testSuiteName.c_str()); CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry(testSuiteName).makeTest(); - */ - CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); - /* if(suite->getChildTestCount() == 0) { _error("Invalid test suite name: %s", testSuiteName.c_str()); exit(-1); } - */ - Manager::instance().initConfigFile(true, CONFIG_SAMPLE); - Manager::instance().init(); - + // Adds the test to the list of test to run CppUnit::TextTestRunner runner; runner.addTest(suite); // Change the default outputter to a compiler error format outputter - runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), - std::cerr)); + runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); + // Run the tests. bool wasSucessful = runner.run(); + Manager::instance().terminate(); + // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; - - Manager::instance().terminate(); }