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
30 changes: 25 additions & 5 deletions .github/workflows/mediasoup-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- os: ubuntu-22.04
cc: gcc
cxx: g++
build-type: Release
run-lint: false
run-test: true
run-test-asan-address: false
Expand All @@ -30,6 +31,7 @@ jobs:
- os: ubuntu-22.04
cc: clang
cxx: clang++
build-type: Release
run-lint: false
run-test: true
run-test-asan-address: false
Expand All @@ -38,6 +40,7 @@ jobs:
- os: ubuntu-22.04-arm
cc: gcc
cxx: g++
build-type: Release
# No clang-format for ARM.
run-lint: false
run-test: true
Expand All @@ -47,17 +50,31 @@ jobs:
- os: ubuntu-24.04
cc: gcc
cxx: g++
build-type: Release
pip-break-system-packages: true
run-lint: false
run-test: true
run-test-asan-address: false
run-test-asan-undefined: false
run-test-asan-thread: false
# Let's just compile with all Meson option flags enabled once with gcc.
# Compile with all Meson option flags enabled once with gcc in Release mode.
meson_args: '-Dms_log_trace=true -Dms_log_file_line=true -Dms_rtc_logger_rtp=true -Dms_disable_liburing=true -Dms_sctp_stack=true'
- os: ubuntu-24.04
cc: gcc
cxx: g++
build-type: Debug
pip-break-system-packages: true
run-lint: false
run-test: true
run-test-asan-address: false
run-test-asan-undefined: false
run-test-asan-thread: false
# 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_disable_liburing=true -Dms_sctp_stack=true'
- os: ubuntu-24.04
cc: clang
cxx: clang++
build-type: Release
pip-break-system-packages: true
run-lint: false
run-test: true
Expand All @@ -69,6 +86,7 @@ jobs:
- os: ubuntu-24.04-arm
cc: gcc
cxx: g++
build-type: Release
pip-break-system-packages: true
# No clang-format for ARM.
run-lint: false
Expand All @@ -79,6 +97,7 @@ jobs:
- os: ubuntu-24.04-arm
cc: clang
cxx: clang++
build-type: Release
pip-break-system-packages: true
# No clang-format for ARM.
run-lint: false
Expand All @@ -89,6 +108,7 @@ jobs:
- os: macos-14
cc: clang
cxx: clang++
build-type: Release
pip-break-system-packages: true
run-lint: false
run-test: true
Expand All @@ -98,6 +118,7 @@ jobs:
- os: macos-15
cc: clang
cxx: clang++
build-type: Release
pip-break-system-packages: true
# Run lint for the latest macos.
run-lint: true
Expand All @@ -108,6 +129,7 @@ jobs:
- os: windows-2022
cc: cl
cxx: cl
build-type: Release
# No clang-format for Windows.
run-lint: false
# Maybe some day we fix this.
Expand All @@ -119,6 +141,7 @@ jobs:
- os: windows-2025
cc: cl
cxx: cl
build-type: Release
# No clang-format for Windows.
run-lint: false
# Maybe some day we fix this.
Expand All @@ -130,9 +153,6 @@ jobs:
# A single Node.js version should be fine for C++.
node:
- 24
build-type:
- Release
- Debug

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

Expand All @@ -141,7 +161,7 @@ jobs:
CXX: ${{ matrix.build.cxx }}
MEDIASOUP_SKIP_WORKER_PREBUILT_DOWNLOAD: 'true'
MEDIASOUP_LOCAL_DEV: 'false'
MEDIASOUP_BUILDTYPE: ${{ matrix.build-type }}
MEDIASOUP_BUILDTYPE: ${{ matrix.build.build-type }}
MESON_ARGS: ${{ matrix.build.meson_args }}

steps:
Expand Down
1 change: 1 addition & 0 deletions worker/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Checks: "*,\
-cppcoreguidelines-pro-type-vararg,\
-cppcoreguidelines-special-member-functions,\
-hicpp-exception-baseclass,\
-hicpp-no-malloc,\
-fuchsia-default-arguments-calls,\
-fuchsia-default-arguments-declarations,\
-fuchsia-overloaded-operator,\
Expand Down
9 changes: 7 additions & 2 deletions worker/include/RTC/Codecs/DependencyDescriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ namespace RTC
static std::unordered_map<DecodeTargetIndication, std::string> dtiToString;

private:
struct FameDependencyTemplate
struct FrameDependencyTemplate
{
FrameDependencyTemplate(uint32_t spatialLayer, uint32_t temporalLayer)
: spatialLayer(spatialLayer), temporalLayer(temporalLayer)
{
}

uint32_t spatialLayer;
uint32_t temporalLayer;
std::vector<DecodeTargetIndication> decodeTargetIndications;
Expand All @@ -47,7 +52,7 @@ namespace RTC
uint32_t temporalLayers{ 0 };
uint8_t templateIdOffset{ 0 };
uint8_t decodeTargetCount{ 0 };
std::vector<FameDependencyTemplate> templateLayers;
std::vector<FrameDependencyTemplate> templateLayers;
};

public:
Expand Down
3 changes: 1 addition & 2 deletions worker/src/RTC/Codecs/DependencyDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ namespace RTC

do
{
this->templateDependencyStructure->templateLayers.emplace_back(
FameDependencyTemplate{ spatialId, temporalId });
this->templateDependencyStructure->templateLayers.emplace_back(spatialId, temporalId);

if (this->bitStream.GetLeftBits() < 2)
{
Expand Down
5 changes: 5 additions & 0 deletions worker/src/RTC/Codecs/VP8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ namespace RTC
{
MS_TRACE();

if (data == nullptr)
{
MS_ABORT("data is nullptr");
}

// Nothing to do.
if (!this->extended)
{
Expand Down
1 change: 1 addition & 0 deletions worker/src/RTC/DtlsTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cstring> // std::memcpy(), std::strcmp()

// clang-format off
// NOLINTNEXTLINE (cppcoreguidelines-macro-usage)
#define LOG_OPENSSL_ERROR(desc) \
do \
{ \
Expand Down
1 change: 1 addition & 0 deletions worker/src/RTC/PipeTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ namespace RTC
MS_THROW_TYPE_ERROR("missing port");
}

// NOLINTNEXTLINE (bugprone-unchecked-optional-access)
port = body->port().value();

int err;
Expand Down
8 changes: 6 additions & 2 deletions worker/src/RTC/PlainTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ namespace RTC

if (options->enableSrtp())
{
if (!options->srtpCryptoSuite().has_value())
auto srtpCryptoSuite = options->srtpCryptoSuite();

if (!srtpCryptoSuite.has_value())
{
MS_THROW_TYPE_ERROR("missing srtpCryptoSuite");
}

// NOTE: The SRTP crypto suite may change later on connect().
this->srtpCryptoSuite = SrtpSession::CryptoSuiteFromFbs(options->srtpCryptoSuite().value());
this->srtpCryptoSuite = SrtpSession::CryptoSuiteFromFbs(srtpCryptoSuite.value());

switch (this->srtpCryptoSuite)
{
Expand Down Expand Up @@ -592,6 +594,7 @@ namespace RTC
MS_THROW_TYPE_ERROR("missing port");
}

// NOLINTNEXTLINE (bugprone-unchecked-optional-access)
port = body->port().value();

if (body->rtcpPort().has_value())
Expand All @@ -601,6 +604,7 @@ namespace RTC
MS_THROW_TYPE_ERROR("cannot set rtcpPort with rtcpMux enabled");
}

// NOLINTNEXTLINE (bugprone-unchecked-optional-access)
rtcpPort = body->rtcpPort().value();
}
else
Expand Down
5 changes: 2 additions & 3 deletions worker/src/RTC/Producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ namespace RTC

auto& encodingMapping = this->rtpMapping.encodings.back();

// ssrc is optional.
if (encoding->ssrc().has_value())
if (auto ssrc = encoding->ssrc(); ssrc.has_value())
{
encodingMapping.ssrc = encoding->ssrc().value();
encodingMapping.ssrc = ssrc.value();
}

// rid is optional.
Expand Down
2 changes: 1 addition & 1 deletion worker/src/RTC/RTCP/CompoundPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace RTC

if (this->xrPacket.Begin() != this->xrPacket.End())
{
offset += this->xrPacket.Serialize(this->header + offset);
this->xrPacket.Serialize(this->header + offset);
}
}

Expand Down
4 changes: 2 additions & 2 deletions worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ namespace RTC
this->clockRate = data->clockRate();

// channels is optional.
if (data->channels().has_value())
if (auto channels = data->channels(); channels.has_value())
{
this->channels = data->channels().value();
this->channels = channels.value();
}

// parameters is optional.
Expand Down
14 changes: 7 additions & 7 deletions worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace RTC
MS_TRACE();

// ssrc is optional.
if (data->ssrc().has_value())
if (auto ssrc = data->ssrc(); ssrc.has_value())
{
this->ssrc = data->ssrc().value();
this->ssrc = ssrc.value();
}

// rid is optional.
Expand All @@ -28,9 +28,9 @@ namespace RTC
}

// codecPayloadType is optional.
if (data->codecPayloadType().has_value())
if (auto codecPayloadType = data->codecPayloadType(); codecPayloadType.has_value())
{
this->codecPayloadType = data->codecPayloadType().value();
this->codecPayloadType = codecPayloadType.value();
this->hasCodecPayloadType = true;
}

Expand All @@ -42,9 +42,9 @@ namespace RTC
}

