typedef struct RTP_
{
unsigned int cc : 4;
unsigned int x : 1;
unsigned int p : 1;
unsigned int ver : 2;
unsigned int pt : 7;
unsigned int m : 1;
unsigned int seq : 16;
unsigned int ts;
unsigned int ssrc;
} ST_RTP_HEAD;
#include <stdio.h>
typedef struct RTP
{
unsigned int cc : 4; // 低4位
unsigned int x : 1;
unsigned int p : 1;
unsigned int ver : 2;
unsigned int pt : 7;
unsigned int m : 1;
unsigned int seq : 16; // 高16位
} RTP_HEAD; // 切记: 只是在存的时候才分大小端
RTP_HEAD test;
/*
int main()
{
test.cc = 4; // 0100
test.x = 1; // 1
test.p = 0; // 0
test.ver= 2; // 10
test.pt = 9; // 0001001
test.m = 0;
test.seq = 5; // 0000000000000101
printf("%d \n",test); // 00000000000001010000100110010100
}
*/
int main()
{
test.cc = 0; // 0100
test.x = 0; // 1
test.p = 0; // 0
test.ver= 2; // 10
test.pt = 0; // 0001001
test.m = 1;
test.seq = 0; // 0000000000000101
printf("%d \n",test); // 00000000000001010000100110010100
}