Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update ProducerC and PiC for Windows
  • Loading branch information
Sean-Der committed May 27, 2020
1 parent acdd18e commit 2f7db86
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 268 deletions.
6 changes: 6 additions & 0 deletions .github/build_windows.bat
@@ -0,0 +1,6 @@
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
mkdir build
cd build
cmd.exe /c cmake -G "NMake Makefiles" ..
cmake -G "NMake Makefiles" -DBUILD_TEST=TRUE ..
nmake
19 changes: 18 additions & 1 deletion .github/msan-tester.Dockerfile
Expand Up @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

# Build libcxx with MSAN
RUN git clone --depth 1 https://github.com/llvm/llvm-project.git \
RUN git clone --depth 1 https://github.com/llvm/llvm-project.git -b llvmorg-9.0.1 \
&& cd llvm-project \
&& cp -r libcxx llvm/projects/ \
&& cp -r libcxxabi llvm/projects/ \
Expand Down Expand Up @@ -99,5 +99,22 @@ RUN git clone https://github.com/sctplab/usrsctp.git \
&& make install \
&& rm -rf /usr/src/usrsctp

RUN git clone https://github.com/awslabs/amazon-kinesis-video-streams-pic.git \
&& cd amazon-kinesis-video-streams-pic \
&& mkdir build \
&& cd build \
&& cmake .. -DBUILD_DEPENDENCIES=FALSE -DMEMORY_SANITIZER=TRUE -DCMAKE_C_FLAGS="$MSAN_CFLAGS" -DCMAKE_CXX_FLAGS="$MSAN_CFLAGS" \
&& make \
&& make install \
&& rm -rf /usr/src/amazon-kinesis-video-streams-pic

RUN git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git \
&& cd amazon-kinesis-video-streams-producer-c \
&& mkdir build \
&& cd build \
&& cmake .. -DBUILD_COMMON_CURL=FALSE -DBUILD_COMMON_LWS=TRUE -DBUILD_DEPENDENCIES=FALSE -DMEMORY_SANITIZER=TRUE -DCMAKE_C_FLAGS="$MSAN_CFLAGS" -DCMAKE_CXX_FLAGS="$MSAN_CFLAGS" \
&& make \
&& make install \
&& rm -rf /usr/src/amazon-kinesis-video-streams-producer-c

ENV LD_LIBRARY_PATH='/usr/src/libcxx_msan/lib/'
8 changes: 1 addition & 7 deletions .gitignore
Expand Up @@ -6,12 +6,6 @@ build
cmake-build-debug/
cmake-build-release/
doc/
open-source/libgtest
open-source/libjsmn
open-source/libopenssl
open-source/libsrtp
open-source/libusrsctp
open-source/libwebsockets
open-source/local
open-source/
outputs
tags
329 changes: 170 additions & 159 deletions .travis.yml

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions CMake/Dependencies/FindJsmn.cmake

This file was deleted.

14 changes: 14 additions & 0 deletions CMake/Dependencies/libkvsCommonLws-CMakeLists.txt
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 2.8)

project(libkvsCommonLws-download NONE)

include(ExternalProject)

ExternalProject_Add(libkvsCommonLws-download
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git
GIT_TAG 3ab764e77ea962b262f540325f2128b3d760e946
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX} -DBUILD_COMMON_LWS=ON -DBUILD_COMMON_CURL=OFF -DBUILD_DEPENDENCIES=FALSE -DOPEN_SRC_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
BUILD_ALWAYS TRUE
TEST_COMMAND ""
)
15 changes: 15 additions & 0 deletions CMake/Dependencies/libkvspic-CMakeLists.txt
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8)

project(libkvspic-download NONE)

include(ExternalProject)

ExternalProject_Add(libkvspic-download
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-pic.git
GIT_TAG bf7d7c6108d9d18ab9878318a235f5501bdbe0dc
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
BUILD_ALWAYS TRUE
TEST_COMMAND ""
)
2 changes: 1 addition & 1 deletion CMake/Dependencies/libwebsockets-CMakeLists.txt
Expand Up @@ -14,7 +14,7 @@ endif()

ExternalProject_Add(project_libwebsockets
GIT_REPOSITORY https://github.com/warmcat/libwebsockets.git
GIT_TAG 3179323afa81448287a15982755ed0e4a34d80cb
GIT_TAG v3.2.3
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
Expand Down
14 changes: 8 additions & 6 deletions CMake/Utilities.cmake
Expand Up @@ -8,7 +8,9 @@ function(build_dependency lib_name)
usrsctp
websockets
curl
mbedtls)
mbedtls
kvspic
kvsCommonLws)
list(FIND supported_libs ${lib_name} index)
if(${index} EQUAL -1)
message(WARNING "${lib_name} is not supported to build from source")
Expand Down Expand Up @@ -36,30 +38,30 @@ function(build_dependency lib_name)
# library building cmake.
set(build_args ${ARGN})

