diff --git a/CMakeLists.txt b/CMakeLists.txt index aae7c136f0..26b1f9ba27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,8 +195,6 @@ 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 .) @@ -204,7 +202,6 @@ 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}) diff --git a/README.md b/README.md index d0b23c80b6..ed2c057ee8 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/samples/Common.c b/samples/Common.c index 3b6ec2dc5b..c5b920a539 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -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; } diff --git a/samples/Samples.h b/samples/Samples.h index 5561c0f3fc..6048dfb07a 100644 --- a/samples/Samples.h +++ b/samples/Samples.h @@ -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, @@ -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; diff --git a/samples/kvsWebRTCClientMaster.c b/samples/kvsWebRTCClientMaster.c index f3e3bddb00..d3a481da01 100644 --- a/samples/kvsWebRTCClientMaster.c +++ b/samples/kvsWebRTCClientMaster.c @@ -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, @@ -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; @@ -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); diff --git a/samples/kvsWebRTCClientMasterGstreamerSample.c b/samples/kvsWebRTCClientMasterGstreamerSample.c index 3d093ef81b..0dd1941872 100644 --- a/samples/kvsWebRTCClientMasterGstreamerSample.c +++ b/samples/kvsWebRTCClientMasterGstreamerSample.c @@ -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; @@ -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); diff --git a/samples/kvsWebRTCClientViewer.c b/samples/kvsWebRTCClientViewer.c index a070cad6f4..489f1de3c4 100644 --- a/samples/kvsWebRTCClientViewer.c +++ b/samples/kvsWebRTCClientViewer.c @@ -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) { @@ -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) {