Skip to content

Commit

Permalink
Release 1 7 0 (#1354)
Browse files Browse the repository at this point in the history
* Log ice candidate protocol appropriately (#1230)

* Log ice candidate protocol appropriately

* Add develop to travis CI

* Address comments

* Realign branches during transition (#1257)

* create data channel sample (#1203)

* create data channel sample

* moved variables to Samples.h, encapsulated with ENABLE_DATA_CHANNEL directive

* removed unused variables, moved variable declarations to the top of a block

* create data channel sample

* moved variables to Samples.h, encapsulated with ENABLE_DATA_CHANNEL directive

* Cancel the thread once mediaThreadStarted flag is set to false (#1227)

* Initial stale PR template (#1226)

* Update stale issue template

* Testing every minute

* Fix stale issue PR template (#1234)

No code changed. Just a template change. So merging

* Add bug and question label

* Switch stale PR action to daily cadence

* [FIX] When protocol in DCEP header of data channel open command is not empty, there is a check preventing the data channel to be opened. Now protocol length is correctly handled to avoid check failing. (#1228)

Co-authored-by: Niyati Maheshwari <[email protected]>
Co-authored-by: Divya Sampath Kumar <[email protected]>
Co-authored-by: ela34 <[email protected]>

* set protocol value following the spec (#1259)

Co-authored-by: liyufang <[email protected]>

* filter out invalid candidate in sdp (#1260)

Co-authored-by: liyufang <[email protected]>

* Added targets for cmake clean (#1253)

* added targets for cmake clean

* added new line, updated readme

* added missing new line

* updated readme to include folder details

* updated readme to include folder details

* viewer sample: wrap datachannel callback with `ENABLE_DATA_CHANNEL` (#1261)

* create data channel sample (#1203)

* create data channel sample

* moved variables to Samples.h, encapsulated with ENABLE_DATA_CHANNEL directive

* removed unused variables, moved variable declarations to the top of a block

* create data channel sample

* moved variables to Samples.h, encapsulated with ENABLE_DATA_CHANNEL directive

* Cancel the thread once mediaThreadStarted flag is set to false (#1227)

* Initial stale PR template (#1226)

* Update stale issue template

* Testing every minute

* Fix stale issue PR template (#1234)

No code changed. Just a template change. So merging

* Add bug and question label

* Switch stale PR action to daily cadence

* [FIX] When protocol in DCEP header of data channel open command is not empty, there is a check preventing the data channel to be opened. Now protocol length is correctly handled to avoid check failing. (#1228)

* viewer sample: wrap datachannel callback with `ENABLE_DATA_CHANNEL`

Signed-off-by: [email protected] <[email protected]>

Co-authored-by: Niyati Maheshwari <[email protected]>
Co-authored-by: Divya Sampath Kumar <[email protected]>
Co-authored-by: ela34 <[email protected]>

* libwebsockets: add patch to fix pipe fd leak issue (#1264)

Signed-off-by: Alex.Li <[email protected]>

* Fix scripts/pare_status.py for non-status #defines (#1268) (#1274)

Co-authored-by: Kevin Allen <[email protected]>

* fix a few bugs

* Revert "fix a few bugs"

This reverts commit 0939024.

* fix some bugs (#1277)

* Fix bugs (#1279)

* fix edge case try to unlock a mutex which is not locked in teh acse the sample config was NULL (#1286)

* cmake: allow user to specify OPEN_SRC_INSTALL_PREFIX (#1293)

Signed-off-by: Alex.Li <[email protected]>

* Fix inconsistent log priority (#1309)

Patch reduces priority of a few info level log messages to verbose
level to be consistent with other functions in file and rest of
code base.

* Modify protocol loggin design in develop (#1311)

* typo: typo fix (#1317)

Signed-off-by: Alex.Li <[email protected]>

* Signaling state machine rework (#1323)

* replaced recursive calls to stepSignalingStateMachine with loops

* removed recursive calls to stepSignalingStateMachine

* replaced stepSignalingstatemachine with signalingStateMachineIterator

* removed stepUntil, continueOnReady; removed status from iterator signature; set signalingclient version; added a lock in refreshIceConfiguration

* changed the declaration for i from int to UINT32

* added signaling version; removed unnecessary comment

* removed redeclaration; changed value in an existing macro

* Fix issue with API call failures being treated as success (#1328)

* return proper error, do not reset call result value

* for non retriable failures, set the terminal exit status for state in… (#1320)

* for non retriable failures, set the terminal exit status for state in state machine

* address comments

* adjust tests set retry max to 1

* Update LwsApiCalls.c

trigger travis ci

* Incorporating PIC state machine level retry changes into webrtc signaling state machine (#1326)

* Incorporating PIC state machine level retry changes into webrtc signaling state machine

* Signaling state machine rework (#1323)

* replaced recursive calls to stepSignalingStateMachine with loops

* removed recursive calls to stepSignalingStateMachine

* replaced stepSignalingstatemachine with signalingStateMachineIterator

* removed stepUntil, continueOnReady; removed status from iterator signature; set signalingclient version; added a lock in refreshIceConfiguration

* changed the declaration for i from int to UINT32

* added signaling version; removed unnecessary comment

* removed redeclaration; changed value in an existing macro

* Fix issue with API call failures being treated as success (#1328)

* return proper error, do not reset call result value

* for non retriable failures, set the terminal exit status for state in… (#1320)

* for non retriable failures, set the terminal exit status for state in state machine

* address comments

* adjust tests set retry max to 1

* Update LwsApiCalls.c

trigger travis ci

* Add retry strategy to client info to avoiud changing create signaling channel API signature

* Incorporating PIC state machine level retry changes into webrtc signaling state machine

* Add retry strategy to client info to avoiud changing create signaling channel API signature

* Adding more debug logs in the code

* fix merge conflicts

* PR feedback

Co-authored-by: Niyati Maheshwari <[email protected]>
Co-authored-by: Hassan Sahibzada <[email protected]>

* Revert " Incorporating PIC state machine level retry changes into webrtc signaling state machine (#1326)" (#1339)

This reverts commit 06bffce.

* Incorporating PIC state machine level retry changes into webrtc signaling state machine (#1341)

* Incorporating PIC state machine level retry changes into webrtc signaling state machine

* Add a n optional check for free retry strategy

* Remove unused goto label

* add missing sleep in get token state machine execute API

* update log line

* Update Producer hash

* Adding a high level retry strategy while creating signaling client

* Add Retry count retrieval in hook (#1335)

* Add Retry count retrieval in hook

* Fix compile issue on travis

* Pull in latest changes in retry structures

* Rebasing off develop with successful travis run for retry

* Log git hash (#1345)

* Log git hash

* Update CMakeLists.txt

white space change to trigger travis

Co-authored-by: Hassan Sahibzada <[email protected]>

* Fix retry count to indicate count only after a retry has occured (#1348)

Fix retry count to indicate count only after a retry has occurred

* add support for automatic clock skew detection and correction (#1344)

* add support for automatic clock skew detection and correction

* auto fix clock skew and add tests

* enable test to check clock recovery

* remove stuff left over from debugging, reset logging default to WARN

* remove unused variable

* get rid of verbose logging in unit tests causes static build to fail due to excessive log output

* simplify code get rid of extra call to length because the lws_hdr_copy returns the same value

* handle null stream track in case of recvonly (#1346)

* handle null stream track in case of recvonly

* a test with null stream track for revconly

* Fix a comment

* whitespace change

* State machine preparation is decoupled from the constructor (#1343)

* Merge master into develop (#1352)

* Missing the public API switch in the other samples (#1356)

* Fix Fetch error retry cases (#1359)

* Fix Fetch error retry cases

* update comment

Co-authored-by: Divya Sampath Kumar <[email protected]>
Co-authored-by: Niyati Maheshwari <[email protected]>
Co-authored-by: ela34 <[email protected]>
Co-authored-by: northteam <[email protected]>
Co-authored-by: liyufang <[email protected]>
Co-authored-by: Alex.D.Scofield <[email protected]>
Co-authored-by: Kevin Allen <[email protected]>
Co-authored-by: Hassan Sahibzada <[email protected]>
Co-authored-by: Chris Hiszpanski <[email protected]>
Co-authored-by: Anurag Katey <[email protected]>
  • Loading branch information
11 people authored Dec 23, 2021
1 parent 4127014 commit 22c9e3d
Show file tree
Hide file tree
Showing 32 changed files with 1,807 additions and 388 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo: true
branches:
only:
- master
- develop

cache:
- directories:
Expand Down
2 changes: 1 addition & 1 deletion CMake/Dependencies/libkvsCommonLws-CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include(ExternalProject)

ExternalProject_Add(libkvsCommonLws-download
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git
GIT_TAG 99c1a8cd8cec88f99c9c4ce3944b53ae341d1491
GIT_TAG c7fce9e06021452ff3c42dc70c8360606b22ad53
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
Expand Down
4 changes: 2 additions & 2 deletions CMake/Dependencies/libwebsockets-CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)

project(libwebsocket-download NONE)

SET(PATCH_COMMAND git apply --ignore-whitespace ${CMAKE_CURRENT_LIST_DIR}/libwebsockets-old-gcc-fix-cast-cmakelists.patch)
SET(PATCH_COMMAND git apply --ignore-whitespace ${CMAKE_CURRENT_LIST_DIR}/libwebsockets-old-gcc-fix-cast-cmakelists.patch ${CMAKE_CURRENT_LIST_DIR}/libwebsockets-leak-pipe-fix.patch)

include(ExternalProject)

Expand All @@ -25,7 +25,7 @@ endif()

ExternalProject_Add(project_libwebsockets
GIT_REPOSITORY https://github.com/warmcat/libwebsockets.git
GIT_TAG v4.2.1
GIT_TAG v4.2.2
PATCH_COMMAND ${PATCH_COMMAND}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS
Expand Down
36 changes: 36 additions & 0 deletions CMake/Dependencies/libwebsockets-leak-pipe-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Author: Andy Green <[email protected]>
Date: Wed Sep 08 12:25:47 2021 +0200

cancel pipe: make sure we closed it on destroy with no EVENTFD case


diff --git a/lib/core/context.c b/lib/core/context.c
index 6194801..4f3bb45 100644
--- a/lib/core/context.c
+++ b/lib/core/context.c
@@ -1625,11 +1625,25 @@ lws_pt_destroy(struct lws_context_per_thread *pt)
vpt->foreign_pfd_list = NULL;

lws_pt_lock(pt, __func__);
+
if (pt->pipe_wsi) {
lws_destroy_event_pipe(pt->pipe_wsi);
pt->pipe_wsi = NULL;
}

+ if (pt->dummy_pipe_fds[0]
+#if !defined(WIN32)
+ && (int)pt->dummy_pipe_fds[0] != -1
+#endif
+ ) {
+ struct lws wsi;
+
+ memset(&wsi, 0, sizeof(wsi));
+ wsi.a.context = pt->context;
+ wsi.tsi = (char)pt->tid;
+ lws_plat_pipe_close(&wsi);
+ }
+
#if defined(LWS_WITH_SECURE_STREAMS)
lws_dll2_foreach_safe(&pt->ss_owner, NULL, lws_ss_destroy_dll);

16 changes: 0 additions & 16 deletions CMake/Dependencies/libwebsockets-old-gcc-fix-cast-cmakelists.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
diff --git a/lib/misc/base64-decode.c b/lib/misc/base64-decode.c
index f8e8e49a..9d18b33f 100644
--- a/lib/misc/base64-decode.c
+++ b/lib/misc/base64-decode.c
@@ -72,9 +72,9 @@ _lws_b64_encode_string(const char *encode, const char *in, int in_len,
*out++ = encode[triple[0] >> 2];
*out++ = encode[(((triple[0] & 0x03) << 4) & 0x30) |
(((triple[1] & 0xf0) >> 4) & 0x0f)];
- *out++ = (len > 1 ? encode[(((triple[1] & 0x0f) << 2) & 0x3c) |
+ *out++ = (char)(len > 1 ? encode[(((triple[1] & 0x0f) << 2) & 0x3c) |
(((triple[2] & 0xc0) >> 6) & 3)] : '=');
- *out++ = (len > 2 ? encode[triple[2] & 0x3f] : '=');
+ *out++ = (char)(len > 2 ? encode[triple[2] & 0x3f] : '=');

done += 4;
}
diff --git a/lib/roles/h2/hpack.c b/lib/roles/h2/hpack.c
index 68629e6f..6ef628b8 100644
--- a/lib/roles/h2/hpack.c
Expand Down
21 changes: 20 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ option(THREAD_SANITIZER "Build with ThreadSanitizer." OFF)
option(UNDEFINED_BEHAVIOR_SANITIZER "Build with UndefinedBehaviorSanitizer." OFF)
option(LINK_PROFILER "Link gperftools profiler" OFF)

set(OPEN_SRC_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/open-source" CACHE PATH "Libraries will be downloaded and built in this directory.")
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)

add_definitions(-DSDK_VERSION=\"${GIT_COMMIT_HASH}\")
add_definitions(-DDETECTED_GIT_HASH)

if(NOT OPEN_SRC_INSTALL_PREFIX OR OPEN_SRC_INSTALL_PREFIX STREQUAL "")
set(OPEN_SRC_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/open-source" CACHE PATH "Libraries will be downloaded and built in this directory.")
else()
set(OPEN_SRC_INSTALL_PREFIX ${OPEN_SRC_INSTALL_PREFIX} CACHE PATH "Libraries will be downloaded and built in this directory.")
endif()

if(NOT WIN32)
CHECK_INCLUDE_FILES(ifaddrs.h KVSWEBRTC_HAVE_IFADDRS_H)
Expand Down Expand Up @@ -342,3 +355,9 @@ endif()
if(BUILD_BENCHMARK)
add_subdirectory(bench)
endif()

get_directory_property(clean_files ADDITIONAL_CLEAN_FILES)
list(APPEND clean_files "${OPEN_SRC_INSTALL_PREFIX}")
list(APPEND clean_files "${CMAKE_CURRENT_SOURCE_DIR}/build")
set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "${clean_files}")

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ You can pass the following options to `cmake ..`.
* `-DUNDEFINED_BEHAVIOR_SANITIZER` -- Build with UndefinedBehaviorSanitizer
* `-DLINK_PROFILER` -- Link with gperftools (available profiler options are listed [here](https://github.com/gperftools/gperftools))

To clean up the `open-source` and `build` folders from previous build, use `cmake --build . --target clean` from the `build` folder

For windows builds, you will have to include additional flags for libwebsockets CMake. Add the following flags to your cmake command, or edit the CMake file in ./CMake/Dependencies/libwebsockets-CMakeLists.txt with the following:

```
Expand Down
73 changes: 33 additions & 40 deletions samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ VOID onDataChannelMessage(UINT64 customData, PRtcDataChannel pDataChannel, BOOL
// Send a response to the message sent by the viewer
STATUS retStatus = STATUS_SUCCESS;
retStatus = dataChannelSend(pDataChannel, FALSE, (PBYTE) MASTER_DATA_CHANNEL_MESSAGE, STRLEN(MASTER_DATA_CHANNEL_MESSAGE));
if(retStatus != STATUS_SUCCESS) {
if (retStatus != STATUS_SUCCESS) {
DLOGI("[KVS Master] dataChannelSend(): operation returned status code: 0x%08x \n", retStatus);
}
}
Expand Down Expand Up @@ -493,7 +493,7 @@ STATUS createSampleStreamingSession(PSampleConfiguration pSampleConfiguration, P
CHK_STATUS(transceiverOnBandwidthEstimation(pSampleStreamingSession->pVideoRtcRtpTransceiver, (UINT64) pSampleStreamingSession,
sampleBandwidthEstimationHandler));

// Add a SendRecv Transceiver of type video
// Add a SendRecv Transceiver of type audio
audioTrack.kind = MEDIA_STREAM_TRACK_KIND_AUDIO;
audioTrack.codec = RTC_CODEC_OPUS;
audioRtpTransceiverInit.direction = RTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV;
Expand Down Expand Up @@ -551,7 +551,7 @@ STATUS freeSampleStreamingSession(PSampleStreamingSession* ppSampleStreamingSess
// the running thread but it's OK as it's re-entrant
MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock);
if (pSampleConfiguration->iceCandidatePairStatsTimerId != MAX_UINT32 && pSampleConfiguration->streamingSessionCount == 0 &&
pSampleConfiguration->iceCandidatePairStatsTimerId != MAX_UINT32) {
pSampleConfiguration->iceCandidatePairStatsTimerId != MAX_UINT32 && IS_VALID_TIMER_QUEUE_HANDLE(pSampleConfiguration->timerQueueHandle)) {
CHK_LOG_ERR(timerQueueCancelTimer(pSampleConfiguration->timerQueueHandle, pSampleConfiguration->iceCandidatePairStatsTimerId,
(UINT64) pSampleConfiguration));
pSampleConfiguration->iceCandidatePairStatsTimerId = MAX_UINT32;
Expand Down Expand Up @@ -596,10 +596,10 @@ VOID sampleFrameHandler(UINT64 customData, PFrame pFrame)
}
}

VOID sampleBandwidthEstimationHandler(UINT64 customData, DOUBLE maxiumBitrate)
VOID sampleBandwidthEstimationHandler(UINT64 customData, DOUBLE maximumBitrate)
{
UNUSED_PARAM(customData);
DLOGV("received bitrate suggestion: %f", maxiumBitrate);
DLOGV("received bitrate suggestion: %f", maximumBitrate);
}

VOID sampleSenderBandwidthEstimationHandler(UINT64 customData, UINT32 txBytes, UINT32 rxBytes, UINT32 txPacketsCnt, UINT32 rxPacketsCnt,
Expand Down Expand Up @@ -782,6 +782,7 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE
pSampleConfiguration->clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION;
pSampleConfiguration->clientInfo.loggingLevel = logLevel;
pSampleConfiguration->clientInfo.cacheFilePath = NULL; // Use the default path
pSampleConfiguration->clientInfo.signalingClientCreationMaxRetryAttempts = CREATE_SIGNALING_CLIENT_RETRY_ATTEMPTS_SENTINEL_VALUE;
pSampleConfiguration->iceCandidatePairStatsTimerId = MAX_UINT32;
pSampleConfiguration->pregenerateCertTimerId = MAX_UINT32;

Expand Down Expand Up @@ -838,6 +839,7 @@ STATUS logSignalingClientStats(PSignalingClientMetrics pSignalingClientMetrics)
// This gives the EMA of the getIceConfig() call.
DLOGD("Data Plane API call latency: %" PRIu64 " ms",
(pSignalingClientMetrics->signalingClientStats.dpApiCallLatency / HUNDREDS_OF_NANOS_IN_A_MILLISECOND));
DLOGD("API call retry count: %d", pSignalingClientMetrics->signalingClientStats.apiCallRetryCount);
CleanUp:
LEAVES();
return retStatus;
Expand Down Expand Up @@ -1004,6 +1006,28 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration)

CHK(pSampleConfiguration != NULL, retStatus);

if (IS_VALID_TIMER_QUEUE_HANDLE(pSampleConfiguration->timerQueueHandle)) {
if (pSampleConfiguration->iceCandidatePairStatsTimerId != MAX_UINT32) {
retStatus = timerQueueCancelTimer(pSampleConfiguration->timerQueueHandle, pSampleConfiguration->iceCandidatePairStatsTimerId,
(UINT64) pSampleConfiguration);
if (STATUS_FAILED(retStatus)) {
DLOGE("Failed to cancel stats timer with: 0x%08x", retStatus);
}
pSampleConfiguration->iceCandidatePairStatsTimerId = MAX_UINT32;
}

if (pSampleConfiguration->pregenerateCertTimerId != MAX_UINT32) {
retStatus = timerQueueCancelTimer(pSampleConfiguration->timerQueueHandle, pSampleConfiguration->pregenerateCertTimerId,
(UINT64) pSampleConfiguration);
if (STATUS_FAILED(retStatus)) {
DLOGE("Failed to cancel certificate pre-generation timer with: 0x%08x", retStatus);
}
pSampleConfiguration->pregenerateCertTimerId = MAX_UINT32;
}

timerQueueFree(&pSampleConfiguration->timerQueueHandle);
}

if (pSampleConfiguration->pPendingSignalingMessageForRemoteClient != NULL) {
// Iterate and free all the pending queues
stackQueueGetIterator(pSampleConfiguration->pPendingSignalingMessageForRemoteClient, &iterator);
Expand All @@ -1025,12 +1049,7 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration)
MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock);
locked = TRUE;
}
// Cancel the media thread
if(!(pSampleConfiguration->mediaThreadStarted)) {
DLOGD("Canceling media thread");
THREAD_CANCEL(pSampleConfiguration->mediaSenderTid);
}


for (i = 0; i < pSampleConfiguration->streamingSessionCount; ++i) {
retStatus = gatherIceServerStats(pSampleConfiguration->sampleStreamingSessionList[i]);
if (STATUS_FAILED(retStatus)) {
Expand Down Expand Up @@ -1074,28 +1093,6 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration)
freeStaticCredentialProvider(&pSampleConfiguration->pCredentialProvider);
#endif

if (IS_VALID_TIMER_QUEUE_HANDLE(pSampleConfiguration->timerQueueHandle)) {
if (pSampleConfiguration->iceCandidatePairStatsTimerId != MAX_UINT32) {
retStatus = timerQueueCancelTimer(pSampleConfiguration->timerQueueHandle, pSampleConfiguration->iceCandidatePairStatsTimerId,
(UINT64) pSampleConfiguration);
if (STATUS_FAILED(retStatus)) {
DLOGE("Failed to cancel stats timer with: 0x%08x", retStatus);
}
pSampleConfiguration->iceCandidatePairStatsTimerId = MAX_UINT32;
}

if (pSampleConfiguration->pregenerateCertTimerId != MAX_UINT32) {
retStatus = timerQueueCancelTimer(pSampleConfiguration->timerQueueHandle, pSampleConfiguration->pregenerateCertTimerId,
(UINT64) pSampleConfiguration);
if (STATUS_FAILED(retStatus)) {
DLOGE("Failed to cancel certificate pre-generation timer with: 0x%08x", retStatus);
}
pSampleConfiguration->pregenerateCertTimerId = MAX_UINT32;
}

timerQueueFree(&pSampleConfiguration->timerQueueHandle);
}

if (pSampleConfiguration->pregeneratedCertificates != NULL) {
stackQueueGetIterator(pSampleConfiguration->pregeneratedCertificates, &iterator);
while (IS_VALID_ITERATOR(iterator)) {
Expand All @@ -1109,8 +1106,7 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration)
pSampleConfiguration->pregeneratedCertificates = NULL;
}

MEMFREE(*ppSampleConfiguration);
*ppSampleConfiguration = NULL;
SAFE_MEMFREE(*ppSampleConfiguration);

CleanUp:

Expand Down Expand Up @@ -1161,10 +1157,7 @@ STATUS sessionCleanupWait(PSampleConfiguration pSampleConfiguration)

// Check if we need to re-create the signaling client on-the-fly
if (ATOMIC_LOAD_BOOL(&pSampleConfiguration->recreateSignalingClient) &&
STATUS_SUCCEEDED(freeSignalingClient(&pSampleConfiguration->signalingClientHandle)) &&
STATUS_SUCCEEDED(createSignalingClientSync(&pSampleConfiguration->clientInfo, &pSampleConfiguration->channelInfo,
&pSampleConfiguration->signalingClientCallbacks, pSampleConfiguration->pCredentialProvider,
&pSampleConfiguration->signalingClientHandle))) {
STATUS_SUCCEEDED(signalingClientFetchSync(pSampleConfiguration->signalingClientHandle))) {
// Re-set the variable again
ATOMIC_STORE_BOOL(&pSampleConfiguration->recreateSignalingClient, FALSE);
}
Expand Down Expand Up @@ -1234,7 +1227,7 @@ STATUS signalingMessageReceived(UINT64 customData, PReceivedSignalingMessage pRe
{
STATUS retStatus = STATUS_SUCCESS;
PSampleConfiguration pSampleConfiguration = (PSampleConfiguration) customData;
BOOL peerConnectionFound = FALSE, locked = TRUE, startStats = FALSE;
BOOL peerConnectionFound = FALSE, locked = FALSE, startStats = FALSE;
UINT32 clientIdHash;
UINT64 hashValue = 0;
PPendingMessageQueue pPendingMessageQueue = NULL;
Expand Down
32 changes: 26 additions & 6 deletions samples/kvsWebRTCClientMaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ INT32 main(INT32 argc, CHAR* argv[])
PSampleConfiguration pSampleConfiguration = NULL;
SignalingClientMetrics signalingClientMetrics;
PCHAR pChannelName;
signalingClientMetrics.version = 0;
signalingClientMetrics.version = SIGNALING_CLIENT_METRICS_CURRENT_VERSION;

SET_INSTRUMENTED_ALLOCATORS();

Expand Down Expand Up @@ -91,6 +91,12 @@ INT32 main(INT32 argc, CHAR* argv[])
printf("[KVS Master] Signaling client created successfully\n");

// Enable the processing of the messages
retStatus = signalingClientFetchSync(pSampleConfiguration->signalingClientHandle);
if (retStatus != STATUS_SUCCESS) {
printf("[KVS Master] signalingClientFetchSync(): operation returned status code: 0x%08x \n", retStatus);
goto CleanUp;
}

retStatus = signalingClientConnectSync(pSampleConfiguration->signalingClientHandle);
if (retStatus != STATUS_SUCCESS) {
printf("[KVS Master] signalingClientConnectSync(): operation returned status code: 0x%08x \n", retStatus);
Expand All @@ -114,14 +120,28 @@ INT32 main(INT32 argc, CHAR* argv[])
CleanUp:

if (retStatus != STATUS_SUCCESS) {
printf("[KVS Master] Terminated with status code 0x%08x", retStatus);
printf("[KVS Master] Terminated with status code 0x%08x\n", retStatus);
}

printf("[KVS Master] Cleaning up....\n");
if (pSampleConfiguration != NULL) {
// Kick of the termination sequence
ATOMIC_STORE_BOOL(&pSampleConfiguration->appTerminateFlag, TRUE);

if (IS_VALID_MUTEX_VALUE(pSampleConfiguration->sampleConfigurationObjLock)) {
MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock);
}

// Cancel the media thread
if (pSampleConfiguration->mediaThreadStarted) {
DLOGD("Canceling media thread");
THREAD_CANCEL(pSampleConfiguration->mediaSenderTid);
}

if (IS_VALID_MUTEX_VALUE(pSampleConfiguration->sampleConfigurationObjLock)) {
MUTEX_UNLOCK(pSampleConfiguration->sampleConfigurationObjLock);
}

if (pSampleConfiguration->mediaSenderTid != INVALID_TID_VALUE) {
THREAD_JOIN(pSampleConfiguration->mediaSenderTid, NULL);
}
Expand All @@ -133,7 +153,7 @@ INT32 main(INT32 argc, CHAR* argv[])
if (retStatus == STATUS_SUCCESS) {
logSignalingClientStats(&signalingClientMetrics);
} else {
printf("[KVS Master] signalingClientGetMetrics() operation returned status code: 0x%08x", retStatus);
printf("[KVS Master] signalingClientGetMetrics() operation returned status code: 0x%08x\n", retStatus);
}
retStatus = freeSignalingClient(&pSampleConfiguration->signalingClientHandle);
if (retStatus != STATUS_SUCCESS) {
Expand Down Expand Up @@ -272,7 +292,7 @@ PVOID sendVideoPackets(PVOID args)

CHK_LOG_ERR(retStatus);

return (PVOID) (ULONG_PTR) retStatus;
return (PVOID)(ULONG_PTR) retStatus;
}

PVOID sendAudioPackets(PVOID args)
Expand Down Expand Up @@ -340,7 +360,7 @@ PVOID sendAudioPackets(PVOID args)

CleanUp:

return (PVOID) (ULONG_PTR) retStatus;
return (PVOID)(ULONG_PTR) retStatus;
}

PVOID sampleReceiveVideoFrame(PVOID args)
Expand All @@ -360,5 +380,5 @@ PVOID sampleReceiveVideoFrame(PVOID args)

CleanUp:

return (PVOID) (ULONG_PTR) retStatus;
return (PVOID)(ULONG_PTR) retStatus;
}
6 changes: 6 additions & 0 deletions samples/kvsWebRTCClientMasterGstreamerSample.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ INT32 main(INT32 argc, CHAR* argv[])
printf("[KVS GStreamer Master] Signaling client created successfully\n");

// Enable the processing of the messages
retStatus = signalingClientFetchSync(pSampleConfiguration->signalingClientHandle);
if (retStatus != STATUS_SUCCESS) {
printf("[KVS Master] signalingClientFetchSync(): operation returned status code: 0x%08x \n", retStatus);
goto CleanUp;
}

retStatus = signalingClientConnectSync(pSampleConfiguration->signalingClientHandle);
if (retStatus != STATUS_SUCCESS) {
printf("[KVS GStreamer Master] signalingClientConnectSync(): operation returned status code: 0x%08x \n", retStatus);
Expand Down
Loading

0 comments on commit 22c9e3d

Please sign in to comment.