From 8164345756b1a246760db876b399e6ca246e6dde Mon Sep 17 00:00:00 2001 From: Alexandre Savard Date: Wed, 10 Feb 2010 16:53:02 -0500 Subject: [PATCH 1/6] [#2445] Update sflphone-handler in order to use placeCallFirstAccount method --- .../mozilla-telify-sflphone/sflphone-handler | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/tools/mozilla-telify-sflphone/sflphone-handler b/tools/mozilla-telify-sflphone/sflphone-handler index 727ef0f93..db1cf92d0 100755 --- a/tools/mozilla-telify-sflphone/sflphone-handler +++ b/tools/mozilla-telify-sflphone/sflphone-handler @@ -5,25 +5,12 @@ # In Firefox use Preferences > Applications and set the callto handler # to this script. -# The sflphone daemon config file -RESFILE=~/.config/sflphone/sflphonedrc -# Parse sflphonedrc and get default account id string -if [ -f "$RESFILE" ]; then - - # Use first ID - ACCOUNTID=`grep Accounts.order $RESFILE | sed -e 's/Accounts.order=//' -e 's/\/.*//'` - - # Accounts.order is not set - if [ -z $ACCOUNTID ]; then - - # Use first account declared in sflphone config - ACCOUNTID="`grep -m 1 Account: $RESFILE | sed -e 's/\[//' -e 's/\]//'`" - fi - -else - echo Fatal: Cant find sflphonedrc config file. - exit 1 +# Test if a SFLphone client is already open, if not open a new one +# Opening a new client will start sflphoned if not already running +SFLPHONEC=`ps -A | grep sflphone-client` +if [ "$SFLPHONEC" = "" ]; then + /usr/bin/sflphone-client-gnome& fi # Check 1st argument (phone number) @@ -38,13 +25,16 @@ TO="`echo $1 | sed -e 's/[^0123456789]//g'`" # Generate call id. CALLID=${RANDOM}$$ -dbus-send \ - --type="method_call" \ - --dest="org.sflphone.SFLphone" \ - "/org/sflphone/SFLphone/CallManager" \ - "org.sflphone.SFLphone.CallManager.placeCall" \ - string:"$ACCOUNTID" \ - string:"$CALLID" \ +# Dbus placeCallFirstAccount method does not reach sflphoned if starting +# Should find another way to do this +sleep 1 + +dbus-send \ + --type="method_call" \ + --dest="org.sflphone.SFLphone" \ + "/org/sflphone/SFLphone/CallManager" \ + "org.sflphone.SFLphone.CallManager.placeCallFirstAccount" \ + string:"$CALLID" \ string:"$TO" exit 0 From e8c9c69906436774abd508f36d3c9292145b2aa5 Mon Sep 17 00:00:00 2001 From: Alexandre Savard Date: Wed, 10 Feb 2010 17:49:27 -0500 Subject: [PATCH 2/6] [#2521] Fix pysflphonectrlsimple (Module md5 not supported anymore) --- tools/pysflphone/sflphonectrlsimple.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/pysflphone/sflphonectrlsimple.py b/tools/pysflphone/sflphonectrlsimple.py index a7d0a5ee2..bf5ffb75a 100755 --- a/tools/pysflphone/sflphonectrlsimple.py +++ b/tools/pysflphone/sflphonectrlsimple.py @@ -29,7 +29,7 @@ from gobject import GObject import getopt import time -import md5 +import hashlib from threading import Thread @@ -405,11 +405,12 @@ class SflPhoneCtrlSimple(object): if dest is None or dest == "": raise SflPhoneError("Invalid call destination") - # callid = str(random.randrange(2**32-1)) + # Generate a call ID for this + m = hashlib.md5() t = long( time.time() * 1000 ) r = long( random.random()*100000000000000000L ) - data = str(t) + str(r) - callid = md5.md5(data).hexdigest() + m.update(str(t) + str(r)) + callid = m.hexdigest() # Add the call to the list of active calls and set status to SENT self.activeCalls[callid] = {'Account': self.account, 'To': dest, 'State': 'SENT' } From 87670406634dc9539188e7ccef9aa121f5ee4574 Mon Sep 17 00:00:00 2001 From: Alexandre Savard Date: Thu, 11 Feb 2010 15:48:23 -0500 Subject: [PATCH 3/6] [#2521] Update python sample program with tests --- .../dbus/configurationmanager-introspec.xml | 2 + tools/pysflphone/pysflphone.py | 18 +++- tools/pysflphone/pysflphone_testdbus.py | 73 +++++++++++---- tools/pysflphone/sflphonectrlsimple.py | 88 ++++++++++++++----- 4 files changed, 139 insertions(+), 42 deletions(-) diff --git a/sflphone-common/src/dbus/configurationmanager-introspec.xml b/sflphone-common/src/dbus/configurationmanager-introspec.xml index 944cf9f68..c2bab0756 100644 --- a/sflphone-common/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-common/src/dbus/configurationmanager-introspec.xml @@ -162,6 +162,8 @@ - - + + @@ -41,25 +41,25 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + From a45de49dc49db6425ca662b2836596d8fbe02da1 Mon Sep 17 00:00:00 2001 From: Alexandre Savard Date: Thu, 18 Feb 2010 09:47:09 -0500 Subject: [PATCH 6/6] [#2598] Make SFLphone's internal sampling rate configurable --- sflphone-common/src/audio/audiolayer.h | 2 +- .../src/audio/pulseaudio/audiostream.cpp | 28 +++----- .../src/audio/pulseaudio/audiostream.h | 6 +- .../src/audio/pulseaudio/pulselayer.cpp | 4 +- .../src/audio/samplerateconverter.cpp | 2 +- sflphone-common/src/managerimpl.cpp | 6 +- sflphone-common/src/user_cfg.h | 68 +++++++++---------- sflphone-common/test/audiolayerTest.cpp | 4 +- 8 files changed, 56 insertions(+), 64 deletions(-) diff --git a/sflphone-common/src/audio/audiolayer.h b/sflphone-common/src/audio/audiolayer.h index 580c064e5..46dc81533 100644 --- a/sflphone-common/src/audio/audiolayer.h +++ b/sflphone-common/src/audio/audiolayer.h @@ -58,7 +58,7 @@ class AudioLayer { */ AudioLayer( ManagerImpl* manager , int type ) : _defaultVolume(100) - , _layerType( type ) + , _layerType( type ) , _manager(manager) , _urgentRingBuffer( SIZEBUF, default_id ) , _indexIn ( 0 ) diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.cpp b/sflphone-common/src/audio/pulseaudio/audiostream.cpp index 0187585c2..ac51fa0d5 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.cpp +++ b/sflphone-common/src/audio/pulseaudio/audiostream.cpp @@ -24,20 +24,19 @@ static pa_channel_map channel_map; -AudioStream::AudioStream (PulseLayerType * driver) +AudioStream::AudioStream (PulseLayerType * driver, int smplrate) : _audiostream (NULL), _context (driver->context), _streamType (driver->type), _streamDescription (driver->description), _volume(), - flag (PA_STREAM_AUTO_TIMING_UPDATE), - sample_spec(), + _flag (PA_STREAM_AUTO_TIMING_UPDATE), + _sample_spec(), _mainloop (driver->mainloop) { - sample_spec.format = PA_SAMPLE_S16LE; - // sample_spec.format = PA_SAMPLE_FLOAT32LE; - sample_spec.rate = 44100; - sample_spec.channels = 1; + _sample_spec.format = PA_SAMPLE_S16LE; // PA_SAMPLE_FLOAT32LE; + _sample_spec.rate = smplrate; + _sample_spec.channels = 1; channel_map.channels = 1; pa_cvolume_set (&_volume , 1 , PA_VOLUME_NORM) ; // * vol / 100 ; } @@ -178,20 +177,13 @@ AudioStream::createStream (pa_context* c) ost::MutexLock guard (_mutex); pa_stream* s; - //pa_cvolume cv; - // pa_sample_spec ss; - // ss.format = PA_SAMPLE_S16LE; - // ss.rate = 44100; - // ss.channels = 1; - - - assert (pa_sample_spec_valid (&sample_spec)); + assert (pa_sample_spec_valid (&_sample_spec)); assert (pa_channel_map_valid (&channel_map)); pa_buffer_attr* attributes = (pa_buffer_attr*) malloc (sizeof (pa_buffer_attr)); - if (! (s = pa_stream_new (c, _streamDescription.c_str() , &sample_spec, &channel_map))) + if (! (s = pa_stream_new (c, _streamDescription.c_str() , &_sample_spec, &channel_map))) _debug ("%s: pa_stream_new() failed : %s" , _streamDescription.c_str(), pa_strerror (pa_context_errno (c))); assert (s); @@ -202,7 +194,7 @@ AudioStream::createStream (pa_context* c) // 20 ms framesize TODO: take framesize value from config attributes->maxlength = (uint32_t) -1; - attributes->tlength = pa_usec_to_bytes (100 * PA_USEC_PER_MSEC, &sample_spec); + attributes->tlength = pa_usec_to_bytes (100 * PA_USEC_PER_MSEC, &_sample_spec); attributes->prebuf = 0; attributes->minreq = (uint32_t) -1; attributes->fragsize = (uint32_t) -1; @@ -215,7 +207,7 @@ AudioStream::createStream (pa_context* c) attributes->tlength = (uint32_t) -1; attributes->prebuf = (uint32_t) -1; attributes->minreq = (uint32_t) -1; - attributes->fragsize = pa_usec_to_bytes (50 * PA_USEC_PER_MSEC, &sample_spec); + attributes->fragsize = pa_usec_to_bytes (50 * PA_USEC_PER_MSEC, &_sample_spec); diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.h b/sflphone-common/src/audio/pulseaudio/audiostream.h index 1d860ebc1..75705f18d 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.h +++ b/sflphone-common/src/audio/pulseaudio/audiostream.h @@ -54,7 +54,7 @@ class AudioStream { * Constructor * @param context The PulseLayerType structure containing various information. */ - AudioStream(PulseLayerType * driver); + AudioStream(PulseLayerType * driver, int smplrate); /** * Destructor @@ -175,8 +175,8 @@ class AudioStream { * Streams parameters */ pa_cvolume _volume; - pa_stream_flags_t flag; - pa_sample_spec sample_spec ; + pa_stream_flags_t _flag; + pa_sample_spec _sample_spec ; pa_threaded_mainloop * _mainloop; diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index 773956df5..c1db2e2e3 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -243,7 +243,7 @@ bool PulseLayer::createStreams (pa_context* c) playbackParam->volume = _manager->getSpkrVolume(); playbackParam->mainloop = m; - playback = new AudioStream (playbackParam); + playback = new AudioStream (playbackParam, _audioSampleRate); playback->connectStream(); pa_stream_set_write_callback (playback->pulseStream(), playback_callback, this); pa_stream_set_overflow_callback (playback->pulseStream(), playback_overflow_callback, this); @@ -259,7 +259,7 @@ bool PulseLayer::createStreams (pa_context* c) recordParam->volume = _manager->getMicVolume(); recordParam->mainloop = m; - record = new AudioStream (recordParam); + record = new AudioStream (recordParam, _audioSampleRate); record->connectStream(); pa_stream_set_read_callback (record->pulseStream() , capture_callback, this); // pa_stream_set_suspended_callback(record->pulseStream(), stream_suspended_callback, this); diff --git a/sflphone-common/src/audio/samplerateconverter.cpp b/sflphone-common/src/audio/samplerateconverter.cpp index 8d115a255..9a2ace32e 100644 --- a/sflphone-common/src/audio/samplerateconverter.cpp +++ b/sflphone-common/src/audio/samplerateconverter.cpp @@ -20,7 +20,7 @@ #include "manager.h" SamplerateConverter::SamplerateConverter (void) - : _frequence (Manager::instance().getConfigInt (AUDIO , ALSA_SAMPLE_RATE)) //44100 + : _frequence (Manager::instance().getConfigInt (AUDIO , AUDIO_SAMPLE_RATE)) //44100 , _framesize (Manager::instance().getConfigInt (AUDIO , ALSA_FRAME_SIZE)) , _floatBufferDownMic (NULL) , _floatBufferUpMic (NULL) diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 501e49091..406c534bb 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2293,7 +2293,7 @@ ManagerImpl::initConfigFile (bool load_user_value, std::string alternate) // Audio settings _config.addDefaultValue (std::pair (ALSA_CARD_ID_IN, ALSA_DFT_CARD), AUDIO); _config.addDefaultValue (std::pair (ALSA_CARD_ID_OUT, ALSA_DFT_CARD), AUDIO); - _config.addDefaultValue (std::pair (ALSA_SAMPLE_RATE, DFT_SAMPLE_RATE), AUDIO); + _config.addDefaultValue (std::pair (AUDIO_SAMPLE_RATE, DFT_SAMPLE_RATE), AUDIO); _config.addDefaultValue (std::pair (ALSA_FRAME_SIZE, DFT_FRAME_SIZE), AUDIO); _config.addDefaultValue (std::pair (ALSA_PLUGIN, PCM_DEFAULT), AUDIO); _config.addDefaultValue (std::pair (RING_CHOICE, DFT_RINGTONE), AUDIO); @@ -2954,7 +2954,7 @@ ManagerImpl::selectAudioDriver (void) alsaPlugin = getConfigString (AUDIO , ALSA_PLUGIN); numCardIn = getConfigInt (AUDIO , ALSA_CARD_ID_IN); numCardOut = getConfigInt (AUDIO , ALSA_CARD_ID_OUT); - sampleRate = getConfigInt (AUDIO , ALSA_SAMPLE_RATE); + sampleRate = getConfigInt (AUDIO , AUDIO_SAMPLE_RATE); if (sampleRate <=0 || sampleRate > 48000) { sampleRate = 44100; @@ -3003,7 +3003,7 @@ void ManagerImpl::switchAudioManager (void) type = _audiodriver->getLayerType(); - samplerate = getConfigInt (AUDIO , ALSA_SAMPLE_RATE); + samplerate = getConfigInt (AUDIO , AUDIO_SAMPLE_RATE); framesize = getConfigInt (AUDIO , ALSA_FRAME_SIZE); diff --git a/sflphone-common/src/user_cfg.h b/sflphone-common/src/user_cfg.h index 652027dc7..f3fae44b2 100644 --- a/sflphone-common/src/user_cfg.h +++ b/sflphone-common/src/user_cfg.h @@ -31,31 +31,31 @@ #define ACCOUNT_IAX0 "IAX0" /** Account type IAX */ /** User configuration file fields */ -#define AUDIO "Audio" /** Section Audio */ -#define CODECS "ActiveCodecs" /** List of active codecs */ +#define AUDIO "Audio" /** Section Audio */ +#define CODECS "ActiveCodecs" /** List of active codecs */ #define ALSA_CARD_ID_IN "Alsa.cardID_In" /** Soundcard index to use for capture */ #define ALSA_CARD_ID_OUT "Alsa.cardID_Out" /** Soundcard index to use for playback */ #define ALSA_FRAME_SIZE "Alsa.framesize" /** Audio layer frame size */ -#define ALSA_PLUGIN "Alsa.plugin" /** Alsa plugin */ -#define ALSA_SAMPLE_RATE "Alsa.sampleRate" /** Audio layer sample rate */ -#define RING_CHOICE "Rings.ringChoice" /** Ringtone */ -#define VOLUME_SPKR "Volume.speakers" /** Speaker volume */ +#define ALSA_PLUGIN "Alsa.plugin" /** Alsa plugin */ +#define AUDIO_SAMPLE_RATE "Alsa.sampleRate" /** Audio layer sample rate */ +#define RING_CHOICE "Rings.ringChoice" /** Ringtone */ +#define VOLUME_SPKR "Volume.speakers" /** Speaker volume */ #define VOLUME_MICRO "Volume.micro" /** Mic volume */ #define RECORD_PATH "Record.path" /** Recording path */ -#define PREFERENCES "Preferences" /** Section Preferences */ +#define PREFERENCES "Preferences" /** Section Preferences */ #define CONFIG_MD5HASH "md5Hash" /** Option to store credential as md5 hash*/ -#define CONFIG_DIALPAD "Dialpad.display" /** Display dialpad preferences */ +#define CONFIG_DIALPAD "Dialpad.display" /** Display dialpad preferences */ #define CONFIG_SEARCHBAR "Searchbar.display" /** Whether or nor display the search bar */ #define CONFIG_HISTORY_LIMIT "History.limit" /** Set the maximum number of days kept */ #define CONFIG_HISTORY_ENABLED "History.enabled" /** Is the history enabled or not */ #define CONFIG_NOTIFY "Notify.all" /** Desktop notification level */ #define CONFIG_MAIL_NOTIFY "Notify.mails" /** Desktop mail notification level */ -#define ZONE_TONE "Options.zoneToneChoice" /** Country tone */ -#define CONFIG_RINGTONE "Ringtones.enable" /** Ringtones preferences */ -#define CONFIG_START "Start.hidden" /** SFLphone starts in the systm tray or not */ -#define CONFIG_POPUP "Window.popup" /** SFLphone pops up on incoming calls or not */ -#define CONFIG_VOLUME "Volume.display" /** Display the mic and speaker volume controls */ +#define ZONE_TONE "Options.zoneToneChoice" /** Country tone */ +#define CONFIG_RINGTONE "Ringtones.enable" /** Ringtones preferences */ +#define CONFIG_START "Start.hidden" /** SFLphone starts in the systm tray or not */ +#define CONFIG_POPUP "Window.popup" /** SFLphone pops up on incoming calls or not */ +#define CONFIG_VOLUME "Volume.display" /** Display the mic and speaker volume controls */ #define CONFIG_AUDIO "Audio.api" /** Audio manager (ALSA or pulseaudio) */ #define CONFIG_PA_VOLUME_CTRL "Pulseaudio.volumeCtrl" /** Whether or not PA should modify volume of other applications on the same sink */ #define CONFIG_SIP_PORT "SIP.portNum" @@ -64,11 +64,11 @@ #define IP2IP_PROFILE "IP2IP" #define SIGNALISATION "VoIPLink" /** Section Signalisation */ #define ZRTP_ZIDFILE "ZRTP.zidFile" /** The filename used for storing ZIDs */ -#define PLAY_DTMF "DTMF.playDtmf" /** Whether or not should play dtmf */ -#define PLAY_TONES "DTMF.playTones" /** Whether or not should play tones */ +#define PLAY_DTMF "DTMF.playDtmf" /** Whether or not should play dtmf */ +#define PLAY_TONES "DTMF.playTones" /** Whether or not should play tones */ #define PULSE_LENGTH "DTMF.pulseLength" /** Length of the DTMF in millisecond */ #define SEND_DTMF_AS "DTMF.sendDTMFas" /** DTMF send mode */ -#define SYMMETRIC "VoIPLink.symmetric" /** VoIP link type */ +#define SYMMETRIC "VoIPLink.symmetric" /** VoIP link type */ #define ADDRESSBOOK "Addressbook" /** Address book section */ #define ADDRESSBOOK_ENABLE "Addressbook.enable" /** Enable address book */ @@ -87,26 +87,26 @@ #define PHONE_NUMBER_HOOK_ENABLED "Hooks.phone_number_enabled" #define PHONE_NUMBER_HOOK_ADD_PREFIX "Hooks.phone_number_add_prefix" -#define EMPTY_FIELD "" /** Default value for empty field */ +#define EMPTY_FIELD "" /** Default value for empty field */ #define DEFAULT_ACCOUNT_TYPE "SIP" -#define DFT_STUN_SERVER "stun.sflphone.org" /** Default STUN server address */ -#define TRUE_STR "true" /** Default YES value */ -#define FALSE_STR "false" /** Default NO value */ +#define DFT_STUN_SERVER "stun.sflphone.org" /** Default STUN server address */ +#define TRUE_STR "true" /** Default YES value */ +#define FALSE_STR "false" /** Default NO value */ #define DFT_PULSE_LENGTH_STR "250" /** Default DTMF lenght */ -#define SIP_INFO_STR "0" /** Default DTMF transport mode */ -#define ALSA_DFT_CARD "0" /** Default sound card index */ -#define DFT_VOL_SPKR_STR "100" /** Default speaker volume */ -#define DFT_VOL_MICRO_STR "100" /** Default mic volume */ -#define DFT_RINGTONE "konga.ul" /** Default ringtone */ -#define DFT_ZONE "North America" /** Default geographical zone */ -#define DFT_VOICEMAIL "888" /** Default voicemail number */ -#define DFT_FRAME_SIZE "20" /** Default frame size in millisecond */ -#define DFT_SAMPLE_RATE "44100" /** Default sample rate in HZ */ -#define DFT_NOTIF_LEVEL "2" /** Default desktop notification level : maximum */ -#define DFT_HISTORY_LIMIT "30" /** Default maximum days in history */ -#define DFT_EXPIRE_VALUE "600" /** Default expire value for registration */ -#define DFT_RESOLVE_ONCE FALSE_STR -#define DFT_AUDIO_MANAGER "1" /** Default audio manager */ +#define SIP_INFO_STR "0" /** Default DTMF transport mode */ +#define ALSA_DFT_CARD "0" /** Default sound card index */ +#define DFT_VOL_SPKR_STR "100" /** Default speaker volume */ +#define DFT_VOL_MICRO_STR "100" /** Default mic volume */ +#define DFT_RINGTONE "konga.ul" /** Default ringtone */ +#define DFT_ZONE "North America" /** Default geographical zone */ +#define DFT_VOICEMAIL "888" /** Default voicemail number */ +#define DFT_FRAME_SIZE "20" /** Default frame size in millisecond */ +#define DFT_SAMPLE_RATE "44100" /** Default sample rate in HZ */ +#define DFT_NOTIF_LEVEL "2" /** Default desktop notification level : maximum */ +#define DFT_HISTORY_LIMIT "30" /** Default maximum days in history */ +#define DFT_EXPIRE_VALUE "600" /** Default expire value for registration */ +#define DFT_RESOLVE_ONCE FALSE_STR +#define DFT_AUDIO_MANAGER "1" /** Default audio manager */ #define DFT_SIP_PORT "5060" #define DFT_STUN_ENABLE FALSE_STR #define DFT_RECORD_PATH HOMEDIR diff --git a/sflphone-common/test/audiolayerTest.cpp b/sflphone-common/test/audiolayerTest.cpp index 065b396c4..962bb8fc4 100644 --- a/sflphone-common/test/audiolayerTest.cpp +++ b/sflphone-common/test/audiolayerTest.cpp @@ -63,7 +63,7 @@ void AudioLayerTest::setUp() void AudioLayerTest::testAudioLayerConfig() { - int sampling_rate = Manager::instance().getConfigInt (AUDIO, ALSA_SAMPLE_RATE); + int sampling_rate = Manager::instance().getConfigInt (AUDIO, AUDIO_SAMPLE_RATE); int frame_size = Manager::instance().getConfigInt (AUDIO, ALSA_FRAME_SIZE); frame_size = 0; // frame size in config not used anymore @@ -122,7 +122,7 @@ void AudioLayerTest::testPulseConnect() alsaPlugin = manager->getConfigString (AUDIO , ALSA_PLUGIN); numCardIn = manager->getConfigInt (AUDIO , ALSA_CARD_ID_IN); numCardOut = manager->getConfigInt (AUDIO , ALSA_CARD_ID_OUT); - sampleRate = manager->getConfigInt (AUDIO , ALSA_SAMPLE_RATE); + sampleRate = manager->getConfigInt (AUDIO , AUDIO_SAMPLE_RATE); frameSize = manager->getConfigInt (AUDIO, ALSA_FRAME_SIZE); CPPUNIT_ASSERT (_pulselayer->getPlaybackStream() == NULL);