file(REMOVE_RECURSE ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/lib${lib_name})
file(REMOVE_RECURSE ${OPEN_SRC_INSTALL_PREFIX}/lib${lib_name})

# build library
configure_file(
./CMake/Dependencies/lib${lib_name}-CMakeLists.txt
${KINESIS_VIDEO_OPEN_SOURCE_SRC}/lib${lib_name}/CMakeLists.txt COPYONLY)
${OPEN_SRC_INSTALL_PREFIX}/lib${lib_name}/CMakeLists.txt COPYONLY)
execute_process(
COMMAND ${CMAKE_COMMAND} ${build_args}
-DOPEN_SRC_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX} -G
${CMAKE_GENERATOR} .
RESULT_VARIABLE result
WORKING_DIRECTORY ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/lib${lib_name})
WORKING_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX}/lib${lib_name})
if(result)
message(FATAL_ERROR "CMake step for lib${lib_name} failed: ${result}")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/lib${lib_name})
WORKING_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX}/lib${lib_name})
if(result)
message(FATAL_ERROR "CMake step for lib${lib_name} failed: ${result}")
endif()

file(REMOVE_RECURSE ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/lib${lib_name})
file(REMOVE_RECURSE ${OPEN_SRC_INSTALL_PREFIX}/lib${lib_name})
endfunction()

function(enableSanitizer SANITIZER)
Expand Down
97 changes: 41 additions & 56 deletions CMakeLists.txt
Expand Up @@ -24,54 +24,28 @@ set(CMAKE_MACOSX_RPATH TRUE)
get_filename_component(ROOT "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)

# static settings
if(BUILD_STATIC_LIBS)
if(BUILD_STATIC_LIBS OR WIN32)
set(LINKAGE STATIC)

set(USRSCTP_LIBNAME "libusrsctp.a") # todo: why doesn't CMAKE_STATIC_LIBRARY_SUFFIX work on my ubuntu cmake 3.10 system? evaluates to .so
set(LIBSRTP_LIB_DIR_VARNAME LIBSRTP_STATIC_LIBRARY_DIRS)
set(LIBSRTP_LIB_VARNAME LIBSRTP_STATIC_LIBRARIES)
set(LIBWEBSOCKET_LIB_DIR_VARNAME LIBWEBSOCKET_STATIC_LIBRARY_DIRS)
else()
set(LINKAGE SHARED)

set(USRSCTP_LIBNAME "libusrsctp.${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(LIBSRTP_LIB_DIR_VARNAME LIBSRTP_LIBRARY_DIRS)
set(LIBSRTP_LIB_VARNAME LIBSRTP_LIBRARIES)
set(LIBWEBSOCKET_LIB_DIR_VARNAME LIBWEBSOCKET_LIBRARY_DIRS)
endif()

set(KINESIS_VIDEO_PIC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/open-source/amazon-kinesis-video-streams-pic/")
set(KINESIS_VIDEO_PRODUCER_C_SRC "${CMAKE_CURRENT_SOURCE_DIR}/open-source/amazon-kinesis-video-streams-producer-c/")
set(KINESIS_VIDEO_WEBRTC_CLIENT_SRC "${CMAKE_CURRENT_SOURCE_DIR}")

# expecting libjsmn, libwebsockets and gtest to be in
# ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/lib and their headers in
# ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/include
set(KINESIS_VIDEO_OPEN_SOURCE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/open-source)

message(STATUS "Kinesis Video PIC path is ${KINESIS_VIDEO_PIC_SRC}")
message(STATUS "Kinesis Video C Producer path is ${KINESIS_VIDEO_PRODUCER_C_SRC}")
message(STATUS "Kinesis Video WebRTC Client path is ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}")
message(STATUS "dependencies install path is ${KINESIS_VIDEO_OPEN_SOURCE_SRC}")

if(NOT EXISTS ${KINESIS_VIDEO_PIC_SRC})
message(FATAL_ERROR "KINESIS_VIDEO_PIC_SRC ${KINESIS_VIDEO_PIC_SRC} does not exist")
elseif(NOT EXISTS ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC})
message(FATAL_ERROR "KINESIS_VIDEO_WEBRTC_CLIENT_SRC ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC} does not exist")
elseif(NOT EXISTS ${KINESIS_VIDEO_PRODUCER_C_SRC})
message(FATAL_ERROR "KINESIS_VIDEO_PRODUCER_C_SRC ${KINESIS_VIDEO_PRODUCER_C_SRC} does not exist")
endif()
message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}")

# pass ca cert location to sdk
add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem")
add_definitions(-DCMAKE_DETECTED_CACERT_PATH)

if(BUILD_DEPENDENCIES)
if(NOT EXISTS ${KINESIS_VIDEO_OPEN_SOURCE_SRC})
file(MAKE_DIRECTORY ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/local)
set(OPEN_SRC_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/open-source)
if(NOT EXISTS ${OPEN_SRC_INSTALL_PREFIX})
file(MAKE_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX})
endif()

