DVBCore  22.11.0
Open Source DVB Engine
rtp.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2020 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2020 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
18 
25 #ifndef __RTP_H
26 #define __RTP_H
27 
28 /*---includes for this file--------------------------------------------------*/
29 
30 /*---Constant and macro definitions for public use---------------------------*/
31 #define RTP_VERSION_NUMBER 2
32 #define RTP_HEADER_LENGTH 12
33 #define RTCP_HEADER_LENGTH 4
34 #define FEC_HEADER_SIZE 16
35 
36 /* RTP Header */
37 #define RTP_VERSION(x) (((x)[0] >> 6) & 0x2)
38 #define RTP_EXTENSION(x) (((x)[0] & 0x10) != 0)
39 #define RTP_CSRCCOUNT(x) ((x)[0] & 0x0f)
40 #define RTP_MARKER(x) (((x)[1] >> 7) & 0x01)
41 #define RTP_PAYLOAD(x) ((x)[1] & 0x7f)
42 #define RTP_SEQUENCE(x) (U16BIT)(((x)[2] << 8) + ((x)[3]))
43 #define RTP_TIMESTAMP(x) (U32BIT)(((x)[4] << 24) + ((x)[5] << 16) + ((x)[6] << 8) + ((x)[7]))
44 #define RTP_SSRC(x) (U32BIT)(((x)[8] << 24) + ((x)[9] << 16) + ((x)[10] << 8) + ((x)[11]))
45 
46 /* RTCP Header */
47 #define RTCP_RCOUNT(x) ((x)[0] & 0x1f)
48 #define RTCP_PKTTYPE(x) ((x)[1])
49 /* RTCP Length in total bytes inc hdr - (not in 32 bit words, excl hdr) */
50 #define RTCP_LENGTH(x) ((x)[2] << 10) + ((x)[3] << 2)
51 
52 /* FEC Header - coming after RTP header */
53 #define FEC_SNBASE(x) (U16BIT)(((x)[0] << 8) + ((x)[1]))
54 #define FEC_TS_RECOVERY(x) (U32BIT)(((x)[8] << 24) | ((x)[9] << 16) | ((x)[10] << 8) | ((x)[11]))
55 #define FEC_D_BIT(x) (((x)[12] >> 6) & 0x01)
56 #define FEC_OFFSET(x) ((x)[13])
57 #define FEC_COUNT(x) ((x)[14]) /* NA */
58 
59 
60 /*---Enumerations for public use---------------------------------------------*/
61 
62 /*---Global type defs for public use-----------------------------------------*/
63 
64 /*---Global variable declarations for public use-----------------------------*/
65 
66 /*---Global Function prototypes for public use-------------------------------*/
67 
68 #endif /* __RTP_H */