// maxBitrate is optional.
if (data->maxBitrate().has_value())
if (auto maxBitrate = data->maxBitrate(); maxBitrate.has_value())
{
this->maxBitrate = data->maxBitrate().value();
this->maxBitrate = maxBitrate.value();
}

// dtx is optional, default is false.
Expand Down Expand Up @@ -89,7 +89,7 @@ namespace RTC
return FBS::RtpParameters::CreateRtpEncodingParametersDirect(
builder,
this->ssrc != 0u ? flatbuffers::Optional<uint32_t>(this->ssrc) : flatbuffers::nullopt,
this->rid.size() > 0 ? this->rid.c_str() : nullptr,
!this->rid.empty() ? this->rid.c_str() : nullptr,
this->hasCodecPayloadType ? flatbuffers::Optional<uint8_t>(this->codecPayloadType)
: flatbuffers::nullopt,
this->hasRtx ? this->rtx.FillBuffer(builder) : 0u,
Expand Down
12 changes: 6 additions & 6 deletions worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ namespace RTC
// ordered is optional.
bool orderedGiven = false;

if (data->ordered().has_value())
if (auto ordered = data->ordered(); ordered.has_value())
{
orderedGiven = true;
this->ordered = data->ordered().value();
this->ordered = ordered.value();
}

// maxPacketLifeTime is optional.
if (data->maxPacketLifeTime().has_value())
if (auto maxPacketLifeTime = data->maxPacketLifeTime(); maxPacketLifeTime.has_value())
{
this->maxPacketLifeTime = data->maxPacketLifeTime().value();
this->maxPacketLifeTime = maxPacketLifeTime.value();
}

// maxRetransmits is optional.
if (data->maxRetransmits().has_value())
if (auto maxRetransmits = data->maxRetransmits(); maxRetransmits.has_value())
{
this->maxRetransmits = data->maxRetransmits().value();
this->maxRetransmits = maxRetransmits.value();
}

if (this->maxPacketLifeTime && this->maxRetransmits)
Expand Down
13 changes: 8 additions & 5 deletions worker/src/RTC/SimulcastConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ namespace RTC
this->preferredLayers.spatial = static_cast<int16_t>(encoding.spatialLayers - 1);
}

if (preferredLayers->temporalLayer().has_value())
if (auto preferredTemporalLayer = preferredLayers->temporalLayer();
preferredTemporalLayer.has_value())
{
this->preferredLayers.temporal = preferredLayers->temporalLayer().value();
this->preferredLayers.temporal = preferredTemporalLayer.value();

if (this->preferredLayers.temporal > encoding.temporalLayers - 1)
{
Expand Down Expand Up @@ -255,9 +256,11 @@ namespace RTC
}

// preferredTemporaLayer is optional.
if (preferredLayers->temporalLayer().has_value())
auto preferredTemporalLayer = preferredLayers->temporalLayer();

if (preferredTemporalLayer.has_value())
{
this->preferredLayers.temporal = preferredLayers->temporalLayer().value();
this->preferredLayers.temporal = preferredTemporalLayer.value();

if (this->preferredLayers.temporal > this->rtpStream->GetTemporalLayers() - 1)
{
Expand All @@ -277,7 +280,7 @@ namespace RTC
this->preferredLayers.temporal,
this->id.c_str());

const flatbuffers::Optional<int16_t> preferredTemporalLayer{ this->preferredLayers.temporal };
preferredTemporalLayer = this->preferredLayers.temporal;
auto preferredLayersOffset = FBS::Consumer::CreateConsumerLayers(
request->GetBufferBuilder(), this->preferredLayers.spatial, preferredTemporalLayer);
auto responseOffset = FBS::Consumer::CreateSetPreferredLayersResponse(
Expand Down
8 changes: 5 additions & 3 deletions worker/src/RTC/SvcConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ namespace RTC
}

// preferredTemporaLayer is optional.
if (preferredLayers->temporalLayer().has_value())
auto preferredTemporalLayer = preferredLayers->temporalLayer();

if (preferredTemporalLayer.has_value())
{
this->preferredLayers.temporal = preferredLayers->temporalLayer().value();
this->preferredLayers.temporal = preferredTemporalLayer.value();

if (this->preferredLayers.temporal > this->rtpStream->GetTemporalLayers() - 1)
{
Expand All @@ -254,7 +256,7 @@ namespace RTC
this->preferredLayers.temporal,
this->id.c_str());

const flatbuffers::Optional<int16_t> preferredTemporalLayer{ this->preferredLayers.temporal };
preferredTemporalLayer = this->preferredLayers.temporal;
auto preferredLayersOffset = FBS::Consumer::CreateConsumerLayers(
request->GetBufferBuilder(), this->preferredLayers.spatial, preferredTemporalLayer);
auto responseOffset = FBS::Consumer::CreateSetPreferredLayersResponse(
Expand Down
Loading
Loading