Skip to content

Commit

Permalink
Introducing profiling of code sections and APIs (#1755)
Browse files Browse the repository at this point in the history
* Adds RTSP Source to GStreamer Sample (#1740)

* Adds rtsp source support, modifies source-type determination

* All use cases tested and debugged.

* Clang formatting.

* Clang formatting.

* Updates credentials configuration to fix sample-check error.

* Sample-check fix attempt #2

* Sample-check fix attempt 3

* Sample-check fix attempt 4

* Sample-check fix attempt

* ""

* " "

* " "

* " "

* Update README.md

* Updates sample run instructions structure, adds RTSP source instructions

* Update README.md

* Renames sample file to be same as executable, updates CMakeLists to reflect this.

* Update README.md

Co-authored-by: Niyati Maheshwari <niyatim23@gmail.com>

* Update README.md

* Updates usage statement to new sample executable name

---------

Co-authored-by: Niyati Maheshwari <niyatim23@gmail.com>

* Connection timeout sleep (#1744)

* Remove thread_detach and looping sleep, add thread_join

* Added support for socketpair() and added it to connectionlistener

* Clang formatting

* Fix test that previously expected TID to be invalid

* remove unused variables

* Fixing incorrect typing on comparison

* clang formatting

* strlen -> STRLEN macro

* Off by 1 error in poll rfds

* clang formatting

* Fix comment typo regarding default source in Gst sample (#1750)

* Initial commit

* New structures to track signaling latency in diagnostics

* Make peer connection stats accessible in application

* Fix ice agent profling to store in variables, new APIs for getting ice agent metrics

* Profile create peer connection

* Macro fixes

* More macro fix

---------

Co-authored-by: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com>
Co-authored-by: Niyati Maheshwari <niyatim23@gmail.com>
Co-authored-by: jdelapla <delaplan@amazon.com>
  • Loading branch information
4 people authored Jul 31, 2023
1 parent 95020ba commit 863a1a4
Show file tree
Hide file tree
Showing 26 changed files with 745 additions and 617 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<h4 align="center">Pure C WebRTC Client for Amazon Kinesis Video Streams </h4>

<p align="center">
<a href="https://travis-ci.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c"> <img src="https://travis-ci.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.svg?branch=master" alt="Build Status"> </a>
<a href="https://codecov.io/gh/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c"> <img src="https://codecov.io/gh/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/branch/master/graph/badge.svg" alt="Coverage Status"> </a>
</p>

Expand Down Expand Up @@ -164,7 +163,7 @@ export AWS_SESSION_TOKEN=<session token>
export AWS_DEFAULT_REGION= <AWS region>
```

### Setup desired log level:
### Setup logging:
Set up the desired log level. The log levels and corresponding values currently available are:
1. `LOG_LEVEL_VERBOSE` ---- 1
2. `LOG_LEVEL_DEBUG` ---- 2
Expand All @@ -186,12 +185,23 @@ export AWS_KVS_LOG_LEVEL = 2 switches on DEBUG level logs while runnning the sam

Note: The default log level is `LOG_LEVEL_WARN`.

* Optionally, set path to SSL CA certificate with variable (`../certs/cert.pem` is default one and points to file in this repository):
Starting v1.7.x (**TO_BE_UPDATED**), by default, the SDK creates a log file that would have execution timing details of certain steps in connection establishment. It would be stored in the `build` directory as `kvsFileLogFilter.x`. In case you do not want to use defaults, you can modify certain parameters such as log file directory, log file size and file rotation index in the `createFileLoggerWithLevelFiltering` function in the samples.
In addition to these logs, if you would like to have other level logs in a file as well, run:

```
export AWS_ENABLE_FILE_LOGGING=TRUE
```

### Set path to SSL CA certificate (**Optional**)

If you have a custom CA certificate path to set, you can set it using:

```
export AWS_KVS_CACERT_PATH=../certs/cert.pem
```

By defaut, the SSL CA certificate is set to `../certs/cert.pem` which points to the file in this repository:

### Running the Samples
After executing `make` you will have sample applications in your `build/samples` directory. From the `build/` directory, run any of the sample applications by passing to it the name of your signaling channel. If a signaling channel does not exist with the name you provide, the application creates one.

Expand Down Expand Up @@ -298,11 +308,6 @@ In the mbedTLS version, the SDK uses /dev/urandom on Unix and CryptGenRandom API
If you would like to print out the SDPs, run this command:
`export DEBUG_LOG_SDP=TRUE`

### File logging
If you would like to enable file logging, run this command:
`export AWS_ENABLE_FILE_LOGGING=TRUE`
You can also change settings such as buffer size, number of log files for rotation and log file path in the samples

### Adjust MTU
If ICE connection can be established successfully but media can not be transferred, make sure the actual MTU is higher than the MTU setting here: https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/master/src/source/PeerConnection/Rtp.h#L12.

Expand Down
143 changes: 99 additions & 44 deletions samples/Common.c

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions samples/Samples.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {

#define CA_CERT_PEM_FILE_EXTENSION ".pem"

#define FILE_LOGGING_BUFFER_SIZE (100 * 1024)
#define FILE_LOGGING_BUFFER_SIZE (10 * 1024)
#define MAX_NUMBER_OF_LOG_FILES 5

#define SAMPLE_HASH_TABLE_BUCKET_COUNT 50
Expand Down Expand Up @@ -110,6 +110,7 @@ typedef struct {
startRoutine videoSource;
startRoutine receiveAudioVideoSource;
RtcOnDataChannel onDataChannel;
SignalingClientMetrics signalingClientMetrics;

PStackQueue pPendingSignalingMessageForRemoteClient;
PHashTable pRtcPeerConnectionForRemoteClient;
Expand All @@ -134,6 +135,7 @@ typedef struct {
PStackQueue pregeneratedCertificates; // Max MAX_RTCCONFIGURATION_CERTIFICATES certificates

PCHAR rtspUri;
UINT32 logLevel;
} SampleConfiguration, *PSampleConfiguration;

typedef struct {
Expand All @@ -148,6 +150,7 @@ struct __SampleStreamingSession {
volatile ATOMIC_BOOL terminateFlag;
volatile ATOMIC_BOOL candidateGatheringDone;
volatile ATOMIC_BOOL peerIdReceived;
volatile ATOMIC_BOOL firstFrame;
volatile SIZE_T frameIndex;
PRtcPeerConnection pPeerConnection;
PRtcRtpTransceiver pVideoRtcRtpTransceiver;
Expand All @@ -158,15 +161,16 @@ struct __SampleStreamingSession {
UINT64 videoTimestamp;
CHAR peerId[MAX_SIGNALING_CLIENT_ID_LEN + 1];
TID receiveAudioVideoSenderTid;
UINT64 offerReceiveTime;
UINT64 startUpLatency;
BOOL firstFrame;
RtcMetricsHistory rtcMetricsHistory;
BOOL remoteCanTrickleIce;

// this is called when the SampleStreamingSession is being freed
StreamSessionShutdownCallback shutdownCallback;
UINT64 shutdownCallbackCustomData;
UINT64 offerReceiveTime;
PeerConnectionMetrics peerConnectionMetrics;
KvsIceAgentMetrics iceMetrics;
};

VOID sigintHandler(INT32);
Expand All @@ -178,7 +182,7 @@ PVOID sampleReceiveAudioVideoFrame(PVOID);
PVOID getPeriodicIceCandidatePairStats(PVOID);
STATUS getIceCandidatePairStatsCallback(UINT32, UINT64, UINT64);
STATUS pregenerateCertTimerCallback(UINT32, UINT64, UINT64);
STATUS createSampleConfiguration(PCHAR, SIGNALING_CHANNEL_ROLE_TYPE, BOOL, BOOL, PSampleConfiguration*);
STATUS createSampleConfiguration(PCHAR, SIGNALING_CHANNEL_ROLE_TYPE, BOOL, BOOL, UINT32, PSampleConfiguration*);
STATUS freeSampleConfiguration(PSampleConfiguration*);
STATUS signalingClientStateChanged(UINT64, SIGNALING_CLIENT_STATE);
STATUS signalingMessageReceived(UINT64, PReceivedSignalingMessage);
Expand Down Expand Up @@ -208,7 +212,9 @@ STATUS freeMessageQueue(PPendingMessageQueue);
STATUS submitPendingIceCandidate(PPendingMessageQueue, PSampleStreamingSession);
STATUS removeExpiredMessageQueues(PStackQueue);
STATUS getPendingMessageQueueForHash(PStackQueue, UINT64, BOOL, PPendingMessageQueue*);
STATUS initSignaling(PSampleConfiguration, PCHAR);
BOOL sampleFilterNetworkInterfaces(UINT64, PCHAR);
UINT32 setLogLevel();

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 863a1a4

Please sign in to comment.