1/*
2 *
3 *  BlueZ - Bluetooth protocol stack for Linux
4 *
5 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
6 *  Copyright (C) 2019       Pali Rohár <pali.rohar@gmail.com>
7 *
8 *
9 *  This library is free software; you can redistribute it and/or
10 *  modify it under the terms of the GNU Lesser General Public
11 *  License as published by the Free Software Foundation; either
12 *  version 2.1 of the License, or (at your option) any later version.
13 *
14 *  This library is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 *  Lesser General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public
20 *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 */
22
23#include <endian.h>
24#include <stdint.h>
25
26#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
27	__BYTE_ORDER == __LITTLE_ENDIAN
28
29struct rtp_header {
30	uint8_t cc:4;
31	uint8_t x:1;
32	uint8_t p:1;
33	uint8_t v:2;
34
35	uint8_t pt:7;
36	uint8_t m:1;
37
38	uint16_t sequence_number;
39	uint32_t timestamp;
40	uint32_t ssrc;
41	uint32_t csrc[0];
42} __attribute__ ((packed));
43
44struct rtp_payload {
45	uint8_t frame_count:4;
46	uint8_t rfa0:1;
47	uint8_t is_last_fragment:1;
48	uint8_t is_first_fragment:1;
49	uint8_t is_fragmented:1;
50} __attribute__ ((packed));
51
52#elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
53	__BYTE_ORDER == __BIG_ENDIAN
54
55struct rtp_header {
56	uint8_t v:2;
57	uint8_t p:1;
58	uint8_t x:1;
59	uint8_t cc:4;
60
61	uint8_t m:1;
62	uint8_t pt:7;
63
64	uint16_t sequence_number;
65	uint32_t timestamp;
66	uint32_t ssrc;
67	uint32_t csrc[0];
68} __attribute__ ((packed));
69
70struct rtp_payload {
71	uint8_t is_fragmented:1;
72	uint8_t is_first_fragment:1;
73	uint8_t is_last_fragment:1;
74	uint8_t rfa0:1;
75	uint8_t frame_count:4;
76} __attribute__ ((packed));
77
78#else
79#error "Unknown byte order"
80#endif
81