Skip to content

Commit 87e5cdf

Browse files
committed
Continue with the peer connection even if getIceServerConfig failed
- TURN servers are not `MUST` for the peer connection - The device can still continue with the STUN server - In cases where, server is configured to not allow IceServers, we can continue
1 parent 151f464 commit 87e5cdf

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

esp_port/components/kvs_webrtc/src/LwsApiCallsESP.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,16 @@ STATUS getIceConfigEsp(PSignalingClient pSignalingClient, UINT64 time)
15811581
retStatus = performEspHttpRequest(pSignalingClient, url, HTTP_METHOD_POST,
15821582
paramsJson, &pResponseStr, &resultLen);
15831583

1584+
1585+
// It should be okay if this failed
1586+
if (STATUS_FAILED(retStatus)) {
1587+
ESP_LOGW(TAG, "Failed to get ice config, proceeding anyway...");
1588+
// Store successful result
1589+
ATOMIC_STORE(&pSignalingClient->result, (SIZE_T) SERVICE_CALL_RESULT_OK);
1590+
retStatus = STATUS_SUCCESS;
1591+
goto CleanUp;
1592+
}
1593+
15841594
// Set the service call result
15851595
ATOMIC_STORE(&pSignalingClient->result, (SIZE_T) retStatus);
15861596

@@ -2117,6 +2127,9 @@ STATUS performEspHttpRequest(PSignalingClient pSignalingClient, PCHAR url,
21172127
int statusCode = esp_http_client_get_status_code(client);
21182128
if (statusCode < 200 || statusCode >= 300) {
21192129
ESP_LOGE(TAG, "HTTP request failed with status code %d", statusCode);
2130+
if (response != NULL && responseLen > 0) {
2131+
ESP_LOGE(TAG, "Response data: %.*s", (int) responseLen, response);
2132+
}
21202133
CHK(FALSE, STATUS_INTERNAL_ERROR);
21212134
}
21222135

esp_port/components/kvs_webrtc/src/app_webrtc.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,22 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP
732732

733733
if (pSampleConfiguration->useTurn && !isStreamingOnly) {
734734
// Set the URIs from the configuration
735-
CHK_STATUS(signalingClientGetIceConfigInfoCount(pSampleConfiguration->signalingClientHandle, &iceConfigCount));
735+
retStatus = signalingClientGetIceConfigInfoCount(pSampleConfiguration->signalingClientHandle, &iceConfigCount);
736+
if (STATUS_FAILED(retStatus)) {
737+
ESP_LOGW(TAG, "Failed to get ice config count, proceeding anyway...");
738+
retStatus = STATUS_SUCCESS;
739+
iceConfigCount = 0;
740+
}
736741

737742
/* signalingClientGetIceConfigInfoCount can return more than one turn server. Use only one to optimize
738743
* candidate gathering latency. But user can also choose to use more than 1 turn server. */
739-
for (uriCount = 0, i = 0; i < maxTurnServer; i++) {
740-
CHK_STATUS(signalingClientGetIceConfigInfo(pSampleConfiguration->signalingClientHandle, i, &pIceConfigInfo));
744+
for (uriCount = 0, i = 0; i < maxTurnServer && i < iceConfigCount; i++) {
745+
retStatus = signalingClientGetIceConfigInfo(pSampleConfiguration->signalingClientHandle, i, &pIceConfigInfo);
746+
if (STATUS_FAILED(retStatus)) {
747+
ESP_LOGW(TAG, "Failed to get ice config, proceeding anyway...");
748+
retStatus = STATUS_SUCCESS;
749+
break;
750+
}
741751
for (j = 0; j < pIceConfigInfo->uriCount; j++) {
742752
CHECK(uriCount < MAX_ICE_SERVERS_COUNT);
743753
/*

0 commit comments

Comments
 (0)