Module: sems
Branch: rco/sbc_rtp_relay
Commit: 69627e2a82d1fafbea2eeb3d902651bb347ad01b
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=69627e2a82d1fafbea2eeb3d902651bb347ad01b

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Wed Feb 16 15:31:59 2011 +0100

changed relay_rtp_stream to AmRtpStream**.

this allows for non-default AmRtpStream constructor.

---

 core/AmB2BSession.cpp |   40 +++++++++++++++++++++++++---------------
 core/AmB2BSession.h   |    2 +-
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp
index 73fc74b..aea2997 100644
--- a/core/AmB2BSession.cpp
+++ b/core/AmB2BSession.cpp
@@ -67,8 +67,11 @@ AmB2BSession::~AmB2BSession()
   if (rtp_relay_enabled)
     clearRtpReceiverRelay();
 
-  if (NULL != relay_rtp_streams)
+  if (NULL != relay_rtp_streams){
+    for(unsigned int i=0; i<relay_rtp_streams_cnt; i++)
+      delete relay_rtp_streams[i];
     delete[] relay_rtp_streams;
+  }
 
   DBG("relayed_req.size() = %u\n",(unsigned int)relayed_req.size());
   DBG("recvd_req.size() = %u\n",(unsigned int)recvd_req.size());
@@ -268,13 +271,16 @@ void AmB2BSession::updateRelayStreams(const string& 
content_type, const string&
   if (NULL == relay_rtp_streams) {
     relay_rtp_streams_cnt = parser_sdp.media.size();
     if (relay_rtp_streams_cnt > MAX_RELAY_STREAMS) {
-      WARN("got SDP with more media streams (%zd) than MAX_RELAY_STREAMS (%u),"
+      WARN("got SDP with more media streams (%d) than MAX_RELAY_STREAMS (%u),"
           "consider changing MAX_RELAY_STREAMS and rebuilding SEMS.\n",
           relay_rtp_streams_cnt, MAX_RELAY_STREAMS);
       relay_rtp_streams_cnt = MAX_RELAY_STREAMS;
     }
 
-    relay_rtp_streams = new AmRtpStream[relay_rtp_streams_cnt];
+    relay_rtp_streams = new AmRtpStream*[relay_rtp_streams_cnt];
+    for(unsigned int i=0; i<relay_rtp_streams_cnt; i++){
+      relay_rtp_streams[i] = new AmRtpStream(NULL,dlg.getOutboundIf());
+    }
     DBG("Created %u RTP relay streams\n", relay_rtp_streams_cnt);
   }
 
@@ -292,9 +298,9 @@ void AmB2BSession::updateRelayStreams(const string& 
content_type, const string&
 
     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);
+    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]->setPassiveMode(true);
     }
     media_index ++;
   }
@@ -323,6 +329,8 @@ bool AmB2BSession::replaceConnectionAddress(const string& 
content_type,
   if (!parser_sdp.conn.address.empty())
     parser_sdp.conn.address = advertisedIP();
 
+  DBG("new connection address: %s",parser_sdp.conn.address.c_str());
+
   string replaced_ports;
 
   unsigned int media_index = 0;
@@ -336,7 +344,7 @@ bool AmB2BSession::replaceConnectionAddress(const string& 
content_type,
     if (!it->conn.address.empty())
       it->conn.address = advertisedIP();
     try {
-      it->port = relay_rtp_streams[media_index].getLocalPort();
+      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());
@@ -726,17 +734,19 @@ void AmB2BSession::setupRelayStreams(AmB2BSession* 
other_session) {
     relay_rtp_streams_cnt = other_session->relay_rtp_streams_cnt;
     DBG("creating %u RTP streams from other_session\n",
        relay_rtp_streams_cnt);
-    relay_rtp_streams = new AmRtpStream[relay_rtp_streams_cnt];
+    relay_rtp_streams = new AmRtpStream*[relay_rtp_streams_cnt];
+    for(unsigned int i=0; i<relay_rtp_streams_cnt; i++){
+      relay_rtp_streams[i] = new AmRtpStream(NULL,dlg.getOutboundIf());
+    }
   }
 
-
   // link the other streams as our relay streams
   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();
+    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(AmConfig::LocalIP);
-    relay_rtp_streams[i].enableRtpRelay();
+    relay_rtp_streams[i]->setLocalIP(other_session->advertisedIP());
+    relay_rtp_streams[i]->enableRtpRelay();
   }
 }
 
@@ -748,8 +758,8 @@ void AmB2BSession::clearRtpReceiverRelay() {
       other_stream_fds[i] = 0;
     }
     // clear our relay streams from RTP receiver
-    if (relay_rtp_streams[i].hasLocalSocket()) {
-      
AmRtpReceiver::instance()->removeStream(relay_rtp_streams[i].getLocalSocket());
+    if (relay_rtp_streams[i]->hasLocalSocket()) {
+      
AmRtpReceiver::instance()->removeStream(relay_rtp_streams[i]->getLocalSocket());
     }
   }
 }
@@ -975,7 +985,7 @@ void 
AmB2BCallerSession::initializeRTPRelay(AmB2BCalleeSession* callee_session)
 
   // bind caller session's relay_streams to a port
   for (unsigned int i=0; i<relay_rtp_streams_cnt; i++)
-    relay_rtp_streams[i].getLocalPort();
+    relay_rtp_streams[i]->getLocalPort();
 }
 
 AmB2BCalleeSession::AmB2BCalleeSession(const string& other_local_tag)
diff --git a/core/AmB2BSession.h b/core/AmB2BSession.h
index a06d99e..7cf6c14 100644
--- a/core/AmB2BSession.h
+++ b/core/AmB2BSession.h
@@ -227,7 +227,7 @@ class AmB2BSession: public AmSession
 
   /** RTP streams which receive from our side and are used
       for relaying RTP from the other side */
-  AmRtpStream* relay_rtp_streams;
+  AmRtpStream** relay_rtp_streams;
   /** number of relay RTP streams */
   unsigned int relay_rtp_streams_cnt;
   /** fd of the other streams' sockets (to remove from

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to