From 1aad1089fd9227f7c893f46b12847c2632697181 Mon Sep 17 00:00:00 2001 From: Divya Sampath Kumar Date: Wed, 10 Jan 2024 12:39:46 -0800 Subject: [PATCH] Fix disable data channel unit test build failure and reduce SDP character array lengths wherever relevant following spec --- src/source/PeerConnection/PeerConnection.c | 9 +-- src/source/Sdp/Sdp.h | 64 +++++++++++++++------- tst/DataChannelApiTest.cpp | 3 + tst/DataChannelFunctionalityTest.cpp | 3 + 4 files changed, 52 insertions(+), 27 deletions(-) diff --git a/src/source/PeerConnection/PeerConnection.c b/src/source/PeerConnection/PeerConnection.c index 745ae7d3fa..6509b816fa 100644 --- a/src/source/PeerConnection/PeerConnection.c +++ b/src/source/PeerConnection/PeerConnection.c @@ -1370,7 +1370,7 @@ STATUS setRemoteDescription(PRtcPeerConnection pPeerConnection, PRtcSessionDescr CHK_STATUS(setReceiversSsrc(pSessionDescription, pKvsPeerConnection->pTransceivers)); if (NULL != GETENV(DEBUG_LOG_SDP)) { - DLOGI("REMOTE_SDP:%s\n", pSessionDescriptionInit->sdp); + DLOGD("REMOTE_SDP:%s\n", pSessionDescriptionInit->sdp); } CleanUp: @@ -1403,16 +1403,13 @@ STATUS createOffer(PRtcPeerConnection pPeerConnection, PRtcSessionDescriptionIni #endif CHK_STATUS(setPayloadTypesForOffer(pKvsPeerConnection->pCodecTable)); - DLOGI("Entering populating"); CHK_STATUS(populateSessionDescription(pKvsPeerConnection, &(pKvsPeerConnection->remoteSessionDescription), pSessionDescription)); CHK_STATUS(serializeSessionDescription(pSessionDescription, NULL, &serializeLen)); CHK(serializeLen <= MAX_SESSION_DESCRIPTION_INIT_SDP_LEN, STATUS_NOT_ENOUGH_MEMORY); - DLOGI("Here"); CHK_STATUS(serializeSessionDescription(pSessionDescription, pSessionDescriptionInit->sdp, &serializeLen)); - DLOGI("Out"); // If embedded SDK acts as the viewer if (NULL != GETENV(DEBUG_LOG_SDP)) { - DLOGI("LOCAL_SDP:%s", pSessionDescriptionInit->sdp); + DLOGD("LOCAL_SDP:%s", pSessionDescriptionInit->sdp); } CleanUp: @@ -1438,7 +1435,7 @@ STATUS createAnswer(PRtcPeerConnection pPeerConnection, PRtcSessionDescriptionIn CHK_STATUS(peerConnectionGetCurrentLocalDescription(pPeerConnection, pSessionDescriptionInit)); // If embedded SDK acts as the master if (NULL != GETENV(DEBUG_LOG_SDP)) { - DLOGI("LOCAL_SDP:%s", pSessionDescriptionInit->sdp); + DLOGD("LOCAL_SDP:%s", pSessionDescriptionInit->sdp); } CleanUp: diff --git a/src/source/Sdp/Sdp.h b/src/source/Sdp/Sdp.h index 1e9787b2c0..542259ce09 100644 --- a/src/source/Sdp/Sdp.h +++ b/src/source/Sdp/Sdp.h @@ -46,17 +46,47 @@ extern "C" { #define MAX_SDP_OFFSET_LENGTH 255 #define MAX_SDP_ENCRYPTION_KEY_METHOD_LENGTH 255 #define MAX_SDP_ENCRYPTION_KEY_LENGTH 255 -#define MAX_SDP_NETWORK_TYPE_LENGTH 255 -#define MAX_SDP_ADDRESS_TYPE_LENGTH 255 -#define MAX_SDP_CONNECTION_ADDRESS_LENGTH 255 -#define MAX_SDP_SESSION_USERNAME_LENGTH 255 -#define MAX_SDP_ATTRIBUTE_NAME_LENGTH 255 -#define MAX_SDP_ATTRIBUTE_VALUE_LENGTH 513 // One of the attributes is streamId + trackId which sums up to 512 maximum characters -#define MAX_SDP_MEDIA_NAME_LENGTH 255 -#define MAX_SDP_MEDIA_TITLE_LENGTH 255 -#define MAX_SDP_BANDWIDTH_LENGTH 255 + +/* https://datatracker.ietf.org/doc/html/rfc4566#section-5.7 -- the SDK hardcodes this to be IN as per spec. + * Also, this SDK is to be used in the Internet realm + */ +#define MAX_SDP_NETWORK_TYPE_LENGTH 8 + +/* https://datatracker.ietf.org/doc/html/rfc4566#section-5.7 -- Given the SDK is to operate in IP based sessions, + * the possible values are IP4/IP6 as registered with IANA + */ +#define MAX_SDP_ADDRESS_TYPE_LENGTH 8 + +/* https://datatracker.ietf.org/doc/html/rfc4566#section-5.7 -- Given the SDK is to operate in IP based sessions, + * an IPv4 address can be a maximum of characters where TTL is + * between 0 and 255. IPv6 can be a maximum of . Setting to 63 for additional padding + */ +#define MAX_SDP_CONNECTION_ADDRESS_LENGTH 63 + +// https://datatracker.ietf.org/doc/html/rfc4566#section-5.2 -- the SDK sets it to "-" and the SDK does not parse incoming username either +#define MAX_SDP_SESSION_USERNAME_LENGTH 32 + +// https://datatracker.ietf.org/doc/html/rfc4566#section-6 -- name length restricted based on current supported attribute set +#define MAX_SDP_ATTRIBUTE_NAME_LENGTH 32 + +// One of the attributes is streamId + trackId which sums up to 512 maximum characters +#define MAX_SDP_ATTRIBUTE_VALUE_LENGTH 512 + +#define MAX_SDP_MEDIA_NAME_LENGTH 255 + +/* https://tools.ietf.org/html/rfc4566#section-5.4. Given these are free-form textual strings, that is, the length could be anything. + * Although our SDK parses this information, the SDK does not use it. Leaving this attribute in if SDK uses it in + * the future, but keeping it at smaller size to ensure structure memory efficiency + */ +#define MAX_SDP_MEDIA_TITLE_LENGTH 127 + +/* https://tools.ietf.org/html/rfc4566#section-5.4. Given these are free-form textual strings, that is, the length could be anything. + * Although our SDK parses this information, the SDK does not use it. Leaving this attribute in if SDK uses it in + * the future, but keeping it at smaller size to ensure structure memory efficiency + */ +#define MAX_SDP_SESSION_INFORMATION_LENGTH 127 + #define MAX_SDP_SESSION_NAME_LENGTH 255 -#define MAX_SDP_SESSION_INFORMATION_LENGTH 255 #define MAX_SDP_SESSION_URI_LENGTH 255 #define MAX_SDP_SESSION_EMAIL_ADDRESS_LENGTH 255 #define MAX_SDP_SESSION_PHONE_NUMBER_LENGTH 255 @@ -64,7 +94,6 @@ extern "C" { #define MAX_SDP_TOKEN_LENGTH 128 #define MAX_SDP_FMTP_VALUES 64 -#define MAX_SDP_SESSION_BANDWIDTH_COUNT 2 #define MAX_SDP_SESSION_TIME_DESCRIPTION_COUNT 2 #define MAX_SDP_SESSION_TIMEZONE_COUNT 2 /** @@ -98,11 +127,6 @@ typedef struct { SdpConnectionInformation sdpConnectionInformation; } SdpOrigin, *PSdpOrigin; -typedef struct { - CHAR sdpBandwidthType[MAX_SDP_BANDWIDTH_LENGTH + 1]; - UINT64 sdpBandwidthValue; // bps -} SdpBandwidth, *PSdpBandwidth; - /* * https://tools.ietf.org/html/rfc4566#section-5.9 * https://tools.ietf.org/html/rfc4566#section-5.10 @@ -142,13 +166,13 @@ typedef struct { CHAR mediaName[MAX_SDP_MEDIA_NAME_LENGTH + 1]; // i= - // https://tools.ietf.org/html/rfc4566#section-5.4 + // https://tools.ietf.org/html/rfc4566#section-5.4. Given these are free-form strings, the length could be anything. + // Although our SDK parses this information, the SDK does not use it. Leaving this attribute in if SDK uses it in + // the future CHAR mediaTitle[MAX_SDP_MEDIA_TITLE_LENGTH + 1]; SdpConnectionInformation sdpConnectionInformation; - SdpBandwidth sdpBandwidth[MAX_SDP_MEDIA_BANDWIDTH_COUNT]; - SdpEncryptionKey sdpEncryptionKey; SdpAttributes sdpAttributes[MAX_SDP_ATTRIBUTES_COUNT]; @@ -186,8 +210,6 @@ typedef struct { SdpConnectionInformation sdpConnectionInformation; - SdpBandwidth sdpBandwidth[MAX_SDP_SESSION_BANDWIDTH_COUNT]; - SdpTimeDescription sdpTimeDescription[MAX_SDP_SESSION_TIME_DESCRIPTION_COUNT]; SdpTimeZone sdpTimeZone[MAX_SDP_SESSION_TIMEZONE_COUNT]; diff --git a/tst/DataChannelApiTest.cpp b/tst/DataChannelApiTest.cpp index 05f0836275..0c0f9bc1c6 100644 --- a/tst/DataChannelApiTest.cpp +++ b/tst/DataChannelApiTest.cpp @@ -1,5 +1,6 @@ #include "WebRTCClientTestFixture.h" +#ifdef ENABLE_DATA_CHANNEL namespace com { namespace amazonaws { namespace kinesis { @@ -37,3 +38,5 @@ TEST_F(DataChannelApiTest, createDataChannel_Disconnected) } // namespace kinesis } // namespace amazonaws } // namespace com + +#endif diff --git a/tst/DataChannelFunctionalityTest.cpp b/tst/DataChannelFunctionalityTest.cpp index abf373d5f5..a2a355cd36 100644 --- a/tst/DataChannelFunctionalityTest.cpp +++ b/tst/DataChannelFunctionalityTest.cpp @@ -1,5 +1,6 @@ #include "WebRTCClientTestFixture.h" +#ifdef ENABLE_DATA_CHANNEL namespace com { namespace amazonaws { namespace kinesis { @@ -595,3 +596,5 @@ TEST_F(DataChannelFunctionalityTest, createDataChannel_DataChannelMetricsTest) } // namespace kinesis } // namespace amazonaws } // namespace com + +#endif