Skip to content

Commit 4c8f794

Browse files
author
Mikołaj Małecki
committed
Updated to latest upstream
2 parents d3147d7 + e2a00aa commit 4c8f794

File tree

138 files changed

+8349
-4955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+8349
-4955
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ _*/
3737
# Ignode Visual Studio Code temp folder
3838
.vs/
3939
.vscode/
40+
41+
# Ignore vcpkg submodule
42+
vcpkg/

.travis.yml

+15-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ addons:
1414
token:
1515
secure: "wJZC0kyyjuf4SZyonZ6p/5Ga9asEqSnKWF9NpRbu6S6ceERO7vbebuSJF5qX3A6ivPuw0TTk5WASOdnvIyfA28FU/D0MWRdH8K7T3w77wdE9EgAEYTUXzdrbzJY18+9pxjljHwWXWALPSGf3MClg4irWrdk1e6uHK+68R39+ZvBGBFpWeeZy/+at9+xwhtAGKBlSHe8zc+3wPxuYdvviLVJ25qbpNmnzkUR0X89G+UBl90raCPSN32EHFdImHZ5DxfEQQJgZFRjzQUY4EW/iYwaMel7jufAq0ClgV4psKujl9Lz8cPqx3WgqRfJyiIthOMTsac7G4zAw8LK2CI0VsssBp0JalLXaumi6vG7o6c3rIwKckzSKccq3pHa7h45praIVVn9s3nq+Q/JGA11FMkKQxdQtmwgFsLhbi6ZxabgsUi5KtWoWY2z6MgpJuROuAjNxZi9XJzUoJs7zSTUtRRW7V8Q2lRiOnknYh25N6TCA5bpyy1EZmRdJErm071YNI9P01gbFz5137FWJFiJzro9TGF0KoHSGiCIdUt3WlMzwr/i/wFLxFBQOZQ2rjTXvhs4hxONxMZV3gzxA1NdLaf9i5Mh6jxVMV+ujaRSV7JmPGzxqiAlpT9cJUhTCYuar9diLLeDrpe7RawEZR8V1xVDQ7yT8ruDNQ78VbSn/sC0="
1616
homebrew:
17-
update: true # TODO: this should be removed once this bug is fixed: https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296
17+
update: false
1818
packages:
1919
- openssl
2020

