Skip to content

Commit

Permalink
Fixed the old test. Added one more test to close during connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj Malecki committed Jun 25, 2024
2 parents cf3850c + 72303d7 commit 9967d1d
Show file tree
Hide file tree
Showing 65 changed files with 2,039 additions and 1,105 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
25 changes: 20 additions & 5 deletions .github/workflows/cxx11-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,34 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]

types: [opened, synchronize, reopened]
jobs:
build:
name: ubuntu
runs-on: ubuntu-20.04

env:
BUILD_WRAPPER_OUT_DIR: sonar-output # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v3
- name: Install sonar-scanner and build-wrapper
uses: sonarsource/sonarcloud-github-c-cpp@v2
- name: configure
run: |
mkdir _build && cd _build
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=ON -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON -DENABLE_CODE_COVERAGE=ON
- name: build
run: cd _build && cmake --build ./
run: cd _build && build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build .
- name: test
run: cd _build && ctest --extra-verbose
run: |
cd _build && ctest --extra-verbose
- name: codecov
run: |
source ./scripts/collect-gcov.sh
bash <(curl -s https://codecov.io/bash)
- name: Run SonarCloud Scan for C and C++
if: ${{ !github.event.pull_request.head.repo.fork }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Consult https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-cli/ for more information and options.
run: sonar-scanner --define sonar.cfamily.build-wrapper-output=_build/"${{ env.BUILD_WRAPPER_OUT_DIR }}"
41 changes: 41 additions & 0 deletions .github/workflows/s390x-focal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: QEMU to run s390x-focal

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

jobs:
Tests:
runs-on: ubuntu-latest
steps:
- name: Setup multiarch/qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- name: ubuntu-core:s390x-focal
uses: docker://multiarch/ubuntu-core:s390x-focal
with:
args: >
bash -c
"uname -a &&
lscpu | grep Endian
"
- name: Checkout
uses: actions/checkout@v3
- name: configure
uses: docker://multiarch/ubuntu-core:s390x-focal
with:
args: >
bash -c
"apt-get -y update &&
export DEBIAN_FRONTEND=noninteractive &&
export TZ=Etc/UTC &&
apt-get -y install tzdata &&
uname -a &&
lscpu | grep Endian &&
apt-get -y install cmake g++ libssl-dev git &&
mkdir _build && cd _build &&
cmake ../ -DENABLE_ENCRYPTION=ON -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON &&
cmake --build ./ &&
./test-srt -disable-ipv6"
28 changes: 2 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ addons:
- build-essential
- libmbedtls-dev
- gdb
sonarcloud:
organization: "haivision"
token:
secure: "wJZC0kyyjuf4SZyonZ6p/5Ga9asEqSnKWF9NpRbu6S6ceERO7vbebuSJF5qX3A6ivPuw0TTk5WASOdnvIyfA28FU/D0MWRdH8K7T3w77wdE9EgAEYTUXzdrbzJY18+9pxjljHwWXWALPSGf3MClg4irWrdk1e6uHK+68R39+ZvBGBFpWeeZy/+at9+xwhtAGKBlSHe8zc+3wPxuYdvviLVJ25qbpNmnzkUR0X89G+UBl90raCPSN32EHFdImHZ5DxfEQQJgZFRjzQUY4EW/iYwaMel7jufAq0ClgV4psKujl9Lz8cPqx3WgqRfJyiIthOMTsac7G4zAw8LK2CI0VsssBp0JalLXaumi6vG7o6c3rIwKckzSKccq3pHa7h45praIVVn9s3nq+Q/JGA11FMkKQxdQtmwgFsLhbi6ZxabgsUi5KtWoWY2z6MgpJuROuAjNxZi9XJzUoJs7zSTUtRRW7V8Q2lRiOnknYh25N6TCA5bpyy1EZmRdJErm071YNI9P01gbFz5137FWJFiJzro9TGF0KoHSGiCIdUt3WlMzwr/i/wFLxFBQOZQ2rjTXvhs4hxONxMZV3gzxA1NdLaf9i5Mh6jxVMV+ujaRSV7JmPGzxqiAlpT9cJUhTCYuar9diLLeDrpe7RawEZR8V1xVDQ7yT8ruDNQ78VbSn/sC0="
homebrew:
update: false
packages:
Expand All @@ -25,9 +21,7 @@ matrix:
- os: linux
env:
- BUILD_TYPE=Debug
- BUILD_OPTS='-DENABLE_CODE_COVERAGE=ON -DENABLE_BONDING=ON -DCMAKE_CXX_FLAGS="-Werror"'
- RUN_SONARCUBE=1
- RUN_CODECOV=1
- BUILD_OPTS='-DENABLE_BONDING=ON -DCMAKE_CXX_FLAGS="-Werror"'
- env:
- BUILD_TYPE=Debug
- BUILD_OPTS='-DENABLE_LOGGING=OFF -DUSE_ENCLIB=mbedtls -DENABLE_MONOTONIC_CLOCK=ON -DENABLE_BONDING=ON -DCMAKE_CXX_FLAGS="-Werror"'
Expand Down Expand Up @@ -81,29 +75,11 @@ script:
export PKG_CONFIG_PATH=$(brew --prefix openssl)"/lib/pkgconfig";
cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE $BUILD_OPTS -DENABLE_UNITTESTS="ON";
fi
- echo "TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG"
- echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"
- if [[ "$TRAVIS_REPO_SLUG" != "Haivision/srt" || "$TRAVIS_PULL_REQUEST" -gt 0 ]]; then
export RUN_SONARCUBE=0;
fi
- echo "RUN_SONARCUBE=$RUN_SONARCUBE"
- if (( "$RUN_SONARCUBE" )); then
build-wrapper-linux-x86-64 --out-dir bw-output make;
else
make -j$(nproc);
fi
- make -j$(nproc);
- if [ "$TRAVIS_COMPILER" != "x86_64-w64-mingw32-g++" ]; then
ulimit -c unlimited;
./test-srt -disable-ipv6;
SUCCESS=$?;
if [ -f core ]; then gdb -batch ./test-srt -c core -ex bt -ex "info thread" -ex quit; else echo "NO CORE - NO CRY!"; fi;
test $SUCCESS == 0;
fi
after_success:
- if (( "$RUN_CODECOV" )); then
source ./scripts/collect-gcov.sh;
bash <(curl -s https://codecov.io/bash);
fi
- if (( "$RUN_SONARCUBE" )); then
sonar-scanner -D"sonar.cfamily.gcov.reportPath=.";
fi
26 changes: 14 additions & 12 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 @@ -73,7 +74,12 @@ if (NOT MICROSOFT)
# that ENABLE_DEBUG is set as it should.
if (ENABLE_DEBUG EQUAL 2)
set (CMAKE_BUILD_TYPE "RelWithDebInfo")
add_definitions(-DNDEBUG)
if (ENABLE_ASSERT)
# Add _DEBUG macro if explicitly requested, to enable SRT_ASSERT().
add_definitions(-D_DEBUG)
else()
add_definitions(-DNDEBUG)
endif()
elseif (ENABLE_DEBUG) # 1, ON, YES, TRUE, Y, or any other non-zero number
set (CMAKE_BUILD_TYPE "Debug")

Expand Down Expand Up @@ -232,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 Expand Up @@ -360,11 +366,11 @@ if (ENABLE_ENCRYPTION)
set (SSL_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set (SSL_LIBRARIES ${MBEDTLS_LIBRARIES})
endif()
if (WIN32)
set (SSL_LIBRARIES ${SSL_LIBRARIES} bcrypt)
endif()
if ("${SSL_LIBRARIES}" STREQUAL "")
set (SSL_LIBRARIES mbedtls mbedcrypto)
if (WIN32)
set (SSL_LIBRARIES ${SSL_LIBRARIES} bcrypt)
endif()
endif()
message(STATUS "SSL enforced mbedtls: -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")

Expand Down Expand Up @@ -1522,15 +1528,11 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
)
#set_tests_properties(test-srt PROPERTIES RUN_SERIAL TRUE)
else()
gtest_add_tests(
TEST_LIST tests_srt
TARGET test-srt
)
set_tests_properties(${tests_srt} PROPERTIES RUN_SERIAL TRUE)
gtest_discover_tests(test-srt)
endif()

enable_testing()

endif()


Expand Down
2 changes: 1 addition & 1 deletion apps/srt-live-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#include <thread>
#include <list>


#include "srt_compat.h"
#include "apputil.hpp" // CreateAddr
#include "uriparser.hpp" // UriParser
#include "socketoptions.hpp"
Expand Down
1 change: 1 addition & 0 deletions apps/srt-tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <mutex>
#include <condition_variable>

#include "srt_compat.h"
#include "apputil.hpp" // CreateAddr
#include "uriparser.hpp" // UriParser
#include "socketoptions.hpp"
Expand Down
2 changes: 1 addition & 1 deletion apps/verbose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ inline void Print(Log& ) {}
template <typename Arg1, typename... Args>
inline void Print(Log& out, Arg1&& arg1, Args&&... args)
{
out << arg1;
out << std::forward(arg1);
Print(out, args...);
}

Expand Down
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ coverage:
threshold: null
patch: false
changes: false
ignore:
- "testing"
- "apps"
- "example"
40 changes: 30 additions & 10 deletions 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 Expand Up @@ -301,7 +301,8 @@ connection is rejected - **however** you may also change the value of this
option for the accepted socket in the listener callback (see `srt_listen_callback`)
if an appropriate instruction was given in the Stream ID.

Currently supported congestion controllers are designated as "live" and "file"
Currently supported congestion controllers are designated as "live" and "file",
which correspond to the Live and File modes.

Note that it is not recommended to change this option manually, but you should
rather change the whole set of options using the [`SRTO_TRANSTYPE`](#SRTO_TRANSTYPE) option.
Expand Down Expand Up @@ -772,7 +773,8 @@ for more details.
| `SRTO_LATENCY` | 1.0.2 | pre | `int32_t` | ms | 120 * | 0.. | RW | GSD |

This option sets both [`SRTO_RCVLATENCY`](#SRTO_RCVLATENCY) and [`SRTO_PEERLATENCY`](#SRTO_PEERLATENCY)
to the same value specified.
to the same value specified. Note that the default value for `SRTO_RCVLATENCY` is modified by the
[`SRTO_TRANSTYPE`](#SRTO_TRANSTYPE) option.

Prior to SRT version 1.3.0 `SRTO_LATENCY` was the only option to set the latency.
However it is effectively equivalent to setting `SRTO_PEERLATENCY` in the sending direction
Expand Down Expand Up @@ -1212,6 +1214,8 @@ considered broken on timeout.
The latency value (as described in [`SRTO_RCVLATENCY`](#SRTO_RCVLATENCY)) provided by the sender
side as a minimum value for the receiver.

This value is only significant when [`SRTO_TSBPDMODE`](#SRTO_TSBPDMODE) is enabled.

Reading the value of the option on an unconnected socket reports the configured value.
Reading the value on a connected socket reports the effective receiver buffering latency of the peer.

Expand Down Expand Up @@ -1296,16 +1300,22 @@ This value is only significant when [`SRTO_TSBPDMODE`](#SRTO_TSBPDMODE) is enabl
**Default value**: 120 ms in Live mode, 0 in File mode (see [`SRTO_TRANSTYPE`](#SRTO_TRANSTYPE)).

The latency value defines the **minimum** receiver buffering delay before delivering an SRT data packet
from a receiving SRT socket to a receiving application. The provided value is used in the connection establishment (handshake exchange) stage
to fix the end-to-end latency of the transmission. The effective end-to-end latency `L` will be fixed
as the network transmission time of the final handshake packet (~1/2 RTT) plus the **negotiated** latency value `Ln`.
Data packets will stay in the receiver buffer for at least `L` microseconds since the timestamp of the
packet, independent of the actual network transmission times (RTT variations) of these packets.
from a receiving SRT socket to a receiving application.

The actual value of the receiver buffering delay `Ln` (the negotiated latency) used on a connection
is determined by the negotiation in the connection establishment (handshake exchange) phase as the maximum of the
`SRTO_RCVLATENCY` value and the value of [`SRTO_PEERLATENCY`](#SRTO_PEERLATENCY) set by the peer.

The general idea for the latency mechanism is to keep the time distance between two consecutive
received packets the same as the time when these same packets were scheduled for sending by the
sender application (or per the time explicitly declared when sending - see
[`srt_sendmsg2`](API-functions.md#srt_sendmsg2) for details). This keeps any packets that have arrived
earlier than their delivery time in the receiver buffer until their delivery time comes. This should
compensate for any jitter in the network and provides an extra delay needed for a packet retransmission.

For detailed information on how the latency setting influences the actual packet delivery time and
how this time is defined, refer to the [latency documentation](../features/latency.md).

Reading the `SRTO_RCVLATENCY` value on a socket after the connection is established provides the actual (negotiated)
latency value `Ln`.

Expand Down Expand Up @@ -1638,9 +1648,19 @@ enabled in sender if receiver supports it.

Sets the transmission type for the socket, in particular, setting this option
sets multiple other parameters to their default values as required for a
particular transmission type.
particular transmission type. This sets the following options to their defaults
in particular mode:

* [`SRTO_CONGESTION`](#SRTO_CONGESTION)
* [`SRTO_MESSAGEAPI`](#SRTO_MESSAGEAPI)
* [`SRTO_NAKREPORT`](#SRTO_NAKREPORT)
* [`SRTO_RCVLATENCY`](#SRTO_RCVLATENCY), also set as [`SRTO_LATENCY`](#SRTO_LATENCY)
* [`SRTO_TLPKTDROP`](#SRTO_TLPKTDROP)
* [`SRTO_TSBPDMODE`](#SRTO_TSBPDMODE)



Values defined by enum `SRT_TRANSTYPE` (see above for possible values)
Values defined by enum [`SRT_TRANSTYPE`](#SRT_TRANSTYPE).

[Return to list](#list-of-options)

Expand Down
Loading

0 comments on commit 9967d1d

Please sign in to comment.