Amazon Kinesis Webrtc C SDK
 
Loading...
Searching...
No Matches
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
7extern "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
50
56
57typedef struct {
60
62
65
67
70
75
78
80
85
86 BOOL twccEnabled; // whether TWCC was negotiated for this transceiver's m-line
87
88 // Caller-supplied fmtp override (H264 only). Empty string means "use the default".
90
91 // The direction the application configured at addTransceiver() time. Re-negotiation
92 // intersects the remote offer against THIS, not against the previously-negotiated
93 // transceiver.direction — otherwise a narrowed direction (e.g. the peer paused our
94 // track with a sendonly offer) could never widen again when the peer re-enables it.
96
97 // Lock-free snapshot of transceiver.direction for the media path. writeFrame() runs on
98 // the application's media thread while re-negotiation (signaling thread) or the
99 // application itself rewrites transceiver.direction, so the media path must not read
100 // the plain field. Updated wherever the SDK writes transceiver.direction, and re-synced
101 // from the field in createOffer/createAnswer to publish direct application writes.
103
104 // Lock-free snapshot of (sender.payloadType << 8) | sender.rtxPayloadType, packed so
105 // readers get a consistent pair. Same rationale as atomicDirection: re-negotiation
106 // (setTransceiverPayloadTypes, signaling thread) rewrites the payload types while
107 // writeFrame (media thread) and the retransmitter (RTCP thread) read them.
109
110 // Codec the sender's rolling buffer capacity was sized for. Re-negotiation reuses the
111 // buffer rather than re-allocating it, so this is how a codec change is detected.
114
115#define KVS_RTP_TRANSCEIVER_PACK_PAYLOAD_TYPES(payloadType, rtxPayloadType) ((SIZE_T) ((((UINT32) (payloadType)) << 8) | (UINT32) (rtxPayloadType)))
116#define KVS_RTP_TRANSCEIVER_UNPACK_PAYLOAD_TYPE(packed) ((UINT8) ((packed) >> 8))
117#define KVS_RTP_TRANSCEIVER_UNPACK_RTX_PAYLOAD_TYPE(packed) ((UINT8) ((packed) & 0xFF))
118
122
124
125#define CONVERT_TIMESTAMP_TO_RTP(clockRate, pts) ((UINT64) ((DOUBLE) (pts) * ((DOUBLE) (clockRate) / HUNDREDS_OF_NANOS_IN_A_SECOND)))
126
128
131
134
135#ifdef __cplusplus
136}
137#endif
138#endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_PEERCONNECTION_RTP__ */
STATUS setUpRollingBufferConfigInternal(PKvsRtpTransceiver, PRtcMediaStreamTrack, DOUBLE, DOUBLE)
Definition Rtp.c:54
STATUS findTransceiverBySsrc(PKvsPeerConnection pKvsPeerConnection, PKvsRtpTransceiver *ppTransceiver, UINT32 ssrc)
Definition Rtp.c:567
STATUS hasTransceiverWithSsrc(PKvsPeerConnection pKvsPeerConnection, UINT32 ssrc)
Definition Rtp.c:561
STATUS freeRollingBufferConfig(PRollingBufferConfig)
Definition Rtp.c:129
STATUS writeRtpPacket(PKvsPeerConnection pKvsPeerConnection, PRtpPacket pRtpPacket)
Definition Rtp.c:534
STATUS kvsRtpTransceiverSetJitterBuffer(PKvsRtpTransceiver, PJitterBuffer)
Definition Rtp.c:174
struct RtcRtpSender * PRtcRtpSender
struct RollingBufferConfig * PRollingBufferConfig
STATUS freeKvsRtpTransceiver(PKvsRtpTransceiver *)
Definition Rtp.c:135
struct KvsRtpTransceiver * PKvsRtpTransceiver
STATUS createKvsRtpTransceiver(RTC_RTP_TRANSCEIVER_DIRECTION, PKvsPeerConnection, UINT32, UINT32, PRtcMediaStreamTrack, PJitterBuffer, RTC_CODEC, PKvsRtpTransceiver *)
Definition Rtp.c:7
#define MAX_SDP_ATTRIBUTE_VALUE_LENGTH
Definition Sdp.h:73
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:1193
VOID(* RtcOnPictureLoss)(UINT64)
RtcOnPictureLoss is fired everytime a Picture Loss Indication (PLI) feedback message is received....
Definition Include.h:1290
VOID(* RtcOnBandwidthEstimation)(UINT64, DOUBLE)
RtcOnBandwidthEstimation is fired everytime a bandwidth estimation value is computed....
Definition Include.h:1202
RTC_RTP_TRANSCEIVER_DIRECTION
RTC_RTP_TRANSCEIVER_DIRECTION indicates direction of a transceiver.
Definition Include.h:1057
RTC_CODEC
The enum specifies the codec types for audio and video tracks.
Definition Include.h:1028
@ RTC_RTP_TRANSCEIVER_DIRECTION_UNINITIALIZED
Will use the default "sendrecv" after initialization.
Definition Include.h:1058
Definition JitterBuffer.h:20
Definition PeerConnection.h:81
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
RTC_CODEC rollingBufferCodec
Definition Rtp.h:112
UINT32 peerFrameBufferSize
Definition Rtp.h:77
RtcOnBandwidthEstimation onBandwidthEstimation
Definition Rtp.h:72
RTC_RTP_TRANSCEIVER_DIRECTION configuredDirection
Definition Rtp.h:95
volatile SIZE_T atomicSenderPayloadTypes
Definition Rtp.h:108
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
BOOL twccEnabled
Definition Rtp.h:86
volatile SIZE_T atomicDirection
Definition Rtp.h:102
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:465
Represents a single track in a MediaStream.
Definition Include.h:1371
RtcOutboundRtpStreamStats Gathers stats for media stream from the embedded device Note: RTCOutboundRt...
Definition Stats.h:364
RTCRemoteInboundRtpStreamStats Represents the remote endpoint's measurement metrics for a particular ...
Definition Stats.h:416
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:1397
Definition RtpRollingBuffer.h:13
Definition RtpPacket.h:87
Definition RtpPacket.h:99