Files
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

5.2 KiB

Building

This document is intended for mediasoup developers.

Makefile

The worker folder contains a Makefile to build the mediasoup worker subproject.

make

The default task runs the Release task unless the environment MEDIASOUP_BUILDTYPE is set to Debug (if so it runs the Debug task).

make Release

Builds the production ready mediasoup worker binary at worker/out/Release/. This is the binary used in production when installing the mediasoup NPM module with npm install mediasoup.

make Debug

Builds a more verbose and non optimized mediasoup worker binary at worker/out/Debug/ with some C flags enabled (such as -O0) and some macros defined (such as DEBUG, MS_LOG_TRACE and MS_LOG_FILE_LINE).

Check the meaning of these macros in the Logger.hpp header file.

In order to instruct the mediasoup Node.js module to use the Debug mediasoup worker binary, an environment variable must be set before running the Node.js application:

$ MEDIASOUP_BUILDTYPE=Debug node myapp.js

make test

Runs the test-Release task unless the environment MEDIASOUP_BUILDTYPE is set to Debug (if so it runs the test-Debug task).

make test-Release

Builds the mediasoup-worker-test test unit binary at worker/out/Release/.

make test-Debug

Builds the mediasoup-worker-test test unit binary in Debug mode at worker/out/Debug/.

fuzzer

Builds the mediasoup-worker-fuzzer target (which uses libFuzzer) and generates the worker/out/Release/mediasoup-worker-fuzzer binary.

  • Linux is required with fuzzer capable clang++.
  • CC environment variable must point to clang.
  • CXX environment variable must point to clang++.

Read the Fuzzer documentation to run the fuzzer binary.

fuzzer-docker-build

Builds a Linux image with fuzzer capable clang++.

NOTE: Before running this command, a specific version of Linux clang must be downloaded. To get it, run:

$ cd worker
$ ./scripts/get-dep.sh clang-fuzzer

fuzzer-docker-run

Runs a container of the Docker image created with fuzzer-docker-build. It automatically executes a bash session in the /mediasoup/worker directory, which is a Docker volume that points to the real mediasoup/worker directory (so we can do make fuzzer, etc).

make xcode

Builds a Xcode project for the mediasoup worker subproject.

make clean

Cleans objects and binaries related to the mediasoup worker.

make clean-all

Cleans all the objects and binaries, including those generated for library dependencies (such as libuv, openssl and libsrtp).

gulpfile.js

mediasoup comes with a gulpfile.js file to enable gulp tasks.

In order to tun these tasks, gulp-cli (version >= 1.2.2) must be globally installed:

$ npm install -g gulp-cli

gulp

The default task runs the gulp:lint and gulp:test tasks.

gulp lint

Runs both the lint:node and lint:worker gulp tasks.

gulp lint:node

Validates the Node.js JavaScript code/syntax.

gulp lint:worker

Validates the worker C++ code/syntax using clang-format following worker/.clang-format rules.

gulp format

Runs the format:worker gulp task.

gulp format:worker

Rewrites worker source and include files using clang-format.

gulp tidy

Runs the tidy:worker gulp task.

gulp tidy:worker

Performs C++ code check using clang-tidy following following worker/.clang-tidy rules.

clang-tidy uses a JSON compilation database to get the information on how a single compilation unit is processed.

In order to generate this file we use Bear. This works on linux only.

Once installed, compile mediasoup as follows:

$ bear make

An output file compile_commands.json is generated which must be copied to the worker directory after making the following changes:

Replace the references of the current directory by the keywork 'PATH':

$  sed -i "s|$PWD|PATH|g" compile_commands.json

Edit the file and remove the entry related to Utils/IP.cpp compilation unit, which is automatically created and does not follow the clang-tidy rules.

NOTE: It just works on Linux and OSX.

gulp test

Runs both the test:node and test:worker gulp tasks.

gulp test:node

Runs the Node.js test units. Before it, it invokes the make command.

In order to run the JavaScript test units with the mediasoup worker in Debug mode the MEDIASOUP_BUILDTYPE environment variable must be set to Debug:

$ MEDIASOUP_BUILDTYPE=Debug gulp test:node

gulp test:worker

Runs the mediasoup worker test units. Before it, it invokes the make test command.

In order to run the worker test units with the mediasoup worker in Debug mode the MEDIASOUP_BUILDTYPE environment variable must be set to Debug:

$ MEDIASOUP_BUILDTYPE=Debug gulp test:worker