diff --git a/src/audio/Makefile.am b/src/audio/Makefile.am
index 3dfd56bdffac16cc42b6a46e508ad30fbc11deef..81564003259883cb3a623bceed515a11a3d26b8c 100644
--- a/src/audio/Makefile.am
+++ b/src/audio/Makefile.am
@@ -29,9 +29,9 @@ SPEEX_FLAG=
 SPEEX_LIB=
 endif
 
-#SUBDIRS = ilbc
+#SUBDIRS = gsm 
  
-libaudio_la_SOURCES =      audiofile.cpp	 tonelist.cpp     \
+libaudio_la_SOURCES =    audiofile.cpp	 tonelist.cpp     \
 audiortp.cpp         dtmf.cpp   tone.cpp  audiolayer.cpp audiodevice.cpp  dtmfgenerator.cpp   \
 tonegenerator.cpp   codecDescriptor.cpp \
 audioloop.cpp ringbuffer.cpp $(SPEEX_SOURCES_CPP)
@@ -40,7 +40,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $
  	      -DCODECS_DIR=\""$(sflcodecdir)"\"	
 libaudio_la_CPPFLAGS = $(SPEEX_FLAG)
 
-noinst_HEADERS = audioloop.h       common.h ringbuffer.h           audiofile.h  \
+noinst_HEADERS = audioloop.h    common.h ringbuffer.h           audiofile.h  \
  tonelist.h         audiortp.h audiocodec.h    audiolayer.h audiodevice.h \
  dtmfgenerator.h         tonegenerator.h     \
  codecDescriptor.h    dtmf.h tone.h \
@@ -63,8 +63,8 @@ uninstall-libcodec_ulaw_so:
 	rm -f $(sflcodecdir)/libcodec_ulaw.so
 uninstall-libcodec_alaw_so:
 	rm -f $(sflcodecdir)/libcodec_alaw.so
-uninstall-libcodec_gsm_so:
-	rm -f $(sflcodecdir)/libcodec_gsm.so  
+#uninstall-libcodec_gsm_so:
+#	rm -f $(sflcodecdir)/libcodec_gsm.so  
 uninstall-libcodec_speex_so:
 	rm -f $(sflcodecdir)/libcodec_speex.so  
 	rm -rf $(sflcodecdir) 
diff --git a/src/audio/alaw.cpp b/src/audio/alaw.cpp
index 71490076edca91712cc98a97f59215aac8061d0a..331e5ddd1c7d9b51a6dfe0335ca01990d714e606 100644
--- a/src/audio/alaw.cpp
+++ b/src/audio/alaw.cpp
@@ -31,7 +31,7 @@ public:
   		_channel   = 1;
 	}
 
