Skip to content
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
46 changes: 40 additions & 6 deletions .github/workflows/mediasoup-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ jobs:
run-test: true
run-test-asan-address: false
run-test-asan-undefined: false
# Tests write their output to a file since dev logs make it huge.
quiet-tests: true
# Compile with all Meson option flags enabled once with gcc in
# Debug mode.
meson_args: '-Dms_log_trace=true -Dms_log_file_line=true -Dms_rtc_logger_rtp=true -Dms_rtc_logger_send_burst=true -Dms_dump_rtp_payload_descriptor=true -Dms_dump_rtp_shared_packet_memory_usage=true -Dms_werror=true'
meson_args: '-Dms_log_trace=true -Dms_log_file_line=true -Dms_log_dev_level=3 -Dms_rtc_logger_rtp=true -Dms_rtc_logger_send_burst=true -Dms_dump_rtp_payload_descriptor=true -Dms_dump_rtp_shared_packet_memory_usage=true -Dms_werror=true'
- os: ubuntu-26.04
cc: clang
cxx: clang++
Expand All @@ -153,9 +155,11 @@ jobs:
run-test: true
run-test-asan-address: true
run-test-asan-undefined: true
# Tests write their output to a file since dev logs make it huge.
quiet-tests: true
# Let's just compile with all Meson option flags enabled once with
# clang.
meson_args: '-Dms_log_trace=true -Dms_log_file_line=true -Dms_rtc_logger_rtp=true -Dms_rtc_logger_send_burst=true -Dms_dump_rtp_payload_descriptor=true -Dms_dump_rtp_shared_packet_memory_usage=true -Dms_werror=true'
meson_args: '-Dms_log_trace=true -Dms_log_file_line=true -Dms_log_dev_level=3 -Dms_rtc_logger_rtp=true -Dms_rtc_logger_send_burst=true -Dms_dump_rtp_payload_descriptor=true -Dms_dump_rtp_shared_packet_memory_usage=true -Dms_werror=true'
- os: ubuntu-26.04-arm
cc: gcc
cxx: g++
Expand Down Expand Up @@ -221,10 +225,12 @@ jobs:
# Address Sanitizer does not work on Windows.
run-test-asan-address: false
run-test-asan-undefined: false
# Tests write their output to a file since dev logs make it huge.
quiet-tests: true
# Let's just compile with all Meson option flags enabled once with
# MSVC. MESON_ARGS replaces the default `--vsenv` on Windows, so it
# must be given here.
meson_args: '--vsenv -Dms_log_trace=true -Dms_log_file_line=true -Dms_rtc_logger_rtp=true -Dms_rtc_logger_send_burst=true -Dms_dump_rtp_payload_descriptor=true -Dms_dump_rtp_shared_packet_memory_usage=true -Dms_werror=true'
meson_args: '--vsenv -Dms_log_trace=true -Dms_log_file_line=true -Dms_log_dev_level=3 -Dms_rtc_logger_rtp=true -Dms_rtc_logger_send_burst=true -Dms_dump_rtp_payload_descriptor=true -Dms_dump_rtp_shared_packet_memory_usage=true -Dms_werror=true'

runs-on: ${{ matrix.build.os }}

Expand Down Expand Up @@ -302,14 +308,42 @@ jobs:
# NOTE: Sanitizer tests run before the regular ones since they report
# issues (such as misaligned accesses) with file and line, whereas the
# regular tests may just crash. They use their own build directory.
- if: ${{ matrix.build.run-test-asan-undefined }}
# NOTE: With `quiet-tests`, the stdout of the tests goes to a file, whose
# last lines are printed if they fail, and the whole file is uploaded as
# an artifact of the run. stderr goes to that file and to the output.
- if: ${{ matrix.build.run-test-asan-undefined && !matrix.build.quiet-tests }}
name: invoke -r worker test-asan-undefined
run: invoke -r worker test-asan-undefined

- if: ${{ matrix.build.run-test-asan-address }}
- if: ${{ matrix.build.run-test-asan-undefined && matrix.build.quiet-tests }}
name: invoke -r worker test-asan-undefined (stdout in test-asan-undefined.log)
shell: bash
run: |
{ invoke -r worker test-asan-undefined 2>&1 1>&3 | tee -a test-asan-undefined.log >&2; } 3>>test-asan-undefined.log || { tail -n 300 test-asan-undefined.log; exit 1; }

- if: ${{ matrix.build.run-test-asan-address && !matrix.build.quiet-tests }}
name: invoke -r worker test-asan-address
run: invoke -r worker test-asan-address

- if: ${{ matrix.build.run-test }}
- if: ${{ matrix.build.run-test-asan-address && matrix.build.quiet-tests }}
name: invoke -r worker test-asan-address (stdout in test-asan-address.log)
shell: bash
run: |
{ invoke -r worker test-asan-address 2>&1 1>&3 | tee -a test-asan-address.log >&2; } 3>>test-asan-address.log || { tail -n 300 test-asan-address.log; exit 1; }

