Amazon Kinesis Webrtc C SDK
Rtp.h
Go to the documentation of this file.
1 #ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_PEERCONNECTION_RTP__
2 #define __KINESIS_VIDEO_WEBRTC_CLIENT_PEERCONNECTION_RTP__
3 
4 #pragma once
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 // Default MTU comes from libwebrtc
11 // https://groups.google.com/forum/#!topic/discuss-webrtc/gH5ysR3SoZI
12 #define DEFAULT_MTU_SIZE_BYTES 1200
13 #define DEFAULT_ROLLING_BUFFER_DURATION_IN_SECONDS (DOUBLE) 3
14 #define DEFAULT_EXPECTED_VIDEO_BIT_RATE (DOUBLE)(10 * 1024 * 1024)
15 #define DEFAULT_EXPECTED_AUDIO_BIT_RATE (DOUBLE)(10 * 1024 * 1024)
16 #define DEFAULT_SEQ_NUM_BUFFER_SIZE 1000
17 #define DEFAULT_VALID_INDEX_BUFFER_SIZE 1000
18 #define DEFAULT_PEER_FRAME_BUFFER_SIZE (5 * 1024)
19 #define SRTP_AUTH_TAG_OVERHEAD 10
20 #define MIN_ROLLING_BUFFER_DURATION_IN_SECONDS (DOUBLE) 0.1
21 #define MIN_EXPECTED_BIT_RATE (DOUBLE)(102.4 * 1024) // Considering 1Kib = 1024 bits
22 #define MAX_ROLLING_BUFFER_DURATION_IN_SECONDS (DOUBLE) 10
23 #define MAX_EXPECTED_BIT_RATE (DOUBLE)(240 * 1024 * 1024) // Considering 1Kib = 1024 bits
24 
25 // https://www.w3.org/TR/webrtc-stats/#dom-rtcoutboundrtpstreamstats-huge
26 // Huge frames, by definition, are frames that have an encoded size at least 2.5 times the average size of the frames.
27 #define HUGE_FRAME_MULTIPLIER 2.5
28 
29 typedef struct {
30  UINT8 payloadType;
34  UINT32 ssrc;
35  UINT32 rtxSsrc;
37 
41 
42  UINT64 rtpTimeOffset;
43  UINT64 firstFrameWallClockTime; // 100ns precision
44 
45  // used for fps calculation
47  UINT64 lastKnownFrameCountTime; // 100ns precision
48 
50 
51 typedef struct {
56 
57 typedef struct {
60 
62 
65 
67 
70 
75 
78 
80 
81  MUTEX statsLock;
86 
90 
92 
93 #define CONVERT_TIMESTAMP_TO_RTP(clockRate, pts) ((UINT64) ((DOUBLE) (pts) * ((DOUBLE) (clockRate) / HUNDREDS_OF_NANOS_IN_A_SECOND)))
94 
95 STATUS writeRtpPacket(PKvsPeerConnection pKvsPeerConnection, PRtpPacket pRtpPacket);
96 
97 STATUS hasTransceiverWithSsrc(PKvsPeerConnection pKvsPeerConnection, UINT32 ssrc);
98 STATUS findTransceiverBySsrc(PKvsPeerConnection pKvsPeerConnection, PKvsRtpTransceiver* ppTransceiver, UINT32 ssrc);
99 
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 #endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_PEERCONNECTION_RTP__ */
STATUS setUpRollingBufferConfigInternal(PKvsRtpTransceiver, PRtcMediaStreamTrack, DOUBLE, DOUBLE)
Definition: Rtp.c:52
STATUS findTransceiverBySsrc(PKvsPeerConnection pKvsPeerConnection, PKvsRtpTransceiver *ppTransceiver, UINT32 ssrc)
Definition: Rtp.c:504
STATUS hasTransceiverWithSsrc(PKvsPeerConnection pKvsPeerConnection, UINT32 ssrc)
Definition: Rtp.c:498
STATUS freeRollingBufferConfig(PRollingBufferConfig)
Definition: Rtp.c:127
STATUS writeRtpPacket(PKvsPeerConnection pKvsPeerConnection, PRtpPacket pRtpPacket)
Definition: Rtp.c:471
STATUS kvsRtpTransceiverSetJitterBuffer(PKvsRtpTransceiver, PJitterBuffer)
Definition: Rtp.c:172
struct RtcRtpSender * PRtcRtpSender
struct RollingBufferConfig * PRollingBufferConfig
STATUS freeKvsRtpTransceiver(PKvsRtpTransceiver *)
Definition: Rtp.c:133
struct KvsRtpTransceiver * PKvsRtpTransceiver
STATUS createKvsRtpTransceiver(RTC_RTP_TRANSCEIVER_DIRECTION, PKvsPeerConnection, UINT32, UINT32, PRtcMediaStreamTrack, PJitterBuffer, RTC_CODEC, PKvsRtpTransceiver *)
Definition: Rtp.c:7
VOID(* RtcOnFrame)(UINT64, PFrame)
RtcOnFrame is fired everytime a frame is received from the remote peer. It is available via the RtpRe...
Definition: Include.h:984
VOID(* RtcOnPictureLoss)(UINT64)
RtcOnPictureLoss is fired everytime a Picture Loss Indication (PLI) feedback message is received....
Definition: Include.h:1021
VOID(* RtcOnBandwidthEstimation)(UINT64, DOUBLE)
RtcOnBandwidthEstimation is fired everytime a bandwidth estimation value is computed....
Definition: Include.h:993
RTC_RTP_TRANSCEIVER_DIRECTION
RTC_RTP_TRANSCEIVER_DIRECTION indicates direction of a transceiver.
Definition: Include.h:855
RTC_CODEC
The enum specifies the codec types for audio and video tracks.
Definition: Include.h:826
Definition: JitterBuffer.h:20
Definition: PeerConnection.h:72
Definition: Rtp.h:57
RtcInboundRtpStreamStats inboundStats
Definition: Rtp.h:84
UINT64 onPictureLossCustomData
Definition: Rtp.h:73
UINT32 rtcpReportsTimerId
Definition: Rtp.h:79
PBYTE peerFrameBuffer
Definition: Rtp.h:76
PKvsPeerConnection pKvsPeerConnection
Definition: Rtp.h:61
RtcOnFrame onFrame
Definition: Rtp.h:69
UINT32 peerFrameBufferSize
Definition: Rtp.h:77
RtcOnBandwidthEstimation onBandwidthEstimation
Definition: Rtp.h:72
UINT64 onFrameCustomData
Definition: Rtp.h:68
RtcOutboundRtpStreamStats outboundStats
Definition: Rtp.h:82
RtcRemoteInboundRtpStreamStats remoteInboundStats
Definition: Rtp.h:83
UINT64 onBandwidthEstimationCustomData
Definition: Rtp.h:71
RtcOnPictureLoss onPictureLoss
Definition: Rtp.h:74
UINT32 jitterBufferSsrc
Definition: Rtp.h:63
PJitterBuffer pJitterBuffer
Definition: Rtp.h:64
RtcRtpSender sender
Definition: Rtp.h:59
RtcRtpTransceiver transceiver
Definition: Rtp.h:58
PRollingBufferConfig pRollingBufferConfig
Definition: Rtp.h:66
MUTEX statsLock
Definition: Rtp.h:81
Definition: Retransmitter.h:13
Definition: Rtp.h:51
DOUBLE rollingBufferDurationSec
Maximum duration of media that needs to be buffered (in seconds). The lowest allowed is 0....
Definition: Rtp.h:52
DOUBLE rollingBufferBitratebps
Definition: Rtp.h:53
The RTCInboundRtpStreamStats dictionary represents the measurement metrics for the incoming RTP media...
Definition: Stats.h:458
Represents a single track in a MediaStream.
Definition: Include.h:1102
RtcOutboundRtpStreamStats Gathers stats for media stream from the embedded device Note: RTCOutboundRt...
Definition: Stats.h:357
RTCRemoteInboundRtpStreamStats Represents the remote endpoint's measurement metrics for a particular ...
Definition: Stats.h:409
Definition: Rtp.h:29
PRtpRollingBuffer packetBuffer
Definition: Rtp.h:39
UINT64 lastKnownFrameCountTime
Definition: Rtp.h:47
UINT64 firstFrameWallClockTime
Definition: Rtp.h:43
UINT16 rtxSequenceNumber
Definition: Rtp.h:33
UINT8 rtxPayloadType
Definition: Rtp.h:31
UINT64 rtpTimeOffset
Definition: Rtp.h:42
PRetransmitter retransmitter
Definition: Rtp.h:40
UINT64 lastKnownFrameCount
Definition: Rtp.h:46
UINT32 rtxSsrc
Definition: Rtp.h:35
RtcMediaStreamTrack track
Definition: Rtp.h:38
UINT32 ssrc
Definition: Rtp.h:34
PayloadArray payloadArray
Definition: Rtp.h:36
UINT8 payloadType
Definition: Rtp.h:30
UINT16 sequenceNumber
Definition: Rtp.h:32
The RTCRtpTransceiver represents a combination of an RTCRtpSender and an RTCRtpReceiver that share a ...
Definition: Include.h:1128
Definition: RtpRollingBuffer.h:13
Definition: RtpPacket.h:87
Definition: RtpPacket.h:99