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 3
14 #define DEFAULT_EXPECTED_VIDEO_BIT_RATE (5 * 1024 * 1024)
15 // Opus has highest based on the supported codecs which is 510Kibps. So setting this to twice
16 #define DEFAULT_EXPECTED_AUDIO_BIT_RATE (1000 * 1024)
17 #define DEFAULT_SEQ_NUM_BUFFER_SIZE 1000
18 #define DEFAULT_VALID_INDEX_BUFFER_SIZE 1000
19 #define DEFAULT_PEER_FRAME_BUFFER_SIZE (5 * 1024)
20 #define SRTP_AUTH_TAG_OVERHEAD 10
21 #define MIN_ROLLING_BUFFER_DURATION_IN_SECONDS (DOUBLE) 0.1
22 #define MIN_EXPECTED_BIT_RATE (DOUBLE)(102.4 * 1024) // Considering 1Kib = 1024 bits
23 
24 // https://www.w3.org/TR/webrtc-stats/#dom-rtcoutboundrtpstreamstats-huge
25 // Huge frames, by definition, are frames that have an encoded size at least 2.5 times the average size of the frames.
26 #define HUGE_FRAME_MULTIPLIER 2.5
27 
28 typedef struct {
29  UINT8 payloadType;
33  UINT32 ssrc;
34  UINT32 rtxSsrc;
36 
40 
41  UINT64 rtpTimeOffset;
42  UINT64 firstFrameWallClockTime; // 100ns precision
43 
44  // used for fps calculation
46  UINT64 lastKnownFrameCountTime; // 100ns precision
47 
49 
50 typedef struct {
53 
55 
58 
61 
64 
69 
72 
74 
75  MUTEX statsLock;
80 
84 
86 
87 #define CONVERT_TIMESTAMP_TO_RTP(clockRate, pts) ((UINT64) ((DOUBLE) (pts) * ((DOUBLE) (clockRate) / HUNDREDS_OF_NANOS_IN_A_SECOND)))
88 
89 STATUS writeRtpPacket(PKvsPeerConnection pKvsPeerConnection, PRtpPacket pRtpPacket);
90 
91 STATUS hasTransceiverWithSsrc(PKvsPeerConnection pKvsPeerConnection, UINT32 ssrc);
92 STATUS findTransceiverBySsrc(PKvsPeerConnection pKvsPeerConnection, PKvsRtpTransceiver* ppTransceiver, UINT32 ssrc);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 #endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_PEERCONNECTION_RTP__ */
STATUS createKvsRtpTransceiver(RTC_RTP_TRANSCEIVER_DIRECTION, DOUBLE, DOUBLE, PKvsPeerConnection, UINT32, UINT32, PRtcMediaStreamTrack, PJitterBuffer, RTC_CODEC, PKvsRtpTransceiver *)
Definition: Rtp.c:7
STATUS findTransceiverBySsrc(PKvsPeerConnection pKvsPeerConnection, PKvsRtpTransceiver *ppTransceiver, UINT32 ssrc)
Definition: Rtp.c:448
STATUS hasTransceiverWithSsrc(PKvsPeerConnection pKvsPeerConnection, UINT32 ssrc)
Definition: Rtp.c:442
STATUS writeRtpPacket(PKvsPeerConnection pKvsPeerConnection, PRtpPacket pRtpPacket)
Definition: Rtp.c:415
STATUS kvsRtpTransceiverSetJitterBuffer(PKvsRtpTransceiver, PJitterBuffer)
Definition: Rtp.c:116
struct RtcRtpSender * PRtcRtpSender
STATUS freeKvsRtpTransceiver(PKvsRtpTransceiver *)
Definition: Rtp.c:80
struct KvsRtpTransceiver * PKvsRtpTransceiver
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:1010
VOID(* RtcOnPictureLoss)(UINT64)
RtcOnPictureLoss is fired everytime a Picture Loss Indication (PLI) feedback message is received....
Definition: Include.h:1047
VOID(* RtcOnBandwidthEstimation)(UINT64, DOUBLE)
RtcOnBandwidthEstimation is fired everytime a bandwidth estimation value is computed....
Definition: Include.h:1019
RTC_RTP_TRANSCEIVER_DIRECTION
RTC_RTP_TRANSCEIVER_DIRECTION indicates direction of a transceiver.
Definition: Include.h:881
RTC_CODEC
The enum specifies the codec types for audio and video tracks.
Definition: Include.h:850
Definition: JitterBuffer.h:20
Definition: PeerConnection.h:72
Definition: Rtp.h:50
RtcInboundRtpStreamStats inboundStats
Definition: Rtp.h:78
UINT64 onPictureLossCustomData
Definition: Rtp.h:67
UINT32 rtcpReportsTimerId
Definition: Rtp.h:73
PBYTE peerFrameBuffer
Definition: Rtp.h:70
PKvsPeerConnection pKvsPeerConnection
Definition: Rtp.h:54
RtcOnFrame onFrame
Definition: Rtp.h:63
DOUBLE rollingBufferBitratebps
Definition: Rtp.h:57
UINT32 peerFrameBufferSize
Definition: Rtp.h:71
RtcOnBandwidthEstimation onBandwidthEstimation
Definition: Rtp.h:66
UINT64 onFrameCustomData
Definition: Rtp.h:62
RtcOutboundRtpStreamStats outboundStats
Definition: Rtp.h:76
RtcRemoteInboundRtpStreamStats remoteInboundStats
Definition: Rtp.h:77
UINT64 onBandwidthEstimationCustomData
Definition: Rtp.h:65
RtcOnPictureLoss onPictureLoss
Definition: Rtp.h:68
UINT32 jitterBufferSsrc
Definition: Rtp.h:59
PJitterBuffer pJitterBuffer
Definition: Rtp.h:60
RtcRtpSender sender
Definition: Rtp.h:52
RtcRtpTransceiver transceiver
Definition: Rtp.h:51
DOUBLE rollingBufferDurationSec
Definition: Rtp.h:56
MUTEX statsLock
Definition: Rtp.h:75
Definition: Retransmitter.h:13
The RTCInboundRtpStreamStats dictionary represents the measurement metrics for the incoming RTP media...
Definition: Stats.h:457
Represents a single track in a MediaStream.
Definition: Include.h:1128
RtcOutboundRtpStreamStats Gathers stats for media stream from the embedded device Note: RTCOutboundRt...
Definition: Stats.h:356
RTCRemoteInboundRtpStreamStats Represents the remote endpoint's measurement metrics for a particular ...
Definition: Stats.h:408
Definition: Rtp.h:28
PRtpRollingBuffer packetBuffer
Definition: Rtp.h:38
UINT64 lastKnownFrameCountTime
Definition: Rtp.h:46
UINT64 firstFrameWallClockTime
Definition: Rtp.h:42
UINT16 rtxSequenceNumber
Definition: Rtp.h:32
UINT8 rtxPayloadType
Definition: Rtp.h:30
UINT64 rtpTimeOffset
Definition: Rtp.h:41
PRetransmitter retransmitter
Definition: Rtp.h:39
UINT64 lastKnownFrameCount
Definition: Rtp.h:45
UINT32 rtxSsrc
Definition: Rtp.h:34
RtcMediaStreamTrack track
Definition: Rtp.h:37
UINT32 ssrc
Definition: Rtp.h:33
PayloadArray payloadArray
Definition: Rtp.h:35
UINT8 payloadType
Definition: Rtp.h:29
UINT16 sequenceNumber
Definition: Rtp.h:31
The RTCRtpTransceiver represents a combination of an RTCRtpSender and an RTCRtpReceiver that share a ...
Definition: Include.h:1154
Definition: RtpRollingBuffer.h:13
Definition: RtpPacket.h:77
Definition: RtpPacket.h:89