From b0d9f745c0dbeb57438946f57dd92a5ccfb4a7a3 Mon Sep 17 00:00:00 2001 From: paulc Date: Thu, 27 Oct 2011 17:35:18 +0000 Subject: [PATCH] Added support for MDCX to change RTP parameters in mgcpgw. git-svn-id: http://voip.null.ro/svn/yate@4657 acf43c95-373e-0410-b603-e72c3f656dc1 --- conf.d/mgcpgw.conf.sample | 4 ++++ modules/server/mgcpgw.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/conf.d/mgcpgw.conf.sample b/conf.d/mgcpgw.conf.sample index 1da45747..2cdfe235 100644 --- a/conf.d/mgcpgw.conf.sample +++ b/conf.d/mgcpgw.conf.sample @@ -106,6 +106,10 @@ ; This allows preserving the local RTP session and port ;ignore_sdp_port=no +; ignore_sdp_addr: bool: Ignore SDP changes if only the address is different +; This allows preserving the local RTP session and port +;ignore_sdp_addr=no + ;[ep PUT_NAME_HERE] ; One ep ... section is required for each of our endpoints diff --git a/modules/server/mgcpgw.cpp b/modules/server/mgcpgw.cpp index b85da95c..e4267eea 100644 --- a/modules/server/mgcpgw.cpp +++ b/modules/server/mgcpgw.cpp @@ -124,6 +124,9 @@ static MGCPPlugin splugin; static YMGCPEngine* s_engine = 0; +// preserve RTP session (local addr+port) even if remote address changed +static bool s_rtp_preserve = false; + // cluster and standby support static bool s_cluster = false; @@ -428,6 +431,7 @@ bool MGCPChan::processEvent(MGCPTransaction* tr, MGCPMessage* mm) if (param) m_ntfyId = *param; rqntParams(mm); + MimeSdpBody* sdp = 0; if (m_isRtp) { Message m("chan.rtp"); m.addParam("mgcp_allowed",String::boolText(false)); @@ -441,7 +445,26 @@ bool MGCPChan::processEvent(MGCPTransaction* tr, MGCPMessage* mm) m_rtpId = m.getValue(YSTRING("rtpid"),m_rtpId); } } - tr->setResponse(200,¶ms); + else { + sdp = static_cast(mm->sdp[0]); + if (sdp) { + String addr; + ObjList* lst = splugin.parser().parse(sdp,addr); + sdp = 0; + if (lst) { + if (m_rtpAddr != addr) { + m_rtpAddr = addr; + Debug(this,DebugAll,"New RTP addr '%s'",m_rtpAddr.c_str()); + // clear all data endpoints - createRtpSDP will build new ones + if (!s_rtp_preserve) + clearEndpoint(); + } + setMedia(lst); + sdp = createRtpSDP(true); + } + } + } + tr->setResponse(200,¶ms,sdp); return true; } if (mm->name() == YSTRING("AUCX")) { @@ -660,6 +683,7 @@ void MGCPPlugin::initialize() } m_parser.initialize(cfg.getSection("codecs"),cfg.getSection("hacks"), cfg.getSection("general")); + s_rtp_preserve = cfg.getBoolValue("hacks","ignore_sdp_addr",false); } }; // anonymous namespace