Skip to content

Commit

Permalink
Habemus sender side bandwidth estimation (#295)
Browse files Browse the repository at this point in the history
Sender side bandwidth estimation working.
  • Loading branch information
ibc authored Apr 24, 2019
1 parent c70dea5 commit 56d5301
Show file tree
Hide file tree
Showing 90 changed files with 1,941 additions and 822 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
* José Luis Millán [[github](https://github.com/jmillan/)]


## Sponsors

* [46 Labs LLC](https://46labs.com): Special thanks to 46 Labs where we both, José Luis and Iñaki, develop a mediasoup based multiparty video conferencing app focused on the enterprise market for more than a year.


## Donate

You can support **mediasoup** by making a donation in [open collective][opencollective-mediasoup]. Thanks!
Expand Down
4 changes: 2 additions & 2 deletions lib/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class Router extends EnhancedEventEmitter
* @param {Boolean} [enableTcp=false] - Enable TCP.
* @param {Boolean} [preferUdp=false] - Prefer UDP.
* @param {Boolean} [preferTcp=false] - Prefer TCP.
* @param {Number} [initialAvailableOutgoingBitrate=300000] - Initial available
* @param {Number} [initialAvailableOutgoingBitrate=600000] - Initial available
* outgoing bitrate (in bps) when the endpoint supports REMB or Transport-CC.
* @param {Object} [appData={}] - Custom app data.
*
Expand All @@ -227,7 +227,7 @@ class Router extends EnhancedEventEmitter
enableTcp = false,
preferUdp = false,
preferTcp = false,
initialAvailableOutgoingBitrate = 300000,
initialAvailableOutgoingBitrate = 600000,
appData = {}
} = {}
)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-plugin-jest": "^22.4.1",
"gulp": "^4.0.0",
"eslint-plugin-jest": "^22.5.0",
"gulp": "^4.0.1",
"gulp-clang-format": "^1.0.27",
"jest": "^24.7.1",
"jest-tobetype": "^1.2.2",
Expand Down
2 changes: 2 additions & 0 deletions test/test-PlainRtpTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ test('plaintRtpTransport.getStats() succeeds', async () =>
expect(data[0].tuple.localPort).toBeType('number');
expect(data[0].tuple.protocol).toBe('udp');
expect(data[0].rtcpTuple).toBe(undefined);
expect(data[0].recvBitrate).toBe(0);
expect(data[0].sendBitrate).toBe(0);
}, 2000);

test('plaintRtpTransport.connect() succeeds', async () =>
Expand Down
2 changes: 2 additions & 0 deletions test/test-WebRtcTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ test('webRtcTransport.getStats() succeeds', async () =>
expect(data[0].bytesSent).toBe(0);
expect(data[0].iceSelectedTuple).toBe(undefined);
expect(data[0].maxIncomingBitrate).toBe(undefined);
expect(data[0].recvBitrate).toBe(0);
expect(data[0].sendBitrate).toBe(0);
}, 2000);

test('webRtcTransport.connect() succeeds', async () =>
Expand Down
5 changes: 5 additions & 0 deletions worker/compile_commands_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"directory": "PATH/out",
"file": "PATH/src/RTC/RtpPacket.cpp"
},
{
"command": "c++ -c -DMS_LITTLE_ENDIAN -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_INT16_T -DHAVE_INT32_T -DHAVE_INT8_T -DHAVE_UINT16_T -DHAVE_UINT32_T -DHAVE_UINT64_T -DHAVE_UINT8_T -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DCPU_CISC -IPATH/include -IPATH/deps/netstring/netstring-c -IPATH/deps/libuv/include -IPATH/deps/openssl/openssl/include -IPATH/deps/libsrtp/srtp/include -std=c++11 -Wall -Wextra -Wno-unused-parameter -m64 -g -o PATH/out/Release/obj.target/mediasoup-worker/src/RTC/RtpProbator.o PATH/src/RTC/RtpProbator.cpp",
"directory": "PATH/out",
"file": "PATH/src/RTC/RtpProbator.cpp"
},
{
"command": "c++ -c -DMS_LITTLE_ENDIAN -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_INT16_T -DHAVE_INT32_T -DHAVE_INT8_T -DHAVE_UINT16_T -DHAVE_UINT32_T -DHAVE_UINT64_T -DHAVE_UINT8_T -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DCPU_CISC -IPATH/include -IPATH/deps/netstring/netstring-c -IPATH/deps/libuv/include -IPATH/deps/openssl/openssl/include -IPATH/deps/libsrtp/srtp/include -std=c++11 -Wall -Wextra -Wno-unused-parameter -m64 -g -o PATH/out/Release/obj.target/mediasoup-worker/src/RTC/RtpStream.o PATH/src/RTC/RtpStream.cpp",
"directory": "PATH/out",
Expand Down
2 changes: 1 addition & 1 deletion worker/deps/catch/.conan/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def stable_branch_pattern(self):

@property
def reference(self):
""" Read project version from branch create Conan referece
""" Read project version from branch create Conan reference
"""
return os.getenv("CONAN_REFERENCE", "Catch2/{}".format(self._version))

Expand Down
2 changes: 1 addition & 1 deletion worker/deps/catch/.github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ at docs/contributing.md. It will tell you how to properly test your changes.
<!--
Describe the what and the why of your pull request. Remember that these two
are usually a bit different. As an example, if you have made various changes
to decrease the number of new strings allocated, thats what. The why probably
to decrease the number of new strings allocated, that's what. The why probably
was that you have a large set of tests and found that this speeds them up.
-->

Expand Down
2 changes: 1 addition & 1 deletion worker/deps/catch/CMake/FindGcov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY})

get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
foreach (LANG ${ENABLED_LANGUAGES})
# Gcov evaluation is dependend on the used compiler. Check gcov support for
# Gcov evaluation is dependent on the used compiler. Check gcov support for
# each compiler that is used. If gcov binary was already found for this
# compiler, do not try to find it again.
if (NOT GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN)
Expand Down
2 changes: 1 addition & 1 deletion worker/deps/catch/CMake/Findcodecov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY})

get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
foreach (LANG ${ENABLED_LANGUAGES})
# Coverage flags are not dependend on language, but the used compiler. So
# Coverage flags are not dependent on language, but the used compiler. So
# instead of searching flags foreach language, search flags foreach compiler
# used.
set(COMPILER ${CMAKE_${LANG}_COMPILER_ID})
Expand Down
13 changes: 12 additions & 1 deletion worker/deps/catch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON)
endif()

project(Catch2 LANGUAGES CXX VERSION 2.7.1)
project(Catch2 LANGUAGES CXX VERSION 2.7.2)

# Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
Expand Down Expand Up @@ -205,4 +205,15 @@ if (NOT_SUBPROJECT)
${PKGCONFIG_INSTALL_DIR}
)

# CPack/CMake started taking the package version from project version 3.12
# So we need to set the version manually for older CMake versions
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
endif()

set(CPACK_PACKAGE_CONTACT "https://github.com/catchorg/Catch2/")


include( CPack )

endif(NOT_SUBPROJECT)
4 changes: 2 additions & 2 deletions worker/deps/catch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2)
[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2)
[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/ZFBZ5XbLA9F1gzKi)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/rsEsNO9M0flb5NlQ)
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)


<a href="https://github.com/catchorg/Catch2/releases/download/v2.7.1/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
<a href="https://github.com/catchorg/Catch2/releases/download/v2.7.2/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>

## Catch2 is released!

Expand Down
66 changes: 47 additions & 19 deletions worker/deps/catch/contrib/CatchAddTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,47 @@ function(add_command NAME)
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
endfunction()

macro(_add_catch_test_labels LINE)
# convert to list of tags
string(REPLACE "][" "]\\;[" tags ${line})

add_command(
set_tests_properties "${prefix}${test}${suffix}"
PROPERTIES
LABELS "${tags}"
)
endmacro()

macro(_add_catch_test LINE)
set(test ${line})
# use escape commas to handle properly test cases with commans inside the name
string(REPLACE "," "\\," test_name ${test})
# ...and add to script
add_command(
add_test "${prefix}${test}${suffix}"
${TEST_EXECUTOR}
"${TEST_EXECUTABLE}"
"${test_name}"
${extra_args}
)

add_command(
set_tests_properties "${prefix}${test}${suffix}"
PROPERTIES
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${properties}
)
list(APPEND tests "${prefix}${test}${suffix}")
endmacro()

# Run test executable to get list of available tests
if(NOT EXISTS "${TEST_EXECUTABLE}")
message(FATAL_ERROR
"Specified test executable '${TEST_EXECUTABLE}' does not exist"
)
endif()
execute_process(
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-tests
OUTPUT_VARIABLE output
RESULT_VARIABLE result
)
Expand All @@ -47,27 +80,22 @@ elseif(${result} LESS 0)
endif()

string(REPLACE "\n" ";" output "${output}")
set(test)
set(tags_regex "(\\[([^\\[]*)\\])+$")

# Parse output
foreach(line ${output})
set(test ${line})
# use escape commas to handle properly test cases with commans inside the name
string(REPLACE "," "\\," test_name ${test})
# ...and add to script
add_command(add_test
"${prefix}${test}${suffix}"
${TEST_EXECUTOR}
"${TEST_EXECUTABLE}"
"${test_name}"
${extra_args}
)
add_command(set_tests_properties
"${prefix}${test}${suffix}"
PROPERTIES
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${properties}
)
list(APPEND tests "${prefix}${test}${suffix}")
# lines without leading whitespaces are catch output not tests
if(${line} MATCHES "^[ \t]+")
# strip leading spaces and tabs
string(REGEX REPLACE "^[ \t]+" "" line ${line})

if(${line} MATCHES "${tags_regex}")
_add_catch_test_labels(${line})
else()
_add_catch_test(${line})
endif()
endif()
endforeach()

# Create a list of all discovered tests, which users may use to e.g. set
Expand Down
56 changes: 39 additions & 17 deletions worker/deps/catch/contrib/ParseAndAddCatchTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,27 @@
# set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NUMPROC}) #
# just before calling this ParseAndAddCatchTests function #
# #
# The AdditionalCatchParameters optional variable can be used to pass extra argument to the test #
# command. For example, to include successful tests in the output, one can write #
# set(AdditionalCatchParameters --success) #
# #
# After the script, the ParseAndAddCatchTests_TESTS property for the target, and for each source #
# file in the target is set, and contains the list of the tests extracted from that target, or #
# from that file. This is useful, for example to add further labels or properties to the tests. #
# #
#==================================================================================================#

cmake_minimum_required(VERSION 2.8.8)
if (CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8)
message(FATAL_ERROR "ParseAndAddCatchTests requires CMake 2.8.8 or newer")
endif()

option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF)
option(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS "Exclude tests with [!hide], [.] or [.foo] tags" OFF)
option(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME "Add fixture class name to the test name" ON)
option(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME "Add target name to the test name" ON)
option(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS "Add test file to CMAKE_CONFIGURE_DEPENDS property" OFF)

function(PrintDebugMessage)
function(ParseAndAddCatchTests_PrintDebugMessage)
if(PARSE_CATCH_TESTS_VERBOSE)
message(STATUS "ParseAndAddCatchTests: ${ARGV}")
endif()
Expand All @@ -65,7 +75,7 @@ endfunction()
# - full line comments (i.e. // ... )
# contents have been read into '${CppCode}'.
# !keep partial line comments
function(RemoveComments CppCode)
function(ParseAndAddCatchTests_RemoveComments CppCode)
string(ASCII 2 CMakeBeginBlockComment)
string(ASCII 3 CMakeEndBlockComment)
string(REGEX REPLACE "/\\*" "${CMakeBeginBlockComment}" ${CppCode} "${${CppCode}}")
Expand All @@ -77,24 +87,29 @@ function(RemoveComments CppCode)
endfunction()

# Worker function
function(ParseFile SourceFile TestTarget)
function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
# If SourceFile is an object library, do not scan it (as it is not a file). Exit without giving a warning about a missing file.
if(SourceFile MATCHES "\\\$<TARGET_OBJECTS:.+>")
ParseAndAddCatchTests_PrintDebugMessage("Detected OBJECT library: ${SourceFile} this will not be scanned for tests.")
return()
endif()
# According to CMake docs EXISTS behavior is well-defined only for full paths.
get_filename_component(SourceFile ${SourceFile} ABSOLUTE)
if(NOT EXISTS ${SourceFile})
message(WARNING "Cannot find source file: ${SourceFile}")
return()
endif()
PrintDebugMessage("parsing ${SourceFile}")
ParseAndAddCatchTests_PrintDebugMessage("parsing ${SourceFile}")
file(STRINGS ${SourceFile} Contents NEWLINE_CONSUME)

# Remove block and fullline comments
RemoveComments(Contents)
ParseAndAddCatchTests_RemoveComments(Contents)

# Find definition of test names
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^\)]+\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")

if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests)
PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
ParseAndAddCatchTests_PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
set_property(
DIRECTORY
APPEND
Expand Down Expand Up @@ -155,7 +170,6 @@ function(ParseFile SourceFile TestTarget)

list(APPEND Labels ${Tags})

list(FIND Labels "!hide" IndexOfHideLabel)
set(HiddenTagFound OFF)
foreach(label ${Labels})
string(REGEX MATCH "^!hide|^\\." result ${label})
Expand All @@ -165,26 +179,34 @@ function(ParseFile SourceFile TestTarget)
endif(result)
endforeach(label)
if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_LESS "3.9")
PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label")
ParseAndAddCatchTests_PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label")
else()
PrintDebugMessage("Adding test \"${CTestName}\"")
ParseAndAddCatchTests_PrintDebugMessage("Adding test \"${CTestName}\"")
if(Labels)
PrintDebugMessage("Setting labels to ${Labels}")
ParseAndAddCatchTests_PrintDebugMessage("Setting labels to ${Labels}")
endif()

# Escape commas in the test spec
string(REPLACE "," "\\," Name ${Name})

# Add the test and set its properties
add_test(NAME "\"${CTestName}\"" COMMAND ${OptionalCatchTestLauncher} ${TestTarget} ${Name} ${AdditionalCatchParameters})
add_test(NAME "\"${CTestName}\"" COMMAND ${OptionalCatchTestLauncher} $<TARGET_FILE:${TestTarget}> ${Name} ${AdditionalCatchParameters})
# Old CMake versions do not document VERSION_GREATER_EQUAL, so we use VERSION_GREATER with 3.8 instead
if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_GREATER "3.8")
PrintDebugMessage("Setting DISABLED test property")
ParseAndAddCatchTests_PrintDebugMessage("Setting DISABLED test property")
set_tests_properties("\"${CTestName}\"" PROPERTIES DISABLED ON)
else()
set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
LABELS "${Labels}")
endif()
set_property(
TARGET ${TestTarget}
APPEND
PROPERTY ParseAndAddCatchTests_TESTS "\"${CTestName}\"")
set_property(
SOURCE ${SourceFile}
APPEND
PROPERTY ParseAndAddCatchTests_TESTS "\"${CTestName}\"")
endif()


Expand All @@ -193,11 +215,11 @@ endfunction()

# entry point
function(ParseAndAddCatchTests TestTarget)
PrintDebugMessage("Started parsing ${TestTarget}")
ParseAndAddCatchTests_PrintDebugMessage("Started parsing ${TestTarget}")
get_target_property(SourceFiles ${TestTarget} SOURCES)
PrintDebugMessage("Found the following sources: ${SourceFiles}")
ParseAndAddCatchTests_PrintDebugMessage("Found the following sources: ${SourceFiles}")
foreach(SourceFile ${SourceFiles})
ParseFile(${SourceFile} ${TestTarget})
ParseAndAddCatchTests_ParseFile(${SourceFile} ${TestTarget})
endforeach()
PrintDebugMessage("Finished parsing ${TestTarget}")
ParseAndAddCatchTests_PrintDebugMessage("Finished parsing ${TestTarget}")
endfunction()
2 changes: 1 addition & 1 deletion worker/deps/catch/docs/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[Override output colouring](#override-output-colouring)<br>

Catch works quite nicely without any command line options at all - but for those times when you want greater control the following options are available.
Click one of the followings links to take you straight to that option - or scroll on to browse the available options.
Click one of the following links to take you straight to that option - or scroll on to browse the available options.

<a href="#specifying-which-tests-to-run"> ` <test-spec> ...`</a><br />
<a href="#usage"> ` -h, -?, --help`</a><br />
Expand Down
2 changes: 1 addition & 1 deletion worker/deps/catch/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ them yourself, their signatures are:
By default, when Catch's stringification machinery has to stringify
a type that does not specialize `StringMaker`, does not overload `operator<<`,
is not an enumeration and is not a range, it uses `"{?}"`. This can be
overriden by defining `CATCH_CONFIG_FALLBACK_STRINGIFIER` to name of a
overridden by defining `CATCH_CONFIG_FALLBACK_STRINGIFIER` to name of a
function that should perform the stringification instead.

All types that do not provide `StringMaker` specialization or `operator<<`
Expand Down
Loading

0 comments on commit 56d5301

Please sign in to comment.