Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing profiling of code sections and APIs #1755

Merged
merged 10 commits into from
Jul 31, 2023
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