Amazon Kinesis Webrtc C SDK
Loading...
Searching...
No Matches
Rtcp.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RTCP_PLI_PACKET_LEN   (RTCP_PACKET_HEADER_LEN + 2 * SIZEOF(UINT32))
#define TWCC_TICKS_PER_SECOND   (1000000LL / 250)
#define MICROSECONDS_PER_SECOND   1000000LL
#define MILLISECONDS_PER_SECOND   1000LL
#define TWCC_PACKET_LOST_TIME   ((UINT64) (-1LL))
#define TWCC_PACKET_UNITIALIZED_TIME   0
#define TWCC_ESTIMATOR_TIME_WINDOW   (4 * HUNDREDS_OF_NANOS_IN_A_SECOND)
#define TWCC_MAX_PACKET_STATUS_COUNT   2048
#define TWCC_FB_PAYLOAD_MIN_LEN   16
#define TWCC_TRENDLINE_SMOOTHING_FACTOR   0.2
#define TWCC_FB_PACKETCHUNK_SIZE   2
#define IS_TWCC_RUNLEN(packetChunk)
#define TWCC_RUNLEN_STATUS_SYMBOL(packetChunk)
#define TWCC_RUNLEN_GET(packetChunk)
#define TWCC_IS_NOTRECEIVED(statusSymbol)
#define TWCC_ISRECEIVED(statusSymbol)
#define TWCC_RUNLEN_ISRECEIVED(packetChunk)
#define TWCC_STATUSVECTOR_IS_2BIT(packetChunk)
#define TWCC_STATUSVECTOR_SSIZE(packetChunk)
#define TWCC_STATUSVECTOR_SMASK(packetChunk)
#define TWCC_STATUSVECTOR_STATUS(packetChunk, i)
#define TWCC_STATUSVECTOR_COUNT(packetChunk)
#define TWCC_PACKET_STATUS_COUNT(payload)

Enumerations

enum  TWCC_STATUS_SYMBOL { TWCC_STATUS_SYMBOL_NOTRECEIVED = 0 , TWCC_STATUS_SYMBOL_SMALLDELTA , TWCC_STATUS_SYMBOL_LARGEDELTA }

Functions

STATUS onRtcpPacket (PKvsPeerConnection, PBYTE, UINT32)
STATUS onRtcpRembPacket (PRtcpPacket, PKvsPeerConnection)
STATUS onRtcpPLIPacket (PRtcpPacket, PKvsPeerConnection)
STATUS createRtcpPLIPacket (UINT32, UINT32, PBYTE, PUINT32)
STATUS parseRtcpTwccPacket (PRtcpPacket, PTwccManager)
STATUS onRtcpTwccPacket (PRtcpPacket, PKvsPeerConnection)
STATUS updateTwccHashTable (PTwccManager, PINT64, PUINT64, PUINT64, PUINT64, PUINT64)
STATUS computeTwccTrendline (PTwccManager, PDOUBLE, PDOUBLE)
 Estimates network congestion trend using least-squares linear regression on accumulated one-way delay variations, smoothed with an exponential moving average (EMA).

Macro Definition Documentation

◆ IS_TWCC_RUNLEN

#define IS_TWCC_RUNLEN ( packetChunk)
Value:
((((packetChunk) >> 15u) & 1u) == 0)

◆ MICROSECONDS_PER_SECOND

#define MICROSECONDS_PER_SECOND   1000000LL

◆ MILLISECONDS_PER_SECOND

#define MILLISECONDS_PER_SECOND   1000LL

◆ RTCP_PLI_PACKET_LEN

#define RTCP_PLI_PACKET_LEN   (RTCP_PACKET_HEADER_LEN + 2 * SIZEOF(UINT32))

◆ TWCC_ESTIMATOR_TIME_WINDOW

#define TWCC_ESTIMATOR_TIME_WINDOW   (4 * HUNDREDS_OF_NANOS_IN_A_SECOND)

◆ TWCC_FB_PACKETCHUNK_SIZE

#define TWCC_FB_PACKETCHUNK_SIZE   2

◆ TWCC_FB_PAYLOAD_MIN_LEN

#define TWCC_FB_PAYLOAD_MIN_LEN   16

◆ TWCC_IS_NOTRECEIVED

#define TWCC_IS_NOTRECEIVED ( statusSymbol)
Value:
((statusSymbol) == TWCC_STATUS_SYMBOL_NOTRECEIVED)
@ TWCC_STATUS_SYMBOL_NOTRECEIVED
Definition Rtcp.h:74

◆ TWCC_ISRECEIVED

#define TWCC_ISRECEIVED ( statusSymbol)
Value:
((statusSymbol) == TWCC_STATUS_SYMBOL_SMALLDELTA || (statusSymbol) == TWCC_STATUS_SYMBOL_LARGEDELTA)
@ TWCC_STATUS_SYMBOL_LARGEDELTA
Definition Rtcp.h:76
@ TWCC_STATUS_SYMBOL_SMALLDELTA
Definition Rtcp.h:75

◆ TWCC_MAX_PACKET_STATUS_COUNT

#define TWCC_MAX_PACKET_STATUS_COUNT   2048

◆ TWCC_PACKET_LOST_TIME

#define TWCC_PACKET_LOST_TIME   ((UINT64) (-1LL))

◆ TWCC_PACKET_STATUS_COUNT

#define TWCC_PACKET_STATUS_COUNT ( payload)
Value:
(getUnalignedInt16BigEndian((payload) + 10))

◆ TWCC_PACKET_UNITIALIZED_TIME

#define TWCC_PACKET_UNITIALIZED_TIME   0

◆ TWCC_RUNLEN_GET

#define TWCC_RUNLEN_GET ( packetChunk)
Value:
((packetChunk) & 0x1fffu)

◆ TWCC_RUNLEN_ISRECEIVED

#define TWCC_RUNLEN_ISRECEIVED ( packetChunk)
Value:
#define TWCC_RUNLEN_STATUS_SYMBOL(packetChunk)
Definition Rtcp.h:81
#define TWCC_ISRECEIVED(statusSymbol)
Definition Rtcp.h:84

◆ TWCC_RUNLEN_STATUS_SYMBOL

#define TWCC_RUNLEN_STATUS_SYMBOL ( packetChunk)
Value:
(((packetChunk) >> 13u) & 3u)

◆ TWCC_STATUSVECTOR_COUNT

#define TWCC_STATUSVECTOR_COUNT ( packetChunk)
Value:
(TWCC_STATUSVECTOR_IS_2BIT(packetChunk) ? 7 : 14)
#define TWCC_STATUSVECTOR_IS_2BIT(packetChunk)
Definition Rtcp.h:86

◆ TWCC_STATUSVECTOR_IS_2BIT

#define TWCC_STATUSVECTOR_IS_2BIT ( packetChunk)
Value:
(((packetChunk) >> 14u) & 1u)

◆ TWCC_STATUSVECTOR_SMASK

#define TWCC_STATUSVECTOR_SMASK ( packetChunk)
Value:
(TWCC_STATUSVECTOR_IS_2BIT(packetChunk) ? 2u : 1u)

◆ TWCC_STATUSVECTOR_SSIZE

#define TWCC_STATUSVECTOR_SSIZE ( packetChunk)
Value:
(TWCC_STATUSVECTOR_IS_2BIT(packetChunk) ? 2u : 1u)

◆ TWCC_STATUSVECTOR_STATUS

#define TWCC_STATUSVECTOR_STATUS ( packetChunk,
i )
Value:
(((packetChunk) >> (14u - (i) * TWCC_STATUSVECTOR_SSIZE(packetChunk))) & TWCC_STATUSVECTOR_SMASK(packetChunk))
#define TWCC_STATUSVECTOR_SMASK(packetChunk)
Definition Rtcp.h:88
#define TWCC_STATUSVECTOR_SSIZE(packetChunk)
Definition Rtcp.h:87