set(OPEN_SRC_INSTALL_PREFIX ${KINESIS_VIDEO_OPEN_SOURCE_SRC}/local)
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OPEN_SRC_INSTALL_PREFIX}/lib/pkgconfig")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OPEN_SRC_INSTALL_PREFIX})

Expand All @@ -97,11 +71,13 @@ if(BUILD_DEPENDENCIES)

build_dependency(usrsctp)
build_dependency(jsmn)

if(BUILD_TEST)
build_dependency(gtest)
build_dependency(gtest)
endif()

build_dependency(kvspic)
build_dependency(kvsCommonLws)

message(STATUS "Finished building dependencies.")
endif()

Expand All @@ -111,8 +87,17 @@ find_package(Threads)
find_package(PkgConfig REQUIRED)
find_package(OpenSSL REQUIRED)

pkg_check_modules(LIBWEBSOCKET REQUIRED libwebsockets)
pkg_check_modules(LIBSRTP REQUIRED libsrtp2)
if (OPEN_SRC_INSTALL_PREFIX)
find_library(SRTP_LIBRARIES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})
else()
find_library(SRTP_LIBRARIES srtp2 REQUIRED )
endif()

if (WIN32)
SET(LIBWEBSOCKET_LIBRARIES "websockets.lib")
else()
pkg_check_modules(LIBWEBSOCKET REQUIRED libwebsockets)
endif()

# usrsctp dont support pkgconfig yet
find_library(
Expand All @@ -123,8 +108,9 @@ find_library(
set(OPEN_SRC_INCLUDE_DIRS ${LIBSRTP_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}
${CURL_INCLUDE_DIRS} ${LIBWEBSOCKET_INCLUDE_DIRS})

link_directories(${${LIBSRTP_LIB_DIR_VARNAME}})
link_directories(${${LIBWEBSOCKET_LIB_DIR_VARNAME}})
link_directories(${LIBSRTP_LIBRARY_DIRS})
link_directories(${LIBWEBSOCKET_LIBRARY_DIRS})
link_directories(${OPEN_SRC_INSTALL_PREFIX}/lib)

find_library(
Jsmn
Expand Down Expand Up @@ -220,21 +206,12 @@ file(GLOB PIC_HEADERS "${KINESIS_VIDEO_PIC_SRC}/src/*/include")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/opusSampleFrames" DESTINATION .)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/h264SampleFrames" DESTINATION .)

include_directories(${PIC_HEADERS})
include_directories(${OPEN_SRC_INCLUDE_DIRS})
include_directories(${KINESIS_VIDEO_OPEN_SOURCE_SRC}/include)
include_directories(${OPEN_SRC_INSTALL_PREFIX}/include)
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/include)
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/ice)
include_directories(${KINESIS_VIDEO_PRODUCER_C_SRC}/src/include)

set(BUILD_COMMON_LWS
TRUE
CACHE BOOL "Build ProducerC with LWS Support" FORCE)
set(BUILD_COMMON_CURL
FALSE
CACHE BOOL "Build ProducerC without CURL Support" FORCE)
add_subdirectory(${KINESIS_VIDEO_PRODUCER_C_SRC} ./kvscproducer EXCLUDE_FROM_ALL)

add_library(kvsWebrtcClient ${LINKAGE} ${WEBRTC_CLIENT_SOURCE_FILES})

target_link_libraries(
Expand All @@ -243,29 +220,39 @@ target_link_libraries(
kvspicState
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
${${LIBSRTP_LIB_VARNAME}}
${SRTP_LIBRARIES}
${Jsmn}
${Usrsctp})
${Usrsctp}
${EXTRA_DEPS})

add_library(kvsWebrtcSignalingClient ${LINKAGE} ${WEBRTC_SIGNALING_CLIENT_SOURCE_FILES})

target_link_libraries(
kvsWebrtcSignalingClient
PRIVATE kvspicUtils kvspicState
PRIVATE kvspicUtils
kvspicState
${LIBWEBSOCKET_LIBRARIES}
${EXTRA_DEPS}
${Jsmn}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
PUBLIC kvsCommonLws)

if (WIN32)
target_link_libraries(kvsWebrtcClient PRIVATE "Ws2_32" "iphlpapi")
endif()

