Amazon Kinesis Webrtc C SDK
 
Loading...
Searching...
No Matches
Sdp.h
Go to the documentation of this file.
1//
2// Session Description Protocol Utils
3//
4
5#ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_SDP_SDP__
6#define __KINESIS_VIDEO_WEBRTC_CLIENT_SDP_SDP__
7
8#pragma once
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#define SDP_ATTRIBUTE_MARKER "a="
15#define SDP_BANDWIDTH_MARKER "b="
16#define SDP_CONNECTION_INFORMATION_MARKER "c="
17#define SDP_EMAIL_ADDRESS_MARKER "e="
18#define SDP_ENCRYPTION_KEY_MARKER "k="
19
20// Media title information or Session information
21#define SDP_INFORMATION_MARKER "i="
22
23#define SDP_MEDIA_NAME_MARKER "m="
24#define SDP_ORIGIN_MARKER "o="
25#define SDP_PHONE_NUMBER_MARKER "p="
26#define SDP_SESSION_NAME_MARKER "s="
27#define SDP_TIME_DESCRIPTION_MARKER "t="
28#define SDP_TIMEZONE_MARKER "z="
29#define SDP_URI_MARKER "u="
30#define SDP_VERSION_MARKER "v="
31
32// The sequence CRLF (0x0d0a) is used to end a record, although parsers SHOULD be
33// tolerant and also accept records terminated with a single newline
34// character.
35// Reference: https://tools.ietf.org/html/rfc4566#section-5
36#define SDP_LINE_SEPARATOR "\r\n"
37
38#define SDP_CANDIDATE_TYPE_HOST "host"
39#define SDP_CANDIDATE_TYPE_SERFLX "srflx"
40#define SDP_CANDIDATE_TYPE_PRFLX "prflx"
41#define SDP_CANDIDATE_TYPE_RELAY "relay"
42#define SDP_CANDIDATE_TYPE_UNKNOWN "unknown"
43
44#define SDP_ATTRIBUTE_LENGTH 2
45
46#define MAX_SDP_OFFSET_LENGTH 255
47#define MAX_SDP_ENCRYPTION_KEY_METHOD_LENGTH 255
48#define MAX_SDP_ENCRYPTION_KEY_LENGTH 255
49
50/* https://datatracker.ietf.org/doc/html/rfc4566#section-5.7 -- the SDK hardcodes this to be IN as per spec.
51 * Also, this SDK is to be used in the Internet realm. Allowing for some extra buffer
52 */
53#define MAX_SDP_NETWORK_TYPE_LENGTH 7
54
55/* https://datatracker.ietf.org/doc/html/rfc4566#section-5.7 -- Given the SDK is to operate in IP based sessions,
56 * the possible values are IP4/IP6 as registered with IANA. Allowing for some extra buffer
57 */
58#define MAX_SDP_ADDRESS_TYPE_LENGTH 7
59
60/* https://datatracker.ietf.org/doc/html/rfc4566#section-5.7 -- Given the SDK is to operate in IP based sessions,
61 * an IPv4 address can be a maximum of <IPv4(15)/TTL(3)/multicast number of addresses(3)> characters where TTL is
62 * between 0 and 255. IPv6 can be a maximum of <IPv6 uncompressed(39)>. Setting to 63 for additional padding
63 */
64#define MAX_SDP_CONNECTION_ADDRESS_LENGTH 63
65
66// https://datatracker.ietf.org/doc/html/rfc4566#section-5.2 -- the SDK sets it to "-" and the SDK does not parse incoming username either
67#define MAX_SDP_SESSION_USERNAME_LENGTH 32
68
69// https://datatracker.ietf.org/doc/html/rfc4566#section-6 -- name length restricted based on current supported attribute set
70#define MAX_SDP_ATTRIBUTE_NAME_LENGTH 32
71
72// One of the attributes is streamId + trackId which sums up to 512 maximum characters
73#define MAX_SDP_ATTRIBUTE_VALUE_LENGTH 512
74
75#define MAX_SDP_MEDIA_NAME_LENGTH 255
76
77/* https://tools.ietf.org/html/rfc4566#section-5.4. Given these are free-form textual strings, that is, the length could be anything.
78 * Although our SDK parses this information, the SDK does not use it. Leaving this attribute in if SDK uses it in
79 * the future, but keeping it at smaller size to ensure structure memory efficiency
80 */
81#define MAX_SDP_MEDIA_TITLE_LENGTH 127
82
83/* https://tools.ietf.org/html/rfc4566#section-5.4. Given these are free-form textual strings, that is, the length could be anything.
84 * Although our SDK parses this information, the SDK does not use it. Leaving this attribute in if SDK uses it in
85 * the future, but keeping it at smaller size to ensure structure memory efficiency
86 */
87#define MAX_SDP_SESSION_INFORMATION_LENGTH 127
88
89#define MAX_SDP_SESSION_NAME_LENGTH 255
90#define MAX_SDP_SESSION_URI_LENGTH 255
91#define MAX_SDP_SESSION_EMAIL_ADDRESS_LENGTH 255
92#define MAX_SDP_SESSION_PHONE_NUMBER_LENGTH 255
93
94#define MAX_SDP_TOKEN_LENGTH 128
95#define MAX_SDP_FMTP_VALUES 64
96
97#define MAX_SDP_SESSION_TIME_DESCRIPTION_COUNT 2
98#define MAX_SDP_SESSION_TIMEZONE_COUNT 2
99
111#ifndef MAX_SDP_SESSION_MEDIA_COUNT
112#define MAX_SDP_SESSION_MEDIA_COUNT 5
113#endif
114
115#define MAX_SDP_MEDIA_BANDWIDTH_COUNT 2
116
126#ifndef MAX_SDP_ATTRIBUTES_COUNT
127#define MAX_SDP_ATTRIBUTES_COUNT 256
128#endif
129
130/*
131 * c=<nettype> <addrtype> <connection-address>
132 * https://tools.ietf.org/html/rfc4566#section-5.7
133 */
139
140/*
141 * o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address>
142 * https://tools.ietf.org/html/rfc4566#section-5.2
143 */
150
151/*
152 * https://tools.ietf.org/html/rfc4566#section-5.9
153 * https://tools.ietf.org/html/rfc4566#section-5.10
154 */
159
160/*
161 * z=<adjustment time> <offset> <adjustment time> <offset> ...
162 * https://tools.ietf.org/html/rfc4566#section-5.11
163 */
168
173
174/*
175 * a=<attribute>
176 * a=<attribute>:<value>
177 * https://tools.ietf.org/html/rfc4566#section-5.13
178 */
183
184typedef struct {
185 // m=<media> <port>/<number of ports> <proto> <fmt> ...
186 // https://tools.ietf.org/html/rfc4566#section-5.14
188
189 // i=<session description>
190 // https://tools.ietf.org/html/rfc4566#section-5.4. Given these are free-form strings, the length could be anything.
191 // Although our SDK parses this information, the SDK does not use it. Leaving this attribute in if SDK uses it in
192 // the future
194
196
198
200
201 // Must be able to represent MAX_SDP_ATTRIBUTES_COUNT. With a narrower type the bounds check in parseMediaAttributes() can never fail
202 // and the counter wraps to 0, silently overwriting the attributes already parsed for this media section.
204
207
208typedef struct {
209 // https://tools.ietf.org/html/rfc4566#section-5.1
211
213
214 // s=<session name>
215 // https://tools.ietf.org/html/rfc4566#section-5.3
217
218 // i=<session description>
219 // https://tools.ietf.org/html/rfc4566#section-5.4
221
222 // u=<uri>
223 // https://tools.ietf.org/html/rfc4566#section-5.5
225
226 // e=<email-address>
227 // https://tools.ietf.org/html/rfc4566#section-5.6
229
230 // p=<phone-number>
231 // https://tools.ietf.org/html/rfc4566#section-5.6
233
235
237
239
241
243
245
247
249
251
253
256
257// Return code maps to an errno just for SDP parsing
259
260// Return code maps to a code if we are trying to serialize an invalid session_description
262
266
267#ifdef __cplusplus
268}
269#endif
270#endif //__KINESIS_VIDEO_WEBRTC_CLIENT_SDP_SDP__
#define MAX_SDP_SESSION_URI_LENGTH
Definition Sdp.h:90
#define MAX_SDP_SESSION_NAME_LENGTH
Definition Sdp.h:89
#define MAX_SDP_SESSION_PHONE_NUMBER_LENGTH
Definition Sdp.h:92
#define MAX_SDP_SESSION_EMAIL_ADDRESS_LENGTH
Definition Sdp.h:91
STATUS deserializeSessionDescription(PSessionDescription, PCHAR)
Definition Deserialize.c:74
STATUS serializeSessionDescription(PSessionDescription, PCHAR, PUINT32)
Definition Serialize.c:166
#define MAX_SDP_NETWORK_TYPE_LENGTH
Definition Sdp.h:53
struct SdpOrigin * PSdpOrigin
#define MAX_SDP_MEDIA_NAME_LENGTH
Definition Sdp.h:75
#define MAX_SDP_ENCRYPTION_KEY_METHOD_LENGTH
Definition Sdp.h:47
struct SdpTimeDescription * PSdpTimeDescription
#define MAX_SDP_OFFSET_LENGTH
Definition Sdp.h:46
#define MAX_SDP_ATTRIBUTE_VALUE_LENGTH
Definition Sdp.h:73
#define MAX_SDP_SESSION_USERNAME_LENGTH
Definition Sdp.h:67
struct SdpMediaDescription * PSdpMediaDescription
#define MAX_SDP_SESSION_TIME_DESCRIPTION_COUNT
Definition Sdp.h:97
#define MAX_SDP_MEDIA_TITLE_LENGTH
Definition Sdp.h:81
struct SdpAttributes * PSdpAttributes
#define MAX_SDP_SESSION_MEDIA_COUNT
Definition Sdp.h:112
#define MAX_SDP_ENCRYPTION_KEY_LENGTH
Definition Sdp.h:48
struct SdpConnectionInformation * PSdpConnectionInformation
#define MAX_SDP_ATTRIBUTE_NAME_LENGTH
Definition Sdp.h:70
struct SessionDescription * PSessionDescription
struct SdpEncryptionKey * PSdpEncryptionKey
#define MAX_SDP_SESSION_INFORMATION_LENGTH
Definition Sdp.h:87
#define MAX_SDP_CONNECTION_ADDRESS_LENGTH
Definition Sdp.h:64
STATUS parseMediaAttributes(PSessionDescription, PCHAR, UINT32)
Definition Deserialize.c:46
struct SdpTimeZone * PSdpTimeZone
STATUS parseMediaName(PSessionDescription, PCHAR, UINT32)
Definition Deserialize.c:4
#define MAX_SDP_ATTRIBUTES_COUNT
Definition Sdp.h:127
#define MAX_SDP_ADDRESS_TYPE_LENGTH
Definition Sdp.h:58
STATUS parseSessionAttributes(PSessionDescription, PCHAR, UINT32)
Definition Deserialize.c:20
#define MAX_SDP_SESSION_TIMEZONE_COUNT
Definition Sdp.h:98
@ RTC_RTP_TRANSCEIVER_DIRECTION_UNINITIALIZED
Will use the default "sendrecv" after initialization.
Definition Include.h:1058
Definition Sdp.h:179
Definition Sdp.h:134
Definition Sdp.h:169
Definition Sdp.h:184
UINT8 mediaBandwidthCount
Definition Sdp.h:205
UINT16 mediaAttributesCount
Definition Sdp.h:203
SdpConnectionInformation sdpConnectionInformation
Definition Sdp.h:195
SdpEncryptionKey sdpEncryptionKey
Definition Sdp.h:197
Definition Sdp.h:144
UINT64 sessionVersion
Definition Sdp.h:147
SdpConnectionInformation sdpConnectionInformation
Definition Sdp.h:148
UINT64 sessionId
Definition Sdp.h:146
Definition Sdp.h:155
UINT64 startTime
Definition Sdp.h:156
UINT64 stopTime
Definition Sdp.h:157
Definition Sdp.h:164
UINT64 adjustmentTime
Definition Sdp.h:165
Definition Sdp.h:208
UINT16 mediaCount
Definition Sdp.h:248
SdpEncryptionKey sdpEncryptionKey
Definition Sdp.h:240
SdpConnectionInformation sdpConnectionInformation
Definition Sdp.h:234
UINT8 bandwidthCount
Definition Sdp.h:254
UINT64 version
Definition Sdp.h:210
UINT8 timezoneCount
Definition Sdp.h:250
UINT16 sessionAttributesCount
Definition Sdp.h:246
SdpOrigin sdpOrigin
Definition Sdp.h:212
UINT8 timeDescriptionCount
Definition Sdp.h:252