Skip to content

Commit

Permalink
Add STUN component as submodule after re-factoring (#1960)
Browse files Browse the repository at this point in the history
* Update Serializer and Deserializer

* Add Stun component

* Fix clang format

* Fix warnings

* Fix address copy length

* Fix test case message length

* Minor update

* Add MAGIC check

* Update padded len

* Update comments

* Add API test for convertStunErrorCodeTest

* Remove unused variable
  • Loading branch information
moninom1 authored Apr 23, 2024
1 parent ec203eb commit bf43342
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 425 deletions.
23 changes: 23 additions & 0 deletions CMake/Dependencies/libkvsstun-CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.6.3)

project(libkvsstun NONE)

include(ExternalProject)
if (BUILD_STATIC_LIBS OR WIN32)
set(LIBKVSSTUN_SHARED_LIBS OFF)
else()
set(LIBKVSSTUN_SHARED_LIBS ON)
endif()

ExternalProject_Add(libkvsstun
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-stun.git
GIT_TAG 2fa9ed638239aa058a71db0d9430ab427e6e21a3
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DBUILD_SHARED_LIBS=${LIBKVSSTUN_SHARED_LIBS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_ALWAYS TRUE
TEST_COMMAND ""
)
3 changes: 2 additions & 1 deletion CMake/Utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function(build_dependency lib_name)
mbedtls
kvspic
kvsCommonLws
kvssdp)
kvssdp
kvsstun)
list(FIND supported_libs ${lib_name} index)
if(${index} EQUAL -1)
message(WARNING "${lib_name} is not supported to build from source")
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ if(BUILD_DEPENDENCIES)

build_dependency(kvssdp ${BUILD_ARGS})

set(BUILD_ARGS
-DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})

build_dependency(kvsstun ${BUILD_ARGS})

set(BUILD_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
Expand Down Expand Up @@ -407,6 +414,7 @@ target_link_libraries(
PRIVATE kvspicUtils
kvspicState
kvssdp
kvsstun
${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
Expand All @@ -429,6 +437,7 @@ target_link_libraries(
kvsCommonLws
${LIBWEBSOCKETS_LIBRARIES}
kvssdp
kvsstun
PRIVATE kvspicUtils
kvspicState
${CMAKE_THREAD_LIBS_INIT}
Expand Down
8 changes: 4 additions & 4 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ add_executable(
kvsWebrtcClientMaster
Common.c
kvsWebRTCClientMaster.c)
target_link_libraries(kvsWebrtcClientMaster kvsWebrtcClient kvsWebrtcSignalingClient ${EXTRA_DEPS} kvsCommonLws kvspicUtils websockets kvssdp)
target_link_libraries(kvsWebrtcClientMaster kvsWebrtcClient kvsWebrtcSignalingClient ${EXTRA_DEPS} kvsCommonLws kvspicUtils websockets kvssdp kvsstun)

add_executable(
kvsWebrtcClientViewer
Common.c
kvsWebRTCClientViewer.c)
target_link_libraries(kvsWebrtcClientViewer kvsWebrtcClient kvsWebrtcSignalingClient ${EXTRA_DEPS} kvsCommonLws kvspicUtils websockets kvssdp)
target_link_libraries(kvsWebrtcClientViewer kvsWebrtcClient kvsWebrtcSignalingClient ${EXTRA_DEPS} kvsCommonLws kvspicUtils websockets kvssdp kvsstun)

add_executable(
discoverNatBehavior
discoverNatBehavior.c)
target_link_libraries(discoverNatBehavior kvsWebrtcClient ${EXTRA_DEPS} kvssdp)
target_link_libraries(discoverNatBehavior kvsWebrtcClient ${EXTRA_DEPS} kvssdp kvsstun)

if(GST_FOUND)
add_executable(
Expand All @@ -81,7 +81,7 @@ if(GST_FOUND)
GstAudioVideoReceiver.c
kvsWebRTCClientMasterGstSample.c
)
target_link_libraries(kvsWebrtcClientMasterGstSample kvsWebrtcClient kvsWebrtcSignalingClient ${EXTRA_DEPS} ${GST_SAMPLE_LIBRARIES} kvsCommonLws kvspicUtils websockets kvssdp)
target_link_libraries(kvsWebrtcClientMasterGstSample kvsWebrtcClient kvsWebrtcSignalingClient ${EXTRA_DEPS} ${GST_SAMPLE_LIBRARIES} kvsCommonLws kvspicUtils websockets kvssdp kvsstun)

install(TARGETS kvsWebrtcClientMasterGstSample
RUNTIME DESTINATION bin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ extern "C" {
#define STATUS_STUN_INVALID_ICE_CONTROL_ATTRIBUTE_LENGTH STATUS_STUN_BASE + 0x00000017
#define STATUS_STUN_INVALID_CHANNEL_NUMBER_ATTRIBUTE_LENGTH STATUS_STUN_BASE + 0x00000018
#define STATUS_STUN_INVALID_CHANGE_REQUEST_ATTRIBUTE_LENGTH STATUS_STUN_BASE + 0x00000019
#define STATUS_STUN_INVALID_MESSAGE_LENGTH STATUS_STUN_BASE + 0x0000001A
#define STATUS_STUN_INVALID_ATTRIBUTE_LENGTH STATUS_STUN_BASE + 0x0000001B
#define STATUS_STUN_ATTRIBUTE_NOT_FOUND STATUS_STUN_BASE + 0x0000001C
#define STATUS_STUN_NO_MORE_ATTRIBUTE_FOUND STATUS_STUN_BASE + 0x0000001D
#define STATUS_STUN_UNKNOWN_ERROR STATUS_STUN_BASE + 0x0000001E
/*!@} */

/////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions src/source/Include_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern "C" {
////////////////////////////////////////////////////
#include <com/amazonaws/kinesis/video/webrtcclient/Include.h>
#include "kvssdp/sdp_data_types.h"
#include "kvsstun/stun_data_types.h"

#ifdef KVS_USE_OPENSSL
#include <openssl/bio.h>
Expand Down Expand Up @@ -173,6 +174,7 @@ STATUS generateJSONSafeString(PCHAR, UINT32);
#define KVS_CONVERT_TIMESCALE(pts, from_timescale, to_timescale) (pts * to_timescale / from_timescale)

STATUS convertSdpErrorCode(SdpResult_t sdpResult);
STATUS convertStunErrorCode(StunResult_t sdpResult);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit bf43342

Please sign in to comment.