- if: ${{ matrix.build.run-test && !matrix.build.quiet-tests }}
name: invoke -r worker test
run: invoke -r worker test

- if: ${{ matrix.build.run-test && matrix.build.quiet-tests }}
name: invoke -r worker test (stdout in test.log)
shell: bash
run: |
{ invoke -r worker test 2>&1 1>&3 | tee -a test.log >&2; } 3>>test.log || { tail -n 300 test.log; exit 1; }

- if: ${{ failure() && matrix.build.quiet-tests }}
name: Upload test logs
uses: actions/upload-artifact@v4
with:
name: test-logs-${{ matrix.build.os }}-${{ matrix.build.cc }}
path: test*.log
10 changes: 9 additions & 1 deletion worker/include/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,17 @@
(Settings::configuration.logTags.tag1 || Settings::configuration.logTags.tag2)
// NOLINTEND

// A source file that doesn't define MS_LOG_DEV_LEVEL gets the one given to the
// whole build with the `ms_log_dev_level` Meson option, if any.
#ifndef MS_LOG_DEV_LEVEL
#ifdef MS_LOG_DEV_LEVEL_DEFAULT
#define MS_LOG_DEV_LEVEL MS_LOG_DEV_LEVEL_DEFAULT
#else
#define MS_LOG_DEV_LEVEL 0
#elif MS_LOG_DEV_LEVEL < 0 || MS_LOG_DEV_LEVEL > 3
#endif
#endif

#if MS_LOG_DEV_LEVEL < 0 || MS_LOG_DEV_LEVEL > 3
#error "invalid MS_LOG_DEV_LEVEL macro value"
#endif

Expand Down
2 changes: 1 addition & 1 deletion worker/include/RTC/ActiveSpeakerObserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace RTC

void EvalLongActivityScore();

void UpdateMinLevel(int8_t level);
void UpdateMinLevel(uint8_t level);

public:
bool paused{ false };
Expand Down
4 changes: 2 additions & 2 deletions worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ namespace RTC
/**
* Number of probes in the run.
*/
int count{ 0 };
int64_t count{ 0 };
/**
* How many of those probes came far enough apart from the previous one
* for the gap to be measurable.
*/
int numAboveMinDelta{ 0 };
int64_t numAboveMinDelta{ 0 };
};

enum class ProbeResult : uint8_t
Expand Down
4 changes: 2 additions & 2 deletions worker/include/RTC/BWE/TrendlineEstimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ namespace RTC

private:
const TrendlineEstimatorOptions options;
int numOfDeltas{ 0 };
uint64_t numOfDeltas{ 0 };
std::optional<int64_t> firstArrivalTimeUs;
double accumulatedDelayUs{ 0 };
double smoothedDelayUs{ 0 };
std::deque<PacketTiming> delayHist;
double threshold{ 12.5 };
double prevTrend{ 0 };
std::optional<double> timeOverUsingUs;
int overuseCounter{ 0 };
uint64_t overuseCounter{ 0 };
std::optional<int64_t> lastSampleArrivalTimeUs;
Types::BandwidthUsage state{ Types::BandwidthUsage::NORMAL };
};
Expand Down
6 changes: 6 additions & 0 deletions worker/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ if get_option('ms_log_file_line')
]
endif

if get_option('ms_log_dev_level') > 0
cpp_args += [
'-DMS_LOG_DEV_LEVEL_DEFAULT=@0@'.format(get_option('ms_log_dev_level')),
]
endif

