Skip to content

Commit

Permalink
Merge pull request #4 from Haivision/master
Browse files Browse the repository at this point in the history
同步远程代码
  • Loading branch information
cg82616424 authored Oct 20, 2021
2 parents 05cb756 + 3f2945c commit e338581
Show file tree
Hide file tree
Showing 134 changed files with 10,535 additions and 5,257 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Android

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: NDK-R23
runs-on: ubuntu-18.04

steps:
- name: Setup Android NDK R23
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r23
add-to-path: false
- uses: actions/checkout@v2
- name: build
run: |
cd ./scripts/build-android/
echo ${{ steps.setup-ndk.outputs.ndk-path }}
source ./build-android -n ${{ steps.setup-ndk.outputs.ndk-path }}
25 changes: 25 additions & 0 deletions .github/workflows/iOS.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: iOS

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
strategy:
matrix:
cxxstdsync: [OFF, ON]

name: iOS-cxxsync${{ matrix.cxxstdsync }}
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: configure
run: |
mkdir _build && cd _build
cmake ../ -DENABLE_ENCRYPTION=OFF -DENABLE_STDCXX_SYNC=${{matrix.cxxstdsync}} -DENABLE_UNITTESTS=OFF -DENABLE_EXPERIMENTAL_BONDING=ON --toolchain scripts/iOS.cmake
- name: build
run: cd _build && cmake --build ./
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ _*/
# Ignode Visual Studio Code temp folder
.vs/
.vscode/

# Ignore vcpkg submodule
vcpkg/

# LSP
compile_commands.json
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ matrix:
- make
- cd ..
env: BUILD_TYPE=Release

# Power jobs
- os: linux
arch: ppc64le
Expand All @@ -69,6 +69,7 @@ matrix:
- BUILD_TYPE=Release
- BUILD_OPTS='-DENABLE_MONOTONIC_CLOCK=ON'
script:
- TESTS_IPv6="TestMuxer.IPv4_and_IPv6:TestIPv6.v6_calls_v6*:ReuseAddr.ProtocolVersion" ; # Tests to skip due to lack of IPv6 support
- if [ "$TRAVIS_COMPILER" == "x86_64-w64-mingw32-g++" ]; then
export CC="x86_64-w64-mingw32-gcc";
export CXX="x86_64-w64-mingw32-g++";
Expand All @@ -91,7 +92,7 @@ script:
make -j$(nproc);
fi
- if [ "$TRAVIS_COMPILER" != "x86_64-w64-mingw32-g++" ]; then
./test-srt --gtest_filter="-TestMuxer.IPv4_and_IPv6:TestIPv6.v6_calls_v6*";
./test-srt --gtest_filter="-$TESTS_IPv6";
fi
- if (( "$RUN_CODECOV" )); then
source ./scripts/collect-gcov.sh;
Expand Down
118 changes: 96 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
set (SRT_VERSION 1.4.3)
set (SRT_VERSION 1.4.4)

