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

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Mon Nov 26 13:08:36 2012 +0100

adds support for raw UDP relay.

---

 core/AmRtpStream.cpp |   41 +++++++++++++++++++++++++++++++++++++----
 core/AmRtpStream.h   |   14 ++++++++++++++
 2 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/core/AmRtpStream.cpp b/core/AmRtpStream.cpp
index 18f1d69..c4a9f38 100644
--- a/core/AmRtpStream.cpp
+++ b/core/AmRtpStream.cpp
@@ -920,9 +920,13 @@ void AmRtpStream::recvPacket(int fd)
   }
   
   if(p->recv(l_sd) > 0){
-    int parse_res = p->parse();
+    int parse_res = 0;
+
     gettimeofday(&p->recv_time,NULL);
     
+    if(!relay_raw)
+      parse_res = p->parse();
+ 
     if (parse_res == -1) {
       DBG("error while parsing RTP packet.\n");
       clearRTPTimeout(&p->recv_time);
@@ -973,14 +977,15 @@ void AmRtpStream::relay(AmRtpPacket* p) {
     return;
 
   rtp_hdr_t* hdr = (rtp_hdr_t*)p->getBuffer();
-  if (!relay_transparent_seqno)
+  if (!relay_raw && !relay_transparent_seqno)
     hdr->seq = htons(sequence++);
-  if (!relay_transparent_ssrc)
+  if (!relay_raw && !relay_transparent_ssrc)
     hdr->ssrc = htonl(l_ssrc);
   p->setAddr(&r_saddr);
 
   if(p->send(l_sd) < 0){
-    ERROR("while sending RTP packet.\n");
+    ERROR("while sending RTP packet to '%s':%i\n",
+         get_addr_str(&r_saddr).c_str(),am_get_port(&r_saddr));
   }
 }
 
@@ -1030,6 +1035,18 @@ void AmRtpStream::enableRtpRelay(const PayloadMask 
&_relay_payloads, AmRtpStream
   relay_enabled = true;
 }
 
+void AmRtpStream::enableRawRelay()
+{
+  DBG("enabled RAW relay for RTP stream instance [%p]\n", this);
+  relay_raw = true;
+}
+
+void AmRtpStream::disableRawRelay()
+{
+  DBG("disabled RAW relay for RTP stream instance [%p]\n", this);
+  relay_raw = false;
+}
+ 
 void AmRtpStream::setRtpRelayTransparentSeqno(bool transparent) {
   DBG("%sabled RTP relay transparent seqno for RTP stream instance [%p]\n",
       transparent ? "en":"dis", this);
@@ -1042,6 +1059,22 @@ void AmRtpStream::setRtpRelayTransparentSSRC(bool 
transparent) {
   relay_transparent_ssrc = transparent;
 }
 
+void AmRtpStream::stopReceiving()
+{
+  if (hasLocalSocket()){
+    DBG("remove stream [%p] from RTP receiver\n", this);
+    AmRtpReceiver::instance()->removeStream(getLocalSocket());
+  }
+}
+
+void AmRtpStream::resumeReceiving()
+{
+  if (hasLocalSocket()){
+    DBG("resume stream [%p] into RTP receiver\n",this);
+    AmRtpReceiver::instance()->addStream(getLocalSocket(), this);
+  }
+}
+
 string AmRtpStream::getPayloadName(int payload_type)
 {
   for(PayloadCollection::iterator it = payloads.begin();
diff --git a/core/AmRtpStream.h b/core/AmRtpStream.h
index 077b561..591f819 100644
--- a/core/AmRtpStream.h
+++ b/core/AmRtpStream.h
@@ -249,6 +249,8 @@ protected:
 
   /** if relay_stream is initialized, received RTP is relayed there */
   bool            relay_enabled;
+  /** if true, packets are note parsed or checked */
+  bool            relay_raw;
   /** pointer to relay stream.
       NOTE: This may only be accessed in initialization
       or by the AmRtpReceiver thread while relaying!  */
@@ -452,11 +454,23 @@ public:
   /** disable RTP relaying through relay stream */
   void disableRtpRelay();
 
+  /** enable raw UDP relaying through relay stream */
+  void enableRawRelay();
+
+  /** disable raw UDP relaying through relay stream */
+  void disableRawRelay();
+
   /** enable or disable transparent RTP seqno for relay */
   void setRtpRelayTransparentSeqno(bool transparent);
 
   /** enable or disable transparent SSRC seqno for relay */
   void setRtpRelayTransparentSSRC(bool transparent);
+
+  /** remove from RTP receiver */
+  void stopReceiving();
+
+  /** (re-)insert into RTP receiver */
+  void resumeReceiving();
 };
 
 #endif

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

Reply via email to