diff --git a/core/AmRtpPacket.cpp b/core/AmRtpPacket.cpp index c61a1897..ce9fd5cd 100644 --- a/core/AmRtpPacket.cpp +++ b/core/AmRtpPacket.cpp @@ -82,26 +82,35 @@ int AmRtpPacket::parse() assert(b_size); rtp_hdr_t* hdr = (rtp_hdr_t*)buffer; - - if(hdr->version != RTP_VERSION){ - DBG("received RTP packet with unsupported version (%i).\n", - hdr->version); - return -1; - } + 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; + } 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 @@ unsigned char *AmRtpPacket::getData() 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 @@ int AmRtpPacket::compile(unsigned char* data_buf, unsigned int size) 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; diff --git a/core/AmRtpPacket.h b/core/AmRtpPacket.h index 3faeff4b..55cfff12 100644 --- a/core/AmRtpPacket.h +++ b/core/AmRtpPacket.h @@ -72,6 +72,9 @@ public: // 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 @@ public: 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;