Skip to content

Commit 22cd346

Browse files
Merge branch 'master' into develop/opt-min-response-timeo
2 parents 22efc55 + d7dcf0c commit 22cd346

19 files changed

+406
-171
lines changed

configure-data.tcl

+13-2
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,19 @@ proc postprocess {} {
343343
# Otherwise don't set PKG_CONFIG_PATH and we'll see.
344344
}
345345

346-
if { $::HAVE_DARWIN && !$toolchain_changed} {
347-
346+
set use_brew 0
347+
if { $::HAVE_DARWIN && !$toolchain_changed } {
348+
set use_brew 1
349+
}
350+
if { $use_brew } {
351+
foreach item $::cmakeopt {
352+
if { [string first "Android" $item] != -1 } {
353+
set use_brew 0
354+
break
355+
}
356+
}
357+
}
358+
if { $use_brew } {
348359
if { $have_gnutls } {
349360
# Use gnutls explicitly, as found in brew
350361
set er [catch {exec brew info gnutls} res]

docs/API/API-socket-options.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ The following table lists SRT API socket options in alphabetical order. Option d
239239
| [`SRTO_RCVSYN`](#SRTO_RCVSYN) | | post | `bool` | | true | | RW | GSI |
240240
| [`SRTO_RCVTIMEO`](#SRTO_RCVTIMEO) | | post | `int32_t` | ms | -1 | -1, 0.. | RW | GSI |
241241
| [`SRTO_RENDEZVOUS`](#SRTO_RENDEZVOUS) | | pre | `bool` | | false | | RW | S |
242-
| [`SRTO_RETRANSMITALGO`](#SRTO_RETRANSMITALGO) | 1.4.2 | pre | `int32_t` | | 0 | [0, 1] | RW | GSD |
242+
| [`SRTO_RETRANSMITALGO`](#SRTO_RETRANSMITALGO) | 1.4.2 | pre | `int32_t` | | 1 | [0, 1] | RW | GSD |
243243
| [`SRTO_REUSEADDR`](#SRTO_REUSEADDR) | | pre-bind | `bool` | | true | | RW | GSD |
244244
| [`SRTO_SENDER`](#SRTO_SENDER) | 1.0.4 | pre | `bool` | | false | | W | S |
245245
| [`SRTO_SNDBUF`](#SRTO_SNDBUF) | | pre-bind | `int32_t` | bytes | 8192 payloads | \* | RW | GSD+ |
@@ -1275,12 +1275,12 @@ procedure of `srt_bind` and then `srt_connect` (or `srt_rendezvous`) to one anot
12751275

12761276
| OptName | Since | Restrict | Type | Units | Default | Range | Dir | Entity |
12771277
| --------------------- | ----- | -------- | --------- | ------ | ------- | ------ | --- | ------ |
1278-
| `SRTO_RETRANSMITALGO` | 1.4.2 | pre | `int32_t` | | 0 | [0, 1] | RW | GSD |
1278+
| `SRTO_RETRANSMITALGO` | 1.4.2 | pre | `int32_t` | | 1 | [0, 1] | RW | GSD |
12791279

12801280
Retransmission algorithm to use (SENDER option):
12811281

1282-
- 0 - Default (retransmit on every loss report).
1283-
- 1 - Reduced retransmissions (not more often than once per RTT); reduced
1282+
- 0 - Retransmit on every loss report (higher overhead, but slightly higher chance to recover a lost packet).
1283+
- 1 - Reduced retransmissions (retransmit not more often than once per RTT); reduced
12841284
bandwidth consumption.
12851285

12861286
This option is effective only on the sending side. It influences the decision

docs/API/API.md

+22-16
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,15 @@ either `FASTREXMIT` or `LATEREXMIT`. This will be explained below.
521521

522522
Setting `SRTO_TRANSTYPE` to `SRTT_LIVE` sets the following [socket options](API-socket-options.md):
523523

524-
- `SRTO_TSBPDMODE` = true
525-
- `SRTO_RCVLATENCY` = 120
526-
- `SRTO_PEERLATENCY` = 0
527-
- `SRTO_TLPKTDROP` = true
528-
- `SRTO_MESSAGEAPI` = true
529-
- `SRTO_NAKREPORT` = true
530-
- `SRTO_PAYLOADSIZE` = 1316
531-
- `SRTO_CONGESTION` = "live"
524+
- [`SRTO_TSBPDMODE`](API-socket-options.md#SRTO_TSBPDMODE) = true
525+
- [`SRTO_RCVLATENCY`](API-socket-options.md#SRTO_RCVLATENCY) = 120
526+
- [`SRTO_PEERLATENCY`](API-socket-options.md#SRTO_PEERLATENCY) = 0
527+
- [`SRTO_TLPKTDROP`](API-socket-options.md#SRTO_TLPKTDROP) = true
528+
- [`SRTO_MESSAGEAPI`](API-socket-options.md#SRTO_MESSAGEAPI) = true
529+
- [`SRTO_NAKREPORT`](API-socket-options.md#SRTO_NAKREPORT) = true
530+
- [`SRTO_RETRANSMITALGO`](API-socket-options.md#SRTO_RETRANSMITALGO) = 1
531+
- [`SRTO_PAYLOADSIZE`](API-socket-options.md#SRTO_PAYLOADSIZE) = 1316
532+
- [`SRTO_CONGESTION`](API-socket-options.md#SRTO_CONGESTION) = "live"
532533

533534
In this mode, every call to a sending function is allowed to send only
534535
so much data, as declared by `SRTO_PAYLOADSIZE`, whose value is still
@@ -580,6 +581,10 @@ loss report itself was lost. Without it, the loss report will be always reported
580581
just once and never repeated again, and then the lost payload packet will
581582
be probably dropped by the TLPKTDROP mechanism.
582583

584+
- `SRTO_RETRANSMITALGO`: Given the receiver sends periodic NAK reports,
585+
the sender can reduce the retransmission overhead by not retransmitting a loss
586+
more often than once per RTT (value 1).
587+
583588
- `SRTO_PAYLOADSIZE`: Default value is for MPEG TS. If you are going
584589
to use SRT to send any different kind of payload, such as, for example,
585590
wrapping a live stream in very small frames, then you can use a bigger
@@ -598,14 +603,15 @@ NAKREPORT method is considered so effective that FASTREXMIT isn't necessary.
598603

599604
Setting `SRTO_TRANSTYPE` to `SRTT_FILE` sets the following [socket options](API-socket-options.md):
600605

601-
- `SRTO_TSBPDMODE` = false
602-
- `SRTO_RCVLATENCY` = 0
603-
- `SRTO_PEERLATENCY` = 0
604-
- `SRTO_TLPKTDROP` = false
605-
- `SRTO_MESSAGEAPI` = false
606-
- `SRTO_NAKREPORT` = false
607-
- `SRTO_PAYLOADSIZE` = 0
608-
- `SRTO_CONGESTION` = "file"
606+
- [`SRTO_TSBPDMODE`](API-socket-options.md#SRTO_TSBPDMODE) = false
607+
- [`SRTO_RCVLATENCY`](API-socket-options.md#SRTO_RCVLATENCY) = 0
608+
- [`SRTO_PEERLATENCY`](API-socket-options.md#SRTO_PEERLATENCY) = 0
609+
- [`SRTO_TLPKTDROP`](API-socket-options.md#SRTO_TLPKTDROP) = false
610+
- [`SRTO_MESSAGEAPI`](API-socket-options.md#SRTO_MESSAGEAPI) = false
611+
- [`SRTO_NAKREPORT`](API-socket-options.md#SRTO_NAKREPORT) = false
612+
- [`SRTO_RETRANSMITALGO`](API-socket-options.md#SRTO_RETRANSMITALGO) = 0
613+
- [`SRTO_PAYLOADSIZE`](API-socket-options.md#SRTO_PAYLOADSIZE) = 0
614+
- [`SRTO_CONGESTION`](API-socket-options.md#SRTO_CONGESTION) = "file"
609615

610616
In this mode, calling a sending function is allowed to potentially send
611617
virtually any size of data. The sending function will HANGUP only if the

scripts/build-android/build-android

+29-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,35 @@ else
5252
fi
5353
fi
5454

55-
# Determine the path of the executing script
56-
BASE_DIR=$(readlink -f $0 | xargs dirname)
55+
SCRIPT_DIR=$(pwd)
56+
HOST_TAG='unknown'
57+
unamestr=$(uname -s)
58+
if [ "$unamestr" = 'Linux' ]; then
59+
SCRIPT_DIR=$(readlink -f $0 | xargs dirname)
60+
HOST_TAG='linux-x86_64'
61+
elif [ "$unamestr" = 'Darwin' ]; then
62+
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
63+
if [ $(uname -p) = 'arm' ]; then
64+
echo "NDK does not currently support ARM64"
65+
exit 128
66+
else
67+
HOST_TAG='darwin-x86_64'
68+
fi
69+
fi
70+
71+
# Write files relative to current location
72+
BASE_DIR=$(pwd)
73+
case "${BASE_DIR}" in
74+
*\ * )
75+
echo "Your path contains whitespaces, which is not supported by 'make install'."
76+
exit 128
77+
;;
78+
esac
79+
cd "${BASE_DIR}"
5780

5881
if [ $ENC_LIB = 'openssl' ]; then
59-
$BASE_DIR/mkssl -n $NDK_ROOT -a $API_LEVEL -t "$BUILD_TARGETS" -o $OPENSSL_VERSION
82+
echo "Building OpenSSL $OPENSSL_VERSION"
83+
$SCRIPT_DIR/mkssl -n $NDK_ROOT -a $API_LEVEL -t "$BUILD_TARGETS" -o $OPENSSL_VERSION -d $BASE_DIR -h $HOST_TAG
6084
elif [ $ENC_LIB = 'mbedtls' ]; then
6185
if [ ! -d $BASE_DIR/mbedtls ]; then
6286
git clone https://github.com/ARMmbed/mbedtls mbedtls
@@ -83,13 +107,13 @@ for build_target in $BUILD_TARGETS; do
83107
mkdir -p $JNI_DIR
84108

85109
if [ $ENC_LIB = 'mbedtls' ]; then
86-
$BASE_DIR/mkmbedtls -n $NDK_ROOT -a $API_LEVEL -t $build_target -s $BASE_DIR/mbedtls -i $BASE_DIR/$build_target
110+
$SCRIPT_DIR/mkmbedtls -n $NDK_ROOT -a $API_LEVEL -t $build_target -s $BASE_DIR/mbedtls -i $BASE_DIR/$build_target
87111
cp $LIB_DIR/libmbedcrypto.so $JNI_DIR/libmbedcrypto.so
88112
cp $LIB_DIR/libmbedtls.so $JNI_DIR/libmbedtls.so
89113
cp $LIB_DIR/libmbedx509.so $JNI_DIR/libmbedx509.so
90114
fi
91115

92116
git -C $BASE_DIR/srt clean -fd
93-
$BASE_DIR/mksrt -n $NDK_ROOT -a $API_LEVEL -t $build_target -e $ENC_LIB -s $BASE_DIR/srt -i $BASE_DIR/$build_target
117+
$SCRIPT_DIR/mksrt -n $NDK_ROOT -a $API_LEVEL -t $build_target -e $ENC_LIB -s $BASE_DIR/srt -i $BASE_DIR/$build_target
94118
cp $LIB_DIR/libsrt.so $JNI_DIR/libsrt.so
95119
done

scripts/build-android/mkssl

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
#!/bin/sh
22

3-
while getopts n:o:a:t: option
3+
while getopts n:o:a:t:d:h: option
44
do
55
case "${option}"
66
in
77
n) ANDROID_NDK=${OPTARG};;
88
o) OPENSSL_VERSION=${OPTARG};;
99
a) API_LEVEL=${OPTARG};;
1010
t) BUILD_TARGETS=${OPTARG};;
11+
d) OUT_DIR=${OPTARG};;
12+
h) HOST_TAG=${OPTARG};;
1113
*) twentytwo=${OPTARG};;
1214
esac
1315
done
1416

1517

1618
BUILD_DIR=/tmp/openssl_android_build
17-
OUT_DIR=$(pwd)
1819

1920
if [ ! -d openssl-${OPENSSL_VERSION} ]
2021
then
@@ -29,7 +30,7 @@ cd openssl-${OPENSSL_VERSION} || exit 128
2930

3031

3132
##### Prepare Files #####
32-
sed -i 's/.*-mandroid.*//' Configurations/15-android.conf
33+
sed -i.bak 's/.*-mandroid.*//' Configurations/15-android.conf
3334
patch -p1 -N <<EOP
3435
--- old/Configurations/unix-Makefile.tmpl 2018-09-11 14:48:19.000000000 +0200
3536
+++ new/Configurations/unix-Makefile.tmpl 2018-10-18 09:06:27.282007245 +0200
@@ -64,7 +65,7 @@ export ANDROID_NDK
6465

6566
##### build-function #####
6667
build_the_thing() {
67-
TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
68+
TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/$HOST_TAG
6869
export PATH=$TOOLCHAIN/$TRIBLE/bin:$TOOLCHAIN/bin:"$PATH"
6970
echo $PATH
7071
make clean

srtcore/api.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,21 @@ friend class CRendezvousQueue;
325325
CEPoll& epoll_ref() { return m_EPoll; }
326326

327327
private:
328-
// void init();
329-
330328
/// Generates a new socket ID. This function starts from a randomly
331329
/// generated value (at initialization time) and goes backward with
332330
/// with next calls. The possible values come from the range without
333331
/// the SRTGROUP_MASK bit, and the group bit is set when the ID is
334332
/// generated for groups. It is also internally checked if the
335333
/// newly generated ID isn't already used by an existing socket or group.
334+
///
335+
/// Socket ID value range.
336+
/// - [0]: reserved for handshake procedure. If the destination Socket ID is 0
337+
/// (destination Socket ID unknown) the packet will be sent to the listening socket
338+
/// or to a socket that is in the rendezvous connection phase.
339+
/// - [1; 2 ^ 30): single socket ID range.
340+
/// - (2 ^ 30; 2 ^ 31): group socket ID range. Effectively any positive number
341+
/// from [1; 2 ^ 30) with bit 30 set to 1. Bit 31 is zero.
342+
/// The most significant bit 31 (sign bit) is left unused so that checking for a value <= 0 identifies an invalid socket ID.
336343
///
337344
/// @param group The socket id should be for socket group.
338345
/// @return The new socket ID.

srtcore/common.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -595,16 +595,20 @@ void LogDispatcher::CreateLogLinePrefix(std::ostringstream& serr)
595595
{
596596
using namespace std;
597597

598-
char tmp_buf[512];
598+
SRT_STATIC_ASSERT(ThreadName::BUFSIZE >= sizeof("hh:mm:ss.") * 2, // multiply 2 for some margin
599+
"ThreadName::BUFSIZE is too small to be used for strftime");
600+
char tmp_buf[ThreadName::BUFSIZE];
599601
if ( !isset(SRT_LOGF_DISABLE_TIME) )
600602
{
601603
// Not necessary if sending through the queue.
602604
timeval tv;
603-
gettimeofday(&tv, 0);
605+
gettimeofday(&tv, NULL);
604606
struct tm tm = SysLocalTime((time_t) tv.tv_sec);
605607

606-
strftime(tmp_buf, 512, "%X.", &tm);
607-
serr << tmp_buf << setw(6) << setfill('0') << tv.tv_usec;
608+
if (strftime(tmp_buf, sizeof(tmp_buf), "%X.", &tm))
609+
{
610+
serr << tmp_buf << setw(6) << setfill('0') << tv.tv_usec;
611+
}
608612
}
609613

610614
string out_prefix;

0 commit comments

Comments
 (0)