From 2c199e937275877a75daa3d729cdd293408d5622 Mon Sep 17 00:00:00 2001 From: Thierry Lelegard Date: Mon, 14 Oct 2024 09:44:33 +0200 Subject: [PATCH 1/9] [build] Update Windows installer for new OpenSSL versions (#3049). --- scripts/win-installer/build-win-installer.ps1 | 59 +++++++++++++++--- scripts/win-installer/install-openssl.ps1 | 61 +++++++++++++------ scripts/win-installer/libsrt.nsi | 18 +++--- 3 files changed, 100 insertions(+), 38 deletions(-) diff --git a/scripts/win-installer/build-win-installer.ps1 b/scripts/win-installer/build-win-installer.ps1 index 4265edf8e..d08ee186c 100644 --- a/scripts/win-installer/build-win-installer.ps1 +++ b/scripts/win-installer/build-win-installer.ps1 @@ -89,18 +89,53 @@ Write-Output "Windows version info: $VersionInfo" #----------------------------------------------------------------------------- # Locate OpenSSL root from local installation. -$SslRoot = @{ - "x64" = "C:\Program Files\OpenSSL-Win64"; - "Win32" = "C:\Program Files (x86)\OpenSSL-Win32" +# After version 3.something, OpenSSL has changed its installation layout. +# We have to look for OpenSSL libraries in various locations. +$SSL = @{ + "x64" = @{ + "alt" = "Win64"; + "bits" = 64; + "root" = "C:\Program Files\OpenSSL-Win64" + }; + "Win32" = @{ + "alt" = "x86"; + "bits" = 32; + "root" = "C:\Program Files (x86)\OpenSSL-Win32" + } } -# Verify OpenSSL directories. +# Verify OpenSSL directories and static libraries. +Write-Output "Searching OpenSSL libraries ..." $Missing = 0 -foreach ($file in @($SslRoot["x64"], $SslRoot["Win32"])) { - if (-not (Test-Path $file)) { - Write-Output "**** Missing $file" +foreach ($arch in @("x64", "Win32")) { + $root = $SSL[$arch]["root"] + $bits = $SSL[$arch]["bits"] + $alt = $SSL[$arch]["alt"] + if (-not (Test-Path $root)) { + Write-Output "**** Missing $root" $Missing = $Missing + 1 } + else { + foreach ($lib in @("ssl", "crypto")) { + foreach ($conf in @("MD", "MDd")) { + $name = "lib${lib}${conf}" + $SSL[$arch][$name] = "" + foreach ($try in @("$root\lib\VC\static\lib${lib}${bits}${conf}.lib", + "$root\lib\VC\${arch}\${conf}\lib${lib}_static.lib", + "$root\lib\VC\${alt}\${conf}\lib${lib}_static.lib")) { + if (Test-Path $try) { + $SSL[$arch][$name] = $try + New-Variable "lib${lib}${bits}${conf}" "$try" + break + } + } + if (-not $SSL[$arch][$name]) { + Write-Output "**** OpenSSL static library for $name not found" + $Missing = $Missing + 1 + } + } + } + } } if ($Missing -gt 0) { Exit-Script "Missing $Missing OpenSSL files, use install-openssl.ps1 to install OpenSSL" @@ -157,7 +192,7 @@ foreach ($Platform in @("x64", "Win32")) { # Run CMake. Write-Output "Configuring build for platform $Platform ..." - $SRoot = $SslRoot[$Platform] + $SRoot = $SSL[$Platform]["root"] & $CMake -S $RepoDir -B $BuildDir -A $Platform ` -DENABLE_STDCXX_SYNC=ON ` -DOPENSSL_ROOT_DIR="$SRoot" ` @@ -210,6 +245,14 @@ Write-Output "Building installer ..." /DOutDir="$OutDir" ` /DBuildRoot="$TmpDir" ` /DRepoDir="$RepoDir" ` + /Dlibssl32MD="$libssl32MD" ` + /Dlibssl32MDd="$libssl32MDd" ` + /Dlibcrypto32MD="$libcrypto32MD" ` + /Dlibcrypto32MDd="$libcrypto32MDd" ` + /Dlibssl64MD="$libssl64MD" ` + /Dlibssl64MDd="$libssl64MDd" ` + /Dlibcrypto64MD="$libcrypto64MD" ` + /Dlibcrypto64MDd="$libcrypto64MDd" ` "$ScriptDir\libsrt.nsi" if (-not (Test-Path $InstallExe)) { diff --git a/scripts/win-installer/install-openssl.ps1 b/scripts/win-installer/install-openssl.ps1 index 83b59954f..e24cecc57 100644 --- a/scripts/win-installer/install-openssl.ps1 +++ b/scripts/win-installer/install-openssl.ps1 @@ -1,7 +1,7 @@ #----------------------------------------------------------------------------- # # SRT - Secure, Reliable, Transport -# Copyright (c) 2021, Thierry Lelegard +# Copyright (c) 2021-2024, Thierry Lelegard # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -36,7 +36,26 @@ param( ) Write-Output "OpenSSL download and installation procedure" -$OpenSSLHomePage = "http://slproweb.com/products/Win32OpenSSL.html" + +# A bit of history: Where to load OpenSSL binaries from? +# +# The packages are built by "slproweb". The binaries are downloadable from +# their Web page at: http://slproweb.com/products/Win32OpenSSL.html +# +# Initially, the HTML for this page was built on server-side. This script +# grabbed the URL content, parse the HTML and extracted the URL of the +# binaries for the latest OpenSSL packages from the "href" of the links. +# +# At some point in 2024, the site changed policy. The Web page is no longer +# built on server-side, but on client-side. The downloaded HTML contains some +# JavaScript which dynamically builds the URL of the binaries for the latest +# OpenSSL binaries. The previous method now finds no valid package URL from +# the downloaded page (a full browser is needed to execute the JavaScript). +# The JavaScript downloads a JSON file which contains all references to +# the OpenSSL binaries. This script now uses the same method: download that +# JSON file and parse it. + +$PackageList = "https://github.com/slproweb/opensslhashes/raw/master/win32_openssl_hashes.json" # A function to exit this script. function Exit-Script([string]$Message = "") @@ -62,11 +81,11 @@ $TmpDir = "$RootDir\tmp" # Without this, Invoke-WebRequest is awfully slow. $ProgressPreference = 'SilentlyContinue' -# Get the HTML page for OpenSSL downloads. +# Get the JSON configuration file for OpenSSL downloads. $status = 0 $message = "" try { - $response = Invoke-WebRequest -UseBasicParsing -UserAgent Download -Uri $OpenSSLHomePage + $response = Invoke-WebRequest -UseBasicParsing -UserAgent Download -Uri $PackageList $status = [int] [Math]::Floor($response.StatusCode / 100) } catch { @@ -77,22 +96,27 @@ if ($status -ne 1 -and $status -ne 2) { Exit-Script "Status code $($response.StatusCode), $($response.StatusDescription)" } else { - Exit-Script "#### Error accessing ${OpenSSLHomePage}: $message" + Exit-Script "#### Error accessing ${PackageList}: $message" } } +$config = ConvertFrom-Json $Response.Content + +# Download and install MSI packages for 32 and 64 bit. +foreach ($bits in @(32, 64)) { + + # Get the URL of the MSI installer from the JSON config. + $Url = $config.files | Get-Member | ForEach-Object { + $name = $_.name + $info = $config.files.$($_.name) + if (-not $info.light -and $info.installer -like "msi" -and $info.bits -eq $bits -and $info.arch -like "intel") { + $info.url + } + } | Select-Object -Last 1 + if (-not $Url) { + Exit-Script "#### No MSI installer found for Win${bits}" + } -# Parse HTML page to locate the latest MSI files. -$Ref32 = $response.Links.href | Where-Object { $_ -like "*/Win32OpenSSL-*.msi" } | Select-Object -First 1 -$Ref64 = $response.Links.href | Where-Object { $_ -like "*/Win64OpenSSL-*.msi" } | Select-Object -First 1 - -# Build the absolute URL's from base URL (the download page) and href links. -$Url32 = New-Object -TypeName 'System.Uri' -ArgumentList ([System.Uri]$OpenSSLHomePage, $Ref32) -$Url64 = New-Object -TypeName 'System.Uri' -ArgumentList ([System.Uri]$OpenSSLHomePage, $Ref64) - -# Download and install one MSI package. -function Download-Install([string]$Url) -{ - $MsiName = (Split-Path -Leaf $Url.toString()) + $MsiName = (Split-Path -Leaf $Url) $MsiPath = "$TmpDir\$MsiName" if (-not $ForceDownload -and (Test-Path $MsiPath)) { @@ -113,7 +137,4 @@ function Download-Install([string]$Url) } } -# Download and install the two MSI packages. -Download-Install $Url32 -Download-Install $Url64 Exit-Script diff --git a/scripts/win-installer/libsrt.nsi b/scripts/win-installer/libsrt.nsi index 1dffc3fd1..022ceb617 100644 --- a/scripts/win-installer/libsrt.nsi +++ b/scripts/win-installer/libsrt.nsi @@ -31,8 +31,6 @@ Caption "SRT Libraries Installer" !define ProductName "libsrt" !define Build32Dir "${BuildRoot}\build.Win32" !define Build64Dir "${BuildRoot}\build.x64" -!define SSL32Dir "C:\Program Files (x86)\OpenSSL-Win32" -!define SSL64Dir "C:\Program Files\OpenSSL-Win64" ; Installer file information. VIProductVersion ${VersionInfo} @@ -142,26 +140,26 @@ Section "Install" CreateDirectory "$INSTDIR\lib\Release-x64" SetOutPath "$INSTDIR\lib\Release-x64" File /oname=srt.lib "${Build64Dir}\Release\srt_static.lib" - File /oname=libcrypto.lib "${SSL64Dir}\lib\VC\static\libcrypto64MD.lib" - File /oname=libssl.lib "${SSL64Dir}\lib\VC\static\libssl64MD.lib" + File /oname=libcrypto.lib "${libcrypto64MD}" + File /oname=libssl.lib "${libssl64MD}" CreateDirectory "$INSTDIR\lib\Debug-x64" SetOutPath "$INSTDIR\lib\Debug-x64" File /oname=srt.lib "${Build64Dir}\Debug\srt_static.lib" - File /oname=libcrypto.lib "${SSL64Dir}\lib\VC\static\libcrypto64MDd.lib" - File /oname=libssl.lib "${SSL64Dir}\lib\VC\static\libssl64MDd.lib" + File /oname=libcrypto.lib "${libcrypto64MDd}" + File /oname=libssl.lib "${libssl64MDd}" CreateDirectory "$INSTDIR\lib\Release-Win32" SetOutPath "$INSTDIR\lib\Release-Win32" File /oname=srt.lib "${Build32Dir}\Release\srt_static.lib" - File /oname=libcrypto.lib "${SSL32Dir}\lib\VC\static\libcrypto32MD.lib" - File /oname=libssl.lib "${SSL32Dir}\lib\VC\static\libssl32MD.lib" + File /oname=libcrypto.lib "${libcrypto32MD}" + File /oname=libssl.lib "${libssl32MD}" CreateDirectory "$INSTDIR\lib\Debug-Win32" SetOutPath "$INSTDIR\lib\Debug-Win32" File /oname=srt.lib "${Build32Dir}\Debug\srt_static.lib" - File /oname=libcrypto.lib "${SSL32Dir}\lib\VC\static\libcrypto32MDd.lib" - File /oname=libssl.lib "${SSL32Dir}\lib\VC\static\libssl32MDd.lib" + File /oname=libcrypto.lib "${libcrypto32MDd}" + File /oname=libssl.lib "${libssl32MDd}" ; Add an environment variable to installation root. WriteRegStr HKLM ${EnvironmentKey} "LIBSRT" "$INSTDIR" From e2f133b95c06dd3c157b1669de34b2432e640029 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Mon, 14 Oct 2024 09:52:08 +0200 Subject: [PATCH 2/9] [core] Renamed TSBPD class functions. --- srtcore/buffer_rcv.cpp | 8 ++++---- srtcore/tsbpd_time.cpp | 24 ++++++++++++------------ srtcore/tsbpd_time.h | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/srtcore/buffer_rcv.cpp b/srtcore/buffer_rcv.cpp index 363bd7e9c..e74d48c07 100644 --- a/srtcore/buffer_rcv.cpp +++ b/srtcore/buffer_rcv.cpp @@ -1096,12 +1096,12 @@ void CRcvBuffer::applyGroupDrift(const steady_clock::time_point& timebase, CRcvBuffer::time_point CRcvBuffer::getTsbPdTimeBase(uint32_t usPktTimestamp) const { - return m_tsbpd.getTsbPdTimeBase(usPktTimestamp); + return m_tsbpd.getBaseTime(usPktTimestamp); } void CRcvBuffer::updateTsbPdTimeBase(uint32_t usPktTimestamp) { - m_tsbpd.updateTsbPdTimeBase(usPktTimestamp); + m_tsbpd.updateBaseTime(usPktTimestamp); } string CRcvBuffer::strFullnessState(int iFirstUnackSeqNo, const time_point& tsNow) const @@ -1125,7 +1125,7 @@ string CRcvBuffer::strFullnessState(int iFirstUnackSeqNo, const time_point& tsNo { ss << ", timespan "; const uint32_t usPktTimestamp = packetAt(iLastPos).getMsgTimeStamp(); - ss << count_milliseconds(m_tsbpd.getPktTsbPdTime(usPktTimestamp) - nextValidPkt.tsbpd_time); + ss << count_milliseconds(m_tsbpd.getPktTime(usPktTimestamp) - nextValidPkt.tsbpd_time); ss << " ms"; } } @@ -1142,7 +1142,7 @@ string CRcvBuffer::strFullnessState(int iFirstUnackSeqNo, const time_point& tsNo CRcvBuffer::time_point CRcvBuffer::getPktTsbPdTime(uint32_t usPktTimestamp) const { - return m_tsbpd.getPktTsbPdTime(usPktTimestamp); + return m_tsbpd.getPktTime(usPktTimestamp); } /* Return moving average of acked data pkts, bytes, and timespan (ms) of the receive buffer */ diff --git a/srtcore/tsbpd_time.cpp b/srtcore/tsbpd_time.cpp index ec0f39f7b..d45215a01 100644 --- a/srtcore/tsbpd_time.cpp +++ b/srtcore/tsbpd_time.cpp @@ -122,7 +122,7 @@ bool CTsbpdTime::addDriftSample(uint32_t usPktTimestamp, const time_point& tsPkt // is to estimate RTT change and assume that the change of the one way network delay is // approximated by the half of the RTT change. const duration tdRTTDelta = usRTTSample >= 0 ? microseconds_from((usRTTSample - m_iFirstRTT) / 2) : duration(0); - const time_point tsPktBaseTime = getPktTsbPdBaseTimeNoLock(usPktTimestamp); + const time_point tsPktBaseTime = getPktBaseTimeNoLock(usPktTimestamp); const steady_clock::duration tdDrift = tsPktArrival - tsPktBaseTime - tdRTTDelta; const bool updated = m_DriftTracer.update(count_microseconds(tdDrift)); @@ -210,10 +210,10 @@ void CTsbpdTime::applyGroupDrift(const steady_clock::time_point& timebase, m_DriftTracer.forceDrift(count_microseconds(udrift)); } -CTsbpdTime::time_point CTsbpdTime::getTsbPdTimeBaseNoLock(uint32_t timestamp_us) const +CTsbpdTime::time_point CTsbpdTime::getBaseTimeNoLock(uint32_t timestamp_us) const { // A data packet within [TSBPD_WRAP_PERIOD; 2 * TSBPD_WRAP_PERIOD] would end TSBPD wrap-aware state. - // Some incoming control packets may not update the TSBPD base (calling updateTsbPdTimeBase(..)), + // Some incoming control packets may not update the TSBPD base (calling updateBaseTime(..)), // but may come before a data packet with a timestamp in this range. Therefore the whole range should be tracked. const int64_t carryover_us = (m_bTsbPdWrapCheck && timestamp_us <= 2 * TSBPD_WRAP_PERIOD) ? int64_t(CPacket::MAX_TIMESTAMP) + 1 : 0; @@ -221,31 +221,31 @@ CTsbpdTime::time_point CTsbpdTime::getTsbPdTimeBaseNoLock(uint32_t timestamp_us) return (m_tsTsbPdTimeBase + microseconds_from(carryover_us)); } -CTsbpdTime::time_point CTsbpdTime::getTsbPdTimeBase(uint32_t timestamp_us) const +CTsbpdTime::time_point CTsbpdTime::getBaseTime(uint32_t timestamp_us) const { SharedLock lck(m_mtxRW); - return getTsbPdTimeBaseNoLock(timestamp_us); + return getBaseTimeNoLock(timestamp_us); } -CTsbpdTime::time_point CTsbpdTime::getPktTsbPdTime(uint32_t usPktTimestamp) const +CTsbpdTime::time_point CTsbpdTime::getPktTime(uint32_t usPktTimestamp) const { SharedLock lck(m_mtxRW); - time_point value = getPktTsbPdBaseTimeNoLock(usPktTimestamp) + m_tdTsbPdDelay + microseconds_from(m_DriftTracer.drift()); + time_point value = getPktBaseTimeNoLock(usPktTimestamp) + m_tdTsbPdDelay + microseconds_from(m_DriftTracer.drift()); return value; } -CTsbpdTime::time_point CTsbpdTime::getPktTsbPdBaseTimeNoLock(uint32_t usPktTimestamp) const +CTsbpdTime::time_point CTsbpdTime::getPktBaseTimeNoLock(uint32_t usPktTimestamp) const { - return getTsbPdTimeBaseNoLock(usPktTimestamp) + microseconds_from(usPktTimestamp); + return getBaseTimeNoLock(usPktTimestamp) + microseconds_from(usPktTimestamp); } -CTsbpdTime::time_point CTsbpdTime::getPktTsbPdBaseTime(uint32_t usPktTimestamp) const +CTsbpdTime::time_point CTsbpdTime::getPktBaseTime(uint32_t usPktTimestamp) const { - return getTsbPdTimeBase(usPktTimestamp) + microseconds_from(usPktTimestamp); + return getBaseTime(usPktTimestamp) + microseconds_from(usPktTimestamp); } -void CTsbpdTime::updateTsbPdTimeBase(uint32_t usPktTimestamp) +void CTsbpdTime::updateBaseTime(uint32_t usPktTimestamp) { ExclusiveLock lck(m_mtxRW); if (m_bTsbPdWrapCheck) diff --git a/srtcore/tsbpd_time.h b/srtcore/tsbpd_time.h index 78cf18d6f..9ef2a9838 100644 --- a/srtcore/tsbpd_time.h +++ b/srtcore/tsbpd_time.h @@ -76,31 +76,31 @@ class CTsbpdTime /// When packet timestamp approaches CPacket::MAX_TIMESTAMP, the TSBPD base time should be /// shifted accordingly to correctly handle new packets with timestamps starting from zero. /// @param usPktTimestamp timestamp field value of a data packet. - void updateTsbPdTimeBase(uint32_t usPktTimestamp); + void updateBaseTime(uint32_t usPktTimestamp); /// @brief Get TSBPD base time adjusted for carryover, which occurs when /// a packet's timestamp exceeds the UINT32_MAX and continues from zero. /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return TSBPD base time for a provided packet timestamp. - time_point getTsbPdTimeBase(uint32_t usPktTimestamp) const; + time_point getBaseTime(uint32_t usPktTimestamp) const; /// @brief Get packet TSBPD time without buffering delay and clock drift, which is /// the target time for delivering the packet to an upstream application. - /// Essentially: getTsbPdTimeBase(usPktTimestamp) + usPktTimestamp + /// Essentially: getBaseTime(usPktTimestamp) + usPktTimestamp /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return Packet TSBPD base time without buffering delay. - time_point getPktTsbPdBaseTime(uint32_t usPktTimestamp) const; + time_point getPktBaseTime(uint32_t usPktTimestamp) const; /// @brief Get packet TSBPD time with buffering delay and clock drift, which is /// the target time for delivering the packet to an upstream application /// (including drift and carryover effects, if any). - /// Essentially: getPktTsbPdBaseTime(usPktTimestamp) + m_tdTsbPdDelay + drift() + /// Essentially: getPktBaseTime(usPktTimestamp) + m_tdTsbPdDelay + drift() /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return Packet TSBPD time with buffering delay. - time_point getPktTsbPdTime(uint32_t usPktTimestamp) const; + time_point getPktTime(uint32_t usPktTimestamp) const; /// @brief Get current drift value. /// @return current drift value. @@ -123,16 +123,16 @@ class CTsbpdTime /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return TSBPD base time for a provided packet timestamp. - time_point getTsbPdTimeBaseNoLock(uint32_t usPktTimestamp) const; + time_point getBaseTimeNoLock(uint32_t usPktTimestamp) const; /// @brief Get packet TSBPD time without buffering delay and clock drift, which is /// the target time for delivering the packet to an upstream application. - /// Essentially: getTsbPdTimeBase(usPktTimestamp) + usPktTimestamp + /// Essentially: getBaseTime(usPktTimestamp) + usPktTimestamp /// Does not lock the internal state. /// @param [in] usPktTimestamp 32-bit value of packet timestamp field (microseconds). /// /// @return Packet TSBPD base time without buffering delay. - time_point getPktTsbPdBaseTimeNoLock(uint32_t usPktTimestamp) const; + time_point getPktBaseTimeNoLock(uint32_t usPktTimestamp) const; int m_iFirstRTT; // First measured RTT sample. @@ -143,7 +143,7 @@ class CTsbpdTime /// @note m_tsTsbPdTimeBase is changed in the following cases: /// 1. Initialized upon SRT_CMD_HSREQ packet as the difference with the current time: /// = (NOW - PACKET_TIMESTAMP), at the time of HSREQ reception. - /// 2. Shifted forward on timestamp overflow (@see CTsbpdTime::updateTsbPdTimeBase), when overflow + /// 2. Shifted forward on timestamp overflow (@see CTsbpdTime::updateBaseTime), when overflow /// of the timestamp field value of a data packet is detected. /// += CPacket::MAX_TIMESTAMP + 1 /// 3. Clock drift (@see CTsbpdTime::addDriftSample, executed exclusively From c1803bba86c4af288931aa35b2a6233ac5eab657 Mon Sep 17 00:00:00 2001 From: Jean-Michel Gonet Date: Mon, 21 Oct 2024 07:43:26 +0000 Subject: [PATCH 3/9] [docs] Added 'brew install pkgconfig' to the macOS build guide (#3054). --- docs/build/build-macOS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/build/build-macOS.md b/docs/build/build-macOS.md index b14a56197..07a5a95cd 100644 --- a/docs/build/build-macOS.md +++ b/docs/build/build-macOS.md @@ -19,6 +19,7 @@ Install [CMake](https://cmake.org/) and OpenSSL with development files from `bre ```shell brew install cmake brew install openssl +brew install pkgconfig ``` SRT can be now built with `cmake` or `make` on Mac. From d2811cc215b174e8c3a03b12ba11cdc72c7a3bc3 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Tue, 29 Oct 2024 10:25:53 +0100 Subject: [PATCH 4/9] [build] Apply -stdc=99 on SRT library. --- CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a2fc63d2..7ed11ef8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1046,8 +1046,23 @@ macro(srt_set_stdcxx targetname spec) endif() endmacro() +macro(srt_set_stdc targetname spec) + set (stdcspec ${spec}) + if (NOT "${stdcspec}" STREQUAL "") + if (CMAKE_VERSION VERSION_LESS "3.1") + target_compile_options(${targetname} PRIVATE -std=c${stdcspec}) + message(STATUS "C STD: ${targetname}: forced C${stdcspec} standard - GNU option: -std=c${stdcspec}") + else() + set_target_properties(${targetname} PROPERTIES C_STANDARD ${stdcspec}) + message(STATUS "C STD: ${targetname}: forced C${stdcspec} standard - portable way") + endif() + else() + message(STATUS "APP: ${targetname}: using default C standard") + endif() +endmacro() srt_set_stdcxx(srt_virtual "${USE_CXX_STD_LIB}") +srt_set_stdc(srt_virtual "99") set (VIRTUAL_srt $) From 7df2805a5d993395a4d92d56a4bf1a79711aea1b Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Mon, 21 Oct 2024 11:07:00 +0200 Subject: [PATCH 5/9] [apps] Use sync.h instead of atomic.h in the verbose module. --- apps/verbose.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/verbose.hpp b/apps/verbose.hpp index e3d20732a..56945bf2c 100644 --- a/apps/verbose.hpp +++ b/apps/verbose.hpp @@ -12,7 +12,7 @@ #define INC_SRT_VERBOSE_HPP #include -#include "atomic.h" +#include "sync.h" namespace Verbose { From 47bc92bf42e3b686ca6b5ab249c089e33c2790be Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Mon, 4 Nov 2024 12:05:21 +0100 Subject: [PATCH 6/9] [docs] Set callbacks before listening or connecting. --- docs/API/API-functions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/API/API-functions.md b/docs/API/API-functions.md index 74fbc506f..2fdb8a661 100644 --- a/docs/API/API-functions.md +++ b/docs/API/API-functions.md @@ -751,6 +751,9 @@ automatically created to handle the incoming connection on the listening socket (and is about to be returned by [`srt_accept`](#srt_accept)), but before the connection has been accepted. +Note the callback must be set before starting listening, +i.e. before `srt_listen` is called. + **Arguments**: * `lsn`: Listening socket where you want to install the callback hook @@ -1020,6 +1023,9 @@ mode ([`SRTO_RCVSYN`](API-socket-options.md#SRTO_RCVSYN) option set to true). It is guaranteed to be called when a socket is in non-blocking mode, or when you use a group. +Note the callback must be set before starting the connection procedure, +i.e. before `srt_connect`, `srt_connect_bind`, etc. is called. + This function is mainly intended to be used with group connections. Note that even if you use a group connection in blocking mode, after the group is considered connected the member connections still continue in background. Also, when some From 1ce7dbaf679b68d5f7652a568168fe61451f1547 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Wed, 6 Nov 2024 11:17:26 +0100 Subject: [PATCH 7/9] [core] Resolved GCC13 build warning regarding std::copy of a bool. --- srtcore/group.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/srtcore/group.cpp b/srtcore/group.cpp index 5601cdeee..e7f40d884 100644 --- a/srtcore/group.cpp +++ b/srtcore/group.cpp @@ -447,11 +447,13 @@ static bool operator!=(const struct linger& l1, const struct linger& l2) template static void importOption(vector& storage, SRT_SOCKOPT optname, const ValueType& field) { - ValueType default_opt = ValueType(); - int default_opt_size = sizeof(ValueType); - ValueType opt = field; - if (!getOptDefault(optname, (&default_opt), (default_opt_size)) || default_opt != opt) + ValueType default_opt = ValueType(); + static const int default_opt_size = sizeof(ValueType); + ValueType opt = field; + int opt_size = default_opt_size; + if (!getOptDefault(optname, (&default_opt), (opt_size)) || default_opt != opt) { + SRT_ASSERT(opt_size == default_opt_size); // Store the option when: // - no default for this option is found // - the option value retrieved from the field is different than default From 5b0d844488871de4c0e4fbde8f1f88b563edcbb1 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Wed, 6 Nov 2024 11:18:27 +0100 Subject: [PATCH 8/9] [docs] Fix np.nan in the release notes script. --- scripts/release-notes/generate_release_notes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release-notes/generate_release_notes.py b/scripts/release-notes/generate_release_notes.py index 2392b4348..c92ef3cca 100644 --- a/scripts/release-notes/generate_release_notes.py +++ b/scripts/release-notes/generate_release_notes.py @@ -21,7 +21,7 @@ def define_area(msg): if msg.startswith(f'[{area}] '): return area - return np.NaN + return np.nan def delete_prefix(msg): From a8c6b65520f814c5bd8f801be48c33ceece7c4a6 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Thu, 7 Nov 2024 09:26:05 +0100 Subject: [PATCH 9/9] [core] Fixed group import option. SRTO_CONNTIMEO, SRTO_PAYLOADSIZE, SRTO_PBKEYLEN had size autodetection bugs. --- srtcore/group.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/srtcore/group.cpp b/srtcore/group.cpp index e7f40d884..6b0b16484 100644 --- a/srtcore/group.cpp +++ b/srtcore/group.cpp @@ -517,7 +517,11 @@ void CUDTGroup::deriveSettings(CUDT* u) IM(SRTO_UDP_RCVBUF, iUDPRcvBufSize); // SRTO_RENDEZVOUS: impossible to have it set on a listener socket. // SRTO_SNDTIMEO/RCVTIMEO: groupwise setting - IM(SRTO_CONNTIMEO, tdConnTimeOut); + + // SRTO_CONNTIMEO requires a special handling, because API stores the value in integer milliseconds, + // but the type of the variable is srt::sync::duration. + importOption(m_config, SRTO_CONNTIMEO, (int) count_milliseconds(u->m_config.tdConnTimeOut)); + IM(SRTO_DRIFTTRACER, bDriftTracer); // Reuseaddr: true by default and should only be true. IM(SRTO_MAXBW, llMaxBW); @@ -530,7 +534,9 @@ void CUDTGroup::deriveSettings(CUDT* u) IM(SRTO_RCVLATENCY, iRcvLatency); IM(SRTO_PEERLATENCY, iPeerLatency); IM(SRTO_SNDDROPDELAY, iSndDropDelay); - IM(SRTO_PAYLOADSIZE, zExpPayloadSize); + // Special handling of SRTO_PAYLOADSIZE becuase API stores the value as int32_t, + // while the config structure stores it as size_t. + importOption(m_config, SRTO_PAYLOADSIZE, (int)u->m_config.zExpPayloadSize); IMF(SRTO_TLPKTDROP, m_bTLPktDrop); importOption(m_config, SRTO_STREAMID, u->m_config.sStreamName.str()); @@ -544,7 +550,7 @@ void CUDTGroup::deriveSettings(CUDT* u) importOption(m_config, SRTO_PACKETFILTER, u->m_config.sPacketFilterConfig.str()); - importOption(m_config, SRTO_PBKEYLEN, u->m_pCryptoControl->KeyLen()); + importOption(m_config, SRTO_PBKEYLEN, (int) u->m_pCryptoControl->KeyLen()); // Passphrase is empty by default. Decipher the passphrase and // store as passphrase option @@ -824,7 +830,7 @@ void CUDTGroup::getOpt(SRT_SOCKOPT optname, void* pw_optval, int& w_optlen) if (w_optlen < int(i->value.size())) throw CUDTException(MJ_NOTSUP, MN_XSIZE, 0); - w_optlen = i->value.size(); + w_optlen = (int) i->value.size(); memcpy((pw_optval), &i->value[0], i->value.size()); }