Skip to content

Commit

Permalink
Merge pull request #544 from awslabs/add_file_logging_capability_in_s…
Browse files Browse the repository at this point in the history
…amples

Add file logging option in samples and cmake cleanUp
  • Loading branch information
disa6302 committed Jun 12, 2020
2 parents 33fc27d + 1541273 commit f0ff7e6
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 5 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,13 @@ file(

file(GLOB WEBRTC_SIGNALING_CLIENT_SOURCE_FILES "src/source/Signaling/*.c")

file(GLOB PIC_HEADERS "${KINESIS_VIDEO_PIC_SRC}/src/*/include")

file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/opusSampleFrames" DESTINATION .)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/h264SampleFrames" DESTINATION .)

include_directories(${OPEN_SRC_INCLUDE_DIRS})
include_directories(${OPEN_SRC_INSTALL_PREFIX}/include)
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/include)
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/ice)
include_directories(${KINESIS_VIDEO_PRODUCER_C_SRC}/src/include)

add_library(kvsWebrtcClient ${LINKAGE} ${WEBRTC_CLIENT_SOURCE_FILES})

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ configuration.certificates[0].pPrivateKey = pSampleConfiguration->rtcConfig.cert
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

## Documentation
All Public APIs are documented in our [Include.h](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/master/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.

Expand Down
5 changes: 4 additions & 1 deletion samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,10 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE
CHK_ERR((pAccessKey = getenv(ACCESS_KEY_ENV_VAR)) != NULL, STATUS_INVALID_OPERATION, "AWS_ACCESS_KEY_ID must be set");
CHK_ERR((pSecretKey = getenv(SECRET_KEY_ENV_VAR)) != NULL, STATUS_INVALID_OPERATION, "AWS_SECRET_ACCESS_KEY must be set");
pSessionToken = getenv(SESSION_TOKEN_ENV_VAR);

pSampleConfiguration->enableFileLogging = FALSE;
if(NULL != getenv(ENABLE_FILE_LOGGING)) {
pSampleConfiguration->enableFileLogging = TRUE;
}
if ((pSampleConfiguration->channelInfo.pRegion = getenv(DEFAULT_REGION_ENV_VAR)) == NULL) {
pSampleConfiguration->channelInfo.pRegion = DEFAULT_AWS_REGION;
}
Expand Down
4 changes: 4 additions & 0 deletions samples/Samples.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ extern "C" {
#define ICE_CONFIG_INFO_POLL_PERIOD (20 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND)

#define CA_CERT_PEM_FILE_EXTENSION ".pem"

#define FILE_LOGGING_BUFFER_SIZE (100 * 1024)
#define MAX_NUMBER_OF_LOG_FILES 5
typedef enum {
SAMPLE_STREAMING_VIDEO_ONLY,
SAMPLE_STREAMING_AUDIO_VIDEO,
Expand Down Expand Up @@ -64,6 +67,7 @@ typedef struct {
CVAR cvar;
BOOL trickleIce;
BOOL useTurn;
BOOL enableFileLogging;
UINT64 customData;
PSampleStreamingSession sampleStreamingSessionList[DEFAULT_MAX_CONCURRENT_STREAMING_SESSION];
UINT32 streamingSessionCount;
Expand Down
13 changes: 12 additions & 1 deletion samples/kvsWebRTCClientMaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ INT32 main(INT32 argc, CHAR *argv[])

// do tricketIce by default
printf("[KVS Master] Using trickleICE by default\n");

retStatus = createSampleConfiguration(argc > 1 ? argv[1] : SAMPLE_CHANNEL_NAME,
SIGNALING_CHANNEL_ROLE_TYPE_MASTER,
TRUE,
Expand All @@ -29,6 +28,15 @@ INT32 main(INT32 argc, CHAR *argv[])

printf("[KVS Master] Created signaling channel %s\n", (argc > 1 ? argv[1] : SAMPLE_CHANNEL_NAME));

if(pSampleConfiguration->enableFileLogging) {
retStatus = createFileLogger(FILE_LOGGING_BUFFER_SIZE, MAX_NUMBER_OF_LOG_FILES,
(PCHAR) FILE_LOGGER_LOG_FILE_DIRECTORY_PATH, TRUE, TRUE, NULL);
if(retStatus != STATUS_SUCCESS) {
printf("[KVS Master] createFileLogger(): operation returned status code: 0x%08x \n", retStatus);
pSampleConfiguration->enableFileLogging = FALSE;
}
}

// Set the audio and video handlers
pSampleConfiguration->audioSource = sendAudioPackets;
pSampleConfiguration->videoSource = sendVideoPackets;
Expand Down Expand Up @@ -120,6 +128,9 @@ INT32 main(INT32 argc, CHAR *argv[])
THREAD_JOIN(pSampleConfiguration->audioSenderTid, NULL);
}

if(pSampleConfiguration->enableFileLogging) {
freeFileLogger();
}
retStatus = freeSignalingClient(&pSampleConfiguration->signalingClientHandle);
if(retStatus != STATUS_SUCCESS) {
printf("[KVS Master] freeSignalingClient(): operation returned status code: 0x%08x", retStatus);
Expand Down
12 changes: 12 additions & 0 deletions samples/kvsWebRTCClientMasterGstreamerSample.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,15 @@ INT32 main(INT32 argc, CHAR *argv[])

printf("[KVS GStreamer Master] Created signaling channel %s\n", (argc > 1 ? argv[1] : SAMPLE_CHANNEL_NAME));

if(pSampleConfiguration->enableFileLogging) {
retStatus = createFileLogger(FILE_LOGGING_BUFFER_SIZE, MAX_NUMBER_OF_LOG_FILES,
(PCHAR) FILE_LOGGER_LOG_FILE_DIRECTORY_PATH, TRUE, TRUE, NULL);
if(retStatus != STATUS_SUCCESS) {
printf("[KVS Master] createFileLogger(): operation returned status code: 0x%08x \n", retStatus);
pSampleConfiguration->enableFileLogging = FALSE;
}
}

pSampleConfiguration->videoSource = sendGstreamerAudioVideo;
pSampleConfiguration->mediaType = SAMPLE_STREAMING_VIDEO_ONLY;
pSampleConfiguration->receiveAudioVideoSource = receiveGstreamerAudioVideo;
Expand Down Expand Up @@ -457,6 +466,9 @@ INT32 main(INT32 argc, CHAR *argv[])
THREAD_JOIN(pSampleConfiguration->videoSenderTid, NULL);
}

if(pSampleConfiguration->enableFileLogging) {
freeFileLogger();
}
retStatus = freeSignalingClient(&pSampleConfiguration->signalingClientHandle);
if(retStatus != STATUS_SUCCESS) {
printf("[KVS GStreamer Master] freeSignalingClient(): operation returned status code: 0x%08x \n", retStatus);
Expand Down
12 changes: 12 additions & 0 deletions samples/kvsWebRTCClientViewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ INT32 main(INT32 argc, CHAR *argv[])

printf("[KVS Viewer] Created signaling channel %s\n", (argc > 1 ? argv[1] : SAMPLE_CHANNEL_NAME));

if(pSampleConfiguration->enableFileLogging) {
retStatus = createFileLogger(FILE_LOGGING_BUFFER_SIZE, MAX_NUMBER_OF_LOG_FILES,
(PCHAR) FILE_LOGGER_LOG_FILE_DIRECTORY_PATH, TRUE, TRUE, NULL);
if(retStatus != STATUS_SUCCESS) {
printf("[KVS Master] createFileLogger(): operation returned status code: 0x%08x \n", retStatus);
pSampleConfiguration->enableFileLogging = FALSE;
}
}

// Initialize KVS WebRTC. This must be done before anything else, and must only be done once.
retStatus = initKvsWebRtc();
if(retStatus != STATUS_SUCCESS) {
Expand Down Expand Up @@ -173,6 +182,9 @@ INT32 main(INT32 argc, CHAR *argv[])
MUTEX_UNLOCK(pSampleConfiguration->sampleConfigurationObjLock);
}

if(pSampleConfiguration->enableFileLogging) {
freeFileLogger();
}
if (pSampleConfiguration != NULL) {
retStatus = freeSignalingClient(&pSampleConfiguration->signalingClientHandle);
if(retStatus != STATUS_SUCCESS) {
Expand Down

0 comments on commit f0ff7e6

Please sign in to comment.