Skip to content

Commit 339f24f

Browse files
stefankieszsirknightjdisa6302jdelaplahassanctech
authored
v1.12.0 Release (#2087)
* Reduce hash table size for SDP transceivers (#2067) * Reduce hash table size for SDP transceivers (#1914) * Modify hash table sizes * Add logs * Fix hash table size to be set according to number of m-lines and unique supported codecs * CI branch * Update actions to use node20 * Unit test for fake transceiver * Cleanup * Fix build failure * Fix unit test * Initialize to 0 * PR description check: Reduce minimum character count and print the current character count * Use PR number instead of manually constructing link, add fetch error logging * Print out the PR link * Debug the CI * Fix the extraction logic * Clang-format --------- Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> * Add job to run the sample and check for memory leak (#2071) * Add job to run the sample and check for memory leak * Simulate a memory leak * MEMALLOC instead of MALLOC * Remove simulated memory leak * Print the exit statuses in case of failure * Move offer from stack to heap (#2070) * Ensure remote description does not live in memory for viewer duration (#1915) * Ensure remote description does not live in memory for viewer duration * Fix memory leak * Free the allocated memory upon failure, also add missing enter, leave and chk_log_error in peerconnection * Working reduced stack sizes. Adjusted default stack size to 64kb, moved Offer/Answer messages to be on heap instead of stack * Revert setting the stack sizes by default; Samples: revert disableSenderSideBandwidthEstimation to TRUE by default * Add missing malloc out of memory checks * Undo samples/Common.c changes * Add chk_log_err to freeJitterBuffer and freeKvsRtpTransceiver * Address comments: add additional null checks and adjust comments * Clang-format --------- Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> Co-authored-by: James Delaplane <delaplan@amazon.com> * Memory Optimization - ICE Agent Stats (#1947) (#2074) * Ice memory reduction - enable ice stats flag (#1947) * Change params size * Use dyanmic allocation and flag for ice stats * Debug 1 * Revert "Debug 1" This reverts commit ad7d02f. * Revert "Use dyanmic allocation and flag for ice stats" This reverts commit bf9a2ee. * Working version * enable flag in samples * Add unit test * Fix bug * README for the flag * Update readme * Fix readme typos * clang format * Add ENABLE_STATS_CALCULATION_CONTROL CMake option and compiler flag. Update ReadMe. * Add IceStatsControlOn tests * Add CI test forENABLE_STATS_CALCULATION_CONTROL=TRUE * Clang formatting * Remove unused iceAgentAddConfig * Remove unintended readme merge changes "Controlling RTP rolling buffer capacity" * Address comments, add null check * Cleanup unused variable * Rename and negate variable * Move setting of enableIceStats to fix segfault * Revert member size savings changes (to be applied in separate PR) * Move other instance setting of enableIceStats, clang format. * Fix setting of enableIceStats in tests * Address comment --------- Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> * Memory Optimization - Refactor TWCC (#1934) (#2075) * Refactor TWCC (#1934) * Remove stackqueue usage * Use hashtable instead..working logic * Cleanup, increase hash table size, fix loop bug * method 2, array of pointers * Add rolling window * rolling window with hashtable * hash table with rw * Fix bug * Fix twcc unit test * Cleanup rw logic * Cleanup * Cleanup logic * Update README * unused var fix * Use defines for hash table size * Address comments, disable TWCC by default * readme * Fix windows gst issue * Comments * Remove enableIceStats merge conflict * Address comments * Fix left over typo * Address comments, refactor updaing of TWCC hash table in onRtcpTwccPacket for testing * Clang format, fix compiler Werror * Correct typos * Fix "expression result unused" Werrors * Remove unused variable * Address comments * Fix endless loop * Address comment * Add removal of null hashTable items, add test for null item in hashTable * Address comments * Cleanup freeing of KvsPeerConnection * Clang format --------- Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> * Shorten Stats String Lengths (#2079) * Memory Optimization - Rolling Buffer (#2077) * Rb size config (#1921) * Reduce default size * Rolling buffer configurability * Add configurability * Allow setting parameter through trx instead of config * Add UT, fix the members to DOUBLE * Remove unnecessary fields * Rolling buffer readme update * Use enums for min values * Add usage example in samples * Fix unit test * Memset init in UTs * Modify the bitrates in the samples based on codec used in our samples * Modify unit tests, add video/audio specific defaults * Add missing null check * Readme update * Address nits * Clang fix * Logs for RB * set explicit type cast * add max values * Refactor RB logic, readme update, sample cleanup * nits * Fix unit tests * return * update description in header * fix unused var * minor changes * typo fix * review comments * sdp, stun, rtp * comments * cancelled builds * log status * sctp * Revert unrelated sample changes * Revert unrelated CMake changes * Revert unrelated test changes * Revert unrelated ReadMe changes * Fix DEFAULT_MTU_SIZE variable name * Cleanup merge changes * Fixup and comment on Rtp.c * Fixup Rtp.h * Fixup ReadMe * Clang format * Revert all sample changes * Address comments * Add back accidentally deleted line * Address comment * Update README.md --------- Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> * Add option to specify stack size to pthread_create (#2073) * Thread stack sizes (#1924) * Working reduced stack sizes. Adjusted default stack size to 64kb, moved Offer/Answer messages to be on heap instead of stack * Custom stack sizes in Common.c * CMake flag working and added to README * Adjust connection listener stack size for datachannels * Change stack size for media related threads and connection listener again. Add README notes to highlight this potential problem threads for other applications * Unnecessary memset * nit picks * Update CMakeLists.txt fix for ZLIB since it is not found on Windows, that way we can verify the stack side change on Windows platform, previously it was not running at all due to build fail. * Update CMake dependency back to develop since the other PRs have merged * README update --------- Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com> Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> * Stack size configurablility * Revert setting specific thread stack sizes in the sample and SDK * Check develop branch * Check stack size is forwarded to PIC correctly * Set e * Remove duplicate mkdir build * Print out CMake logs in case of error * Missing fi * Remove square brackets * Dont build samples * Build samples * Pass the stack size down and dont build samples * Remove constrained device * Bump kvsCommonLws from 1.5.4RC to 1.5.4 * Add v * Update README.md --------- Co-authored-by: jdelapla <delaplan@amazon.com> Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com> Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> * SDP Attribute Fixes (#2082) * fix nack pli overwrite bug (#2035) * fix nack pli overwrite bug * create generic strings instead of hard coding * remove stale comment in tests * Check that the sdp lines are not missing, append SDP_LINE_SEPARATOR to lines checked * Remove duplicate session attribute lines, add missing attribute name * Clang format --------- Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com> * ReadMe Fixes (#2083) * Add copy code buttons to github clone commands (#1928) * Add copy code buttons to github clone commands * Add language specifier * build -> built (#1925) * Update clone command * Remove Duplicate ReadMe Lines (#2085) * Update README.md * Update make commad * Bump project version in CMake (#2086) * Upgrade to macos-13 and 15, use DRY for Mac jobs (#2090) * Upgrade to macos-13 and 15, use DRY for Mac jobs, use docker for ubuntu jobs * Revert Ubuntu docker changes * Remove Mac+GCC+Tests combo * Install GStreamer for the mac jobs to check the GStreamer sample builds * Remove unnecessary installs * Build and run the tests without AWS SDK * Add D * Samples: Fit the RTP transceiver rolling buffers to fit the set of sample frames (#2089) * Properly fit the rolling buffers to fit the set of sample frames * Clang-format * Adjust the comment for the rolling buffer configuration for the sample frames * Bump the version from 1.11.1 to 1.12.0 (#2092) * Specify configureTransceiverRollingBuffer as a Public API --------- Co-authored-by: sirknightj <jggunawa@amazon.com> Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> Co-authored-by: James Delaplane <delaplan@amazon.com> Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com>
1 parent 30f52d1 commit 339f24f

30 files changed

+1895
-572
lines changed

.github/workflows/ci.yml

+226-125
Large diffs are not rendered by default.

.github/workflows/pr-desc-lint.yml

+23-14
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,43 @@ jobs:
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525
run: |
26-
pr_description=$(gh pr view https://github.com/${GITHUB_REPOSITORY}/pull/${{ github.event.pull_request.number }} --json body -q ".body")
27-
error_occurred=0
26+
pr_link="https://github.com/${GITHUB_REPOSITORY}/pull/${{ github.event.pull_request.number }}"
27+
28+
echo "$pr_link"
29+
30+
pr_description=$(gh pr view $pr_link --json body -q ".body")
31+
32+
if [ -z "$pr_description" ]; then
33+
echo "Failed to fetch the PR description"
34+
exit 1
35+
fi
36+
2837
# Define minimum character count for each section
29-
MIN_CHARS=25
38+
MIN_CHARS=10
3039
3140
# Extract contents
32-
# Extract contents
33-
what_changed=$(echo "$pr_description" | sed -n -e '/\*What was changed?\*/,/\*/p' | sed '$d' | sed '1d')
34-
why_changed=$(echo "$pr_description" | sed -n -e '/\*Why was it changed?\*/,/\*/p' | sed '$d' | sed '1d')
35-
how_changed=$(echo "$pr_description" | sed -n -e '/\*How was it changed?\*/,/\*/p' | sed '$d' | sed '1d')
36-
testing_done=$(echo "$pr_description" | sed -n -e '/\*What testing was done for the changes?\*/,/\*/p' | sed '$d' | sed '1d')
37-
41+
what_changed=$(echo "$pr_description" | sed -n -e '/\*What was changed?\*/,/\*Why was it changed?\*/p' | sed '$d' | sed '1d')
42+
why_changed=$(echo "$pr_description" | sed -n -e '/\*Why was it changed?\*/,/\*How was it changed?\*/p' | sed '$d' | sed '1d')
43+
how_changed=$(echo "$pr_description" | sed -n -e '/\*How was it changed?\*/,/\*What testing was done for the changes?\*/p' | sed '$d' | sed '1d')
44+
testing_done=$(echo "$pr_description" | sed -n -e '/\*What testing was done for the changes?\*/,/By submitting this pull request/p' | sed '$d' | sed '1d')
45+
46+
error_occurred=0
3847
if [[ ${#what_changed} -lt $MIN_CHARS ]]; then
39-
echo "PR description for what changed section is either missing or too short."
48+
echo "PR description for what changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${what_changed}"
4049
error_occurred=1
4150
fi
4251
if [[ ${#why_changed} -lt $MIN_CHARS ]]; then
43-
echo "PR description for why it changed section is either missing or too short."
52+
echo "PR description for why it changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${why_changed}"
4453
error_occurred=1
4554
fi
4655
if [[ ${#how_changed} -lt $MIN_CHARS ]]; then
47-
echo "PR description for how was it changed section is either missing or too short."
56+
echo "PR description for how was it changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${how_changed}"
4857
error_occurred=1
4958
fi
5059
if [[ ${#testing_done} -lt $MIN_CHARS ]]; then
51-
echo "PR description for testing section are either missing or too short."
60+
echo "PR description for testing section are either missing or too short. Required: ${MIN_CHARS}, Current: ${testing_done}"
5261
error_occurred=1
5362
fi
5463
if [[ $error_occurred -eq 1 ]]; then
55-
exit 1
64+
exit 1
5665
fi

CMake/Dependencies/libkvsCommonLws-CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include(ExternalProject)
66

77
ExternalProject_Add(libkvsCommonLws-download
88
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git
9-
GIT_TAG v1.5.3
9+
GIT_TAG v1.5.4
1010
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
1111
LIST_SEPARATOR |
1212
CMAKE_ARGS
@@ -19,6 +19,7 @@ ExternalProject_Add(libkvsCommonLws-download
1919
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
2020
-DUSE_OPENSSL=${USE_OPENSSL}
2121
-DUSE_MBEDTLS=${USE_MBEDTLS}
22+
-DKVS_DEFAULT_STACK_SIZE=${KVS_DEFAULT_STACK_SIZE}
2223
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
2324
-DBUILD_STATIC=${BUILD_STATIC}
2425
BUILD_ALWAYS TRUE

CMakeLists.txt

+20-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(CheckIncludeFiles)
55
include(CheckFunctionExists)
66

77
# The version MUST be updated before every release
8-
project(KinesisVideoWebRTCClient VERSION 1.11.0 LANGUAGES C)
8+
project(KinesisVideoWebRTCClient VERSION 1.12.0 LANGUAGES C)
99

1010
# User Flags
1111
option(ADD_MUCLIBC "Add -muclibc c flag" OFF)
@@ -21,6 +21,7 @@ option(ENABLE_DATA_CHANNEL "Enable support for data channel" ON)
2121
option(ENABLE_KVS_THREADPOOL "Enable support for KVS thread pool in signaling" OFF)
2222
option(INSTRUMENTED_ALLOCATORS "Enable memory instrumentation" OFF)
2323
option(ENABLE_AWS_SDK_IN_TESTS "Enable support for compiling AWS SDKs for tests" ON)
24+
option(ENABLE_STATS_CALCULATION_CONTROL "Enable support for runtime control of ice agent stat calculations." OFF)
2425

2526
# Developer Flags
2627
option(BUILD_TEST "Build the testing tree." OFF)
@@ -53,6 +54,18 @@ add_definitions(-DSDK_VERSION=\"${GIT_COMMIT_HASH}\")
5354
add_definitions(-DVERSION_STRING=\"${PROJECT_VERSION}\")
5455
add_definitions(-DDETECTED_GIT_HASH)
5556

57+
if(NOT KVS_STACK_SIZE OR KVS_STACK_SIZE STREQUAL "")
58+
message(STATUS "Stack size is system default stack size")
59+
else()
60+
string(REGEX MATCH "^[0-9]+$" IS_KVS_STACK_SIZE_A_NUMBER "${KVS_STACK_SIZE}")
61+
if(IS_KVS_STACK_SIZE_A_NUMBER)
62+
message(STATUS "Setting default stack size to provided value: ${KVS_STACK_SIZE} bytes")
63+
set(KVS_DEFAULT_STACK_SIZE ${KVS_STACK_SIZE})
64+
else()
65+
message(FATAL_ERROR "KVS_STACK_SIZE must be a numeric value, but got: ${KVS_STACK_SIZE}")
66+
endif()
67+
endif()
68+
5669
if(NOT OPEN_SRC_INSTALL_PREFIX OR OPEN_SRC_INSTALL_PREFIX STREQUAL "")
5770
set(OPEN_SRC_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/open-source" CACHE PATH "Libraries will be downloaded and built in this directory.")
5871
else()
@@ -115,6 +128,10 @@ if (ENABLE_KVS_THREADPOOL)
115128
add_definitions(-DENABLE_KVS_THREADPOOL)
116129
endif()
117130

131+
if (ENABLE_STATS_CALCULATION_CONTROL)
132+
add_definitions(-DENABLE_STATS_CALCULATION_CONTROL)
133+
endif()
134+
118135
if(USE_OPENSSL)
119136
add_definitions(-DKVS_USE_OPENSSL)
120137
elseif(USE_MBEDTLS)
@@ -254,6 +271,7 @@ set(BUILD_ARGS
254271
-DBUILD_STATIC=${BUILD_STATIC_LIBS}
255272
-DUSE_OPENSSL=${USE_OPENSSL}
256273
-DUSE_MBEDTLS=${USE_MBEDTLS}
274+
-DKVS_DEFAULT_STACK_SIZE=${KVS_DEFAULT_STACK_SIZE}
257275
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
258276
build_dependency(kvsCommonLws ${BUILD_ARGS})
259277

@@ -386,6 +404,7 @@ endif()
386404
file(GLOB WEBRTC_SIGNALING_CLIENT_SOURCE_FILES "src/source/Signaling/*.c")
387405

388406

407+
message(STATUS "OPEN_SRC_INSTALL_PREFIX: ${OPEN_SRC_INSTALL_PREFIX}")
389408
include_directories(${OPEN_SRC_INCLUDE_DIRS})
390409
include_directories(${OPEN_SRC_INSTALL_PREFIX}/include)
391410
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/include)

README.md

+65-29
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,21 @@ Please refer to the release notes in [Releases](https://github.com/awslabs/amazo
5757
### Download
5858
To download run the following command:
5959

60-
`git clone --recursive https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git`
60+
```shell
61+
git clone https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git --single-branch -b main kvs-webrtc-sdk
62+
```
6163

6264
You will also need to install `pkg-config` and `CMake` and a build environment
6365

6466
### Configuring on Ubuntu / Unix
6567

6668
Create a build directory in the newly checked out repository, and execute CMake from it.
6769

68-
`mkdir -p amazon-kinesis-video-streams-webrtc-sdk-c/build; cd amazon-kinesis-video-streams-webrtc-sdk-c/build; cmake .. `
70+
```shell
71+
mkdir -p kvs-webrtc-sdk/build; cd kvs-webrtc-sdk/build; cmake ..
72+
```
6973

70-
We have provided an example of using GStreamer to capture/encode video, and then send via this library. This is only build if `pkg-config` finds
74+
We have provided an example of using GStreamer to capture/encode video, and then send via this library. This is only built if `pkg-config` finds
7175
GStreamer is installed on your system.
7276

7377
On Ubuntu and Raspberry Pi OS you can get the libraries by running
@@ -136,7 +140,7 @@ If you wish to cross-compile `CC` and `CXX` are respected when building the libr
136140
If `-DBUILD_STATIC_LIBS=TRUE` then all dependencies and KVS WebRTC libraries will be built as static libraries.
137141

138142
#### CMake Arguments
139-
You can pass the following options to `cmake ..`.
143+
You can pass the following options to `cmake ..`:
140144

141145
* `-DBUILD_SAMPLE` -- Build the sample executables. ON by default.
142146
* `-DIOT_CORE_ENABLE_CREDENTIALS` -- Build the sample applications using IoT credentials. OFF by default.
@@ -157,6 +161,10 @@ You can pass the following options to `cmake ..`.
157161
* `-DLINK_PROFILER` -- Link with gperftools (available profiler options are listed [here](https://github.com/gperftools/gperftools))
158162
* `-DPKG_CONFIG_EXECUTABLE` -- Set pkg config path. This might be required to find gstreamer's pkg config specifically on Windows.
159163
* `-DENABLE_KVS_THREADPOOL` -- Enable the KVS threadpool which is off by default.
164+
* `-DENABLE_STATS_CALCULATION_CONTROL` -- Enable the runtime control of ICE agent stats calculations.
165+
166+
These options get propagated to [PIC](https://github.com/awslabs/amazon-kinesis-video-streams-pic):
167+
* `-DKVS_STACK_SIZE` -- Default stack size for threads created using THREAD_CREATE(), in bytes.
160168

161169
To clean up the `open-source` and `build` folders from previous build, use `cmake --build . --target clean` from the `build` folder
162170

@@ -369,6 +377,43 @@ If using the WebRTC SDK Test Page, set the following values using the same AWS c
369377

370378
Then choose Start Viewer to start live video streaming of the sample H264/Opus frames.
371379

380+
## Memory optimization switches
381+
382+
Starting with v1.11.0, the SDK provides some knobs to optimize memory usage to tailor to platform needs and resources
383+
384+
### Controlling RTP rolling buffer capacity
385+
386+
The SDK maintains an RTP rolling buffer to hold the RTP packets. This is useful to respond to NACKs and even in case of JitterBuffer. The rolling buffer size is controlled by 3 parameters:
387+
1. MTU: This is set to a default of 1200 bytes
388+
2. Buffer duration: This is the amount of time of media that you would like the rolling buffer to accommodate before it is overwritten due to buffer overflow. By default, the SDK sets this to 3 seconds
389+
3. Highest expected bitrate: This is the expected bitrate of the media in question. The typical bitrates could vary based on resolution and codec. By default, the SDK sets this to 5 mibps for video and 1 mibps for audio
390+
391+
The rolling buffer capacity is calculated as follows:
392+
```
393+
Capacity = Buffer duration * highest expected bitrate (in bips) / 8 / MTU
394+
395+
With buffer duration = 1 second, Highest expected bitrate = 5 mibps and MTU 1200 bytes, capacity = 546 RTP packets
396+
```
397+
398+
The rolling buffer size can be configured per transceiver using the `configureTransceiverRollingBuffer` API. Make sure to use the API after the addTransceiver call to ensure the `RtcMediaStreamTrack` and `KvsRtpTransceiver` objects are created. By default, the rolling buffer duration is set to 3 sec and bitrate is set to 5mibps for video and 1mibps for audio.
399+
400+
The rolling buffer config parameters are as follows:
401+
```
402+
rollingBufferDurationSec = <duration in seconds>, must be more than 100ms and less than 10 seconds
403+
rollingBufferBitratebps = <bitrate in bits/sec>, must be more than 100kibits/sec and less than 240 mibps
404+
```
405+
406+
For example, if we want to set duration to 200ms and bitrate to 150kibps:
407+
```c
408+
PRtcRtpTransceiver pVideoRtcRtpTransceiver;
409+
RtcMediaStreamTrack videoTrack;
410+
videoTrack.kind = MEDIA_STREAM_TRACK_KIND_VIDEO;
411+
videoTrack.codec = RTC_CODEC_H264_PROFILE_42E01F_LEVEL_ASYMMETRY_ALLOWED_PACKETIZATION_MODE;
412+
CHK_STATUS(configureTransceiverRollingBuffer(pVideoRtcRtpTransceiver, &videoTrack, 0.2, 150 * 1024));
413+
```
414+
By setting these up, applications can have better control over the amount of memory that the application consumes. However, note, if the allocation is too small and the network bad leading to multiple nacks, it can lead to choppy media / dropped frames. Hence, care must be taken while deciding on the values to ensure the parameters satisfy necessary performance requirements.
415+
For more information, check the sample to see how these values are set up.
416+
372417
## Setup IoT
373418
* To use IoT certificate to authenticate with KVS signaling, please refer to [Controlling Access to Kinesis Video Streams Resources Using AWS IoT](https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/how-iot.html) for provisioning details.
374419
* A sample IAM policy for the IoT role looks like below, policy can be modified based on your permission requirement.
@@ -545,31 +590,8 @@ By default, the threadpool starts with 3 threads that it will increase up to the
545590
1. `export AWS_KVS_WEBRTC_THREADPOOL_MIN_THREADS=<value>`
546591
2. `export AWS_KVS_WEBRTC_THREADPOOL_MAX_THREADS=<value>`
547592

548-
### Set up TWCC
549-
TWCC is a mechanism in WebRTC designed to enhance the performance and reliability of real-time communication over the Internet. TWCC addresses the challenges of network congestion by providing detailed feedback on the transport of packets across the network, enabling adaptive bitrate control and optimization of
550-
media streams in real-time. This feedback mechanism is crucial for maintaining high-quality audio and video communication, as it allows senders to adjust their transmission strategies based on comprehensive information about packet losses, delays, and jitter experienced across the entire transport path.
551-
The importance of TWCC in WebRTC lies in its ability to ensure efficient use of available network bandwidth while minimizing the negative impacts of network congestion. By monitoring the delivery of packets across the network, TWCC helps identify bottlenecks and adjust the media transmission rates accordingly.
552-
This dynamic approach to congestion control is essential for preventing degradation in call quality, such as pixelation, stuttering, or drops in audio and video streams, especially in environments with fluctuating network conditions. To learn more about TWCC, you can refer to the [RFC draft](https://datatracker.ietf.org/doc/html/draft-holmer-rmcat-transport-wide-cc-extensions-01)
553-
554-
In order to enable TWCC usage in the SDK, 2 things need to be set up:
555-
556-
1. Set the `disableSenderSideBandwidthEstimation` to FALSE. In our samples, the value is set using `enableTwcc` flag in `pSampleConfiguration`
557-
558-
```c
559-
pSampleConfiguration->enableTwcc = TRUE; // to enable TWCC
560-
pSampleConfiguration->enableTwcc = FALSE; // to disable TWCC
561-
configuration.kvsRtcConfiguration.disableSenderSideBandwidthEstimation = !pSampleConfiguration->enableTwcc;
562-
```
563-
564-
2. Set the callback that will have the business logic to modify the bitrate based on packet loss information. The callback can be set using `peerConnectionOnSenderBandwidthEstimation()`.
565-
566-
```c
567-
CHK_STATUS(peerConnectionOnSenderBandwidthEstimation(pSampleStreamingSession->pPeerConnection, (UINT64) pSampleStreamingSession,
568-
sampleSenderBandwidthEstimationHandler));
569-
```
570-
571-
By default, our SDK enables TWCC listener. The SDK has a sample implementation to integrate TWCC into the Gstreamer pipeline via the `sampleSenderBandwidthEstimationHandler` callback. To get more details, look for this specific callback.
572-
593+
### Thread stack sizes
594+
The default thread stack size in the KVS WebRTC SDK is determined by the system's default configuration. Developers can modify the stack size for all threads created using the `THREAD_CREATE()` macro by specifying the desired value through the `-DKVS_STACK_SIZE` CMake flag. Additionally, stack sizes for individual threads can be customized using the `THREAD_CREATE_WITH_PARAMS()` macro. Notable stack sizes that may need to be changed for your specific application will be the ConnectionListener Receiver thread and the media sender threads.
573595

574596
### Setting ICE related timeouts
575597

@@ -589,6 +611,20 @@ Let us look into when each of these could be changed:
589611
3. `iceConnectionCheckTimeout`: It is useful to increase this timeout in unstable/slow network where the packet exchange takes time and hence the binding request/response. Essentially, increasing it will allow atleast one candidate pair to be tried for nomination by the other peer.
590612
4. `iceConnectionCheckPollingInterval`: This value is set to a default of 50 ms per [spec](https://datatracker.ietf.org/doc/html/rfc8445#section-14.2). Changing this would change the frequency of connectivity checks and essentially, the ICE state machine transitions. Decreasing the value could help in faster connection establishment in a reliable high performant network setting with good system resources. Increasing the value could help in reducing the network load, however, the connection establishment could slow down. Unless there is a strong reasoning, it is **NOT** recommended to deviate from spec/default.
591613

614+
### Enable ICE agent stats
615+
616+
The SDK calculates 4 different stats:
617+
1. ICE server stats - stats for ICE servers the SDK is using
618+
2. [Local candidate stats](https://www.w3.org/TR/webrtc-stats/#dom-rtcstatstype-local-candidate) - stats for the selected local candidate
619+
3. [Remote candidate stats](https://www.w3.org/TR/webrtc-stats/#dom-rtcstatstype-remote-candidate) - stats for the selected remote candidate
620+
4. [Candidate pair stats](https://www.w3.org/TR/webrtc-stats/#dom-rtcstatstype-candidate-pair) - stats for the selected candidate pair
621+
622+
For more information on these stats, refer to [AWS Docs](https://docs.aws.amazon.com/kinesisvideostreams-webrtc-dg/latest/devguide/kvswebrtc-reference.html)
623+
624+
The SDK enables generating these stats by default. To control whether the SDK calculates these stats, the ENABLE_STATS_CALCULATION_CONTROL CMake option must be set, enabling the use of the following field:
625+
`configuration.kvsRtcConfiguration.enableIceStats = FALSE`.
626+
Disabling these stats may lead to reductions in memory use.
627+
592628
## Documentation
593629
All Public APIs are documented in our [Include.h](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/main/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h), we also generate a [Doxygen](https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/) each commit for easier navigation.
594630

0 commit comments

Comments
 (0)