You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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>
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
+
28
37
# Define minimum character count for each section
29
-
MIN_CHARS=25
38
+
MIN_CHARS=10
30
39
31
40
# 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
38
47
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}"
40
49
error_occurred=1
41
50
fi
42
51
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}"
44
53
error_occurred=1
45
54
fi
46
55
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}"
48
57
error_occurred=1
49
58
fi
50
59
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}"
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
71
75
GStreamer is installed on your system.
72
76
73
77
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
136
140
If `-DBUILD_STATIC_LIBS=TRUE` then all dependencies and KVS WebRTC libraries will be built as static libraries.
137
141
138
142
#### CMake Arguments
139
-
You can pass the following options to `cmake ..`.
143
+
You can pass the following options to `cmake ..`:
140
144
141
145
*`-DBUILD_SAMPLE` -- Build the sample executables. ON by default.
142
146
*`-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 ..`.
157
161
*`-DLINK_PROFILER` -- Link with gperftools (available profiler options are listed [here](https://github.com/gperftools/gperftools))
158
162
*`-DPKG_CONFIG_EXECUTABLE` -- Set pkg config path. This might be required to find gstreamer's pkg config specifically on Windows.
159
163
*`-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.
160
168
161
169
To clean up the `open-source` and `build` folders from previous build, use `cmake --build . --target clean` from the `build` folder
162
170
@@ -369,6 +377,43 @@ If using the WebRTC SDK Test Page, set the following values using the same AWS c
369
377
370
378
Then choose Start Viewer to start live video streaming of the sample H264/Opus frames.
371
379
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:
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
+
372
417
## Setup IoT
373
418
* 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.
374
419
* 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
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
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()`.
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.
573
595
574
596
### Setting ICE related timeouts
575
597
@@ -589,6 +611,20 @@ Let us look into when each of these could be changed:
589
611
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.
590
612
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.
591
613
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:
Disabling these stats may lead to reductions in memory use.
627
+
592
628
## Documentation
593
629
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.
0 commit comments