码迷,mamicode.com
首页 > 其他好文 > 详细

rtpdataheader.h

时间:2015-06-04 15:09:46      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:

#ifndef RTPDATAHEADER_H
#define RTPDATAHEADER_H

// For 32bit intel machines
typedef short int16;
typedef int   int32;
typedef unsigned int u_int32;
typedef unsigned short u_int16;

#define RTP_BIG_ENDIAN 0
#define RTP_LITTLE_ENDIAN 1

//  RTP data header
//typedef __attribute__ ((__packed__)) struct {
typedef struct {
#if RTP_BIG_ENDIAN
    unsigned int version:2;         // protocol version
    unsigned int p:1;               // padding flag
    unsigned int x:1;               // header extension flag
    unsigned int cc:4;              // CSRC count
    unsigned int m:1;               // marker bit
    unsigned int pt:7;              // payload type
#elif RTP_LITTLE_ENDIAN
    unsigned int cc:4;              // CSRC count
    unsigned int x:1;               // header extension flag
    unsigned int p:1;               // padding flag
    unsigned int version:2;         // protocol version
    unsigned int pt:7;              // payload type
    unsigned int m:1;               // marker bit
#else
#error Define one of RTP_LITTLE_ENDIAN or RTP_BIG_ENDIAN
#endif
    unsigned int seq:16;            // sequence number
    u_int32 ts;                     // timestamp 32bits
    u_int32 ssrc;                   // synchronization source
} rtp_hdr_t;

#endif

//判断大小端
typedef unsigned char BYTE;
int main(int argc, char* argv[])
{
   unsigned int num,*p;
   p = #
   num = 0;
   *(BYTE *)p = 0xff;
   if(num == 0xff)
   {
      printf("little\n");
   }
   else //num == 0xff000000

   {
      printf("big\n");
   }
   return 0;
}

 

rtpdataheader.h

标签:

原文地址:http://www.cnblogs.com/tangxiacun/p/4551627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!