From 9aaf3ce2ff2ca8c234eb7177afbc3a551b97a856 Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang <1237906+wasphin@users.noreply.github.com> Date: Wed, 10 Nov 2021 14:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=E9=9D=99?= =?UTF-8?q?=E6=80=81=20payload=20type=20=E5=80=BC=20(#1206)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/G711.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Extension/G711.cpp b/src/Extension/G711.cpp index eab141ce..c883a973 100644 --- a/src/Extension/G711.cpp +++ b/src/Extension/G711.cpp @@ -58,7 +58,18 @@ Sdp::Ptr G711Track::getSdp() { WarnL << getCodecName() << " Track未准备好"; return nullptr; } - return std::make_shared(getCodecId(), getAudioSampleRate(), getAudioChannel(), getBitRate() / 1024); + + const auto codec = getCodecId(); + const auto sample_rate = getAudioSampleRate(); + const auto audio_channel = getAudioChannel(); + const auto bitrate = getBitRate() >> 10; + auto payload_type = 98; + if (sample_rate == 8000 && audio_channel == 1) { + // https://datatracker.ietf.org/doc/html/rfc3551#section-6 + payload_type = (codec == CodecG711U) ? Rtsp::PT_PCMU : Rtsp::PT_PCMA; + } + + return std::make_shared(codec, sample_rate, audio_channel, bitrate, payload_type); } }//namespace mediakit