Skip to content

Commit

Permalink
Updated and fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki committed May 31, 2021
2 parents cc7755c + 17fee15 commit a5de970
Show file tree
Hide file tree
Showing 138 changed files with 7,860 additions and 4,826 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ _*/
# Ignode Visual Studio Code temp folder
.vs/
.vscode/

# Ignore vcpkg submodule
vcpkg/
25 changes: 15 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ addons:
token:
secure: "wJZC0kyyjuf4SZyonZ6p/5Ga9asEqSnKWF9NpRbu6S6ceERO7vbebuSJF5qX3A6ivPuw0TTk5WASOdnvIyfA28FU/D0MWRdH8K7T3w77wdE9EgAEYTUXzdrbzJY18+9pxjljHwWXWALPSGf3MClg4irWrdk1e6uHK+68R39+ZvBGBFpWeeZy/+at9+xwhtAGKBlSHe8zc+3wPxuYdvviLVJ25qbpNmnzkUR0X89G+UBl90raCPSN32EHFdImHZ5DxfEQQJgZFRjzQUY4EW/iYwaMel7jufAq0ClgV4psKujl9Lz8cPqx3WgqRfJyiIthOMTsac7G4zAw8LK2CI0VsssBp0JalLXaumi6vG7o6c3rIwKckzSKccq3pHa7h45praIVVn9s3nq+Q/JGA11FMkKQxdQtmwgFsLhbi6ZxabgsUi5KtWoWY2z6MgpJuROuAjNxZi9XJzUoJs7zSTUtRRW7V8Q2lRiOnknYh25N6TCA5bpyy1EZmRdJErm071YNI9P01gbFz5137FWJFiJzro9TGF0KoHSGiCIdUt3WlMzwr/i/wFLxFBQOZQ2rjTXvhs4hxONxMZV3gzxA1NdLaf9i5Mh6jxVMV+ujaRSV7JmPGzxqiAlpT9cJUhTCYuar9diLLeDrpe7RawEZR8V1xVDQ7yT8ruDNQ78VbSn/sC0="
homebrew:
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
update: false
packages:
- openssl

Expand All @@ -23,20 +23,24 @@ matrix:
- os: linux
env:
- BUILD_TYPE=Debug
- BUILD_OPTS='-DENABLE_CODE_COVERAGE=ON -DENABLE_EXPERIMENTAL_BONDING=ON'
- BUILD_OPTS='-DENABLE_CODE_COVERAGE=ON -DENABLE_EXPERIMENTAL_BONDING=ON -DCMAKE_CXX_FLAGS="-Werror"'
- RUN_SONARCUBE=1
- RUN_CODECOV=1
- env:
- BUILD_TYPE=Debug
- BUILD_OPTS='-DENABLE_LOGGING=OFF -DENABLE_MONOTONIC_CLOCK=ON -DENABLE_EXPERIMENTAL_BONDING=ON'
- BUILD_OPTS='-DENABLE_LOGGING=OFF -DENABLE_MONOTONIC_CLOCK=ON -DENABLE_EXPERIMENTAL_BONDING=ON -DCMAKE_CXX_FLAGS="-Werror"'
- os: linux
env: BUILD_TYPE=Release
- os: osx
osx_image: xcode10.2
env: BUILD_TYPE=Debug
osx_image: xcode11.1
env:
- BUILD_TYPE=Debug
- BUILD_OPTS='-DCMAKE_CXX_FLAGS="-Werror"'
- os: osx
osx_image: xcode10.2
env: BUILD_TYPE=Release
osx_image: xcode11.1
env:
- BUILD_TYPE=Release
- BUILD_OPTS='-DCMAKE_CXX_FLAGS="-Werror"'
- os: linux
compiler: x86_64-w64-mingw32-g++
addons:
Expand All @@ -54,7 +58,7 @@ matrix:
- make
- cd ..
env: BUILD_TYPE=Release

