Skip to content

Commit

Permalink
add support for CN region (#1612) (#1777)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Li <[email protected]>
Co-authored-by: Alex.D.Scofield <[email protected]>
  • Loading branch information
disa6302 and codingspirit committed Aug 18, 2023
1 parent 0de3e92 commit 7d84479
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
8 changes: 7 additions & 1 deletion samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,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 @@ -670,7 +670,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 @@ -138,6 +138,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 @@ -228,7 +228,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 @@ -514,7 +514,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
14 changes: 7 additions & 7 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 audio video data
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 @@ -728,7 +728,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 @@ -786,7 +786,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 @@ -849,7 +849,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 Expand Up @@ -1102,7 +1102,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 Expand Up @@ -1320,7 +1320,7 @@ a=ssrc:1644235696 cname:{36a6a74c-73a4-594b-9bb0-023b4d357280})";
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

0 comments on commit 7d84479

Please sign in to comment.