diff --git a/sflphone-common/src/audio/audiortp.cpp b/sflphone-common/src/audio/audiortp.cpp index 671c0aafcf584297dc2d5f9ef46c8e179aee35eb..f947a627828d79de5224527a41a618cf14f333b1 100644 --- a/sflphone-common/src/audio/audiortp.cpp +++ b/sflphone-common/src/audio/audiortp.cpp @@ -186,6 +186,7 @@ AudioRtpRTX::initBuffers() void AudioRtpRTX::initAudioRtpSession (void) { + _debug("************* initAudioRtpSession *******************\n"); try { if (_ca == 0) { return; } @@ -193,8 +194,12 @@ AudioRtpRTX::initAudioRtpSession (void) if (_audiocodec == NULL) { return; } + _debug("************* get codec info *******************\n"); _codecSampleRate = _audiocodec->getClockRate(); _codecFrameSize = _audiocodec->getFrameSize(); + _debug("_codecFrameSize: %i\n", _codecFrameSize); + _debug("_codecSampleRate: %i\n", _codecSampleRate); + ost::InetHostAddress remote_ip(_ca->getLocalSDP()->get_remote_ip().c_str()); _debug("Init audio RTP session %s\n", _ca->getLocalSDP()->get_remote_ip().data()); @@ -553,11 +558,10 @@ AudioRtpRTX::run () { AudioLayer *audiolayer = Manager::instance().getAudioDriver(); _layerFrameSize = audiolayer->getFrameSize(); // en ms _layerSampleRate = audiolayer->getSampleRate(); + initBuffers(); int step; - - int sessionWaiting; //try { @@ -565,8 +569,6 @@ AudioRtpRTX::run () { // Init the session initAudioRtpSession(); - // frame length in ms - int threadSleep = (_codecFrameSize * 1000) / _codecSampleRate; // step = (int) (_layerFrameSize * _codecSampleRate / 1000); step = _codecFrameSize; @@ -581,8 +583,15 @@ AudioRtpRTX::run () { } int timestamp = 0; // for mic + // step = (int) (_layerFrameSize * _codecSampleRate / 1000); + step = _codecFrameSize; + int countTime = 0; // for receive - // TimerPort::setTimer(_layerFrameSize); + // TimerPort::setTimer(20); + _debug("****************************************************** \n"); + _debug("_codecFrameSize: %i\n", _codecFrameSize); + _debug("_codecSampleRate: %i\n", _codecSampleRate); + int threadSleep = (_codecFrameSize * 1000) / _codecSampleRate; TimerPort::setTimer(threadSleep); audiolayer->startStream(); @@ -590,7 +599,8 @@ AudioRtpRTX::run () { _debug("- ARTP Action: Start call %s\n",_ca->getCallId().c_str()); while (!testCancel()) { - printf(" --------- >Step: %i ", step); + printf(" --------- >Step: %i \n", step); + _debug("_codecFrameSize: %i \n", _codecFrameSize); // printf("AudioRtpRTX::run() _session->getFirstTimestamp() %i \n",_session->getFirstTimestamp()); // printf("AudioRtpRTX::run() _session->isWaiting() %i \n",_session->isWaiting()); @@ -622,7 +632,7 @@ AudioRtpRTX::run () { } Thread::sleep(TimerPort::getTimer()); - // TimerPort::incTimer(_layerFrameSize); // 'frameSize' ms + // TimerPort::incTimer(20); // 'frameSize' ms TimerPort::incTimer(threadSleep); } diff --git a/sflphone-common/src/audio/codecs/audiocodec.h b/sflphone-common/src/audio/codecs/audiocodec.h index 8b89d2b461865018a87ab4765f5f22e37b4ec99d..c7ad5ccf1468a78c025c5dbecee0887a68d960d9 100644 --- a/sflphone-common/src/audio/codecs/audiocodec.h +++ b/sflphone-common/src/audio/codecs/audiocodec.h @@ -11,13 +11,13 @@ protected: std::string _codecName; // what we put inside sdp /** Clock rate or sample rate of the codec, in Hz */ - unsigned int _clockRate; + int _clockRate; /** Number of channel 1 = mono, 2 = stereo */ - unsigned int _channel; + int _channel; /** codec frame size in samples*/ - unsigned int _frameSize; + int _frameSize; /** Bitrate */ double _bitrate; @@ -61,9 +61,9 @@ public: std::string getCodecName( void ) { return _codecName; } int getPayload( void ) { return _payload; } bool hasDynamicPayload( void ) { return _hasDynamicPayload; } - unsigned int getClockRate( void ) { return _clockRate; } - unsigned int getFrameSize( void ) { return _frameSize; } - unsigned int getChannel( void ) { return _channel; } + int getClockRate( void ) { return _clockRate; } + int getFrameSize( void ) { return _frameSize; } + int getChannel( void ) { return _channel; } bool getState( void ) { return _state; } void setState(bool b) { _state = b; } double getBitRate( void ) { return _bitrate; } diff --git a/sflphone-common/src/audio/codecs/speexcodec_nb.cpp b/sflphone-common/src/audio/codecs/speexcodec_nb.cpp index ecc03815045bf8c79e98c8ae68083e565a800b78..22089f0454c7f7654de0a4c3f57275c1056dfda4 100644 --- a/sflphone-common/src/audio/codecs/speexcodec_nb.cpp +++ b/sflphone-common/src/audio/codecs/speexcodec_nb.cpp @@ -36,7 +36,7 @@ class Speex : public AudioCodec{ _preprocess_state() { _clockRate = 8000; - _frameSize = 320; // samples, 20 ms at 8kHz + _frameSize = 160; // samples, 20 ms at 8kHz _channel = 1; _bitrate = 0; _bandwidth = 0;