Module: sems Branch: master Commit: e3950674ebe1d136c8bd4d26edd44f354e1921eb URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=e3950674ebe1d136c8bd4d26edd44f354e1921eb
Author: Raphael Coeffic <[email protected]> Committer: Raphael Coeffic <[email protected]> Date: Sat Feb 19 14:52:26 2011 +0100 b/f: disable streams with port == 0. --- core/AmB2BSession.cpp | 47 ++++++++++++++++++++++++++++------------------- core/AmRtpStream.cpp | 7 ++++--- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index cac03cb..83985ea 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -287,25 +287,32 @@ void AmB2BSession::updateRelayStreams(const string& content_type, const string& unsigned int media_index = 0; for (std::vector<SdpMedia>::iterator it = parser_sdp.media.begin(); it != parser_sdp.media.end(); it++) { + if (media_index >= relay_rtp_streams_cnt) { WARN("trying to relay SDP with more media lines than " "relay streams initialized (%u)\n", relay_rtp_streams_cnt); break; } + string r_addr = it->conn.address; if (r_addr.empty()) r_addr = parser_sdp.conn.address; - // TODO: - // - disable streams with port == 0 - - DBG("initializing RTP relay stream %u with remote <%s:%u>\n", - media_index, r_addr.c_str(), it->port); - - relay_rtp_streams[media_index]->setRAddr(r_addr, it->port); - if (sdp.remote_active || rtp_relay_force_symmetric_rtp) { - relay_rtp_streams[media_index]->setPassiveMode(true); + if(it->port) { + DBG("initializing RTP relay stream %u with remote <%s:%u>\n", + media_index, r_addr.c_str(), it->port); + + relay_rtp_streams[media_index]->setRAddr(r_addr, it->port); + if (sdp.remote_active || rtp_relay_force_symmetric_rtp) { + relay_rtp_streams[media_index]->setPassiveMode(true); + } + relay_rtp_streams[media_index]->resume(); + } + else { + relay_rtp_streams[media_index]->pause(); + DBG("disabled RTP relay stream %u\n",media_index); } + media_index ++; } if (rtp_relay_force_symmetric_rtp) { @@ -340,21 +347,24 @@ bool AmB2BSession::replaceConnectionAddress(const string& content_type, unsigned int media_index = 0; for (std::vector<SdpMedia>::iterator it = parser_sdp.media.begin(); it != parser_sdp.media.end(); it++) { + if (media_index >= relay_rtp_streams_cnt) { WARN("trying to relay SDP with more media lines than " "relay streams initialized (%u)\n", relay_rtp_streams_cnt); break; } - if (!it->conn.address.empty()) - it->conn.address = advertisedIP(); - try { - it->port = relay_rtp_streams[media_index]->getLocalPort(); - replaced_ports += (!media_index) ? int2str(it->port) : "/"+int2str(it->port); - } catch (const string& s) { - ERROR("setting port: '%s'\n", s.c_str()); - throw string("error setting RTP port\n"); - } + if(it->port) { // if stream active + if (!it->conn.address.empty()) + it->conn.address = advertisedIP(); + try { + it->port = relay_rtp_streams[media_index]->getLocalPort(); + replaced_ports += (!media_index) ? int2str(it->port) : "/"+int2str(it->port); + } catch (const string& s) { + ERROR("setting port: '%s'\n", s.c_str()); + throw string("error setting RTP port\n"); + } + } media_index++; } @@ -753,7 +763,6 @@ void AmB2BSession::setupRelayStreams(AmB2BSession* other_session) { for (unsigned int i=0; i<relay_rtp_streams_cnt; i++) { other_session->relay_rtp_streams[i]->setRelayStream(relay_rtp_streams[i]); other_stream_fds[i] = other_session->relay_rtp_streams[i]->getLocalSocket(); - // set local IP (todo: option for other interface!) relay_rtp_streams[i]->setLocalIP(advertisedIP()); relay_rtp_streams[i]->enableRtpRelay(); } diff --git a/core/AmRtpStream.cpp b/core/AmRtpStream.cpp index 649f1a3..2e9b4af 100644 --- a/core/AmRtpStream.cpp +++ b/core/AmRtpStream.cpp @@ -426,7 +426,6 @@ AmRtpStream::AmRtpStream(AmSession* _s, int _if) memset(&r_saddr,0,sizeof(struct sockaddr_in)); memset(&l_saddr,0,sizeof(struct sockaddr_in)); #endif - //sched = AmRtpScheduler::instance(); #ifndef SUPPORT_IPV6 /* By default we listen on all interfaces */ @@ -562,12 +561,14 @@ void AmRtpStream::init(const vector<SdpPayload*>& sdp_payloads) void AmRtpStream::pause() { + receiving = false; } void AmRtpStream::resume() { gettimeofday(&last_recv_time,NULL); mem.clear(); + receiving = true; } void AmRtpStream::setOnHold(bool on_hold) { @@ -697,8 +698,8 @@ int AmRtpStream::nextPacket(AmRtpPacket*& p) AmConfig::DeadRtpTime && (diff.tv_sec > 0) && ((unsigned int)diff.tv_sec > AmConfig::DeadRtpTime)){ - WARN("RTP Timeout detected. Last received packet is too old.\n"); - DBG("diff.tv_sec = %i\n",(unsigned int)diff.tv_sec); + WARN("RTP Timeout detected. Last received packet is too old " + "(diff.tv_sec = %i\n",(unsigned int)diff.tv_sec); receive_mut.unlock(); return RTP_TIMEOUT; } _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
