root/vic/branches/cc/rtp/rtp.h @ 4248

Revision 4248, 8.2 KB (checked in by soohyunc, 6 years ago)

XR header and block contents separated. this is because we want to use "chunks"
as AckVec? and the time stamp depending upon the block type (BT).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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 */
89struct 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
97struct 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
103typedef 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 */
111struct 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 */
122struct 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 */
135struct rtcp_xr_hdr {
136        u_int32_t xr_flags;     /* BT:8 TS:8 LEN:16 */
137};
138
139struct rtcp_xr_blk {
140        u_int32_t blk_flags; /*BT:8 rsvd:4 T:4 LEN:16 */
141        u_int32_t ssrc; /* ssrc of the RTP data pkt being reported upon by this */
142        u_int16_t begin_seq; /* first seqno that this block report */
143        u_int16_t end_seq;      /* last seqno that this block report plus 1 */
144        u_int32_t chunk;        /* extended report chunks */
145};
146
147#define RTCP_PT_SR      200     /* sender report */
148#define RTCP_PT_RR      201     /* receiver report */
149#define RTCP_PT_SDES    202     /* source description */
150#define         RTCP_SDES_CNAME 1       /* official name (mandatory) */
151#define         RTCP_SDES_NAME  2       /* personal name (optional) */
152#define         RTCP_SDES_EMAIL 3       /* e-mail addr (optional) */
153#define         RTCP_SDES_PHONE 4       /* telephone # (optional) */
154#define         RTCP_SDES_LOC   5       /* geographical location */
155#define         RTCP_SDES_TOOL  6       /* name/(vers) of app */
156#define         RTCP_SDES_NOTE  7       /* transient messages */
157#define         RTCP_SDES_PRIV  8       /* private SDES extensions */
158#define RTCP_PT_BYE     203     /* end of participation */
159#define RTCP_PT_APP     204     /* application specific functions */
160#define RTCP_PT_XR      207     /* extended report */
161
162#define         RTCP_SDES_MIN   1
163#define         RTCP_SDES_MAX   7
164
165/*
166 * Parameters controling the RTCP report rate timer.
167 */
168#define RTCP_SESSION_BW_FRACTION (0.05)
169#define RTCP_MIN_RPT_TIME (5.)
170#define RTCP_SENDER_BW_FRACTION (0.25)
171#define RTCP_RECEIVER_BW_FRACTION (1. - RTCP_SENDER_BW_FRACTION)
172#define RTCP_SIZE_GAIN (1./8.)
173
174/*
175 * Largest (user-level) packet size generated by our rtp applications.
176 * Individual video formats may use smaller mtu's.
177 */
178#define RTP_MTU 1024
179
180//now defined in pktbuf.h
181//#define MAXHDR 24
182
183/*
184 * Motion JPEG encapsulation.
185 *
186 * 0                   1                   2                   3
187 * 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
188 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
189 * |      MBZ      |                frag offset                    |
190 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
191 * |      Type     |       Q       |     Width     |     Height    |
192 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
193 *
194 * Type = Index into a table of predefined JPEG parameters
195 * Width = Width of input in 8-pixel blocks
196 * Height = Height of input in 8-pixel blocks
197 * Q = Quality factor (0-100 = std, >100 = custom)
198 * Frag offset = The byte offset into the frame for the data in
199 * this packet
200 */
201struct jpeghdr {
202        u_int32_t off;          /* fragment offset */
203        u_int8_t type;          /* id of jpeg decoder params */
204        u_int8_t q;             /* quantization factor (or table id) */
205        u_int8_t width;         /* 1/8 frame width */
206        u_int8_t height;        /* 1/8 frame height */
207};
208
209/*
210 * NV encapsulation.
211 */
212struct nvhdr {
213        u_int16_t width;
214        u_int16_t height;
215        /* nv data */
216};
217
218/*
219 * CellB encapsulation.
220 */
221struct cellbhdr {
222        u_int16_t x;
223        u_int16_t y;
224        u_int16_t width;
225        u_int16_t height;
226        /* cells */
227};
228
229/*
230 * H.261 encapsulation.
231 * See Internet draft.
232 *
233 *  0                   1                   2                   3
234 *  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
235 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
236 * |SBIT |EBIT |I|V| GOBN  |  MBAP   |  QUANT  |  HMVD   |  VMVD   |
237 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238 */
239#ifdef notdef
240struct h261hdr {
241        u_int16_t       flags;
242        u_int16_t off;
243};
244#endif
245
246struct bvchdr {
247        u_int8_t version;
248        u_int8_t pad;
249        u_int8_t width;
250        u_int8_t height;
251        u_int32_t quant;
252        u_int8_t sbit;
253        u_int8_t ebit;
254        u_int16_t blkno;
255};
256
257#endif
Note: See TracBrowser for help on using the browser.