www.pudn.com > H264RtpSource.rar > rtp_type.h


#ifndef RTP_RECV 
#define RTP_RECV 
 
#include  
 
//#define RTP_RCV "2.0.0" 
// 1.0.0 应用在孙波编写的单画面播放程序中,已经过几小时的运行测试,至少是个可用的版本 
 
// 1.0.1 为调整解码的速率,在返回的帧结构中加入了缓存中最后一帧的ts 
 
// 2.0.0 为节省CPU资源,及增加数据包的抖动纠错能力,取消了帧缓存,仅使用包缓存 
//       使用固定长度的包缓存区,不再动态申请。 
//       输入函数返回有效帧的个数,以便解码器调整播放速率 
 
// 2.0.1 修改了struct  send_frame_info,调整了标记位 
 
// 2.1.0 摄象机部分 - 把整个RTP部分重新整理,去掉了不必要的函数调用以提高工作效率 
//       增加了T8、T9来完成RTCP 
//       其他 - 增加了RTCP 
 
#define DROP_ERROR_FRAME 
 
#define RTP_HEADER_SIZE 12 
 
typedef struct rtp_header{ 
    //unsigned int v:2;							/* protocol version */ 
    //unsigned int p:1;							/* padding flag */ 
    //unsigned int x:1;							/* header extension flag */ 
    //unsigned int cc:4;						/* CSRC count */ 
    //unsigned int markbit:1;					/* marker bit */ 
    //unsigned int pt:7;						/* payload type */ 
 
    //unsigned /*int*/short seq;				/*:16; */ /* sequence number */ 
    //unsigned int timestamp;					/* timestamp */ 
    //unsigned int ssrc;						/* synchronization source */ 
    //unsigned int csrc[1];					/* optional CSRC list */ 
	unsigned short cc:4; 
	unsigned short extbit:1; 
	unsigned short padbit:1; 
	unsigned short version:2; 
	unsigned short paytype:7; 
	unsigned short markbit:1; 
	unsigned short seq_number; 
	unsigned int   timestamp; 
	unsigned int   ssrc; 
}rtp_header_t; 
 
struct  payload_mode_a{ 
    unsigned int f:1;         	// f=0 mode A; f=1 mode B */ 
    unsigned int p:1;		// 0=I, P frame 
    unsigned int sbit:3;		// Start Bit 
    unsigned int ebit:3;		// End Bit 
    unsigned int src:3;		// Source Format 
    unsigned int i:1;         	// i=0 I帧; i=1 P帧 
    unsigned int x:1;           // packet of the frame 
     
                                /************* 
                                高级选项和PB帧选项先不考虑 
                                unsigned int u:1;		// 是否使用无限运动矢量 
                                unsigned int s:1;		// 是否使用SAC 
                                unsigned int a:1;		// 是否使用AP 
                                unsigned int r:4;		// Reserved 
                                unsigned int dbq:2;	// 使用PB帧的时候表示量化步长DBQUANT,非PB帧的时候为0 
                                unsigned int trb:3;	// B帧的时域参考,非PB帧的时候为0 
                                unsigned int tr:8;		// P帧的时域参考,非PB帧的时候为0 
    **************/ 
     
    unsigned int r:19;		// Reserved 
}Payload_Mode_a; 
 
// 帧信息 
//struct  send_frame_info { 
//    unsigned int FrameLen;   	// 整帧长度,以字节表示。 
//    unsigned int ts;            // 时戳,即该帧的采样时间。 
//    unsigned int realtime;      // 实际时间,用于录象存储 
//    unsigned int i:1;           // 0-I Frame, 1-P Frame 
//    unsigned int x:1;           // 1-Start packet of a frame 
//    unsigned int m:1;           // 1-End packet of a frame 
//    unsigned int src:3;         // Source format 
//    unsigned int r:26;         // 保留位	 
//}; 
 
struct Frame_Info 
{ 
    unsigned int ts;            // 时戳,即该帧的采样时间。 
    unsigned int realtime;      // 实际时间,用于录象存储 
    unsigned char i;           // 0-I Frame, 1-P Frame 
    unsigned char x;           // 1-Start packet of a frame 
    unsigned char m;           // 1-End packet of a frame 
    unsigned char src;         // Source format 
}; 
 
// 包缓冲单元 
struct packet_buf{ 
    struct Frame_Info    FrameInfo; 
    unsigned int    PacketLen; 
    unsigned char   data[1500]; 
}; 
 
#define MAX_AUDIO_FRAM_SIZE  320     // 最大音频帧的长度(字节数) 
// 接收音频RTP包缓冲单元 
struct audio_packet_buf{ 
    struct Frame_Info    FrameInfo; 
    unsigned int    PacketLen; 
    unsigned char   data[MAX_AUDIO_FRAM_SIZE]; 
}; 
 
// 包缓冲单元个数,即最大缓冲区大小 
#define MAX_FRAME_LEN 150000 
 
// 存放1整帧数据的结构 
typedef struct frame{ 
    struct Frame_Info   FrameInfo; 
	unsigned int		FrameLen; 
    unsigned int  Lastts; 
    unsigned char *data; 
}FRAME; 
 
// 发送端RCTP所需的统计数据&提供的决策数据 
typedef struct RTCPDATA 
{ 
    unsigned int clost:24;  	// cumulative number of packets lost 
    unsigned int ts;            // 最新的RTP时戳 
	unsigned int spc;	        // 累计发送包数 
	unsigned int soc;		    // 累计发送字节数 
    unsigned int cur_delay[20];		// 延时(秒) 
    unsigned int cur_flost[20];     // 丢包率 
    unsigned int current;       // 当前数据指针, 
	/*time_t time;*/		    // 最近一次收到RTCP包的时间 
    struct timeval time;		// 最近一次收到RTCP包的时间 modify2003.8.29 lifang 
}RTCPDATA; 
 
// 接收端RCTP所需的统计数据&提供的决策数据 
typedef struct RECV_RTCPDATA 
{ 
    unsigned int rpc;           // 本区间内收到数据包记数 
    unsigned int RecvPackets;   // 接收到数据包的总数 
    unsigned int spc;           // 上一次的的spc 
    struct timeval time;		// 最近一次收到RTCP包的时间 
}RECV_RTCPDATA; 
 
#endif