Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRT: Upgrade libsrt from 1.4.1 to 1.5.1. v6.0.12 #3362

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
794 changes: 596 additions & 198 deletions trunk/3rdparty/srt-1-fit/CMakeLists.txt

Large diffs are not rendered by default.

63 changes: 0 additions & 63 deletions trunk/3rdparty/srt-1-fit/common/win/ATTIC/winporting.h

This file was deleted.

4 changes: 2 additions & 2 deletions trunk/3rdparty/srt-1-fit/common/win/syslog_defs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef INC__WINDOWS_SYSLOG_DEFS_H
#define INC__WINDOWS_SYSLOG_DEFS_H
#ifndef INC_SRT_WINDOWS_SYSLOG_DEFS_H
#define INC_SRT_WINDOWS_SYSLOG_DEFS_H

#define LOG_EMERG 0
#define LOG_ALERT 1
Expand Down
7 changes: 3 additions & 4 deletions trunk/3rdparty/srt-1-fit/common/win/wintime.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#ifndef INC__WIN_WINTIME
#define INC__WIN_WINTIME
#ifndef INC_SRT_WIN_WINTIME
#define INC_SRT_WIN_WINTIME

#include <winsock2.h>
#include <windows.h>
// HACK: This include is a workaround for a bug in the MinGW headers
// where pthread.h, which defines _POSIX_THREAD_SAFE_FUNCTIONS,
// has to be included before time.h so that time.h defines
// localtime_r correctly
#include <pthread.h>
#include <time.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -53,4 +52,4 @@ SRTCOMPAT_WINTIME_STATIC_INLINE_DECL int gettimeofday(
}
#endif

#endif // INC__WIN_WINTIME
#endif // INC_SRT_WIN_WINTIME
38 changes: 5 additions & 33 deletions trunk/3rdparty/srt-1-fit/common/win_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,11 @@ void SRTCompat_timeradd(struct timeval *a, struct timeval *b, struct timeval *re
}
}

int SRTCompat_gettimeofday(struct timeval* tp, struct timezone* tz)
int SRTCompat_gettimeofday(struct timeval* tp, struct timezone*)
{
static LARGE_INTEGER tickFrequency, epochOffset;

// For our first call, use "ftime()", so that we get a time with a proper epoch.
// For subsequent calls, use "QueryPerformanceCount()", because it's more fine-grain.
static int isFirstCall = 1;

LARGE_INTEGER tickNow;
QueryPerformanceCounter(&tickNow);

if (isFirstCall)
{
struct timeb tb;
ftime(&tb);
tp->tv_sec = (long)tb.time;
tp->tv_usec = 1000*tb.millitm;

// Also get our counter frequency:
QueryPerformanceFrequency(&tickFrequency);

// And compute an offset to add to subsequent counter times, so we get a proper epoch:
epochOffset.QuadPart = tb.time*tickFrequency.QuadPart + (tb.millitm*tickFrequency.QuadPart)/1000 - tickNow.QuadPart;

isFirstCall = 0; // for next time
}
else
{
// Adjust our counter time so that we get a proper epoch:
tickNow.QuadPart += epochOffset.QuadPart;

tp->tv_sec = (long) (tickNow.QuadPart / tickFrequency.QuadPart);
tp->tv_usec = (long) (((tickNow.QuadPart % tickFrequency.QuadPart) * 1000000L) / tickFrequency.QuadPart);
}
struct timeb tb;
ftime(&tb);
tp->tv_sec = (long)tb.time;
tp->tv_usec = 1000*tb.millitm;
return 0;
}
25 changes: 22 additions & 3 deletions trunk/3rdparty/srt-1-fit/configure
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ foreach {o desc} $options {
}


