NEWS update.
[paraslash.git] / ortp.h
1 /*
2 * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file ortp.h some macros used by ortp_send.c and ortp_recv.c*/
8
9 /** the possible packet types */
10 enum ortp_audio_packet_type {ORTP_EOF, ORTP_BOF, ORTP_HEADER, ORTP_DATA};
11
12 /** number of bytes of the paraslash ortp header */
13 #define ORTP_AUDIO_HEADER_LEN 10
14
15 /** write type of this packet to \a buf */
16 #define WRITE_PACKET_TYPE(buf, x) (buf)[0] = (unsigned char)((x)&0xff)
17 /** get type of this packet */
18 #define READ_PACKET_TYPE(buf) (unsigned)(buf)[0]
19
20 /** write the chunk time for this packet to \a buf */
21 #define WRITE_CHUNK_TIME(buf, x) (buf)[1] = (unsigned char)((x)&0xff);\
22 (buf)[2] = (unsigned char)(((x)>>8)&0xff);\
23 (buf)[3] = (unsigned char)(((x)>>16)&0xff);\
24 (buf)[4] = (unsigned char)(((x)>>24)&0xff);
25
26 /** get the chunk time of this packet */
27 #define READ_CHUNK_TIME(buf) (unsigned char)(buf)[1] + \
28 ((unsigned char)(buf)[2] << 8) + \
29 ((unsigned char)(buf)[3] << 16) + \
30 ((unsigned char)(buf)[4] << 24)
31
32 /** write the chunk timestamp */
33 #define WRITE_CHUNK_TS(buf, x) (buf)[5] = (unsigned char)((x) & 0xff); \
34 (buf)[6] = (unsigned char)(((x >> 8) & 0xff));
35 /** get the chunk timestamp */
36 #define READ_CHUNK_TS(buf) (unsigned char)(buf)[5] + \
37 ((unsigned char)(buf)[6] << 8)
38
39 /** write the stream type (header or headerless) */
40 #define WRITE_STREAM_TYPE(buf, x) (buf)[7] = (unsigned char)((x)&0xff)
41 /** get the type of the stream (header or headerless) */
42 #define READ_STREAM_TYPE(buf) (unsigned)(buf)[7]
43
44 /** write the length of the header (only used for streams with header) */
45 #define WRITE_HEADER_LEN(buf, x) (buf)[8] = (unsigned char)((x) & 0xff); \
46 (buf)[9] = (unsigned char)(((x >> 8) & 0xff));
47
48 /** get the length of the header (only used for packets containing a header) */
49 #define READ_HEADER_LEN(buf) (unsigned char)(buf)[8] + \
50 ((unsigned char)(buf)[9] << 8)