diff --git a/core/AmRtpStream.cpp b/core/AmRtpStream.cpp index 14813979..aa884eb7 100644 --- a/core/AmRtpStream.cpp +++ b/core/AmRtpStream.cpp @@ -162,6 +162,30 @@ void AmRtpStream::setLocalPort() DBG("local rtp port set to %i\n",l_port); } +int AmRtpStream::ping() +{ + unsigned char ping_chr[2]; + + ping_chr[0] = 0; + ping_chr[1] = 0; + + AmRtpPacket rp; + rp.payload = payload; + rp.marker = true; + rp.sequence = sequence++; + rp.timestamp = 0; + rp.ssrc = l_ssrc; + rp.compile((unsigned char*)ping_chr,2); + + rp.setAddr(&r_saddr); + if(rp.send(l_sd) < 0){ + ERROR("while sending RTP packet.\n"); + return -1; + } + + return 2; +} + int AmRtpStream::send( unsigned int ts, unsigned char* buffer, unsigned int size ) { if ((mute) || (hold)) diff --git a/core/AmRtpStream.h b/core/AmRtpStream.h index c265fc62..46be880e 100644 --- a/core/AmRtpStream.h +++ b/core/AmRtpStream.h @@ -155,7 +155,10 @@ public: int receive( unsigned char* buffer, unsigned int size, unsigned int& ts, int& payload); - + + /** ping the remote side, to open NATs and enable symmetric RTP */ + int ping(); + /** Allocates resources for future use of RTP. */ AmRtpStream(AmSession* _s=0); /** Stops the stream and frees all resources. */ diff --git a/core/AmSession.cpp b/core/AmSession.cpp index 6253d91d..92d68314 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -648,6 +648,9 @@ void AmSession::onSipReply(const AmSipReply& reply) onEarlySessionStart(reply); rtp_str.setMonitorRTPTimeout(false); + + // ping the other side to open fw/NAT/symmetric RTP + rtp_str.ping(); if(input || output || local_input || local_output) AmMediaProcessor::instance()->addSession(this,