diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index 2cfedd36..f32dba08 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -302,6 +302,21 @@ void AmB2BSession::addFakeSDPbasedOnPort(const AmMimeBody *src_sdp, AmMimeBody & createFakeReply(&fake_mimebody, new_body); } +unsigned int AmB2BSession::getMediaPort(const AmSdp& sdp) +{ + unsigned int result = 0; + + for (auto it = sdp.media.begin(); it != sdp.media.end(); ++it) + { + /* must be a legal port which must also not be ICE dummy port */ + if (it->port > 0 && it->port != 9) { + result = it->port; + break; + } + } + return result; +} + void AmB2BSession::acceptPendingInvite(AmSipRequest *invite) { // reply the INVITE with fake 200 reply diff --git a/core/AmB2BSession.h b/core/AmB2BSession.h index 3bce1913..33090c88 100644 --- a/core/AmB2BSession.h +++ b/core/AmB2BSession.h @@ -213,6 +213,9 @@ private: /** create fake AmSipReply. SDP body based on SDP offer, but with a desired port */ void addFakeSDPbasedOnPort(const AmMimeBody *src_sdp, AmMimeBody &new_body, unsigned int& desired_port); + /** get the first available media port */ + unsigned int getMediaPort(const AmSdp& sdp); + /** generate 200 SIP reply on a pending INVITE (uses fake body) */ virtual void acceptPendingInvite(AmSipRequest *invite);