From 9d3ac799cc428f217b3dfd7152c1f4d2707a9326 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Fri, 6 Jan 2023 15:26:27 +0800 Subject: [PATCH] add support for CN region Signed-off-by: Alex Li --- samples/Common.c | 8 +++++++- .../com/amazonaws/kinesis/video/webrtcclient/Include.h | 4 +++- src/source/Signaling/ChannelInfo.c | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/samples/Common.c b/samples/Common.c index d03f5c64b0..b1588693c2 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -357,7 +357,13 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_ALL; // Set the STUN server - SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, pSampleConfiguration->channelInfo.pRegion); + PCHAR pKinesisVideoStunUrlPostFix = KINESIS_VIDEO_STUN_URL_POSTFIX; + // If region is in CN, add CN region uri postfix + if (STRSTR(pSampleConfiguration->channelInfo.pRegion, "cn-")) { + pKinesisVideoStunUrlPostFix = KINESIS_VIDEO_STUN_URL_POSTFIX_CN; + } + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, pSampleConfiguration->channelInfo.pRegion, + pKinesisVideoStunUrlPostFix); if (pSampleConfiguration->useTurn) { // Set the URIs from the configuration diff --git a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h index bf91f41c48..6baa03a278 100644 --- a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h +++ b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h @@ -623,7 +623,9 @@ extern "C" { /** * Parameterized string for KVS STUN Server */ -#define KINESIS_VIDEO_STUN_URL "stun:stun.kinesisvideo.%s.amazonaws.com:443" +#define KINESIS_VIDEO_STUN_URL_POSTFIX "amazonaws.com" +#define KINESIS_VIDEO_STUN_URL_POSTFIX_CN "amazonaws.com.cn" +#define KINESIS_VIDEO_STUN_URL "stun:stun.kinesisvideo.%s.%s:443" /** * Default signaling SSL port diff --git a/src/source/Signaling/ChannelInfo.c b/src/source/Signaling/ChannelInfo.c index 18e0df7dce..cd794cb2a5 100644 --- a/src/source/Signaling/ChannelInfo.c +++ b/src/source/Signaling/ChannelInfo.c @@ -127,6 +127,10 @@ STATUS createValidateChannelInfo(PChannelInfo pOrigChannelInfo, PChannelInfo* pp // Create a fully qualified URI SNPRINTF(pCurPtr, MAX_CONTROL_PLANE_URI_CHAR_LEN, "%s%s.%s%s", CONTROL_PLANE_URI_PREFIX, KINESIS_VIDEO_SERVICE_NAME, pChannelInfo->pRegion, CONTROL_PLANE_URI_POSTFIX); + // If region is in CN, add CN region uri postfix + if (STRSTR(pChannelInfo->pRegion, "cn-")) { + STRCAT(pCurPtr, ".cn"); + } } pChannelInfo->pControlPlaneUrl = pCurPtr;