Skip to content

Commit 4f3e2a5

Browse files
committed
Prefer dynamic allocations over large STATIC arrays
- Use dynamically allocated WSS URL - Use dynamic allocations for singaling payload - Use required only allocations in LwsApiCalls instead large static arrays
1 parent 0854986 commit 4f3e2a5

File tree

3 files changed

+253
-12
lines changed

3 files changed

+253
-12
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ option(INSTRUMENTED_ALLOCATORS "Enable memory instrumentation" OFF)
2323
option(ENABLE_AWS_SDK_IN_TESTS "Enable support for compiling AWS SDKs for tests" ON)
2424
option(ENABLE_STATS_CALCULATION_CONTROL "Enable support for runtime control of ice agent stat calculations." OFF)
2525
option(BUILD_OLD_MBEDTLS_VERSION "Use MbedTLS version 2.28.8." OFF)
26+
option(PREFER_DYNAMIC_ALLOCS "Prefer dynamic allocations for signalingpayloads and URLs" OFF)
2627

2728
# Developer Flags
2829
option(BUILD_TEST "Build the testing tree." OFF)
@@ -147,6 +148,10 @@ if (ENABLE_STATS_CALCULATION_CONTROL)
147148
add_definitions(-DENABLE_STATS_CALCULATION_CONTROL)
148149
endif()
149150

151+
if (PREFER_DYNAMIC_ALLOCS)
152+
add_definitions(-DPREFER_DYNAMIC_ALLOCS=1)
153+
endif()
154+
150155
if(USE_OPENSSL)
151156
add_definitions(-DKVS_USE_OPENSSL)
152157
elseif(USE_MBEDTLS)

src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,21 @@ typedef struct {
12791279
//!<
12801280
} RtcIceCandidateInit, *PRtcIceCandidateInit;
12811281

1282+
/**
1283+
* @brief Define this macro to use dynamically allocated payload in SignalingMessage
1284+
* This can be useful for platforms with limited memory as it avoids allocating
1285+
* MAX_SIGNALING_MESSAGE_LEN for each message when only a small payload is needed
1286+
*/
1287+
1288+
/**
1289+
* @brief If PREFER_DYNAMIC_ALLOCS is set to 1, use dynamic allocation for signaling payload
1290+
* Otherwise, use the existing DYNAMIC_SIGNALING_PAYLOAD setting
1291+
*/
1292+
#if PREFER_DYNAMIC_ALLOCS
1293+
#define DYNAMIC_SIGNALING_PAYLOAD 1
1294+
#define USE_DYNAMIC_URL 1
1295+
#endif
1296+
12821297
/**
12831298
* @brief Structure defining the basic signaling message
12841299
*/
@@ -1293,7 +1308,11 @@ typedef struct {
12931308

12941309
UINT32 payloadLen; //!< Optional payload length. If 0, the length will be calculated
12951310

1311+
#ifdef DYNAMIC_SIGNALING_PAYLOAD
1312+
PCHAR payload; //!< Actual signaling message payload - dynamically allocated
1313+
#else
12961314
CHAR payload[MAX_SIGNALING_MESSAGE_LEN + 1]; //!< Actual signaling message payload
1315+
#endif
12971316
} SignalingMessage, *PSignalingMessage;
12981317

12991318
/**

0 commit comments

Comments
 (0)