# Power jobs
- os: linux
arch: ppc64le
Expand All @@ -65,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 @@ -87,10 +92,10 @@ 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*";
source ./scripts/collect-gcov.sh;
./test-srt --gtest_filter="-$TESTS_IPv6";
fi
- if (( "$RUN_CODECOV" )); then
source ./scripts/collect-gcov.sh;
bash <(curl -s https://codecov.io/bash);
fi
- if (( "$RUN_SONARCUBE" )); then
Expand Down
59 changes: 34 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ endforeach()
# SRT_DEBUG_TLPKTDROP_DROPSEQ 1
# SRT_DEBUG_SNDQ_HIGHRATE 1
# SRT_DEBUG_BONDING_STATES 1
# SRT_DEBUG_RTT 1 /* RTT trace */
# SRT_MAVG_SAMPLING_RATE 40 /* Max sampling rate */

# option defaults
Expand Down Expand Up @@ -283,14 +284,29 @@ if (ENABLE_ENCRYPTION)
link_directories(
${SSL_LIBRARY_DIRS}
)
else() # Common for mbedtls and openssl
if ("${USE_ENCLIB}" STREQUAL "mbedtls")
add_definitions(-DUSE_MBEDTLS=1)
set (SSL_REQUIRED_MODULES "mbedtls mbedcrypto")
else()
add_definitions(-DUSE_OPENSSL=1)
set (SSL_REQUIRED_MODULES "openssl libcrypto")
elseif ("${USE_ENCLIB}" STREQUAL "mbedtls")
add_definitions(-DUSE_MBEDTLS=1)
if ("${SSL_LIBRARY_DIRS}" STREQUAL "")
set(MBEDTLS_PREFIX "${CMAKE_PREFIX_PATH}" CACHE PATH "The path of mbedtls")
find_package(MbedTLS REQUIRED)
set (SSL_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set (SSL_LIBRARIES ${MBEDTLS_LIBRARIES})
endif()
if ("${SSL_LIBRARIES}" STREQUAL "")
set (SSL_LIBRARIES mbedtls mbedcrypto)
endif()
message(STATUS "SSL enforced mbedtls: -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")

foreach(LIB ${SSL_LIBRARIES})
if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB})
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ${LIB})
else()
set(SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} "-l${LIB}")
endif()
endforeach()
else() # openssl
add_definitions(-DUSE_OPENSSL=1)
set (SSL_REQUIRED_MODULES "openssl libcrypto")
# Try using pkg-config method first if enabled,
# fall back to find_package method otherwise
if (USE_OPENSSL_PC)
Expand All @@ -315,24 +331,12 @@ if (ENABLE_ENCRYPTION)
)
message(STATUS "SSL via pkg-config: -L ${SSL_LIBRARY_DIRS} -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
else()
if ("${USE_ENCLIB}" STREQUAL "mbedtls")
if ("${SSL_LIBRARY_DIRS}" STREQUAL "")
set(MBEDTLS_PREFIX "${CMAKE_PREFIX_PATH}" CACHE PATH "The path of mbedtls")
find_package(MbedTLS REQUIRED)
set (SSL_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set (SSL_LIBRARIES ${MBEDTLS_LIBRARIES})
endif()
if ("${SSL_LIBRARIES}" STREQUAL "")
set (SSL_LIBRARIES mbedtls mbedcrypto)
endif()
message(STATUS "SSL enforced mbedtls: -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
else()
find_package(OpenSSL REQUIRED)
set (SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})
message(STATUS "SSL via find_package(OpenSSL): -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
endif()
find_package(OpenSSL REQUIRED)
set (SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})
message(STATUS "SSL via find_package(OpenSSL): -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
endif()

endif()

add_definitions(-DSRT_ENABLE_ENCRYPTION)
Expand Down Expand Up @@ -786,9 +790,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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Submit a pull request at any time, whether an issue has been created or not. It
* SRT protocol definitions
* portability and platform-specific parts

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

## Code Style

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

### Guides

* [Why SRT Was Created](docs/why-srt-was-created.md)
* [SRT Protocol Technical Overview](https://github.com/Haivision/srt/files/2489142/SRT_Protocol_TechnicalOverview_DRAFT_2018-10-17.pdf)
* SRT Cookbook: [website](https://srtlab.github.io/srt-cookbook), [GitHub](https://github.com/SRTLab/srt-cookbook)
* 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)
* [Using the `srt-live-transmit` App](docs/srt-live-transmit.md)
* [SRT API Documents](docs/API/)
* [Using the `srt-live-transmit` App](docs/apps/srt-live-transmit.md)
* [SRT Developer's Guide](docs/dev/developers-guide.md)
* [Contributing](CONTRIBUTING.md)
* [Developer's Guide](docs/DevelopersGuide.md)
* [SRT Encryption](docs/encryption.md)
* [API](docs/API.md)
* [Reporting problems](docs/reporting.md)
* [Reporting Issues](docs/dev/making-srt-better.md)
* 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)
* SRT CookBook: [Website](https://srtlab.github.io/srt-cookbook), [GitHub Repo](https://github.com/SRTLab/srt-cookbook)
* [SRT Protocol Technical Overview](https://github.com/Haivision/srt/files/2489142/SRT_Protocol_TechnicalOverview_DRAFT_2018-10-17.pdf)
* [Why SRT Was Created](docs/misc/why-srt-was-created.md)

## Requirements

Expand All @@ -51,7 +50,7 @@ As audio/video packets are streamed from a source to a destination device, SRT d
* 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 [BuildOptions.md](docs/BuildOptions.md).
For detailed description of the build system and options, please read [SRT Build Options](docs/build/build-options.md).

### Build on Linux

Expand Down Expand Up @@ -128,7 +127,7 @@ make

### Build on Windows

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

[appveyor-badge]: https://img.shields.io/appveyor/ci/Haivision/srt/master.svg?label=Windows
[appveyor]: https://ci.appveyor.com/project/Haivision/srt
Expand Down
19 changes: 10 additions & 9 deletions apps/apputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ options_t ProcessOptions(char* const* argv, int argc, std::vector<OptionScheme>
isoption = true;
// If a[0] isn't NUL - because it is dash - then
// we can safely check a[1].
if (a[1] && isdigit(a[1]))
// An expression starting with a dash is not
// an option marker if it is a single dash or
// a negative number.
if (!a[1] || isdigit(a[1]))
isoption = false;
}

Expand Down Expand Up @@ -391,10 +394,10 @@ struct SrtStatsTableInit
STAT(SEND, bytes, byteSent);
STAT(SEND, bytesUnique, byteSentUnique);
STAT(SEND, bytesDropped, byteSndDrop);
STAT(SEND, byteAvailBuf, byteAvailSndBuf);
STAT(SEND, msBuf, msSndBuf);
STAT(SEND, mbitRate, mbpsSendRate);
STAT(SEND, sendPeriod, usPktSndPeriod);
//STAT(SEND, msAvgResponseTime, msAvgResponseTime);
//STAT(SEND, msMaxResponseTime, msMaxResponseTime);

STAT(RECV, packets, pktRecv);
STAT(RECV, packetsUnique, pktRecvUnique);
Expand All @@ -409,7 +412,10 @@ struct SrtStatsTableInit
STAT(RECV, bytesUnique, byteRecvUnique);
STAT(RECV, bytesLost, byteRcvLoss);
STAT(RECV, bytesDropped, byteRcvDrop);
STAT(RECV, byteAvailBuf, byteAvailRcvBuf);
STAT(RECV, msBuf, msRcvBuf);
STAT(RECV, mbitRate, mbpsRecvRate);
STAT(RECV, msTsbPdDelay, msRcvTsbPdDelay);
}
} g_SrtStatsTableInit (g_SrtStatsTable);

Expand Down Expand Up @@ -546,7 +552,7 @@ class SrtStatsJson : public SrtStatsWriter
}

// Close the general category entity
output << "}," << pretty_cr << endl;
output << "}" << pretty_cr << endl;

return output.str();
}
Expand Down Expand Up @@ -586,12 +592,8 @@ class SrtStatsCsv : public SrtStatsWriter
output << endl;
first_line_printed = true;
}
int rcv_latency = 0;
int int_len = sizeof rcv_latency;
srt_getsockopt(sid, 0, SRTO_RCVLATENCY, &rcv_latency, &int_len);

// Values

#ifdef HAS_PUT_TIME
// HDR: Timepoint
output << print_timestamp() << ",";
Expand Down Expand Up @@ -685,4 +687,3 @@ SrtStatsPrintFormat ParsePrintFormat(string pf, string& w_extras)

return SRTSTATS_PROFMAT_INVALID;
}

13 changes: 13 additions & 0 deletions apps/apputil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ inline void SysCleanupNetwork()
#include <arpa/inet.h>
#include <unistd.h>

// Fixes Android build on NDK r16b and earlier.
#if defined(__ANDROID__) && (__ANDROID__ == 1)
#include <android/ndk-version.h>
#if !defined(__NDK_MAJOR__) || (__NDK_MAJOR__ <= 16)
struct ip_mreq_sourceFIXED {
struct in_addr imr_multiaddr;
struct in_addr imr_interface;
struct in_addr imr_sourceaddr;
};
#define ip_mreq_source ip_mreq_sourceFIXED
#endif
#endif

// Nothing needs to be done on POSIX; this is a Windows problem.
inline bool SysInitializeNetwork() {return true;}
inline void SysCleanupNetwork() {}
Expand Down
2 changes: 1 addition & 1 deletion apps/socketoptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const SocketOption srt_options [] {
{ "latency", 0, SRTO_LATENCY, SocketOption::PRE, SocketOption::INT, nullptr},
{ "tsbpdmode", 0, SRTO_TSBPDMODE, SocketOption::PRE, SocketOption::BOOL, nullptr},
{ "tlpktdrop", 0, SRTO_TLPKTDROP, SocketOption::PRE, SocketOption::BOOL, nullptr},
{ "snddropdelay", 0, SRTO_SNDDROPDELAY, SocketOption::PRE, SocketOption::INT, nullptr},
{ "snddropdelay", 0, SRTO_SNDDROPDELAY, SocketOption::POST, SocketOption::INT, nullptr},
{ "nakreport", 0, SRTO_NAKREPORT, SocketOption::PRE, SocketOption::BOOL, nullptr},
{ "conntimeo", 0, SRTO_CONNTIMEO, SocketOption::PRE, SocketOption::INT, nullptr},
{ "drifttracer", 0, SRTO_DRIFTTRACER, SocketOption::POST, SocketOption::BOOL, nullptr},
Expand Down
8 changes: 4 additions & 4 deletions apps/srt-file-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ bool DoUpload(UriParser& ut, string path, string filename,
<< tar->GetSRTSocket() << endl;
goto exit;
}
UDT::setstreamid(tar->GetSRTSocket(), filename);
srt::setstreamid(tar->GetSRTSocket(), filename);
}

s = tar->GetSRTSocket();
Expand Down Expand Up @@ -539,7 +539,7 @@ bool DoDownload(UriParser& us, string directory, string filename,
cerr << "Failed to add SRT client to poll" << endl;
goto exit;
}
id = UDT::getstreamid(s);
id = srt::getstreamid(s);
cerr << "Source connected (listener), id ["
<< id << "]" << endl;
connected = true;
Expand All @@ -550,7 +550,7 @@ bool DoDownload(UriParser& us, string directory, string filename,
{
if (!connected)
{
id = UDT::getstreamid(s);
id = srt::getstreamid(s);
cerr << "Source connected (caller), id ["
<< id << "]" << endl;
connected = true;
Expand Down Expand Up @@ -714,7 +714,7 @@ int main(int argc, char** argv)
}
else
{
UDT::setlogstream(logfile_stream);
srt::setlogstream(logfile_stream);
}
}

Expand Down
6 changes: 3 additions & 3 deletions apps/srt-live-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ int parse_args(LiveTransmitConfig &cfg, int argc, char** argv)
PrintOptionHelp(o_statsout, "<filename>", "output stats to file");
PrintOptionHelp(o_statspf, "<format=default>", "stats printing format {json, csv, default}");
PrintOptionHelp(o_statsfull, "", "full counters in stats-report (prints total statistics)");
PrintOptionHelp(o_loglevel, "<level=error>", "log level {fatal,error,info,note,warning}");
PrintOptionHelp(o_loglevel, "<level=warn>", "log level {fatal,error,warn,note,info,debug}");
PrintOptionHelp(o_logfa, "<fas>", "log functional area (see '-h logging' for more info)");
//PrintOptionHelp(o_log_internal, "", "use internal logger");
PrintOptionHelp(o_logfile, "<filename="">", "write logs to file");
Expand Down Expand Up @@ -345,7 +345,7 @@ int parse_args(LiveTransmitConfig &cfg, int argc, char** argv)
}

cfg.full_stats = OptionPresent(params, o_statsfull);
cfg.loglevel = SrtParseLogLevel(Option<OutString>(params, "error", o_loglevel));
cfg.loglevel = SrtParseLogLevel(Option<OutString>(params, "warn", o_loglevel));
cfg.logfas = SrtParseLogFA(Option<OutString>(params, "", o_logfa));
cfg.log_internal = OptionPresent(params, o_log_internal);
cfg.logfile = Option<OutString>(params, o_logfile);
Expand Down Expand Up @@ -434,7 +434,7 @@ int main(int argc, char** argv)
}
else
{
UDT::setlogstream(logfile_stream);
srt::setlogstream(logfile_stream);
}
}

Expand Down
Loading

0 comments on commit a5de970

Please sign in to comment.