How to find Nal header in h.264 RTP packet -


i need find nal header parsing rtp packet each nal unit encapsulated 1 rtp packet, parse nal header know whether it's pps unit or not. tried following got no result:

       databuffer = (char*)message_returnpacket(msg);         byte * hdr = (byte*)databuffer + rtp_hdr_size; //databuffer contains  rtp packet          rtpparsing((byte*)databuffer,rp,hdr);          if (rp.nal_type == 8 )         {             printf("\n  pps found \n");          }         else        {        printf("\n no pps found\n");          } 

where

    int rtpparsing(byte *pdata,rtppacket_t &rp, byte *hdr)     {     if ((pdata[0] & 0xc0) != (2 << 6)){     printf("[rtp] version incorrect! dump = 0x%x 0x%x 0x%x 0x%x       \n",pdata[0], pdata[1], pdata[2], pdata[3]);     return 0;     }  /* parse rtp header */  rp.v = (pdata[0] & 0xc0) >> 6; /* protocol version */ rp.p = (pdata[0] & 0x40) >> 5; /* padding flag */ rp.x = (pdata[0] & 0x20) >> 4; /* header extension flag */ rp.cc = (pdata[0] & 0x0f);  /* csrc count */ rp.m = (pdata[1] & 0x80) >> 7; /* marker bit */ rp.pt = (pdata[1] & 0x7f); //payload type rp.seq = ntohs (((unsigned short *) pdata)[1]);    /* sequence number */ rp.timestamp = ntohl (((unsigned int *) pdata)[1]); /* timestamp */ rp.ssrc = ntohl (((unsigned int *) pdata)[2]);  /* synchronization source */ rp.nal_type = (hdr[1] & 0x1f); // nal unit's type  if (rp.cc)      {     (int = 0; < rp.cc; i++)     {         //fprintf (out, " csrc: 0x%08x",ntohl (((unsigned int *) data)[3 + i]));     }     }     return 0;     } 

any ?

according rfc6184 in single nal unit mode, "the first byte of nal unit co-serves rtp payload header"

you offset incorrect (1 instead of 0):

rp.nal_type = (hdr[1] & 0x1f); // nal unit's type 

also, hard-coding rtp_hdr_size 12 (if that's you're doing) cause issues since size of header may vary based on extension headers, csrcs, etc.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -