Amazon Kinesis Webrtc C SDK
Loading...
Searching...
No Matches
Rtcp.c File Reference
#include "../Include_i.h"
Include dependency graph for Rtcp.c:

Macros

#define LOG_CLASS   "RtcRtcp"

Functions

STATUS parseRtcpTwccPacket (PRtcpPacket pRtcpPacket, PTwccManager pTwccManager)
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).
STATUS updateTwccHashTable (PTwccManager pTwccManager, PINT64 duration, PUINT64 receivedBytes, PUINT64 receivedPackets, PUINT64 sentBytes, PUINT64 sentPackets)
STATUS onRtcpTwccPacket (PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
STATUS onRtcpPacket (PKvsPeerConnection pKvsPeerConnection, PBYTE pBuff, UINT32 buffLen)
STATUS onRtcpRembPacket (PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
STATUS onRtcpPLIPacket (PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
STATUS createRtcpPLIPacket (UINT32 senderSsrc, UINT32 mediaSsrc, PBYTE pRawPacket, PUINT32 pPacketLen)
STATUS transceiverSendPictureLoss (PRtcRtpTransceiver pRtcRtpTransceiver)
 Send a Picture Loss Indication (PLI) to ask the remote sender for a new keyframe.

Macro Definition Documentation

◆ LOG_CLASS

#define LOG_CLASS   "RtcRtcp"

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: