Amazon Kinesis Webrtc C SDK
RtcpPacket.h
Go to the documentation of this file.
1 /*******************************************
2 RTCP Packet include file
3 *******************************************/
4 #ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_RTCP_RTCPPACKET_H
5 #define __KINESIS_VIDEO_WEBRTC_CLIENT_RTCP_RTCPPACKET_H
6 
7 #pragma once
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #define RTCP_PACKET_LEN_OFFSET 2
14 #define RTCP_PACKET_TYPE_OFFSET 1
15 
16 #define RTCP_PACKET_RRC_BITMASK 0x1F
17 
18 #define RTCP_PACKET_HEADER_LEN 4
19 #define RTCP_NACK_LIST_LEN 8
20 
21 #define RTCP_PACKET_VERSION_VAL 2
22 
23 #define RTCP_PACKET_LEN_WORD_SIZE 4
24 
25 #define RTCP_PACKET_REMB_MIN_SIZE 16
26 #define RTCP_PACKET_REMB_IDENTIFIER_OFFSET 8
27 #define RTCP_PACKET_REMB_MANTISSA_BITMASK 0x3FFFF
28 
29 #define RTCP_PACKET_SENDER_REPORT_MINLEN 24
30 #define RTCP_PACKET_RECEIVER_REPORT_BLOCK_LEN 24
31 #define RTCP_PACKET_RECEIVER_REPORT_MINLEN 4 + RTCP_PACKET_RECEIVER_REPORT_BLOCK_LEN
32 
33 // https://tools.ietf.org/html/rfc3550#section-4
34 // If the participant has not yet sent an RTCP packet (the variable
35 // initial is true), the constant Tmin is set to 2.5 seconds, else it
36 // is set to 5 seconds.
37 #define RTCP_FIRST_REPORT_DELAY (3 * HUNDREDS_OF_NANOS_IN_A_SECOND)
38 
39 typedef enum {
40  RTCP_PACKET_TYPE_FIR = 192, // https://tools.ietf.org/html/rfc2032#section-5.2.1
42  RTCP_PACKET_TYPE_RECEIVER_REPORT = 201, // https://tools.ietf.org/html/rfc3550#section-6.4.2
47 
48 typedef enum {
50  RTCP_PSFB_PLI = 1, // https://tools.ietf.org/html/rfc4585#section-6.3
51  RTCP_PSFB_SLI = 2, // https://tools.ietf.org/html/rfc4585#section-6.3.2
54 
55 /*
56  *
57  * 0 1 2 3
58  * 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
59  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60  * |V=2|P| Count | PT | length |
61  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62  */
63 
64 typedef struct {
65  UINT8 version;
68 
69  UINT32 packetLength;
71 
72 typedef struct {
74 
75  PBYTE payload;
76  UINT32 payloadLength;
78 
79 STATUS setRtcpPacketFromBytes(PBYTE, UINT32, PRtcpPacket);
80 STATUS rtcpNackListGet(PBYTE, UINT32, PUINT32, PUINT32, PUINT16, PUINT32);
81 STATUS rembValueGet(PBYTE, UINT32, PDOUBLE, PUINT32, PUINT8);
82 STATUS isRembPacket(PBYTE, UINT32);
83 
84 #define NTP_OFFSET 2208988800ULL
85 #define NTP_TIMESCALE 4294967296ULL
86 
87 // converts 100ns precision time to ntp time
88 UINT64 convertTimestampToNTP(UINT64 time100ns);
89 
90 #define DLSR_TIMESCALE 65536
91 
92 // https://tools.ietf.org/html/rfc3550#section-4
93 // In some fields where a more compact representation is
94 // appropriate, only the middle 32 bits are used; that is, the low 16
95 // bits of the integer part and the high 16 bits of the fractional part.
96 #define MID_NTP(ntp_time) (UINT32)((currentTimeNTP >> 16U) & 0xffffffffULL)
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif //__KINESIS_VIDEO_WEBRTC_CLIENT_RTCP_RTCPPACKET_H
STATUS setRtcpPacketFromBytes(PBYTE, UINT32, PRtcpPacket)
Definition: RtcpPacket.c:5
UINT64 convertTimestampToNTP(UINT64 time100ns)
Definition: RtcpPacket.c:146
STATUS rembValueGet(PBYTE, UINT32, PDOUBLE, PUINT32, PUINT8)
Definition: RtcpPacket.c:109
RTCP_FEEDBACK_MESSAGE_TYPE
Definition: RtcpPacket.h:48
@ RTCP_PSFB_PLI
Definition: RtcpPacket.h:50
@ RTCP_FEEDBACK_MESSAGE_TYPE_NACK
Definition: RtcpPacket.h:49
@ RTCP_PSFB_SLI
Definition: RtcpPacket.h:51
@ RTCP_FEEDBACK_MESSAGE_TYPE_APPLICATION_LAYER_FEEDBACK
Definition: RtcpPacket.h:52
RTCP_PACKET_TYPE
Definition: RtcpPacket.h:39
@ RTCP_PACKET_TYPE_SOURCE_DESCRIPTION
Definition: RtcpPacket.h:43
@ RTCP_PACKET_TYPE_GENERIC_RTP_FEEDBACK
Definition: RtcpPacket.h:44
@ RTCP_PACKET_TYPE_FIR
Definition: RtcpPacket.h:40
@ RTCP_PACKET_TYPE_SENDER_REPORT
Definition: RtcpPacket.h:41
@ RTCP_PACKET_TYPE_PAYLOAD_SPECIFIC_FEEDBACK
Definition: RtcpPacket.h:45
@ RTCP_PACKET_TYPE_RECEIVER_REPORT
Definition: RtcpPacket.h:42
struct RtcpPacket * PRtcpPacket
struct RtcpPacketHeader * PRtcpPacketHeader
STATUS rtcpNackListGet(PBYTE, UINT32, PUINT32, PUINT32, PUINT16, PUINT32)
Definition: RtcpPacket.c:37
STATUS isRembPacket(PBYTE, UINT32)
Definition: RtcpPacket.c:83
Definition: RtcpPacket.h:64
UINT8 receptionReportCount
Definition: RtcpPacket.h:66
UINT8 version
Definition: RtcpPacket.h:65
UINT32 packetLength
Definition: RtcpPacket.h:69
RTCP_PACKET_TYPE packetType
Definition: RtcpPacket.h:67
Definition: RtcpPacket.h:72
RtcpPacketHeader header
Definition: RtcpPacket.h:73
UINT32 payloadLength
Definition: RtcpPacket.h:76
PBYTE payload
Definition: RtcpPacket.h:75