diff --git a/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp index bb2df6e077925a97781488aa811f566420458505..40b6f419d02a735aba69e13cb3fd1850854ae5be 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp +++ b/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp @@ -111,8 +111,8 @@ void AudioRtpSession::setSessionMedia (AudioCodec* audioCodec) bool dynamic = getHasDynamicPayload(); // G722 requires timestamp to be incremented at 8 kHz - if (payloadType == 9) - _timestampIncrement = 160; + if (payloadType == g722PayloadType) + _timestampIncrement = g722RtpTimeincrement; else _timestampIncrement = frameSize; @@ -122,9 +122,9 @@ void AudioRtpSession::setSessionMedia (AudioCodec* audioCodec) _debug ("AudioRtpSession: RTP timestamp increment: %d", _timestampIncrement); // Even if specified as a 16 kHz codec, G722 requires rtp sending rate to be 8 kHz - if (payloadType == 9) { + if (payloadType == g722PayloadType) { _debug ("AudioRtpSession: Setting G722 payload format"); - setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) payloadType, smplRate)); + setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) payloadType, g722RtpClockRate)); } else if (dynamic) { _debug ("AudioRtpSession: Setting dynamic payload format"); setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) payloadType, smplRate)); @@ -243,6 +243,14 @@ void AudioRtpSession::sendMicData() if(!compSize) return; + // Reset timestamp to make sure the timing information are up to date + /* + if (_timestampCount > RTP_TIMESTAMP_RESET_FREQ) { + _timestamp = getCurrentTimestamp(); + _timestampCount = 0; + } + */ + // Increment timestamp for outgoing packet _timestamp += _timestampIncrement; diff --git a/sflphone-common/src/audio/audiortp/AudioRtpSession.h b/sflphone-common/src/audio/audiortp/AudioRtpSession.h index 151a3031780af03ede5f2aa0b623e774049b23fd..3cc8477dbddb05305519bafac5c8552e013fa36f 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpSession.h @@ -57,8 +57,13 @@ namespace sfl { -// class AudioRtpSession : public ost::Thread, public ost::TimerPort, public AudioRtpRecordHandler, public ost::SymmetricRTPSession -// class AudioRtpSession : public ost::Thread, public ost::TimerPort, public ost::SymmetricRTPSession, public AudioRtpRecordHandler +// G.722 VoIP is typically carried in RTP payload type 9.[2] Note that IANA records the clock rate for type 9 G.722 as 8 kHz +// (instead of 16 kHz), RFC3551[3] clarifies that this is due to a historical error and is retained in order to maintain backward +// compatibility. Consequently correct implementations represent the value 8,000 where required but encode and decode audio at 16 kHz. +static const int g722PayloadType = 9; +static const int g722RtpClockRate = 8000; +static const int g722RtpTimeincrement = 160; + class AudioRtpSession : protected ost::Thread, public ost::TimerPort, public AudioRtpRecordHandler, public ost::TRTPSessionBase<ost::DualRTPUDPIPv4Channel,ost::DualRTPUDPIPv4Channel,ost::AVPQueue> { public: