From ae62caebc6769f96d7ffc2e7e4f4e6e07ec0f0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Mon, 30 Mar 2020 18:19:35 -0400 Subject: Use the first payload type number for each codec in the SDP answer It is possible for the SDP offer to feature more than one payload type number (either static or dynamic) that refer to the same codec. For example, a peer that supports ITU-T V.152 may use two payload types, with one of them marked for voice-band data use: m=audio 3456 RTP/AVP 0 98 a=rtpmap:0 PCMU/8000 a=rtpmap:98 PCMU/8000 a=gpmd:98 vbd=yes Ideally, Twinkle should use the number that was listed first in the media formats list when building the SDP answer. Closes #184 --- src/session.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/session.cpp b/src/session.cpp index ae816fa..2007791 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -44,7 +44,10 @@ void t_session::set_recvd_codecs(t_sdp *sdp) { t_audio_codec ac = sdp->get_codec(SDP_AUDIO, *i); if (ac > CODEC_UNSUPPORTED) { recvd_codecs.push_back(ac); - send_ac2payload[ac] = *i; + // Don't overwrite any previous mapping for this codec + if (!send_ac2payload.count(ac)) { + send_ac2payload[ac] = *i; + } send_payload2ac[*i] = ac; } } -- cgit v1.2.3