root/vic/branches/cc/rtp/rtp.h
@
4236
| Revision 4236, 8.1 KB (checked in by soohyunc, 5 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | /*- |
| 2 | * Copyright (c) 1993-1994 The Regents of the University of California. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. All advertising materials mentioning features or use of this software |
| 14 | * must display the following acknowledgement: |
| 15 | * This product includes software developed by the University of |
| 16 | * California, Berkeley and the Network Research Group at |
| 17 | * Lawrence Berkeley Laboratory. |
| 18 | * 4. Neither the name of the University nor of the Laboratory may be used |
| 19 | * to endorse or promote products derived from this software without |
| 20 | * specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 32 | * SUCH DAMAGE. |
| 33 | */ |
| 34 | |
| 35 | #ifndef vic_rtp_h |
| 36 | #define vic_rtp_h |
| 37 | |
| 38 | #ifndef WIN32 |
| 39 | #include <sys/param.h> |
| 40 | #endif |
| 41 | #include "sys-time.h" |
| 42 | |
| 43 | #define RTP_PT_RAW 126 /* XXX */ |
| 44 | #define RTP_PT_BVC 22 /* Berkeley video codec */ |
| 45 | |
| 46 | /* RTP standard content encodings for video */ |
| 47 | #define RTP_PT_LDCT 20 /* Layered DCT */ |
| 48 | #define RTP_PT_PVH 21 /* Steve McCanne's */ |
| 49 | #define RTP_PT_RGB8 23 /* 8-bit dithered RGB */ |
| 50 | #define RTP_PT_HDCC 24 /* SGI proprietary */ |
| 51 | #define RTP_PT_CELLB 25 /* Sun CellB */ |
| 52 | #define RTP_PT_JPEG 26 /* JPEG */ |
| 53 | #define RTP_PT_CUSEEME 27 /* Cornell CU-SeeMe */ |
| 54 | #define RTP_PT_NV 28 /* Xerox PARC nv */ |
| 55 | #define RTP_PT_PICW 29 /* BB&N PictureWindow */ |
| 56 | #define RTP_PT_CPV 30 /* Concept/Bolter/Viewpoint codec */ |
| 57 | #define RTP_PT_H261 31 /* ITU H.261 */ |
| 58 | #define RTP_PT_MPEG 32 /* MPEG-I & MPEG-II */ |
| 59 | #define RTP_PT_MP2T 33 /* MPEG-II either audio or video */ |
| 60 | #define RTP_PT_H263P 42 /* ITU H.263 */ |
| 61 | #define RTP_PT_H263 34 /* ITU H.263 */ |
| 62 | #define RTP_PT_DV 123 /* DV */ |
| 63 | #define RTP_PT_MPEG4 45 |
| 64 | #define RTP_PT_H264 96 |
| 65 | |
| 66 | /* backward compat hack for decoding RTPv1 ivs streams */ |
| 67 | #define RTP_PT_H261_COMPAT 127 |
| 68 | |
| 69 | /* non-standard arbitrary sized h261 */ |
| 70 | #define RTP_PT_H261AS 77 |
| 71 | |
| 72 | /* RTP standard content encodings for audio */ |
| 73 | #define RTP_PT_PCMU 0 |
| 74 | #define RTP_PT_CELP 1 |
| 75 | #define RTP_PT_GSM 3 |
| 76 | #define RTP_PT_DVI 5 |
| 77 | #define RTP_PT_LPC 7 |
| 78 | |
| 79 | |
| 80 | /* Offset from UNIX's epoch to the NTP epoch in seconds (NTP's JAN_1970) */ |
| 81 | #define RTP_EPOCH_OFFSET 2208988800UL |
| 82 | #define RTP_VERSION 2 |
| 83 | |
| 84 | #define RTP_M 0x0080 /* Marker: significant event <e.g. frame boundary> */ |
| 85 | #define RTP_P 0x2000 /* Padding is present */ |
| 86 | #define RTP_X 0x1000 /* Extension Header is present */ |
| 87 | |
| 88 | /* Basic RTP header */ |
| 89 | struct rtphdr { |
| 90 | u_int16_t rh_flags; /* T:2 P:1 X:1 CC:4 M:1 PT:7 */ |
| 91 | u_int16_t rh_seqno; /* sequence number */ |
| 92 | u_int32_t rh_ts; /* media-specific time stamp */ |
| 93 | u_int32_t rh_ssrc; /* synchronization src id */ |
| 94 | /* data sources follow per cc */ |
| 95 | }; |
| 96 | |
| 97 | struct rtcphdr { |
| 98 | u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */ |
| 99 | u_int16_t rh_len; /* length of message (in bytes) */ |
| 100 | u_int32_t rh_ssrc; /* synchronization src id */ |
| 101 | }; |
| 102 | |
| 103 | typedef struct { |
| 104 | u_int32_t upper; /* more significant 32 bits */ |
| 105 | u_int32_t lower; /* less significant 32 bits */ |
| 106 | } ntp64; |
| 107 | |
| 108 | /* |
| 109 | * Sender report. |
| 110 | */ |
| 111 | struct rtcp_sr { |
| 112 | ntp64 sr_ntp; /* 64-bit ntp timestamp */ |
| 113 | u_int32_t sr_ts; /* reference media timestamp */ |
| 114 | u_int32_t sr_np; /* no. packets sent */ |
| 115 | u_int32_t sr_nb; /* no. bytes sent */ |
| 116 | }; |
| 117 | |
| 118 | /* |
| 119 | * Receiver report. |
| 120 | * Time stamps are middle 32-bits of ntp timestamp. |
| 121 | */ |
| 122 | struct rtcp_rr { |
| 123 | u_int32_t rr_srcid; /* sender being reported */ |
| 124 | u_int32_t rr_loss; /* loss stats (8:fraction, 24:cumulative)*/ |
| 125 | u_int32_t rr_ehsr; /* ext. highest seqno received */ |
| 126 | u_int32_t rr_dv; /* jitter (delay variance) */ |
| 127 | u_int32_t rr_lsr; /* orig. ts from last rr from this src */ |
| 128 | u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */ |
| 129 | }; |
| 130 | |
| 131 | /* |
| 132 | * RTCP Extended Report. |
| 133 | * (RFC 3611) |
| 134 | */ |
| 135 | struct rtcp_xr { |
| 136 | u_int32_t xr_flags; /* BT:8 TS:8 LEN:16 */ |
| 137 | u_int32_t xr_srcid; /* SSRC of the RTP data packet being |
| 138 | reported upon by this report block */ |
| 139 | u_int16_t xr_begin_seq; /* first seqno that this block report */ |
| 140 | u_int16_t xr_end_seq; /* last seqno that this block report plus 1 */ |
| 141 | u_int32_t xr_ackvec; /* Ack vector bit chunk */ |
| 142 | }; |
| 143 | |
| 144 | #define RTCP_PT_SR 200 /* sender report */ |
| 145 | #define RTCP_PT_RR 201 /* receiver report */ |
| 146 | #define RTCP_PT_SDES 202 /* source description */ |
| 147 | #define RTCP_SDES_CNAME 1 /* official name (mandatory) */ |
| 148 | #define RTCP_SDES_NAME 2 /* personal name (optional) */ |
| 149 | #define RTCP_SDES_EMAIL 3 /* e-mail addr (optional) */ |
| 150 | #define RTCP_SDES_PHONE 4 /* telephone # (optional) */ |
| 151 | #define RTCP_SDES_LOC 5 /* geographical location */ |
| 152 | #define RTCP_SDES_TOOL 6 /* name/(vers) of app */ |
| 153 | #define RTCP_SDES_NOTE 7 /* transient messages */ |
| 154 | #define RTCP_SDES_PRIV 8 /* private SDES extensions */ |
| 155 | #define RTCP_PT_BYE 203 /* end of participation */ |
| 156 | #define RTCP_PT_APP 204 /* application specific functions */ |
| 157 | #define RTCP_PT_XR 207 /* extended report */ |
| 158 | |
| 159 | #define RTCP_SDES_MIN 1 |
| 160 | #define RTCP_SDES_MAX 7 |
| 161 | |
| 162 | /* |
| 163 | * Parameters controling the RTCP report rate timer. |
| 164 | */ |
| 165 | #define RTCP_SESSION_BW_FRACTION (0.05) |
| 166 | #define RTCP_MIN_RPT_TIME (5.) |
| 167 | #define RTCP_SENDER_BW_FRACTION (0.25) |
| 168 | #define RTCP_RECEIVER_BW_FRACTION (1. - RTCP_SENDER_BW_FRACTION) |
| 169 | #define RTCP_SIZE_GAIN (1./8.) |
| 170 | |
| 171 | /* |
| 172 | * Largest (user-level) packet size generated by our rtp applications. |
| 173 | * Individual video formats may use smaller mtu's. |
| 174 | */ |
| 175 | #define RTP_MTU 1024 |
| 176 | |
| 177 | //now defined in pktbuf.h |
| 178 | //#define MAXHDR 24 |
| 179 | |
| 180 | /* |
| 181 | * Motion JPEG encapsulation. |
| 182 | * |
| 183 | * 0 1 2 3 |
| 184 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 185 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 186 | * | MBZ | frag offset | |
| 187 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 188 | * | Type | Q | Width | Height | |
| 189 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 190 | * |
| 191 | * Type = Index into a table of predefined JPEG parameters |
| 192 | * Width = Width of input in 8-pixel blocks |
| 193 | * Height = Height of input in 8-pixel blocks |
| 194 | * Q = Quality factor (0-100 = std, >100 = custom) |
| 195 | * Frag offset = The byte offset into the frame for the data in |
| 196 | * this packet |
| 197 | */ |
| 198 | struct jpeghdr { |
| 199 | u_int32_t off; /* fragment offset */ |
| 200 | u_int8_t type; /* id of jpeg decoder params */ |
| 201 | u_int8_t q; /* quantization factor (or table id) */ |
| 202 | u_int8_t width; /* 1/8 frame width */ |
| 203 | u_int8_t height; /* 1/8 frame height */ |
| 204 | }; |
| 205 | |
| 206 | /* |
| 207 | * NV encapsulation. |
| 208 | */ |
| 209 | struct nvhdr { |
| 210 | u_int16_t width; |
| 211 | u_int16_t height; |
| 212 | /* nv data */ |
| 213 | }; |
| 214 | |
| 215 | /* |
| 216 | * CellB encapsulation. |
| 217 | */ |
| 218 | struct cellbhdr { |
| 219 | u_int16_t x; |
| 220 | u_int16_t y; |
| 221 | u_int16_t width; |
| 222 | u_int16_t height; |
| 223 | /* cells */ |
| 224 | }; |
| 225 | |
| 226 | /* |
| 227 | * H.261 encapsulation. |
| 228 | * See Internet draft. |
| 229 | * |
| 230 | * 0 1 2 3 |
| 231 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 232 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 233 | * |SBIT |EBIT |I|V| GOBN | MBAP | QUANT | HMVD | VMVD | |
| 234 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 235 | */ |
| 236 | #ifdef notdef |
| 237 | struct h261hdr { |
| 238 | u_int16_t flags; |
| 239 | u_int16_t off; |
| 240 | }; |
| 241 | #endif |
| 242 | |
| 243 | struct bvchdr { |
| 244 | u_int8_t version; |
| 245 | u_int8_t pad; |
| 246 | u_int8_t width; |
| 247 | u_int8_t height; |
| 248 | u_int32_t quant; |
| 249 | u_int8_t sbit; |
| 250 | u_int8_t ebit; |
| 251 | u_int16_t blkno; |
| 252 | }; |
| 253 | |
| 254 | #endif |
Note: See TracBrowser
for help on using the browser.
