Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for CN region #1612

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/source/Signaling/ChannelInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tst/PeerConnectionFunctionalityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tst/SdpApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tst/WebRTCClientTestFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions tst/WebRTCClientTestFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <atomic>

#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"
Expand Down