Skip to content

Commit

Permalink
Fix disable data channel unit test build failure and reduce SDP chara…
Browse files Browse the repository at this point in the history
…cter array lengths wherever relevant following spec
  • Loading branch information
disa6302 committed Jan 10, 2024
1 parent 1327cd0 commit 1aad108
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 27 deletions.
9 changes: 3 additions & 6 deletions src/source/PeerConnection/PeerConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:

Expand All @@ -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:

Expand Down
64 changes: 43 additions & 21 deletions src/source/Sdp/Sdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,54 @@ 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 <IPv4(15)/TTL(3)/multicast number of addresses(3)> characters where TTL is
* between 0 and 255. IPv6 can be a maximum of <IPv6 uncompressed(39)>. 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

#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
/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -142,13 +166,13 @@ typedef struct {
CHAR mediaName[MAX_SDP_MEDIA_NAME_LENGTH + 1];

// i=<session description>
// 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];
Expand Down Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions tst/DataChannelApiTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "WebRTCClientTestFixture.h"

#ifdef ENABLE_DATA_CHANNEL
namespace com {
namespace amazonaws {
namespace kinesis {
Expand Down Expand Up @@ -37,3 +38,5 @@ TEST_F(DataChannelApiTest, createDataChannel_Disconnected)
} // namespace kinesis
} // namespace amazonaws
} // namespace com

#endif
3 changes: 3 additions & 0 deletions tst/DataChannelFunctionalityTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "WebRTCClientTestFixture.h"

#ifdef ENABLE_DATA_CHANNEL
namespace com {
namespace amazonaws {
namespace kinesis {
Expand Down Expand Up @@ -595,3 +596,5 @@ TEST_F(DataChannelFunctionalityTest, createDataChannel_DataChannelMetricsTest)
} // namespace kinesis
} // namespace amazonaws
} // namespace com

#endif

0 comments on commit 1aad108

Please sign in to comment.