-
+        virtual ~Alaw(){}
 	virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) 
 	{
 		int16* end = dst+size;
diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp
index d92255c4b63abd7c9f101b617aa2b2c0d15a4d99..0f0f2e21ec88a99081009126d11b4db7d094ee5d 100644
--- a/src/audio/audiortp.cpp
+++ b/src/audio/audiortp.cpp
@@ -97,13 +97,12 @@ AudioRtp::closeRtpSession () {
 // AudioRtpRTX Class                                                          //
 ////////////////////////////////////////////////////////////////////////////////
 AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym)
-	 : _fstream("/tmp/audio.dat", std::ofstream::binary|std::ios::out|std::ios::app)
+	 : _fstream("/tmp/audio.gsm", std::ofstream::binary|std::ios::out|std::ios::app)
 {
 	setCancel(cancelDeferred);
 	time = new ost::Time();
 	_ca = sipcall;
 	_sym = sym;
-	//std::string s = "snd.dat";
 	// AudioRtpRTX should be close if we change sample rate
 
 	//_codecSampleRate = _ca->getAudioCodec()->getClockRate();
@@ -141,7 +140,6 @@ AudioRtpRTX::~AudioRtpRTX () {
 	}
 	//_debug("terminate audiortprtx ended...\n");
 	_ca = 0;
-	//fd = fopen("snd_data", "wa");
 	if (!_sym) {
 		delete _sessionRecv; _sessionRecv = NULL;
 		delete _sessionSend; _sessionSend = NULL;
@@ -321,7 +319,6 @@ try {
 
 	// we have to get 20ms of data from the mic *20/1000 = /50
 	int maxBytesToGet = _layerSampleRate * _layerFrameSize * sizeof(SFLDataFormat) / 1000;
-
 	// available bytes inside ringbuffer
 	int availBytesFromMic = audiolayer->canGetMic();
 
@@ -332,7 +329,6 @@ try {
 	int nbSample = audiolayer->getMic(_dataAudioLayer, bytesAvail) / sizeof(SFLDataFormat);
 	int nb_sample_up = nbSample;
 	int nbSamplesMax = _layerFrameSize * audiocodec->getClockRate() / 1000;
-	//_fstream.write((char*) _dataAudioLayer, nbSample);
 	
 	nbSample = reSampleData(audiocodec->getClockRate(), nb_sample_up, DOWN_SAMPLING);	
 	
@@ -348,6 +344,7 @@ try {
 //_debug("AR: Nb sample: %d int, [0]=%d [1]=%d [2]=%d\n", nbSample, toSIP[0], toSIP[1], toSIP[2]);
 	// for the mono: range = 0 to RTP_FRAME2SEND * sizeof(int16)
 	// codecEncode(char *dest, int16* src, size in bytes of the src)
+	//int compSize = audiocodec->codecEncode(_sendDataEncoded, toSIP, nbSample*sizeof(int16));
 	int compSize = audiocodec->codecEncode(_sendDataEncoded, toSIP, nbSample*sizeof(int16));
 	//printf("jusqu'ici tout vas bien\n");
 
@@ -401,7 +398,7 @@ try {
 	audiocodec = loadCodec(payload);
 	// Decode data with relevant codec
 	_codecSampleRate = audiocodec->getClockRate();
-	int max = (int)(_codecSampleRate * _layerFrameSize);
+	int max = (int)(_codecSampleRate * _layerFrameSize / 1000);
 
 	if ( size > max ) {
 		_debug("We have received from RTP a packet larger than expected: %s VS %s\n", size, max);
@@ -413,6 +410,7 @@ try {
 
 	if (audiocodec != NULL) {
 		int expandedSize = audiocodec->codecDecode(_receiveDataDecoded, data, size);
+	        _fstream.write((char*) _receiveDataDecoded, 160);
 		//buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes
 		int nbInt16 = expandedSize / sizeof(int16);
 		//nbInt16 represents the number of samples we just decoded
@@ -569,7 +567,7 @@ try {
 		Thread::sleep(TimerPort::getTimer());
 		TimerPort::incTimer(_layerFrameSize); // 'frameSize' ms
 	}
-	//_fstream.close();
+	_fstream.close();
 	//_debug("stop stream for audiortp loop\n");
 	audiolayer->stopStream();
 } catch(std::exception &e) {
diff --git a/src/audio/gsmcodec.cpp b/src/audio/gsmcodec.cpp
index a340882103b1a281b1fb4091d2b0989ac8f596af..30b9ed3bbb5ff9866edddd0682d84c93aa5a2b42 100644
--- a/src/audio/gsmcodec.cpp
+++ b/src/audio/gsmcodec.cpp
@@ -19,54 +19,94 @@
  */
 
 #include <iostream>
+extern "C" {
 #include <gsm/gsm.h>
+}
 #include "audiocodec.h"
 #include "../global.h"
 
+#define GSM_PACKED_FRAME_SIZE_IN_BYTES	33
+#define GSM_UNPACKED_FRAME_SIZE_IN_BYTES	320
+#define GSM_UNPACKED_FRAME_SIZE_IN_SHORTS	160
+/*
+void * GSMCodecHandle = 0;
 
+void* (*gsm_session_create)() = 0;
+void (*gsm_session_destroy)(void *) = 0;
+void (*gsm_session_encode)(void*, unsigned char*, short*) = 0 ;
+int (*gsm_session_decode)(void*, short* , unsigned char*) = 0 ;
+*/
 class Gsm : public AudioCodec {
 public:
 // 3 GSM A 8000 1 [RFC3551]
 Gsm(int payload = 0) 
 : AudioCodec(payload, "GSM")
 {
-  //_description = "GSM";
   _clockRate = 8000;
   _channel   = 1;
-  
+ 
+  //initGSMStruct();
+   
   if (!(_decode_gsmhandle = gsm_create() )) 
     _debug("ERROR: decode_gsm_create\n");
   if (!(_encode_gsmhandle = gsm_create() )) 
     _debug("AudioCodec: ERROR: encode_gsm_create\n");
   
+
+   //_encode_state = gsm_session_create();
+   //_decode_state = gsm_session_create();
+   
 }
 
 ~Gsm (void)
 {
+  //gsm_session_destroy(_decode_state);
+  //gsm_session_destroy(_encode_state);
   gsm_destroy(_decode_gsmhandle);
   gsm_destroy(_encode_gsmhandle);
 }
 
+/*
+bool initGSMStruct()
+{
+  if(GSMCodecHandle)  return true;
+
+  GSMCodecHandle = dlopen("libgsm.so", RTLD_NOW | RTLD_GLOBAL);
+  if(!GSMCodecHandle)  return false;
+  gsm_session_create = (void * (*)()) dlsym(GSMCodecHandle, "gsm_create");
+  gsm_session_destroy = (void (*) (void *)) dlsym(GSMCodecHandle, "gsm_destroy");
+  gsm_session_encode = ( void (*) (void*, unsigned char*, short*)) dlsym(GSMCodecHandle, "gsm_encode");
+  gsm_session_decode = (int (*) (void*, short*, unsigned char*)) dlsym(GSMCodecHandle, "gsm_decode");
+
+  if(!(gsm_session_create && gsm_session_destroy && gsm_session_encode && gsm_session_decode)){
+	dlclose(GSMCodecHandle);
+	GSMCodecHandle = 0 ;
+	return false;}
+  return true;
+}*/
+
 virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) 
 {
-  (void)size;
-  if (gsm_decode(_decode_gsmhandle, (gsm_byte*)src, (gsm_signal*)dst) < 0) {
-    _debug("ERROR: gsm_decode\n");
-  }
-  return 320;
+  if(gsm_decode(_decode_gsmhandle, (gsm_byte *)src, (gsm_signal*)dst) < 0)
+    return 0;
+
+  return GSM_UNPACKED_FRAME_SIZE_IN_BYTES;
 }
 
 virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) 
 {
-  (void)size;
-  gsm_encode(_encode_gsmhandle, (gsm_signal*)src, (gsm_byte*)dst);  
-  return 33;
+  if(size < GSM_UNPACKED_FRAME_SIZE_IN_BYTES) return 0;
+  //if (gsm_session_encode( gsm_signal*)src, (gsm_byte*)dst);  
+  gsm_encode( _encode_gsmhandle, (gsm_signal*)src, (gsm_byte*) dst);
+  return GSM_PACKED_FRAME_SIZE_IN_BYTES;
 }
 
 
 private:
 	gsm _decode_gsmhandle;
  	gsm _encode_gsmhandle;
+	//void * _encode_state;
+	//void * _decode_state;
 
 };
 
@@ -78,3 +118,4 @@ extern "C" AudioCodec* create() {
 extern "C" void destroy(AudioCodec* a) {
     delete a;
 }
+