mediasoup

/ home / Documentation / v3 / libmediasoupclient / Installation

libmediasoupclient v3 Installation

Requirements

Build libwebrtc

libmediasoupclient makes use of libwebrtc. Follow the official instructions to build it and make sure the branch m74 is checked-out and compiled.

Future versions of libmediasoupclient will include a more recent version of libwebrtc. For now, m74 branch is required.

Build libmediasoupclient

Get the libmediasoupclient sources via git and check-out the branch v3:

$ git clone https://github.com/versatica/libmediasoupclient.git
$ cd libmediasoupclient/
$ git checkout v3

Within the libmediasoupclient/ folder:

$ cmake . -Bbuild \
  -DLIBWEBRTC_INCLUDE_PATH:PATH=PATH_TO_LIBWEBRTC_SOURCES \
  -DLIBWEBRTC_BINARY_PATH:PATH=PATH_TO_LIBWEBRTC_BINARY

$ make -C build/

Optionally install the library in the system:

$ make install -C build/

Depending on the host, it will generate the following static library and header files:

-- Installing: /usr/local/lib/libmediasoupclient.a
-- Up-to-date: /usr/local/include/mediasoupclient/mediasoupclient.hpp

Building Flags

Argument Type Description Required Default
LIBWEBRTC_INCLUDE_PATH Path Path to libwebrtc sources (the src folder). Yes  
LIBWEBRTC_BINARY_PATH Path Path to the libwebrtc static library. Yes  
MEDIASOUPCLIENT_LOG_DEV Bool Enable MSC_LOG_DEV C++ macro. See Logger. No false
MEDIASOUPCLIENT_LOG_TRACE Bool Enable MSC_LOG_TRACE C++ macro. See Logger. No false
CMAKE_CXX_FLAGS String C++ flags (see “Linkage Considerations” section below). No  

Linkage Considerations (1)

The application is responsible for defining the symbol visibility of the resulting binary. Symbol visibility mismatch among different libraries will generate plenty of linker warnings such us the one below:

ld: warning: direct access in function 'webrtc::I010Buffer::Rotate(webrtc::I010BufferInterface const&, webrtc::VideoRotation)'
from file '/home/foo/src/webrtc-checkout/src/out/mybuild-m74/obj/libwebrtc.a(i010_buffer.o)'
to global weak symbol 'void rtc::webrtc_checks_impl::LogStreamer<>::Call<>(char const*, int, char const*)::t'
from file '../libmediasoupclient.a(PeerConnection.cpp.o)' means the weak symbol cannot be overridden at runtime.
This was likely caused by different translation units being compiled with different visibility settings.

In order to avoid such warnings make sure the corresponding visibility compilation flags are provided. For example, if libwebrtc was built with hidden symbol visibility, libmediasoupclient needs to be provided with the correspoinding compilation flag:

cmake . -Bbuild \
  -DLIBWEBRTC_INCLUDE_PATH:PATH=PATH_TO_LIBWEBRTC_SOURCES \
  -DLIBWEBRTC_BINARY_PATH:PATH=PATH_TO_LIBWEBRTC_BINARY \
  -DCMAKE_CXX_FLAGS="-fvisibility=hidden"

Linkage Considerations (2)

Linkage errors may happen if libwebrtc and libmediasoupclient are not compiled with the same C++ standard library.

Build libwebrtc with the 'use_custom_libcxx=false' gn gen argument to force it use of the system libstdc++.

Build Example

Building libwebrtc and libmediasoupclient in OSX may look as follows:

$ cd /home/foo/src
$ mkdir webrtc-checkout
$ cd webrtc-checkout
$ fetch --nohooks webrtc
$ gclient sync
$ cd src
$ git checkout -b m74 refs/remotes/branch-heads/m74
$ gn gen out/mybuild-m74 --args='is_debug=false is_component_build=false is_clang=true rtc_include_tests=false rtc_use_h264=true rtc_enable_protobuf=false use_rtti=true mac_deployment_target="10.11" use_custom_libcxx=false'
$ ninja -C out/mybuild-m74
$ cd /home/foo/src/libmediasoupclient

$ cmake . -Bbuild \
  -DLIBWEBRTC_INCLUDE_PATH:PATH=/home/foo/src/webrtc-checkout/src \
  -DLIBWEBRTC_BINARY_PATH:PATH=/home/foo/src/webrtc-checkout/src/out/mybuild-m74/obj

$ make -C build/

Please, check the official instructions to build libwebrtc and do NOT take this example as a reference.

Usage

Once installed include the libmediasoupclient library into your C++ application:

#include "libmediasoupclient/mediasoupclient.hpp"

And add the libmediasoupclient static library to your C++ project.

The libmediasoupclient API is exposed under the mediasoupclient C++ namespace. The library also exposes the nlohmann::json C++ namespace.

The C++ application should also include the required libwebrtc headers.