static int getrtp2(int fd, struct rtpheader *rh, char** data, int* lengthData) { static char buf[1600]; unsigned int intP; char* charP = (char*) &intP; int headerSize; int lengthPacket; int extensionLength; lengthPacket=recv(fd,buf,1590,0); if (lengthPacket<0) mp_msg(MSGT_NETWORK,MSGL_ERR,"rtp: socket read error\n"); else if (lengthPacket<12) mp_msg(MSGT_NETWORK,MSGL_ERR,"rtp: packet too small (%d) to be an rtp frame (>12bytes)\n", lengthPacket); if(lengthPacket<12) { *lengthData = 0; return 0; } rh->b.v = (unsigned int) ((buf[0]>>6)&0x03); rh->b.p = (unsigned int) ((buf[0]>>5)&0x01); rh->b.x = (unsigned int) ((buf[0]>>4)&0x01); rh->b.cc = (unsigned int) ((buf[0]>>0)&0x0f); rh->b.m = (unsigned int) ((buf[1]>>7)&0x01); rh->b.pt = (unsigned int) ((buf[1]>>0)&0x7f); intP = 0; memcpy(charP+2,&buf[2],2); rh->b.sequence = ntohl(intP); intP = 0; memcpy(charP,&buf[4],4); rh->timestamp = ntohl(intP); extensionLength = 0; if(rh->b.x == 1) { /* check extension-flag */ if(((unsigned char)buf[12] == 0xba) && ((unsigned char)buf[13] == 0xbe)) { /* NKF - IDENTIFIER */ intP = 0; memcpy(charP+2,&buf[14],2); /* NKF - DATALENGTH */ extensionLength = ntohl(intP)+16; /* NKF - DATALENGTH + NKF-HEADER(10) + NKF-TRAILER(6)*/ } } headerSize = 12 + 4*rh->b.cc + extensionLength; /* in bytes */ *lengthData = lengthPacket - headerSize; *data = (char*) buf + headerSize; // mp_msg(MSGT_NETWORK,MSGL_DBG2,"Reading rtp: v=%x p=%x x=%x cc=%x m=%x pt=%x seq=%x ts=%x lgth=%d\n",rh->b.v,rh->b.p,rh->b.x,rh->b.cc,rh->b.m,rh->b.pt,rh->b.sequence,rh->timestamp,lengthPacket); return(0); }