@@ -23,20 +23,24 @@ matrix:
2323
- os: linux
2424
env:
2525
- BUILD_TYPE=Debug
26-
- BUILD_OPTS='-DENABLE_CODE_COVERAGE=ON -DENABLE_EXPERIMENTAL_BONDING=ON'
26+
- BUILD_OPTS='-DENABLE_CODE_COVERAGE=ON -DENABLE_EXPERIMENTAL_BONDING=ON -DCMAKE_CXX_FLAGS="-Werror"'
2727
- RUN_SONARCUBE=1
2828
- RUN_CODECOV=1
2929
- env:
3030
- BUILD_TYPE=Debug
31-
- BUILD_OPTS='-DENABLE_LOGGING=OFF -DENABLE_MONOTONIC_CLOCK=ON -DENABLE_EXPERIMENTAL_BONDING=ON'
31+
- BUILD_OPTS='-DENABLE_LOGGING=OFF -DENABLE_MONOTONIC_CLOCK=ON -DENABLE_EXPERIMENTAL_BONDING=ON -DCMAKE_CXX_FLAGS="-Werror"'
3232
- os: linux
3333
env: BUILD_TYPE=Release
3434
- os: osx
35-
osx_image: xcode10.2
36-
env: BUILD_TYPE=Debug
35+
osx_image: xcode11.1
36+
env:
37+
- BUILD_TYPE=Debug
38+
- BUILD_OPTS='-DCMAKE_CXX_FLAGS="-Werror"'
3739
- os: osx
38-
osx_image: xcode10.2
39-
env: BUILD_TYPE=Release
40+
osx_image: xcode11.1
41+
env:
42+
- BUILD_TYPE=Release
43+
- BUILD_OPTS='-DCMAKE_CXX_FLAGS="-Werror"'
4044
- os: linux
4145
compiler: x86_64-w64-mingw32-g++
4246
addons:
@@ -54,7 +58,7 @@ matrix:
5458
- make
5559
- cd ..
5660
env: BUILD_TYPE=Release
57-
61+
5862
# Power jobs
5963
- os: linux
6064
arch: ppc64le
@@ -65,6 +69,7 @@ matrix:
6569
- BUILD_TYPE=Release
6670
- BUILD_OPTS='-DENABLE_MONOTONIC_CLOCK=ON'
6771
script:
72+
- TESTS_IPv6="TestMuxer.IPv4_and_IPv6:TestIPv6.v6_calls_v6*:ReuseAddr.ProtocolVersion" ; # Tests to skip due to lack of IPv6 support
6873
- if [ "$TRAVIS_COMPILER" == "x86_64-w64-mingw32-g++" ]; then
6974
export CC="x86_64-w64-mingw32-gcc";
7075
export CXX="x86_64-w64-mingw32-g++";
@@ -87,10 +92,10 @@ script:
8792
make -j$(nproc);
8893
fi
8994
- if [ "$TRAVIS_COMPILER" != "x86_64-w64-mingw32-g++" ]; then
90-
./test-srt --gtest_filter="-TestMuxer.IPv4_and_IPv6:TestIPv6.v6_calls_v6*";
91-
source ./scripts/collect-gcov.sh;
95+
./test-srt --gtest_filter="-$TESTS_IPv6";
9296
fi
9397
- if (( "$RUN_CODECOV" )); then
98+
source ./scripts/collect-gcov.sh;
9499
bash <(curl -s https://codecov.io/bash);
95100
fi
96101
- if (( "$RUN_SONARCUBE" )); then

CMakeLists.txt

+45-27
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ endforeach()
9797
# SRT_DEBUG_TLPKTDROP_DROPSEQ 1
9898
# SRT_DEBUG_SNDQ_HIGHRATE 1
9999
# SRT_DEBUG_BONDING_STATES 1
100+
# SRT_DEBUG_RTT 1 /* RTT trace */
100101
# SRT_MAVG_SAMPLING_RATE 40 /* Max sampling rate */
101102

102103
# option defaults
@@ -283,14 +284,29 @@ if (ENABLE_ENCRYPTION)
283284
link_directories(
284285
${SSL_LIBRARY_DIRS}
285286
)
286-
else() # Common for mbedtls and openssl
287-
if ("${USE_ENCLIB}" STREQUAL "mbedtls")
288-
add_definitions(-DUSE_MBEDTLS=1)
289-
set (SSL_REQUIRED_MODULES "mbedtls mbedcrypto")
290-
else()
291-
add_definitions(-DUSE_OPENSSL=1)
292-
set (SSL_REQUIRED_MODULES "openssl libcrypto")
287+
elseif ("${USE_ENCLIB}" STREQUAL "mbedtls")
288+
add_definitions(-DUSE_MBEDTLS=1)
289+
if ("${SSL_LIBRARY_DIRS}" STREQUAL "")
290+
set(MBEDTLS_PREFIX "${CMAKE_PREFIX_PATH}" CACHE PATH "The path of mbedtls")
291+
find_package(MbedTLS REQUIRED)
292+
set (SSL_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
293+
set (SSL_LIBRARIES ${MBEDTLS_LIBRARIES})
294+
endif()
295+
if ("${SSL_LIBRARIES}" STREQUAL "")
296+
set (SSL_LIBRARIES mbedtls mbedcrypto)
293297
endif()
298+
message(STATUS "SSL enforced mbedtls: -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
299+
300+
foreach(LIB ${SSL_LIBRARIES})
301+
if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB})
302+
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ${LIB})
303+
else()
304+
set(SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} "-l${LIB}")
305+
endif()
306+
endforeach()
307+
else() # openssl
308+
add_definitions(-DUSE_OPENSSL=1)
309+
set (SSL_REQUIRED_MODULES "openssl libcrypto")
294310
# Try using pkg-config method first if enabled,
295311
# fall back to find_package method otherwise
296312
if (USE_OPENSSL_PC)
@@ -315,24 +331,12 @@ if (ENABLE_ENCRYPTION)
315331
)
316332
message(STATUS "SSL via pkg-config: -L ${SSL_LIBRARY_DIRS} -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
317333
else()
318-
if ("${USE_ENCLIB}" STREQUAL "mbedtls")
319-
if ("${SSL_LIBRARY_DIRS}" STREQUAL "")
320-
set(MBEDTLS_PREFIX "${CMAKE_PREFIX_PATH}" CACHE PATH "The path of mbedtls")
321-
find_package(MbedTLS REQUIRED)
322-
set (SSL_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
323-
set (SSL_LIBRARIES ${MBEDTLS_LIBRARIES})
324-
endif()
325-
if ("${SSL_LIBRARIES}" STREQUAL "")
326-
set (SSL_LIBRARIES mbedtls mbedcrypto)
327-
endif()
328-
message(STATUS "SSL enforced mbedtls: -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
329-
else()
330-
find_package(OpenSSL REQUIRED)
331-
set (SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
332-
set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})
333-
message(STATUS "SSL via find_package(OpenSSL): -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
334-
endif()
334+
find_package(OpenSSL REQUIRED)
335+
set (SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
336+
set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})
337+
message(STATUS "SSL via find_package(OpenSSL): -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
335338
endif()
339+
336340
endif()
337341

338342
add_definitions(-DSRT_ENABLE_ENCRYPTION)
@@ -786,9 +790,14 @@ MafReadDir(srtcore filelist.maf
786790
# Auto generated version file and add it to the HEADERS_srt list.
787791
if(DEFINED ENV{APPVEYOR_BUILD_NUMBER})
788792
set(SRT_VERSION_BUILD ON)
789-
set(APPVEYOR_BUILD_NUMBER_STRING $ENV{APPVEYOR_BUILD_NUMBER})
793+
set(CI_BUILD_NUMBER_STRING $ENV{APPVEYOR_BUILD_NUMBER})
790794
message(STATUS "AppVeyor build environment detected: Adding build number to version header")
791795
endif()
796+
if(DEFINED ENV{TEAMCITY_VERSION})
797+
set(SRT_VERSION_BUILD ON)
798+
set(CI_BUILD_NUMBER_STRING $ENV{CI_BUILD_COUNTER})
799+
message(STATUS "TeamCity build environment detected: Adding build counter to version header")
800+
endif()
792801

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

@@ -1189,6 +1198,16 @@ endif()
11891198

11901199

11911200
if (ENABLE_UNITTESTS AND ENABLE_CXX11)
1201+
1202+
if (${CMAKE_VERSION} VERSION_LESS "3.10.0")
1203+
message(STATUS "VERSION < 3.10 -- adding test using the old method")
1204+
set (USE_OLD_ADD_METHOD 1)
1205+
else()
1206+
message(STATUS "VERSION > 3.10 -- using NEW POLICY for in_list operator")
1207+
cmake_policy(SET CMP0057 NEW) # Support the new IN_LIST operator.
1208+
endif()
1209+
1210+
11921211
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
11931212

11941213
find_package(GTest 1.8)
@@ -1217,13 +1236,12 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
12171236
${PTHREAD_LIBRARY}
12181237
)
12191238

1220-
if (${CMAKE_VERSION} VERSION_LESS "3.10.0")
1239+
if (USE_OLD_ADD_METHOD)
12211240
add_test(
12221241
NAME test-srt
12231242
COMMAND ${CMAKE_BINARY_DIR}/test-srt
12241243
)
12251244
else()
1226-
cmake_policy(SET CMP0057 NEW) # Support the new IN_LIST operator.
12271245
gtest_add_tests(
12281246
test-srt
12291247
""

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Submit a pull request at any time, whether an issue has been created or not. It
2121
* SRT protocol definitions
2222
* portability and platform-specific parts
2323

24-
Please follow the [Developer's guide](./docs/DevelopersGuide.md).
24+
Please follow the [SRT Developer's Guide](docs/dev/developers-guide.md).
2525

2626
## Code Style
2727

README.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ As audio/video packets are streamed from a source to a destination device, SRT d
3333

3434
### Guides
3535

36-
* [Why SRT Was Created](docs/why-srt-was-created.md)
37-
* [SRT Protocol Technical Overview](https://github.com/Haivision/srt/files/2489142/SRT_Protocol_TechnicalOverview_DRAFT_2018-10-17.pdf)
38-
* SRT Cookbook: [website](https://srtlab.github.io/srt-cookbook), [GitHub](https://github.com/SRTLab/srt-cookbook)
39-
* SRT RFC: [txt](https://haivision.github.io/srt-rfc/draft-sharabayko-mops-srt.txt), [html](https://haivision.github.io/srt-rfc/draft-sharabayko-mops-srt.html), [GitHub](https://github.com/Haivision/srt-rfc)
40-
* [Using the `srt-live-transmit` App](docs/srt-live-transmit.md)
36+
* [SRT API Documents](docs/API/)
37+
* [Using the `srt-live-transmit` App](docs/apps/srt-live-transmit.md)
38+
* [SRT Developer's Guide](docs/dev/developers-guide.md)
4139
* [Contributing](CONTRIBUTING.md)
42-
* [Developer's Guide](docs/DevelopersGuide.md)
43-
* [SRT Encryption](docs/encryption.md)
44-
* [API](docs/API.md)
45-
* [Reporting problems](docs/reporting.md)
40+
* [Reporting Issues](docs/dev/making-srt-better.md)
41+
* SRT RFC: [Latest IETF Draft](https://datatracker.ietf.org/doc/html/draft-sharabayko-srt-00), [Latest Working Copy](https://haivision.github.io/srt-rfc/draft-sharabayko-srt.html), [GitHub Repo](https://github.com/Haivision/srt-rfc)
42+
* SRT CookBook: [Website](https://srtlab.github.io/srt-cookbook), [GitHub Repo](https://github.com/SRTLab/srt-cookbook)
43+
* [SRT Protocol Technical Overview](https://github.com/Haivision/srt/files/2489142/SRT_Protocol_TechnicalOverview_DRAFT_2018-10-17.pdf)
44+
* [Why SRT Was Created](docs/misc/why-srt-was-created.md)
4645

4746
## Requirements
4847

@@ -51,7 +50,7 @@ As audio/video packets are streamed from a source to a destination device, SRT d
5150
* OpenSSL
5251
* Pthreads (for POSIX systems it's builtin, for Windows there's a library)
5352

54-
For detailed description of the build system and options, please read [BuildOptions.md](docs/BuildOptions.md).
53+
For detailed description of the build system and options, please read [SRT Build Options](docs/build/build-options.md).
5554

5655
### Build on Linux
5756

@@ -128,7 +127,7 @@ make
128127

129128
### Build on Windows
130129

131-
Follow the [Windows build instructions](docs/build-win.md).
130+
Follow the [Building SRT for Windows](docs/build/build-win.md) instructions.
132131

133132
[appveyor-badge]: https://img.shields.io/appveyor/ci/Haivision/srt/master.svg?label=Windows
134133
[appveyor]: https://ci.appveyor.com/project/Haivision/srt

apps/apputil.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ options_t ProcessOptions(char* const* argv, int argc, std::vector<OptionScheme>
205205
isoption = true;
206206
// If a[0] isn't NUL - because it is dash - then
207207
// we can safely check a[1].
208-
if (a[1] && isdigit(a[1]))
208+
// An expression starting with a dash is not
209+
// an option marker if it is a single dash or
210+
// a negative number.
211+
if (!a[1] || isdigit(a[1]))
209212
isoption = false;
210213
}
211214

@@ -391,10 +394,10 @@ struct SrtStatsTableInit
391394
STAT(SEND, bytes, byteSent);
392395
STAT(SEND, bytesUnique, byteSentUnique);
393396
STAT(SEND, bytesDropped, byteSndDrop);
397+
STAT(SEND, byteAvailBuf, byteAvailSndBuf);
398+
STAT(SEND, msBuf, msSndBuf);
394399
STAT(SEND, mbitRate, mbpsSendRate);
395400
STAT(SEND, sendPeriod, usPktSndPeriod);
396-
//STAT(SEND, msAvgResponseTime, msAvgResponseTime);
397-
//STAT(SEND, msMaxResponseTime, msMaxResponseTime);
398401

399402
STAT(RECV, packets, pktRecv);
400403
STAT(RECV, packetsUnique, pktRecvUnique);
@@ -409,7 +412,10 @@ struct SrtStatsTableInit
409412
STAT(RECV, bytesUnique, byteRecvUnique);
410413
STAT(RECV, bytesLost, byteRcvLoss);
411414
STAT(RECV, bytesDropped, byteRcvDrop);
415+
STAT(RECV, byteAvailBuf, byteAvailRcvBuf);
416+
STAT(RECV, msBuf, msRcvBuf);
412417
STAT(RECV, mbitRate, mbpsRecvRate);
418+
STAT(RECV, msTsbPdDelay, msRcvTsbPdDelay);
413419
}
414420
} g_SrtStatsTableInit (g_SrtStatsTable);
415421

@@ -546,7 +552,7 @@ class SrtStatsJson : public SrtStatsWriter
546552
}
547553

548554
// Close the general category entity
549-
output << "}," << pretty_cr << endl;
555+
output << "}" << pretty_cr << endl;
550556

551557
return output.str();
552558
}
@@ -586,12 +592,8 @@ class SrtStatsCsv : public SrtStatsWriter
586592
output << endl;
587593
first_line_printed = true;
588594
}
589-
int rcv_latency = 0;
590-
int int_len = sizeof rcv_latency;
591-
srt_getsockopt(sid, 0, SRTO_RCVLATENCY, &rcv_latency, &int_len);
592595

593596
// Values
594-
595597
#ifdef HAS_PUT_TIME
596598
// HDR: Timepoint
597599
output << print_timestamp() << ",";
@@ -685,4 +687,3 @@ SrtStatsPrintFormat ParsePrintFormat(string pf, string& w_extras)
685687

686688
return SRTSTATS_PROFMAT_INVALID;
687689
}
688-

apps/apputil.hpp

+15
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ inline void SysCleanupNetwork()
5858
#include <arpa/inet.h>
5959
#include <unistd.h>
6060

61+
// Fixes Android build on NDK r16b and earlier.
62+
#if defined(__ANDROID__) && (__ANDROID__ == 1)
63+
#include <android/ndk-version.h>
64+
#if !defined(__NDK_MAJOR__) || (__NDK_MAJOR__ <= 16)
65+
struct ip_mreq_sourceFIXED {
66+
struct in_addr imr_multiaddr;
67+
struct in_addr imr_interface;
68+
struct in_addr imr_sourceaddr;
69+
};
70+
#define ip_mreq_source ip_mreq_sourceFIXED
71+
#endif
72+
#endif
73+
6174
// Nothing needs to be done on POSIX; this is a Windows problem.
6275
inline bool SysInitializeNetwork() {return true;}
6376
inline void SysCleanupNetwork() {}
@@ -68,8 +81,10 @@ inline void SysCleanupNetwork() {}
6881

6982
#ifdef _WIN32
7083
inline int SysError() { return ::GetLastError(); }
84+
const int SysAGAIN = WSAEWOULDBLOCK;
7185
#else
7286
inline int SysError() { return errno; }
87+
const int SysAGAIN = EAGAIN;
7388
#endif
7489

7590
sockaddr_any CreateAddr(const std::string& name, unsigned short port = 0, int pref_family = AF_UNSPEC);

apps/socketoptions.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ const SocketOption srt_options [] {
229229
{ "latency", 0, SRTO_LATENCY, SocketOption::PRE, SocketOption::INT, nullptr},
230230
{ "tsbpdmode", 0, SRTO_TSBPDMODE, SocketOption::PRE, SocketOption::BOOL, nullptr},
231231
{ "tlpktdrop", 0, SRTO_TLPKTDROP, SocketOption::PRE, SocketOption::BOOL, nullptr},
232-
{ "snddropdelay", 0, SRTO_SNDDROPDELAY, SocketOption::PRE, SocketOption::INT, nullptr},
232+
{ "snddropdelay", 0, SRTO_SNDDROPDELAY, SocketOption::POST, SocketOption::INT, nullptr},
233233
{ "nakreport", 0, SRTO_NAKREPORT, SocketOption::PRE, SocketOption::BOOL, nullptr},
234234
{ "conntimeo", 0, SRTO_CONNTIMEO, SocketOption::PRE, SocketOption::INT, nullptr},
235235
{ "drifttracer", 0, SRTO_DRIFTTRACER, SocketOption::POST, SocketOption::BOOL, nullptr},

apps/srt-file-transmit.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ bool DoUpload(UriParser& ut, string path, string filename,
321321
<< tar->GetSRTSocket() << endl;
322322
goto exit;
323323
}
324-
UDT::setstreamid(tar->GetSRTSocket(), filename);
324+
srt::setstreamid(tar->GetSRTSocket(), filename);
325325
}
326326

327327
s = tar->GetSRTSocket();
@@ -539,7 +539,7 @@ bool DoDownload(UriParser& us, string directory, string filename,
539539
cerr << "Failed to add SRT client to poll" << endl;
540540
goto exit;
541541
}
542-
id = UDT::getstreamid(s);
542+
id = srt::getstreamid(s);
543543
cerr << "Source connected (listener), id ["
544544
<< id << "]" << endl;
545545
connected = true;
@@ -550,7 +550,7 @@ bool DoDownload(UriParser& us, string directory, string filename,
550550
{
551551
if (!connected)
552552
{
553-
id = UDT::getstreamid(s);
553+
id = srt::getstreamid(s);
554554
cerr << "Source connected (caller), id ["
555555
<< id << "]" << endl;
556556
connected = true;
@@ -714,7 +714,7 @@ int main(int argc, char** argv)
714714
}
715715
else
716716
{
717-
UDT::setlogstream(logfile_stream);
717+
srt::setlogstream(logfile_stream);
718718
}
719719
}
720720

0 commit comments

Comments
 (0)