set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
include(haiUtil) # needed for set_version_variables
Expand Down Expand Up @@ -39,8 +39,10 @@ set_if(LINUX ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set_if(BSD ${SYSNAME_LC} MATCHES "bsd$")
set_if(MICROSOFT WIN32 AND (NOT MINGW AND NOT CYGWIN))
set_if(GNU ${CMAKE_SYSTEM_NAME} MATCHES "GNU")
set_if(POSIX LINUX OR DARWIN OR BSD OR (CYGWIN AND CYGWIN_USE_POSIX))
set_if(SYMLINKABLE LINUX OR DARWIN OR BSD OR CYGWIN OR GNU)
set_if(ANDROID ${SYSNAME_LC} MATCHES "android")
set_if(SUNOS "${SYSNAME_LC}" MATCHES "sunos")
set_if(POSIX LINUX OR DARWIN OR BSD OR SUNOS OR ANDROID OR (CYGWIN AND CYGWIN_USE_POSIX))
set_if(SYMLINKABLE LINUX OR DARWIN OR BSD OR SUNOS OR CYGWIN OR GNU)

# Not sure what to do in case of compiling by MSVC.
# This will make installdir in C:\Program Files\SRT then
Expand Down Expand Up @@ -109,9 +111,23 @@ if (ENABLE_DEBUG)
endif()


set(ENABLE_STDCXX_SYNC_DEFAULT OFF)
set(ENABLE_MONOTONIC_CLOCK_DEFAULT OFF)
set(MONOTONIC_CLOCK_LINKLIB "")
if (MICROSOFT)
set(ENABLE_STDCXX_SYNC_DEFAULT ON)
elseif (POSIX)
test_requires_clock_gettime(ENABLE_MONOTONIC_CLOCK_DEFAULT MONOTONIC_CLOCK_LINKLIB)
endif()


# options
option(CYGWIN_USE_POSIX "Should the POSIX API be used for cygwin. Ignored if the system isn't cygwin." OFF)
option(ENABLE_CXX11 "Should the c++11 parts (srt-live-transmit) be enabled" ON)
if (CMAKE_CXX_COMPILER_ID MATCHES "^GNU$" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
option(ENABLE_CXX11 "Should the c++11 parts (srt-live-transmit) be enabled" OFF)
else()
option(ENABLE_CXX11 "Should the c++11 parts (srt-live-transmit) be enabled" ON)
endif()
option(ENABLE_APPS "Should the Support Applications be Built?" ON)
option(ENABLE_EXPERIMENTAL_BONDING "Should the EXPERIMENTAL bonding functionality be enabled?" OFF)
option(ENABLE_TESTING "Should the Developer Test Applications be Built?" OFF)
Expand All @@ -129,13 +145,22 @@ option(ENABLE_CXX_DEPS "Extra library dependencies in srt.pc for the CXX librari
option(USE_STATIC_LIBSTDCXX "Should use static rather than shared libstdc++" OFF)
option(ENABLE_INET_PTON "Set to OFF to prevent usage of inet_pton when building against modern SDKs while still requiring compatibility with older Windows versions, such as Windows XP, Windows Server 2003 etc." ON)
option(ENABLE_CODE_COVERAGE "Enable code coverage reporting" OFF)
option(ENABLE_MONOTONIC_CLOCK "Enforced clock_gettime with monotonic clock on GC CV /temporary fix for #729/" OFF)
option(ENABLE_STDCXX_SYNC "Use C++11 chrono and threads for timing instead of pthreads" OFF)
option(ENABLE_MONOTONIC_CLOCK "Enforced clock_gettime with monotonic clock on GC CV" ${ENABLE_MONOTONIC_CLOCK_DEFAULT})
option(ENABLE_STDCXX_SYNC "Use C++11 chrono and threads for timing instead of pthreads" ${ENABLE_STDCXX_SYNC_DEFAULT})
option(USE_OPENSSL_PC "Use pkg-config to find OpenSSL libraries" ON)
option(USE_BUSY_WAITING "Enable more accurate sending times at a cost of potentially higher CPU load" OFF)
option(USE_GNUSTL "Get c++ library/headers from the gnustl.pc" OFF)
option(ENABLE_SOCK_CLOEXEC "Enable setting SOCK_CLOEXEC on a socket" ON)

option(ENABLE_CLANG_TSA "Enable Clang Thread Safety Analysis" OFF)

# NOTE: Use ATOMIC_USE_SRT_SYNC_MUTEX and will override the auto-detection of the
# Atomic implemetation in srtcore/atomic.h.
option(ATOMIC_USE_SRT_SYNC_MUTEX "Use srt::sync::Mutex to Implement Atomics" OFF)
if (ATOMIC_USE_SRT_SYNC_MUTEX)
add_definitions(-DATOMIC_USE_SRT_SYNC_MUTEX=1)
endif()

set(TARGET_srt "srt" CACHE STRING "The name for the SRT library")

# Use application-defined group reader
Expand Down Expand Up @@ -262,7 +287,15 @@ if (DEFINED HAVE_INET_PTON)
add_definitions(-DHAVE_INET_PTON=1)
endif()

# Defines HAVE_PTHREAD_GETNAME_* and HAVE_PTHREAD_SETNAME_*
include(FindPThreadGetSetName)
FindPThreadGetSetName()

if (ENABLE_MONOTONIC_CLOCK)
if (NOT ENABLE_MONOTONIC_CLOCK_DEFAULT)
message(FATAL_ERROR "Your platform does not support CLOCK_MONOTONIC. Build with -DENABLE_MONOTONIC_CLOCK=OFF.")
endif()
set (WITH_EXTRALIBS "${WITH_EXTRALIBS} ${MONOTONIC_CLOCK_LINKLIB}")
add_definitions(-DENABLE_MONOTONIC_CLOCK=1)
endif()

Expand Down Expand Up @@ -384,6 +417,20 @@ else() # Compiler altered by WITH_COMPILER_TYPE/PREFIX - can't rely on CMAKE_CXX
message(STATUS "COMPILER CHANGED TO: ${COMPILER_TYPE} - forcing C++11 standard for apps")
endif()

# Check for GCC Atomic Intrinsics and C++11 Atomics.
# Sets:
# HAVE_LIBATOMIC
# HAVE_LIBATOMIC_COMPILES
# HAVE_LIBATOMIC_COMPILES_STATIC
# HAVE_GCCATOMIC_INTRINSICS
# HAVE_GCCATOMIC_INTRINSICS_REQUIRES_LIBATOMIC
include(CheckGCCAtomicIntrinsics)
CheckGCCAtomicIntrinsics()
# HAVE_CXX_ATOMIC
# HAVE_CXX_ATOMIC_STATIC
include(CheckCXXAtomic)
CheckCXXAtomic()

if (DISABLE_CXX11)
set (ENABLE_CXX11 0)
elseif( DEFINED ENABLE_CXX11 )
Expand Down Expand Up @@ -433,6 +480,7 @@ elseif (ENABLE_STDCXX_SYNC)
endif()

message(STATUS "STDCXX_SYNC: ${ENABLE_STDCXX_SYNC}")
message(STATUS "MONOTONIC_CLOCK: ${ENABLE_MONOTONIC_CLOCK}")

if (ENABLE_SOCK_CLOEXEC)
add_definitions(-DENABLE_SOCK_CLOEXEC=1)
Expand Down Expand Up @@ -524,14 +572,6 @@ if (USE_STATIC_LIBSTDCXX)
endif()
endif()

# We need clock_gettime, but on some systems this is only provided
# by librt. Check if librt is required.
if (ENABLE_MONOTONIC_CLOCK AND LINUX)
# "requires" - exits on FATAL_ERROR when clock_gettime not available
test_requires_clock_gettime(NEED_CLOCK_GETTIME)
set (WITH_EXTRALIBS "${WITH_EXTRALIBS} ${NEED_CLOCK_GETTIME}")
endif()


# This options is necessary on some systems; on a cross-ARM compiler it
# has been detected, for example, that -lrt is necessary for some applications
Expand Down Expand Up @@ -583,6 +623,9 @@ elseif(CYGWIN)
elseif(GNU)
add_definitions(-DGNU=1)
message(STATUS "DETECTED SYSTEM: GNU; GNU=1" )
elseif(SUNOS)
add_definitions(-DSUNOS=1)
message(STATUS "DETECTED SYSTEM: SunOS|Solaris; SUNOS=1" )
else()
message(FATAL_ERROR "Unsupported system: ${CMAKE_SYSTEM_NAME}")
endif()
Expand Down Expand Up @@ -634,6 +677,11 @@ if (ENABLE_THREAD_CHECK)
)
endif()

if (ENABLE_CLANG_TSA)
list(APPEND SRT_EXTRA_CFLAGS "-Wthread-safety")
message(STATUS "Clang TSA: Enabled")
endif()

if (ENABLE_PROFILE)
if (HAVE_COMPILER_GNU_COMPAT)
# They are actually cflags, not definitions, but CMake is stupid enough.
Expand Down Expand Up @@ -790,9 +838,14 @@ MafReadDir(srtcore filelist.maf
# Auto generated version file and add it to the HEADERS_srt list.
if(DEFINED ENV{APPVEYOR_BUILD_NUMBER})
set(SRT_VERSION_BUILD ON)
set(APPVEYOR_BUILD_NUMBER_STRING $ENV{APPVEYOR_BUILD_NUMBER})
set(CI_BUILD_NUMBER_STRING $ENV{APPVEYOR_BUILD_NUMBER})
message(STATUS "AppVeyor build environment detected: Adding build number to version header")
endif()
if(DEFINED ENV{TEAMCITY_VERSION})
set(SRT_VERSION_BUILD ON)
set(CI_BUILD_NUMBER_STRING $ENV{CI_BUILD_COUNTER})
message(STATUS "TeamCity build environment detected: Adding build counter to version header")
endif()

configure_file("srtcore/version.h.in" "version.h" @ONLY)

Expand Down Expand Up @@ -838,7 +891,7 @@ if (srt_libspec_shared)
endif()
if (MICROSOFT)
target_link_libraries(${TARGET_srt}_shared PRIVATE ws2_32.lib)
if (OPENSSL_USE_STATIC_LIBS)
if (OPENSSL_USE_STATIC_LIBS)
target_link_libraries(${TARGET_srt}_shared PRIVATE crypt32.lib)
else()
set_target_properties(${TARGET_srt}_shared PROPERTIES LINK_FLAGS "/DELAYLOAD:libeay32.dll")
Expand Down Expand Up @@ -876,7 +929,7 @@ if (srt_libspec_static)
endif()
if (MICROSOFT)
target_link_libraries(${TARGET_srt}_static PRIVATE ws2_32.lib)
if (OPENSSL_USE_STATIC_LIBS)
if (OPENSSL_USE_STATIC_LIBS)
target_link_libraries(${TARGET_srt}_static PRIVATE crypt32.lib)
endif()
elseif (MINGW)
Expand All @@ -889,8 +942,8 @@ endif()

target_include_directories(srt_virtual PRIVATE ${SSL_INCLUDE_DIRS})

if (MICROSOFT)
if (OPENSSL_USE_STATIC_LIBS)
if (MICROSOFT)
if (OPENSSL_USE_STATIC_LIBS)
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ws2_32.lib crypt32.lib)
else()
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ws2_32.lib)
Expand Down Expand Up @@ -926,12 +979,29 @@ endif()
if (srt_libspec_shared)
if (MICROSOFT)
target_link_libraries(${TARGET_srt}_shared PUBLIC Ws2_32.lib)
if (OPENSSL_USE_STATIC_LIBS)
if (OPENSSL_USE_STATIC_LIBS)
target_link_libraries(${TARGET_srt}_shared PUBLIC crypt32.lib)
endif()
endif()
endif()

# Required by some toolchains when statically linking this library if the
# GCC Atomic Intrinsics are being used.
if (HAVE_GCCATOMIC_INTRINSICS_REQUIRES_LIBATOMIC AND HAVE_LIBATOMIC)
if (srt_libspec_static)
target_link_libraries(${TARGET_srt}_static PUBLIC atomic)
endif()
if (srt_libspec_shared)
target_link_libraries(${TARGET_srt}_shared PUBLIC atomic)
endif()
elseif (HAVE_LIBATOMIC AND HAVE_LIBATOMIC_COMPILES_STATIC)
# This is a workaround for ANDROID NDK<17 builds, which need to link
# to libatomic when linking statically to the SRT library.
if (srt_libspec_static)
target_link_libraries(${TARGET_srt}_static PUBLIC atomic)
endif()
endif()

# Cygwin installs the *.dll libraries in bin directory and uses PATH.

set (INSTALL_SHARED_DIR ${CMAKE_INSTALL_LIBDIR})
Expand Down Expand Up @@ -1006,10 +1076,14 @@ else()
message(FATAL_ERROR "Either ENABLE_STATIC or ENABLE_SHARED has to be ON!")
endif()

macro(srt_add_program name)
macro(srt_add_program_dont_install name)
add_executable(${name} ${ARGN})
target_include_directories(${name} PRIVATE apps)
target_include_directories(${name} PRIVATE common)
endmacro()

macro(srt_add_program name)
srt_add_program_dont_install(${name} ${ARGN})
install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endmacro()

Expand Down Expand Up @@ -1220,7 +1294,7 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
SOURCES SOURCES_unittests
)

