Skip to content
Snippets Groups Projects
Commit 56371288 authored by asavard's avatar asavard
Browse files

[#4367] Fix g722 codec clock rate

parent e71e1ec9
Branches
Tags
No related merge requests found
......@@ -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;
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment