Skip to the content.

Mafalda

Massively scalable Mediasoup-based SFU

Mafalda is a wrapper on top of Mediasoup SFU focused on provide an easier API by managing itself all the performance and scalability issues by default, including multi-machine clustering.

Name of the project has been taken as a tribute to Mafalda, the character created by Joaquín Salvador Lavado Tejón ‘Quino’, that has a love-hate relationship with both mass media and soup ;-)

It’s designed having in mind high scale one-to-many WebRTC-based videoconferences, but it’s possible to use it with any kind of WebRTC-based application including many-to-many videocalls, specially when they are designed as many one-to-many ones.

Features

Installation

npm install --save mafalda*.tgz

Mafalda is a wrapper on top of Mediasoup, so you need to install a Mediasoup API compatible module and provide it to Mafalda, but you should not use both Mafalda and Mediasoup at the same time, since that could by-pass the Mediasoup Workers and Routers management that Mafalda does internally (in addition to some security checks and meassurements), making Mafalda itself mostly useless. Mafalda already exports all the Mediasoup object collections and functions that you may need, if any.

API

API it’s influced by Mediasoup one, so it’s easy to migrate your project to use Mafalda instead.

Common API

By design, multiple methods and properties are exported by both mafalda module and by Mafalda and MafaldaRouter instances, with the same signature and functionality, just only focused on their own usage scope (mafalda module about global info and objects, and Mafalda and MafaldaRouter instances only about the objects created and managed by them). This is done this way to make it easier to work with Mafalda, specially when fetching statistics.

Global Mafalda API

Mafalda package exports a set of named exports that operate globally on all the objects created by the Mafalda instances, and that have there their equivalent ones for each particular instance:

Mafalda package API

In addition to the Global Mafalda API, Mafalda package also exports a constructor to create a new Mafalda instance, with a single mediasoup argument to set the Mediasoup API compatible module to be used. It also exports the next names exports:

Mafalda API

In addition to the Global Mafalda API, Mafalda class exposes the following API:

MafaldaRouter API

MafaldaRouter is the class that manage the Mediasoup Router instances. It provides an API that is similar to the Mediasoup Routers one, but internally manage the creation of Mediasoup Worker and Router instances, allowing to transparently by-pass the limit of the number of Consumers that can be used in a single CPU. They can only be created by using the mafalda.createMafaldaRouter() function.

In addition to the Mafalda Common API, MafaldaRouter objects has the following properties and methods:

Additionally, it emit the next events: