NEWS: Update
[paraslash.git] / ortp.h
1 /*
2 * Copyright (C) 2006-2007 Andre Noll <maan@systemlinux.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
17 */
18
19 /** \file ortp.h some macros used by ortp_send.c and ortp_recv.c*/
20
21 /** the possible packet types */
22 enum ortp_audio_packet_type {ORTP_EOF, ORTP_BOF, ORTP_HEADER, ORTP_DATA};
23
24 /** number of bytes of the paraslash ortp header */
25 #define ORTP_AUDIO_HEADER_LEN 10
26
27 /** write type of this packet to \a buf */
28 #define WRITE_PACKET_TYPE(buf, x) (buf)[0] = (unsigned char)((x)&0xff)
29 /** get type of this packet */
30 #define READ_PACKET_TYPE(buf) (unsigned)(buf)[0]
31
32 /** write the chunk time for this packet to \a buf */
33 #define WRITE_CHUNK_TIME(buf, x) (buf)[1] = (unsigned char)((x)&0xff);\
34 (buf)[2] = (unsigned char)(((x)>>8)&0xff);\
35 (buf)[3] = (unsigned char)(((x)>>16)&0xff);\
36 (buf)[4] = (unsigned char)(((x)>>24)&0xff);
37
38 /** get the chunk time of this packet */
39 #define READ_CHUNK_TIME(buf) (unsigned char)(buf)[1] + \
40 ((unsigned char)(buf)[2] << 8) + \
41 ((unsigned char)(buf)[3] << 16) + \
42 ((unsigned char)(buf)[4] << 24)
43
44 /** write the chunk timestamp */
45 #define WRITE_CHUNK_TS(buf, x) (buf)[5] = (unsigned char)((x) & 0xff); \
46 (buf)[6] = (unsigned char)(((x >> 8) & 0xff));
47 /** get the chunk timestamp */
48 #define READ_CHUNK_TS(buf) (unsigned char)(buf)[5] + \
49 ((unsigned char)(buf)[6] << 8)
50
51 /** write the stream type (header or headerless) */
52 #define WRITE_STREAM_TYPE(buf, x) (buf)[7] = (unsigned char)((x)&0xff)
53 /** get the type of the stream (header or headerless) */
54 #define READ_STREAM_TYPE(buf) (unsigned)(buf)[7]
55
56 /** write the length of the header (only used for streams with header) */
57 #define WRITE_HEADER_LEN(buf, x) (buf)[8] = (unsigned char)((x) & 0xff); \
58 (buf)[9] = (unsigned char)(((x >> 8) & 0xff));
59
60 /** get the length of the header (only used for packets containing a header) */
61 #define READ_HEADER_LEN(buf) (unsigned char)(buf)[8] + \
62 ((unsigned char)(buf)[9] << 8)