add_executable(
kvsWebrtcClientMaster
${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/samples/Common.c
${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/samples/kvsWebRTCClientMaster.c)
target_link_libraries(kvsWebrtcClientMaster kvsWebrtcClient
kvsWebrtcSignalingClient)
target_link_libraries(kvsWebrtcClientMaster kvsWebrtcClient kvsWebrtcSignalingClient kvspicUtils)

add_executable(
kvsWebrtcClientViewer
${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/samples/Common.c
${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/samples/kvsWebRTCClientViewer.c)
target_link_libraries(kvsWebrtcClientViewer kvsWebrtcClient kvsWebrtcSignalingClient)
target_link_libraries(kvsWebrtcClientViewer kvsWebrtcClient kvsWebrtcSignalingClient kvspicUtils)

if(COMPILER_WARNINGS)
target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option)
Expand All @@ -278,11 +265,9 @@ if(GST_FOUND)
${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/samples/Common.c
${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/samples/kvsWebRTCClientMasterGstreamerSample.c
)
target_link_libraries(kvsWebrtcClientMasterGstSample kvsWebrtcClient
kvsWebrtcSignalingClient ${GST_SAMPLE_LIBRARIES})
target_link_libraries(kvsWebrtcClientMasterGstSample kvsWebrtcClient kvsWebrtcSignalingClient ${GST_SAMPLE_LIBRARIES} kvspicUtils)
endif()

if(BUILD_TEST)
set(ENV{KVS_GTEST_ROOT} ${KINESIS_VIDEO_OPEN_SOURCE_SRC})
add_subdirectory(tst)
endif()
1 change: 0 additions & 1 deletion open-source/amazon-kinesis-video-streams-pic
1 change: 0 additions & 1 deletion open-source/amazon-kinesis-video-streams-producer-c
2 changes: 1 addition & 1 deletion samples/kvsWebRTCClientMaster.c
Expand Up @@ -262,7 +262,7 @@ PVOID sendAudioPackets(PVOID args)

// Re-alloc if needed
if (frameSize > pSampleConfiguration->audioBufferSize) {
pSampleConfiguration->pAudioFrameBuffer = (uint8_t*) realloc(pSampleConfiguration->pAudioFrameBuffer, frameSize);
pSampleConfiguration->pAudioFrameBuffer = (UINT8*) realloc(pSampleConfiguration->pAudioFrameBuffer, frameSize);
if(pSampleConfiguration->pAudioFrameBuffer == NULL) {
printf("[KVS Master] Audio frame Buffer reallocation failed...%s (code %d)\n", strerror(errno), errno);
printf("[KVS Master] realloc(): operation returned status code: 0x%08x \n", STATUS_NOT_ENOUGH_MEMORY);
Expand Down
2 changes: 1 addition & 1 deletion samples/kvsWebRTCClientViewer.c
Expand Up @@ -43,7 +43,7 @@ INT32 main(INT32 argc, CHAR *argv[])

pSampleConfiguration->signalingClientCallbacks.messageReceivedFn = viewerMessageReceived;

sprintf(pSampleConfiguration->clientInfo.clientId, "%s_%u", SAMPLE_VIEWER_CLIENT_ID, RAND() % UINT32_MAX);
sprintf(pSampleConfiguration->clientInfo.clientId, "%s_%u", SAMPLE_VIEWER_CLIENT_ID, RAND() % MAX_UINT32);

retStatus = createSignalingClientSync(&pSampleConfiguration->clientInfo, &pSampleConfiguration->channelInfo,
&pSampleConfiguration->signalingClientCallbacks, pSampleConfiguration->pCredentialProvider,
Expand Down
4 changes: 1 addition & 3 deletions src/CMakeLists.txt
Expand Up @@ -4,16 +4,14 @@ project(KinesisVideoWebRTCClient LANGUAGES C)

file(GLOB_RECURSE HEADERS "include/*.h")
file(GLOB_RECURSE SOURCE "source/*.c")
file(GLOB PRODUCER_C_SOURCE_COMMON "${CMAKE_CURRENT_SOURCE_DIR}/../../../cproducer/src/source/Common/*.c")
file(GLOB PRODUCER_C_SOURCE_COMMON_LWS "${CMAKE_CURRENT_SOURCE_DIR}/../../../cproducer/src/source/Common/Lws/*.c")

set(INCLUDES_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include/")
include_directories(${INCLUDES_PATH})
include_directories(${BP_BUILD_INCLUDE_DIRS})
link_directories(${BP_BUILD_LIB})
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)

add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCE} ${PRODUCER_C_SOURCE_COMMON} ${PRODUCER_C_SOURCE_COMMON_LWS})
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCE})
target_compile_definitions(${PROJECT_NAME} PRIVATE KVS_BUILD_WITH_LWS=1)
target_link_libraries(${PROJECT_NAME} ${BP_BUILD_LIB_DIRS}
client heap trace view mkvgen utils state jsmn crypto ssl)
Expand Down

0 comments on commit 2f7db86

Please sign in to comment.