◆ TWCC_TICKS_PER_SECOND

#define TWCC_TICKS_PER_SECOND   (1000000LL / 250)

◆ TWCC_TRENDLINE_SMOOTHING_FACTOR

#define TWCC_TRENDLINE_SMOOTHING_FACTOR   0.2

Enumeration Type Documentation

◆ TWCC_STATUS_SYMBOL

Enumerator
TWCC_STATUS_SYMBOL_NOTRECEIVED 
TWCC_STATUS_SYMBOL_SMALLDELTA 
TWCC_STATUS_SYMBOL_LARGEDELTA 

Function Documentation

◆ computeTwccTrendline()

STATUS computeTwccTrendline ( PTwccManager pTwccManager,
PDOUBLE pDelayTrend,
PDOUBLE pQueueDelay )

Estimates network congestion trend using least-squares linear regression on accumulated one-way delay variations, smoothed with an exponential moving average (EMA).

Algorithm overview:

  1. For each consecutive packet pair (i-1, i), compute the inter-arrival delay variation: d_i = (recvTime_i - recvTime_{i-1}) - (sendTime_i - sendTime_{i-1}) A positive d_i means the network took longer to deliver packet i than packet i-1.
  2. Accumulate these variations into a running sum (the "accumulated delay"): D_i = D_{i-1} + d_i (where D_0 = 0) This represents the total queuing delay buildup over the observation window.
  3. Fit a line to the points (x_i, y_i) = (i, D_i) using ordinary least-squares regression. The slope formula is: rawSlope = (n * sum(x_i * y_i) - sum(x_i) * sum(y_i)) / (n * sum(x_i^2) - (sum(x_i))^2) A positive slope indicates delay is growing (congestion building up). A near-zero slope indicates stable network conditions. A negative slope indicates delay is decreasing (congestion clearing).
  4. Smooth the slope with an EMA to reduce noise: smoothedSlope = alpha * rawSlope + (1 - alpha) * prevSmoothedSlope where alpha = TWCC_TRENDLINE_SMOOTHING_FACTOR (0.2 by default).
Parameters
[in]pTwccManagerTWCC manager containing packet timing history
[out]pDelayTrendSmoothed slope in ms per sample (positive = congestion building)
[out]pQueueDelayTotal accumulated delay variation in ms over the window
Here is the caller graph for this function:

◆ createRtcpPLIPacket()

STATUS createRtcpPLIPacket ( UINT32 senderSsrc,
UINT32 mediaSsrc,
PBYTE pRawPacket,
PUINT32 pPacketLen )
Here is the caller graph for this function:

◆ onRtcpPacket()

STATUS onRtcpPacket ( PKvsPeerConnection pKvsPeerConnection,
PBYTE pBuff,
UINT32 buffLen )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onRtcpPLIPacket()

STATUS onRtcpPLIPacket ( PRtcpPacket pRtcpPacket,
PKvsPeerConnection pKvsPeerConnection )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onRtcpRembPacket()

STATUS onRtcpRembPacket ( PRtcpPacket pRtcpPacket,
PKvsPeerConnection pKvsPeerConnection )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onRtcpTwccPacket()

STATUS onRtcpTwccPacket ( PRtcpPacket pRtcpPacket,
PKvsPeerConnection pKvsPeerConnection )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseRtcpTwccPacket()

STATUS parseRtcpTwccPacket ( PRtcpPacket pRtcpPacket,
PTwccManager pTwccManager )
Here is the caller graph for this function:

◆ updateTwccHashTable()

STATUS updateTwccHashTable ( PTwccManager pTwccManager,
PINT64 duration,
PUINT64 receivedBytes,
PUINT64 receivedPackets,
PUINT64 sentBytes,
PUINT64 sentPackets )
Here is the caller graph for this function: