Skip to content

Commit

Permalink
Updated to latest upstream. Fixed wrong comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki committed May 7, 2024
2 parents 212750d + 38a3a16 commit f56dba5
Show file tree
Hide file tree
Showing 20 changed files with 480 additions and 211 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/abi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: ABI checks

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

env:
SRT_BASE: v1.5.0

jobs:
build:
name: ABI checks
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
with:
path: pull_request
- name: configure
run: |
cd pull_request
mkdir _build && cd _build
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_UNITTESTS=ON ../
- name: build
run: |
sudo apt install -y abi-dumper
cd pull_request/_build && cmake --build ./
make install DESTDIR=./installdir
SRT_TAG_VERSION=$(cat version.h |grep SRT_VERSION_MINOR |head -n1 |awk {'print $3'})
abi-dumper libsrt.so -o libsrt-pr.dump -public-headers installdir/usr/local/include/srt/ -lver 0
SRT_BASE="v1.$SRT_TAG_VERSION.0"
echo "SRT_BASE=$SRT_BASE" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
with:
path: tag
ref: ${{ env.SRT_BASE }}
- name: configure_tag
run: |
echo $SRT_TAG_VERSION
cd tag
mkdir _build && cd _build
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_UNITTESTS=ON ../
- name: build_tag
run: |
cd tag
cd _build && cmake --build ./
make install DESTDIR=./installdir
abi-dumper libsrt.so -o libsrt-tag.dump -public-headers installdir/usr/local/include/srt/ -lver 1
- name: abi-check
run: |
git clone https://github.com/lvc/abi-compliance-checker.git
cd abi-compliance-checker && sudo make install && cd ../
abi-compliance-checker -l libsrt -old tag/_build/libsrt-tag.dump -new pull_request/_build/libsrt-pr.dump
RES=$?
if (( $RES != 0 ))
then
echo "ABI/API Compatibility check failed with value $?"
exit $RES
fi
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSNAME_LC)
set_if(DARWIN (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
OR (${CMAKE_SYSTEM_NAME} MATCHES "iOS")
OR (${CMAKE_SYSTEM_NAME} MATCHES "tvOS")
OR (${CMAKE_SYSTEM_NAME} MATCHES "watchOS"))
OR (${CMAKE_SYSTEM_NAME} MATCHES "watchOS")
OR (${CMAKE_SYSTEM_NAME} MATCHES "visionOS"))
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))
Expand Down Expand Up @@ -237,12 +238,12 @@ if (NOT USE_ENCLIB)
message("NOTE: USE_GNUTLS is deprecated. Use -DUSE_ENCLIB=gnutls instead.")
set (USE_ENCLIB gnutls)
else()
set (USE_ENCLIB openssl)
set (USE_ENCLIB openssl-evp)
endif()
endif()

set(USE_ENCLIB "${USE_ENCLIB}" CACHE STRING "The crypto library that SRT uses")
set_property(CACHE USE_ENCLIB PROPERTY STRINGS "openssl" "gnutls" "mbedtls" "botan")
set_property(CACHE USE_ENCLIB PROPERTY STRINGS "openssl" "openssl-evp" "gnutls" "mbedtls" "botan")

# Make sure DLLs and executabes go to the same path regardles of subdirectory
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Expand Down
2 changes: 1 addition & 1 deletion docs/API/API-socket-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Exchange for the initial key is done in the handshake.

- `SRT_KM_S_SECURED` (`2`): KM exchange was successful and the data will be sent
encrypted and will be decrypted by the receiver. This state is only possible on
both sides in both directions simultaneously.
both sides in both directions simultaneously. Any unencrypted packet will be dropped by the receiver.

- `SRT_KM_S_NOSECRET` (`3`): If this state is in the sending direction (`SRTO_SNDKMSTATE`),
then it means that the sending party has set a passphrase, but the peer did not.
Expand Down
4 changes: 3 additions & 1 deletion docs/API/statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ Packets may be dropped conditionally when both `SRTO_TSBPDMODE` and `SRTO_TLPKTD
#### pktRcvUndecryptTotal

The total number of packets that failed to be decrypted at the receiver side. Available for receiver.
The statistic also counts unencrypted packets that were expected to be uncrypted on a secured connection (see [SRTO_KM_S_SECURED](API-socket-options.md#srt_km_state))
and hence dropped as not encrypted (undecrypted).

#### pktSndFilterExtraTotal

Expand Down Expand Up @@ -822,4 +824,4 @@ The ratio of unrecovered by the socket group packets `Dropped Packets Ratio` can
```
Dropped Packets Ratio = pktRcvDropTotal / pktSentUniqueTotal; in case both sender and receiver statistics is available
Dropped Packets Ratio = pktRcvDropTotal / (pktRecvUniqueTotal + pktRcvDropTotal); in case receiver only statistics is available
```
```
4 changes: 2 additions & 2 deletions docs/build/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ remember that:

