Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

RTP.h

Go to the documentation of this file.
00001 /* 00002 * rtp.h -- RTP header file (RFC XXXX) 00003 */ 00004 #include <sys/types.h> 00005 00006 /* 00007 * The type definitions below are valid for 32-bit architectures and 00008 * may have to be adjusted for 16- or 64-bit architectures. 00009 */ 00010 typedef unsigned char u_int8; 00011 typedef unsigned short u_int16; 00012 typedef unsigned int u_int32; 00013 typedef short int16; 00014 00015 /* 00016 * Current protocol version. 00017 */ 00018 #define RTP_VERSION 2 00019 00020 #define RTP_SEQ_MOD (1<<16) 00021 #define RTP_MAX_SDES 255 /* maximum text length for SDES */ 00022 00023 typedef enum { 00024 RTCP_SR = 200, 00025 RTCP_RR = 201, 00026 RTCP_SDES = 202, 00027 RTCP_BYE = 203, 00028 RTCP_APP = 204 00029 } rtcp_type_t; 00030 00031 typedef enum { 00032 RTCP_SDES_END = 0, 00033 RTCP_SDES_CNAME = 1, 00034 RTCP_SDES_NAME = 2, 00035 RTCP_SDES_EMAIL = 3, 00036 RTCP_SDES_PHONE = 4, 00037 RTCP_SDES_LOC = 5, 00038 RTCP_SDES_TOOL = 6, 00039 RTCP_SDES_NOTE = 7, 00040 RTCP_SDES_PRIV = 8 00041 } rtcp_sdes_type_t; 00042 00043 /* 00044 * RTP data header 00045 */ 00046 typedef struct { 00047 unsigned int version:2; /* protocol version */ 00048 unsigned int p:1; /* padding flag */ 00049 unsigned int x:1; /* header extension flag */ 00050 unsigned int cc:4; /* CSRC count */ 00051 unsigned int m:1; /* marker bit */ 00052 unsigned int pt:7; /* payload type */ 00053 unsigned int seq:16; /* sequence number */ 00054 u_int32 ts; /* timestamp */ 00055 u_int32 ssrc; /* synchronization source */ 00056 /* u_int32 csrc[1]; */ /* optional CSRC list */ 00057 } rtp_hdr_t; 00058 00059 /* 00060 * RTCP common header word 00061 */ 00062 typedef struct { 00063 unsigned int version:2; /* protocol version */ 00064 unsigned int p:1; /* padding flag */ 00065 unsigned int count:5; /* varies by packet type */ 00066 unsigned int pt:8; /* RTCP packet type */ 00067 u_int16 length; /* pkt len in words, w/o this word */ 00068 } rtcp_common_t; 00069 00070 /* 00071 * Big-endian mask for version, padding bit and packet type pair 00072 */ 00073 #define RTCP_VALID_MASK (0xc000 | 0x2000 | 0xfe) 00074 #define RTCP_VALID_VALUE ((RTP_VERSION << 14) | RTCP_SR) 00075 00076 /* 00077 * Reception report block 00078 */ 00079 typedef struct { 00080 u_int32 ssrc; /* data source being reported */ 00081 unsigned int fraction:8; /* fraction lost since last SR/RR */ 00082 int lost:24; /* cumul. no. pkts lost (signed!) */ 00083 u_int32 last_seq; /* extended last seq. no. received */ 00084 u_int32 jitter; /* interarrival jitter */ 00085 u_int32 lsr; /* last SR packet from this source */ 00086 u_int32 dlsr; /* delay since last SR packet */ 00087 } rtcp_rr_t; 00088 00089 /* 00090 * SDES item 00091 */ 00092 typedef struct { 00093 u_int8 type; /* type of item (rtcp_sdes_type_t) */ 00094 u_int8 length; /* length of item (in octets) */ 00095 char data[1]; /* text, not null-terminated */ 00096 } rtcp_sdes_item_t; 00097 00098 /* 00099 * One RTCP packet 00100 */ 00101 typedef struct { 00102 rtcp_common_t common; /* common header */ 00103 union { 00104 /* sender report (SR) */ 00105 struct { 00106 u_int32 ssrc; /* sender generating this report */ 00107 u_int32 ntp_sec; /* NTP timestamp */ 00108 u_int32 ntp_frac; 00109 u_int32 rtp_ts; /* RTP timestamp */ 00110 u_int32 psent; /* packets sent */ 00111 u_int32 osent; /* octets sent */ 00112 rtcp_rr_t rr[1]; /* variable-length list */ 00113 } sr; 00114 00115 /* reception report (RR) */ 00116 struct { 00117 u_int32 ssrc; /* receiver generating this report */ 00118 rtcp_rr_t rr[1]; /* variable-length list */ 00119 } rr; 00120 00121 /* source description (SDES) */ 00122 struct rtcp_sdes { 00123 u_int32 src; /* first SSRC/CSRC */ 00124 rtcp_sdes_item_t item[1]; /* list of SDES items */ 00125 } sdes; 00126 00127 /* BYE */ 00128 struct { 00129 u_int32 src[1]; /* list of sources */ 00130 /* can't express trailing text for reason */ 00131 } bye; 00132 } r; 00133 } rtcp_t; 00134 00135 typedef struct rtcp_sdes rtcp_sdes_t; 00136 00137 /* 00138 * Per-source state information 00139 */ 00140 typedef struct { 00141 u_int16 max_seq; /* highest seq. number seen */ 00142 u_int32 cycles; /* shifted count of seq. number cycles */ 00143 u_int32 base_seq; /* base seq number */ 00144 u_int32 bad_seq; /* last 'bad' seq number + 1 */ 00145 u_int32 probation; /* sequ. packets till source is valid */ 00146 u_int32 received; /* packets received */ 00147 u_int32 expected_prior; /* packet expected at last interval */ 00148 u_int32 received_prior; /* packet received at last interval */ 00149 u_int32 transit; /* relative trans time for prev pkt */ 00150 u_int32 jitter; /* estimated jitter */ 00151 /* ... */ 00152 } source;

Generated on Wed Nov 3 19:19:02 2004 for xdvshow by doxygen 1.3.7