if get_option('ms_rtc_logger_rtp')
cpp_args += [
'-DMS_RTC_LOGGER_RTP',
Expand Down
1 change: 1 addition & 0 deletions worker/meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
option('ms_log_trace', type: 'boolean', value: false, description: 'Logs the current method/function if current log level is "debug"')
option('ms_log_file_line', type: 'boolean', value: false, description: 'Logging macros print more verbose information, including current file and line')
option('ms_log_dev_level', type: 'integer', min: 0, max: 3, value: 0, description: 'Dev logging level (0 to 3) of every source file that does not set its own')
option('ms_rtc_logger_rtp', type: 'boolean', value: false, description: 'Prints a line with information for each processed RTP packet')
option('ms_rtc_logger_send_burst', type: 'boolean', value: false, description: 'Prints how many RTP packets each transport sends within a single iteration of the event loop')
option('ms_dump_rtp_payload_descriptor', type: 'boolean', value: false, description: 'RTC::RTP::Packet::Dump() method also dumps payload descriptor details')
Expand Down
3 changes: 3 additions & 0 deletions worker/src/Channel/ChannelSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <FBS/message.h>
#include <cstring> // std::memcpy(), std::memmove()
#include <exception>
#if MS_LOG_DEV_LEVEL == 3
#include <flatbuffers/minireflect.h> // flatbuffers::FlatBufferToString()
#endif

namespace Channel
{
Expand Down
8 changes: 4 additions & 4 deletions worker/src/RTC/ActiveSpeakerObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ namespace RTC

this->lastLevelChangeAtMs = nowMs;

int8_t b{ 0 };
uint8_t b{ 0 };

if (level < MinLevel)
{
Expand Down Expand Up @@ -582,7 +582,7 @@ namespace RTC
this->longActivityScore = computeActivityScore(this->longs[0], N3, 0.5, 47);
}

void ActiveSpeakerObserver::Speaker::UpdateMinLevel(int8_t level)
void ActiveSpeakerObserver::Speaker::UpdateMinLevel(uint8_t level)
{
MS_TRACE();

Expand All @@ -606,7 +606,7 @@ namespace RTC
}
else
{
this->nextMinLevel = std::min<int>(this->nextMinLevel, level);
this->nextMinLevel = std::min(this->nextMinLevel, level);

this->nextMinLevelWindowLen++;

Expand All @@ -623,7 +623,7 @@ namespace RTC
newMinLevel = MaxLevel;
}

this->minLevel = static_cast<int8_t>(newMinLevel);
this->minLevel = static_cast<uint8_t>(newMinLevel);
this->nextMinLevel = MinLevel;
this->nextMinLevelWindowLen = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace RTC
// Microseconds a single tick of those shifted timestamps is worth.
static constexpr double TimestampToUs{ 1000000.0 / static_cast<double>(1 << InterArrivalShift) };
// Fewest probes a run must hold to be taken as a burst.
static constexpr int MinClusterSize{ 4 };
static constexpr int64_t MinClusterSize{ 4 };
// Most probes kept while looking for a burst.
static constexpr size_t MaxProbePackets{ 15 };
// How many runs are enough to give up on the probes seen so far.
Expand Down Expand Up @@ -384,7 +384,7 @@ namespace RTC
{
MS_DEBUG_DEV(
"burst failed [sendBitrate:%" PRIi64 " bps, receiveBitrate:%" PRIi64
" bps, sendMean:%" PRIi64 " us, receiveMean:%" PRIi64 " us, numProbes:%d]",
" bps, sendMean:%" PRIi64 " us, receiveMean:%" PRIi64 " us, numProbes:%" PRIi64 "]",
cluster.GetSendBitrate(),
cluster.GetReceiveBitrate(),
cluster.sendMeanUs,
Expand Down Expand Up @@ -429,7 +429,7 @@ namespace RTC
{
MS_DEBUG_DEV(
"burst successful [sendBitrate:%" PRIi64 " bps, receiveBitrate:%" PRIi64
" bps, sendMean:%" PRIi64 " us, receiveMean:%" PRIi64 " us, numProbes:%d]",
" bps, sendMean:%" PRIi64 " us, receiveMean:%" PRIi64 " us, numProbes:%" PRIi64 "]",
best->GetSendBitrate(),
best->GetReceiveBitrate(),
best->sendMeanUs,
Expand Down
4 changes: 2 additions & 2 deletions worker/src/RTC/BWE/TrendlineEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace RTC
// Gain applied to the slope before comparing it against the threshold.
static constexpr double ThresholdGain{ 4.0 };
// Number of deltas at which the modified trend stops being scaled down.
static constexpr int MinNumDeltas{ 60 };
static constexpr uint64_t MinNumDeltas{ 60 };
// Maximum value of the delta counter.
static constexpr int DeltaCounterMax{ 1000 };
static constexpr uint64_t DeltaCounterMax{ 1000 };
// Time the trend must stay above the threshold before declaring overuse.
static constexpr double OverusingTimeThresholdMs{ 10 };
// Rates at which the threshold adapts upwards and downwards, per millisecond.
Expand Down
2 changes: 1 addition & 1 deletion worker/src/RTC/RTP/Packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ namespace RTC

MS_DEBUG_DEV(
"using %" PRIu8 " byte(s) extensions [highestId:%" PRIu8 ", highestLen:%" PRIu8 "]",
type,
static_cast<uint8_t>(type),
highestId,
highestLen);
}
Expand Down
2 changes: 1 addition & 1 deletion worker/src/RTC/SCTP/association/HeartbeatHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace RTC
{
/* Static. */

static constexpr int HeartbeatInfoLength{ 8 };
static constexpr uint16_t HeartbeatInfoLength{ 8 };

/* Instance methods. */

Expand Down
2 changes: 1 addition & 1 deletion worker/src/Utils/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace Utils
uint8_t tmp;
size_t i;
size_t count;
int pad{ 0 };
size_t pad{ 0 };

// NOTE: This is not really accurate but anyway.
if (len > BufferOutSize - 1)
Expand Down
Loading