Encryption library to be used. Possible options for `<name>`:

* openssl (default)
* openssl-evp (OpenSSL EVP API, since 1.5.1)
* openssl-evp (default)
* openssl
* gnutls (with nettle)
* mbedtls
* botan
Expand Down
1 change: 1 addition & 0 deletions haicrypt/hcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ int HaiCrypt_Clone(HaiCrypt_Handle hhcSrc, HaiCrypt_CryptoDir tx, HaiCrypt_Handl
cryptoClone->ctx_pair[1].flags &= ~HCRYPT_CTX_F_ENCRYPT;
memset(cryptoClone->ctx_pair[0].salt, 0, sizeof(cryptoClone->ctx_pair[0].salt));
cryptoClone->ctx_pair[0].salt_len = 0;
cryptoClone->ctx = &cryptoClone->ctx_pair[0];
}

*phhc = (void *)cryptoClone;
Expand Down
171 changes: 171 additions & 0 deletions scripts/visionOS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
# files which are included with CMake 2.8.4
# It has been altered for VISIONOS development

# Options:
#
# VISION_PLATFORM = OS (default) or SIMULATOR or SIMULATOR64
# This decides if SDKS will be selected from the XROS.platform or XRSimulator.platform folders
# OS - the default, used to build for Vision Pro physical device, which have an arm arch.
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
#
# VISIONOS_ARCH = arm64 (default for OS), x86_64 (addiitonal support for SIMULATOR64)
#
# CMAKE_VISIONOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
# By default this location is automatcially chosen based on the VISIONOS_PLATFORM value above.
# If set manually, it will override the default location and force the user of a particular Developer Platform
#
# CMAKE_VISIONOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
# By default this location is automatcially chosen based on the CMAKE_VISIONOS_DEVELOPER_ROOT value.
# In this case it will always be the most up-to-date SDK found in the CMAKE_VISIONOS_DEVELOPER_ROOT path.
# If set manually, this will force the use of a specific SDK version
#

# Standard settings
set (CMAKE_SYSTEM_NAME Darwin)
set (CMAKE_SYSTEM_VERSION 1)
set (UNIX True)
set (APPLE True)
set (VISIONOS True)

# Required as of cmake 2.8.10
set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for visionOs" FORCE)

# Determine the cmake host system version so we know where to find the visionOS SDKs
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
if (CMAKE_UNAME)
execute_process(COMMAND uname -r
OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
endif (CMAKE_UNAME)


set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)

set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")

if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR ENABLE_DEBUG)
set(VISIONOS_DEBUG_OPTIONS "-glldb -gmodules")
else()
set(VISIONOS_DEBUG_OPTIONS "-fvisibility=hidden -fvisibility-inlines-hidden")
endif()

set (CMAKE_C_FLAGS_INIT "${VISIONOS_DEBUG_OPTIONS} ${EMBED_OPTIONS}")
set (CMAKE_CXX_FLAGS_INIT "${VISIONOS_DEBUG_OPTIONS} ${EMBED_OPTIONS}")

set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${EMBED_OPTIONS} ${CMAKE_C_LINK_FLAGS}")
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${EMBED_OPTIONS} ${CMAKE_CXX_LINK_FLAGS}")


set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib")
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle")
set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")

# Specify install_name_tool and pkg-config since it outside of SDK path and therefore can't be found by CMake
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)

if (NOT DEFINED PKG_CONFIG_EXECUTABLE)
find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config)
if (DEFINED PKG_CONFIG_EXECUTABLE)
execute_process(COMMAND pkg-config --version OUTPUT_VARIABLE PKG_CONFIG_VERSION_STRING)
endif(DEFINED PKG_CONFIG_EXECUTABLE)
endif(NOT DEFINED PKG_CONFIG_EXECUTABLE)


# fffio Specify path to install shared library on device
set (CMAKE_INSTALL_NAME_DIR "@executable_path/Frameworks")
set (CMAKE_BUILD_WITH_INSTALL_NAME_DIR TRUE)

# Setup visionOS platform unless specified manually with VISIONOS_PLATFORM
if (NOT DEFINED VISIONOS_PLATFORM)
set (VISIONOS_PLATFORM "OS")
endif (NOT DEFINED VISIONOS_PLATFORM)
set (VISIONOS_PLATFORM ${VISIONOS_PLATFORM} CACHE STRING "Type of visionOS Platform")

# Check the platform selection and setup for developer root
if (${VISIONOS_PLATFORM} STREQUAL OS)
set (VISIONOS_PLATFORM_LOCATION "XROS.platform")

# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-xros")
elseif (${VISIONOS_PLATFORM} STREQUAL SIMULATOR)
set (SIMULATOR true)
set (VISIONOS_PLATFORM_LOCATION "XRSimulator.platform")

# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-xrsimulator")
elseif (${VISIONOS_PLATFORM} STREQUAL SIMULATOR64)
set (SIMULATOR true)
set (VISIONOS_PLATFORM_LOCATION "XRSimulator.platform")

# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-xrsimulator")
else (${VISIONOS_PLATFORM} STREQUAL OS)
message (FATAL_ERROR "Unsupported VISIONOS_PLATFORM value selected. Please choose OS or SIMULATOR")
endif (${VISIONOS_PLATFORM} STREQUAL OS)

# Setup visionOS developer location unless specified manually with CMAKE_VISIONOS_DEVELOPER_ROOT
if (NOT DEFINED CMAKE_VISIONOS_DEVELOPER_ROOT)
execute_process(COMMAND /usr/bin/xcode-select -print-path
OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
string(STRIP "${CMAKE_XCODE_DEVELOPER_DIR}" CMAKE_XCODE_DEVELOPER_DIR) # FIXED: remove new line character, otherwise it complain no visionOS SDK's found in default search path
set (CMAKE_VISIONOS_DEVELOPER_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${VISIONOS_PLATFORM_LOCATION}/Developer")
endif (NOT DEFINED CMAKE_VISIONOS_DEVELOPER_ROOT)
set (CMAKE_VISIONOS_DEVELOPER_ROOT ${CMAKE_VISIONOS_DEVELOPER_ROOT} CACHE PATH "Location of visionOS Platform")

# Find and use the most recent visionOS sdk unless specified manually with CMAKE_VISIONOS_SDK_ROOT
if (NOT DEFINED CMAKE_VISIONOS_SDK_ROOT)
file (GLOB _CMAKE_VISIONOS_SDKS "${CMAKE_VISIONOS_DEVELOPER_ROOT}/SDKs/*")
if (_CMAKE_VISIONOS_SDKS)
list (SORT _CMAKE_VISIONOS_SDKS)
list (REVERSE _CMAKE_VISIONOS_SDKS)
list (GET _CMAKE_VISIONOS_SDKS 0 CMAKE_VISIONOS_SDK_ROOT)
else (_CMAKE_VISIONOS_SDKS)
message (FATAL_ERROR "No visionOS SDK's found in default search path ${CMAKE_VISIONOS_DEVELOPER_ROOT}. Manually set CMAKE_VISIONOS_SDK_ROOT or install the visionOS SDK.")
endif (_CMAKE_VISIONOS_SDKS)
message (STATUS "Toolchain using default visionOS SDK: ${CMAKE_VISIONOS_SDK_ROOT}")
endif (NOT DEFINED CMAKE_VISIONOS_SDK_ROOT)
set (CMAKE_VISIONOS_SDK_ROOT ${CMAKE_VISIONOS_SDK_ROOT} CACHE PATH "Location of the selected visionOS SDK")

# Set the sysroot default to the most recent SDK
set (CMAKE_OSX_SYSROOT ${CMAKE_VISIONOS_SDK_ROOT} CACHE PATH "Sysroot used for visionOS support")

# set the architecture for visionOS
if (NOT DEFINED VISIONOS_ARCH)
if (${VISIONOS_PLATFORM} STREQUAL OS)
set (VISIONOS_ARCH arm64)
elseif (${VISIONOS_PLATFORM} STREQUAL SIMULATOR)
set (VISIONOS_ARCH arm64)
elseif (${VISIONOS_PLATFORM} STREQUAL SIMULATOR64)
set (VISIONOS_ARCH x86_64)
endif (${VISIONOS_PLATFORM} STREQUAL OS)
endif(NOT DEFINED VISIONOS_ARCH)
set (CMAKE_OSX_ARCHITECTURES ${VISIONOS_ARCH} CACHE STRING "Build architecture for visionOS")

# Set the find root to the visionOS developer roots and to user defined paths
set (CMAKE_FIND_ROOT_PATH ${CMAKE_VISIONOS_DEVELOPER_ROOT} ${CMAKE_VISIONOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE STRING "visionOS find search path root")

# default to searching for frameworks first
set (CMAKE_FIND_FRAMEWORK FIRST)

# set up the default search directories for frameworks
set (CMAKE_SYSTEM_FRAMEWORK_PATH
${CMAKE_VISIONOS_SDK_ROOT}/System/Library/Frameworks
${CMAKE_VISIONOS_SDK_ROOT}/System/Library/PrivateFrameworks
${CMAKE_VISIONOS_SDK_ROOT}/Developer/Library/Frameworks
)

# only search the visionOS sdks, not the remainder of the host filesystem (except for programs, so that we can still find Python if needed)
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

3 changes: 3 additions & 0 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ int srt::CUDTUnited::newConnection(const SRTSOCKET listen,
HLOGC(cnlog.Debug, log << "newConnection: mapping peer " << ns->m_PeerID
<< " to that socket (" << ns->m_SocketID << ")");
m_PeerRec[ns->getPeerSpec()].insert(ns->m_SocketID);

LOGC(cnlog.Note, log << "@" << ns->m_SocketID << " connection on listener @" << listen
<< " (" << ns->m_SelfAddr.str() << ") from peer @" << ns->m_PeerID << " (" << peer.str() << ")");
}
catch (...)
{
Expand Down
6 changes: 2 additions & 4 deletions srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,11 @@ class CUDTUnited

SocketKeeper(): socket(NULL) {}

// This is intended for API functions to lock the group's existence
// This is intended for API functions to lock the socket's existence
// for the lifetime of their call.
SocketKeeper(CUDTUnited& glob, SRTSOCKET id, ErrorHandling erh = ERH_RETURN) { socket = glob.locateAcquireSocket(id, erh); }

// This is intended for TSBPD thread that should lock the group's
// This is intended for TSBPD thread that should lock the socket's
// existence until it exits.
SocketKeeper(CUDTUnited& glob, CUDTSocket* s)
{
Expand All @@ -493,8 +493,6 @@ class CUDTUnited
{
SRT_ASSERT(socket->isStillBusy() > 0);
socket->apiRelease();
// Only now that the group lock is lifted, can the
// group be now deleted and this pointer potentially dangling
}
}
};
Expand Down
18 changes: 13 additions & 5 deletions srtcore/buffer_rcv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ int CRcvBuffer::insert(CUnit* unit)
return 0;
}

int CRcvBuffer::dropUpTo(int32_t seqno)
std::pair<int, int> CRcvBuffer::dropUpTo(int32_t seqno)
{
IF_RCVBUF_DEBUG(ScopedLog scoped_log);
IF_RCVBUF_DEBUG(scoped_log.ss << "CRcvBuffer::dropUpTo: seqno " << seqno << " m_iStartSeqNo " << m_iStartSeqNo);
Expand All @@ -215,16 +215,23 @@ int CRcvBuffer::dropUpTo(int32_t seqno)
if (len <= 0)
{
IF_RCVBUF_DEBUG(scoped_log.ss << ". Nothing to drop.");
return 0;
return std::make_pair(0, 0);
}

m_iMaxPosOff -= len;
if (m_iMaxPosOff < 0)
m_iMaxPosOff = 0;

const int iDropCnt = len;
int iNumDropped = 0; // Number of dropped packets that were missing.
int iNumDiscarded = 0; // The number of dropped packets that existed in the buffer.
while (len > 0)
{
// Note! Dropping a EntryState_Read must not be counted as a drop because it was read.
// Note! Dropping a EntryState_Drop must not be counted as a drop because it was already dropped and counted earlier.
if (m_entries[m_iStartPos].status == EntryState_Avail)
++iNumDiscarded;
else if (m_entries[m_iStartPos].status == EntryState_Empty)
++iNumDropped;
dropUnitInPos(m_iStartPos);
m_entries[m_iStartPos].status = EntryState_Empty;
SRT_ASSERT(m_entries[m_iStartPos].pUnit == NULL && m_entries[m_iStartPos].status == EntryState_Empty);
Expand All @@ -246,7 +253,7 @@ int CRcvBuffer::dropUpTo(int32_t seqno)
}
if (!m_tsbpd.isEnabled() && m_bMessageAPI)
updateFirstReadableOutOfOrder();
return iDropCnt;
return std::make_pair(iNumDropped, iNumDiscarded);
}

int CRcvBuffer::dropAll()
Expand All @@ -255,7 +262,8 @@ int CRcvBuffer::dropAll()
return 0;

const int end_seqno = CSeqNo::incseq(m_iStartSeqNo, m_iMaxPosOff);
return dropUpTo(end_seqno);
const std::pair<int, int> numDropped = dropUpTo(end_seqno);
return numDropped.first + numDropped.second;
}

int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, DropActionIfExists actionOnExisting)
Expand Down
Loading

0 comments on commit f56dba5

Please sign in to comment.