functions to access RTP packet (zrtp patch 1)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@949 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent 573b5eec25
commit a5d8e78aa4

@ -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;

@ -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;

Loading…
Cancel
Save