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; diff --git a/tst/PeerConnectionFunctionalityTest.cpp b/tst/PeerConnectionFunctionalityTest.cpp index 955d0a25af..5a5e3ed3d5 100644 --- a/tst/PeerConnectionFunctionalityTest.cpp +++ b/tst/PeerConnectionFunctionalityTest.cpp @@ -232,7 +232,7 @@ TEST_F(PeerConnectionFunctionalityTest, sendDataWithClosedSocketConnectionWithHo PSocketConnection pSocketConnection; MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); - SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); @@ -524,7 +524,7 @@ TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersWithHostAndStun) MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); // Set the STUN server - SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); diff --git a/tst/SdpApiTest.cpp b/tst/SdpApiTest.cpp index 1b05d288bb..0edf661361 100644 --- a/tst/SdpApiTest.cpp +++ b/tst/SdpApiTest.cpp @@ -614,7 +614,7 @@ a=group:BUNDLE 0 RtcSessionDescriptionInit offerSdp{}; RtcSessionDescriptionInit answerSdp{}; - SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); track1.kind = MEDIA_STREAM_TRACK_KIND_VIDEO; track1.codec = RTC_CODEC_VP8; @@ -667,7 +667,7 @@ a=group:BUNDLE 0 RtcSessionDescriptionInit offerSdp{}; RtcSessionDescriptionInit answerSdp{}; - SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); track1.kind = MEDIA_STREAM_TRACK_KIND_VIDEO; track1.codec = RTC_CODEC_VP8; @@ -725,7 +725,7 @@ a=group:BUNDLE 0 RtcSessionDescriptionInit offerSdp{}; RtcSessionDescriptionInit answerSdp{}; - SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); track1.kind = MEDIA_STREAM_TRACK_KIND_VIDEO; track1.codec = RTC_CODEC_VP8; @@ -788,7 +788,7 @@ a=ice-options:trickle RtcSessionDescriptionInit offerSdp{}; RtcSessionDescriptionInit answerSdp{}; - SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); track1.kind = MEDIA_STREAM_TRACK_KIND_VIDEO; track1.codec = RTC_CODEC_VP8; diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index 8291bcf6de..d041db728e 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -256,7 +256,7 @@ void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration) EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(mSignalingClientHandle, &iceConfigCount)); // Set the STUN server - SNPRINTF(pRtcConfiguration->iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION); + SNPRINTF(pRtcConfiguration->iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); for (uriCount = 0, i = 0; i < iceConfigCount; i++) { EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(mSignalingClientHandle, i, &pIceConfigInfo)); diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index c1d6f52d1f..845abbc4f5 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -8,6 +8,7 @@ #include #define TEST_DEFAULT_REGION ((PCHAR) "us-west-2") +#define TEST_DEFAULT_STUN_URL_POSTFIX (KINESIS_VIDEO_STUN_URL_POSTFIX) #define TEST_STREAMING_TOKEN_DURATION (40 * HUNDREDS_OF_NANOS_IN_A_SECOND) #define TEST_JITTER_BUFFER_CLOCK_RATE (1000) #define TEST_SIGNALING_MASTER_CLIENT_ID (PCHAR) "Test_Master_ClientId"