Author: sayer
Date: 2008-05-14 14:15:28 +0200 (Wed, 14 May 2008)
New Revision: 949

Modified:
   trunk/core/AmRtpPacket.cpp
   trunk/core/AmRtpPacket.h
Log:
functions to access RTP packet (zrtp patch 1)

Modified: trunk/core/AmRtpPacket.cpp
===================================================================
--- trunk/core/AmRtpPacket.cpp  2008-05-14 11:54:55 UTC (rev 948)
+++ trunk/core/AmRtpPacket.cpp  2008-05-14 12:15:28 UTC (rev 949)
@@ -82,26 +82,35 @@
   assert(b_size);
 
   rtp_hdr_t* hdr = (rtp_hdr_t*)buffer;
+  if 
+#ifndef WITH_ZRTP
+    (hdr->version != RTP_VERSION)
+#else 
+    ((hdr->version != RTP_VERSION) && (hdr->version != 0))
+#endif
+      {
+       DBG("received RTP packet with unsupported version (%i).\n",
+           hdr->version);
+       return -1;
+      }
 
-  if(hdr->version != RTP_VERSION){
-    DBG("received RTP packet with unsupported version (%i).\n",
-       hdr->version);
-    return -1;
-  }
-
   data_offset = sizeof(rtp_hdr_t) + (hdr->cc*4);
 
   if(hdr->x != 0){
+#ifndef WITH_ZRTP 
     if (AmConfig::IgnoreRTPXHdrs) {
       // skip the extension header
+#endif
       if (b_size >= data_offset + 4) {
        data_offset +=
          ntohs(((rtp_xhdr_t*) (buffer + data_offset))->len)*4;
       }
+#ifndef WITH_ZRTP
     } else {
       DBG("RTP extension headers not supported.\n");
       return -1;
     }
+#endif
   }
 
   payload = hdr->pt;
@@ -132,6 +141,11 @@
   return &buffer[data_offset];
 }
 
+unsigned char *AmRtpPacket::getBuffer()
+{
+  return &buffer[0];
+}
+
 int AmRtpPacket::compile(unsigned char* data_buf, unsigned int size)
 {
   assert(data_buf);
@@ -163,6 +177,23 @@
   return 0;
 }
 
+int AmRtpPacket::compile_raw(unsigned char* data_buf, unsigned int size)
+{
+  if ((!size) || (!data_buf))
+    return -1;
+
+  if(size>sizeof(buffer)){
+    ERROR("builtin buffer size (%d) exceeded: %d\n",
+         (int)sizeof(buffer), size);
+    return -1;
+  }
+
+  memcpy(&buffer[0], data_buf, size);
+  b_size = size;
+
+  return size;
+}
+
 int AmRtpPacket::send(int sd)
 {
   int err;

Modified: trunk/core/AmRtpPacket.h
===================================================================
--- trunk/core/AmRtpPacket.h    2008-05-14 11:54:55 UTC (rev 948)
+++ trunk/core/AmRtpPacket.h    2008-05-14 12:15:28 UTC (rev 949)
@@ -72,6 +72,9 @@
 
   // returns -1 if error, else 0
   int compile(unsigned char* data_buf, unsigned int size);
+  // returns -1 if error, else 0
+  int compile_raw(unsigned char* data_buf, unsigned int size);
+
   int send(int sd);
   int recv(int sd);
 
@@ -80,6 +83,10 @@
   unsigned int   getDataSize() const { return d_size; }
   unsigned char* getData();
 
+  unsigned int   getBufferSize() const { return b_size; }
+  unsigned char* getBuffer();
+  void setBufferSize(unsigned int b) { b_size = b; }
+
   void copy(const AmRtpPacket* p);
 
   friend class AmRtpPacketTracer;

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

Reply via email to