if { $argv == "--help" } {
if { $argv == "--help" || $argv == "-h" } {
puts stderr "Usage: ./configure \[options\]"
puts stderr "OPTIONS:"
foreach o [lsort [array names opt]] {
Expand Down Expand Up @@ -153,8 +153,10 @@ foreach a $argv {

set type ""

if { [string first = $a] != -1 } {
lassign [split $a =] a val
if { [set a1 [string first = $a]] != -1 } {
# Do not split. Options may include =.
set val [string range $a $a1+1 end]
set a [string range $a 0 $a1-1]
}

if { [dict exists $::alias $a] } {
Expand Down Expand Up @@ -194,6 +196,23 @@ if { $saveopt != "" } {
error "Extra unhandled argument: $saveopt"
}

# Save the original call into config-status.sh

set ofd [open config-status.sh w]
puts $ofd "#!/bin/bash"
puts -nonewline $ofd "$argv0 "
foreach a $argv {
set len 1
if {[catch {llength $a} len] || $len > 1 } {
puts -nonewline $ofd "'$a' "
} else {
puts -nonewline $ofd "$a "
}
}
puts $ofd ""
close $ofd
file attributes config-status.sh -permissions +x

set cmakeopt ""

resolve_disablers
Expand Down
106 changes: 77 additions & 29 deletions trunk/3rdparty/srt-1-fit/configure-data.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,55 @@

# Options processed here internally, not passed to cmake
set internal_options {
with-compiler-prefix=<prefix> "set C/C++ toolchains <prefix>gcc and <prefix>g++"
with-compiler-type=<name> "compiler type: gcc(default), cc, others simply add ++ for C++"
with-srt-name=<name> "Override srt library name"
with-haicrypt-name=<name> "Override haicrypt library name (if compiled separately)"
with-compiler-prefix=<prefix> "set C/C++ toolchains <prefix>gcc and <prefix>g++"
with-compiler-type=<name> "compiler type: gcc(default), cc, others simply add ++ for C++"
with-srt-name=<name> "Override srt library name"
with-haicrypt-name=<name> "Override haicrypt library name (if compiled separately)"
with-atomic=<spec> "Select implementation for atomics (compiler-intrinsics or sync-mutex)"
}

# Options that refer directly to variables used in CMakeLists.txt
set cmake_options {
cygwin-use-posix "Should the POSIX API be used for cygwin. Ignored if the system isn't cygwin. (default: OFF)"
enable-encryption "Should encryption features be enabled (default: ON)"
enable-c++11 "Should the c++11 parts (srt-live-transmit) be enabled (default: ON)"
enable-c++11 "Should the c++11 parts (srt-live-transmit) be enabled (default: ON, with gcc < 4.7 OFF)"
enable-apps "Should the Support Applications be Built? (default: ON)"
enable-bonding "Enable 'bonding' SRT feature (default: OFF)"
enable-testing "Should developer testing applications be built (default: OFF)"
enable-c++-deps "Extra library dependencies in srt.pc for C language (default: OFF)"
enable-heavy-logging "Should heavy debug logging be enabled (default: OFF)"
enable-profile "Should instrument the code for profiling. Ignored for non-GNU compiler. (default: OFF)"
enable-logging "Should logging be enabled (default: ON)"
enable-debug=<0,1,2> "Enable debug mode (0=disabled, 1=debug, 2=rel-with-debug)"
enable-heavy-logging "Should heavy debug logging be enabled (default: OFF)"
enable-haicrypt-logging "Should logging in haicrypt be enabled (default: OFF)"
enable-inet-pton "Set to OFF to prevent usage of inet_pton when building against modern SDKs (default: ON)"
enable-code-coverage "Enable code coverage reporting (default: OFF)"
enable-monotonic-clock "Enforced clock_gettime with monotonic clock on GC CV /temporary fix for #729/ (default: OFF)"
enable-profile "Should instrument the code for profiling. Ignored for non-GNU compiler. (default: OFF)"
enable-relative-libpath "Should applications contain relative library paths, like ../lib (default: OFF)"
enable-shared "Should libsrt be built as a shared library (default: ON)"
enable-static "Should libsrt be built as a static library (default: ON)"
enable-suflip "Should suflip tool be built (default: OFF)"
enable-relative-libpath "Should applications contain relative library paths, like ../lib (default: OFF)"
enable-getnameinfo "In-logs sockaddr-to-string should do rev-dns (default: OFF)"
enable-unittests "Enable unit tests (default: OFF)"
enable-unittests "Enable Unit Tests (will download Google UT) (default: OFF)"
enable-encryption "Should encryption features be enabled (default: ON)"
enable-c++-deps "Extra library dependencies in srt.pc for C language (default: ON)"
use-static-libstdc++ "Should use static rather than shared libstdc++ (default: OFF)"
enable-inet-pton "Set to OFF to prevent usage of inet_pton when building against modern SDKs (default: ON)"
enable-code-coverage "Enable code coverage reporting (default: OFF)"
enable-monotonic-clock "Enforced clock_gettime with monotonic clock on GC CV /temporary fix for #729/ (default: OFF)"
enable-thread-check "Enable #include <threadcheck.h> that implements THREAD_* macros"
openssl-crypto-library=<filepath> "Path to a library."
openssl-include-dir=<path> "Path to a file."
openssl-ssl-library=<filepath> "Path to a library."
pkg-config-executable=<filepath> "pkg-config executable"
pthread-include-dir=<path> "Path to a file."
pthread-library=<filepath> "Path to a library."
enable-stdc++-sync "Use standard C++11 chrono/threads instead of pthread wrapper (default: OFF, on Windows: ON)"
use-openssl-pc "Use pkg-config to find OpenSSL libraries (default: ON)"
openssl-use-static-libs "Link OpenSSL statically (default: OFF)."
use-busy-waiting "Enable more accurate sending times at a cost of potentially higher CPU load (default: OFF)"
use-gnustl "Get c++ library/headers from the gnustl.pc"
enable-sock-cloexec "Enable setting SOCK_CLOEXEC on a socket (default: ON)"
enable-show-project-config "Enables use of ShowProjectConfig() in cmake (default: OFF)"
enable-new-rcvbuffer "Enables the new receiver buffer implementation (default: ON)"
enable-clang-tsa "Enable Clang's Thread-Safety-Analysis (default: OFF)"
atomic-use-srt-sync-mutex "Use mutex to implement atomics (alias: --with-atomic=sync-mutex) (default: OFF)"

use-enclib "Encryption library to be used: openssl(default), gnutls, mbedtls"
use-gnutls "DEPRECATED. Use USE_ENCLIB=openssl|gnutls|mbedtls instead"
use-openssl-pc "Use pkg-config to find OpenSSL libraries (default: ON)"
use-static-libstdc++ "Should use static rather than shared libstdc++ (default: OFF)"
enable-debug=<0,1,2> "Enable debug mode (0=disabled, 1=debug, 2=rel-with-debug)"
pkg-config-executable=<filepath> "pkg-config executable"
openssl-crypto-library=<filepath> "OpenSSL: Path to a libcrypto library."
openssl-include-dir=<path> "OpenSSL: Path to includes."
openssl-ssl-library=<filepath> "OpenSSL: Path to a libssl library."
pthread-include-dir=<path> "PThread: Path to includes"
pthread-library=<filepath> "PThread: Path to the pthread library."
}

set options $internal_options$cmake_options
Expand Down Expand Up @@ -162,6 +170,24 @@ proc preprocess {} {
set ::haicrypt_name $::optval(--with-haicrypt-name)
unset ::optval(--with-haicrypt-name)
}

if { "--with-atomic" in $::optkeys } {
switch -- $::optval(--with-atomic) {
compiler-intrinsics {
}

sync-mutex {
set ::optval(--atomic-use-srt-sync-mutex) 1
}

default {
puts "ERROR: --with-atomic option accepts two values: compiler-intrinsics (default) or sync-mutex"
exit 1
}
}

unset ::optval(--with-atomic)
}
}

proc GetCompilerCommand {} {
Expand All @@ -170,9 +196,16 @@ proc GetCompilerCommand {} {
# --cmake-c[++]-compiler
# (cmake-toolchain-file will set things up without the need to check things here)

set compiler gcc
if { [info exists ::optval(--with-compiler-type)] } {
set compiler $::optval(--with-compiler-type)
}

if { [info exists ::optval(--with-compiler-prefix)] } {
set prefix $::optval(--with-compiler-prefix)
return ${prefix}gcc
return ${prefix}$compiler
} else {
return $compiler
}

if { [info exists ::optval(--cmake-c-compiler)] } {
Expand Down Expand Up @@ -201,6 +234,7 @@ proc postprocess {} {
set toolchain_changed no
foreach changer {
--with-compiler-prefix
--with-compiler-type
--cmake-c-compiler
--cmake-c++-compiler
--cmake-cxx-compiler
Expand All @@ -223,6 +257,7 @@ proc postprocess {} {
# Check characteristics of the compiler - in particular, whether the target is different
# than the current target.
set compiler_path ""
set target_platform ""
set cmd [GetCompilerCommand]
if { $cmd != "" } {
set gcc_version [exec $cmd -v 2>@1]
Expand All @@ -237,14 +272,16 @@ proc postprocess {} {
}

if { $target_platform == "" } {
puts "NOTE: can't obtain target from gcc -v: $l"
puts "NOTE: can't obtain target from '[file tail $cmd] -v': $l - ASSUMING HOST compiler"
} else {
if { $target_platform != $::tcl_platform(machine) } {
puts "NOTE: foreign target type detected ($target)" ;# - setting CROSSCOMPILING flag"
#lappend ::cmakeopt "-DHAVE_CROSSCOMPILER=1"
set iscross 1
}
}
} else {
puts "CONFIGURE: default compiler used"
}
}

Expand Down Expand Up @@ -332,8 +369,19 @@ proc postprocess {} {
# Otherwise don't set PKG_CONFIG_PATH and we'll see.
}

if { $::HAVE_DARWIN && !$toolchain_changed} {

set use_brew 0
if { $::HAVE_DARWIN && !$toolchain_changed } {
set use_brew 1
}
if { $use_brew } {
foreach item $::cmakeopt {
if { [string first "Android" $item] != -1 } {
set use_brew 0
break
}
}
}
if { $use_brew } {
if { $have_gnutls } {
# Use gnutls explicitly, as found in brew
set er [catch {exec brew info gnutls} res]
Expand Down
12 changes: 10 additions & 2 deletions trunk/3rdparty/srt-1-fit/haicrypt/cryspr-config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef INC__CRYSPR_CONFIG_H
#define INC__CRYSPR_CONFIG_H
#ifndef INC_SRT_CRYSPR_CONFIG_H
#define INC_SRT_CRYSPR_CONFIG_H

// Size of the single block for encryption.
// This might need tweaking for particular implementation library.
Expand All @@ -8,14 +8,22 @@
#if defined(USE_OPENSSL)
#include "cryspr-openssl.h"
#define cryspr4SRT() crysprOpenSSL()
#define CRYSPR_IMPL_DESC "OpenSSL-AES"
#elif defined(USE_OPENSSL_EVP)
#include "cryspr-openssl-evp.h"
#define cryspr4SRT() crysprOpenSSL_EVP()
#define CRYSPR_IMPL_DESC "OpenSSL-EVP"
#elif defined(USE_GNUTLS)
#include "cryspr-gnutls.h"
#define cryspr4SRT() crysprGnuTLS()
#define CRYSPR_IMPL_DESC "GnuTLS"
#elif defined(USE_MBEDTLS)
#include "cryspr-mbedtls.h"
#define cryspr4SRT() crysprMbedtls()
#define CRYSPR_IMPL_DESC "MbedTLS"
#else
#error Cryspr implementation not selected. Please define USE_* + OPENSSL/GNUTLS/MBEDTLS.
#define CRYSPR_IMPL_DESC "No Cipher"
#endif


Expand Down
Loading