srt_add_program(test-srt ${SOURCES_unittests})
srt_add_program_dont_install(test-srt ${SOURCES_unittests})
srt_make_application(test-srt)
target_include_directories(test-srt PRIVATE ${SSL_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})

Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ As audio/video packets are streamed from a source to a destination device, SRT d

## Requirements

* cmake (as build system)
* Tcl 8.5 (optional for user-friendly build system)
* OpenSSL
* Pthreads (for POSIX systems it's builtin, for Windows there's a library)

For detailed description of the build system and options, please read [SRT Build Options](docs/build/build-options.md).
* C++03 (or above) compliant compiler.
* CMake 2.8.12 or above (as build system).
* OpenSSL 1.1 (to enable encryption, or build with `-DENABLE_ENCRYPTION=OFF`).
* Multithreading is provided by either of the following:
* C++11: standard library (`std` by `-DENABLE_STDCXX_SYNC=ON` CMake option);
* C++03: Pthreads (for POSIX systems it's built in, for Windows there is a ported library).
* Tcl 8.5 (optional, used by `./configure` script or use CMake directly).

For a detailed description of the build system and options, please refer to [SRT Build Options](docs/build/build-options.md).

### Build on Linux

Expand Down
Loading

0 comments on commit e338581

Please sign in to comment.