[pjsip] Bug in sdp_neg/match_offer with prefer_remote_codec=0
r3gis.3r at gmail.com
Fri Oct 7 07:17:54 EDT 2011
I found a bug in sdp_neg.c "match_offer" method when you disable
prefer_remote_codec_order (set PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER
(Tested on pjsip-1.x but regarding code should also affect pjsip-2.x)
In this case master and slave pjmedia_sdp_media are inverted.
As consequence, when tests are done on rtpmap the or_ parameter here
can be the one generated by pjsip and lr the one of the offer.
In this case the test made at this line is not valid cause obviously
or_.param will be empty in case of a single channel codec (pjsip does
not add channel counts if 1 which is fine, but other side could add...).
So test will fail if the other side add the channel count 1, while it
should have succeeded because we have something like remote AMR/8000/1
and local AMR/8000 .
So, in this case if remote party add channel count in rtpmap and
prefer_remote_codec_order is disabled, it will result in unexpected
On my side I did a quick fix :
pjmedia_sdp_rtpmap remote_r = or_;
remote_r = lr;
if (!pj_stricmp(&or_.enc_name, &lr.enc_name) &&
or_.clock_rate == lr.clock_rate &&
(pj_stricmp(&or_.param, &lr.param)==0 ||
(remote_r.param.slen==1 && *remote_r.param.ptr=='1')))
But I don't know if it is the best way to do that (maybe a pointer to
param would be a better idea?).
More information about the pjsip