Skip to content

bundasmanu/baresip-with-audio

Repository files navigation

Baresip-Audio-Support

Context

This project aims to enable and facilitate the use of baresip. Allowing it to be used via Docker Compose, it is already fully configured for use without any changes and provides audio support for the OSX environment.

Essentially, it provides the following:

  • Pre-defined and easily customizable new modules;
  • Audio support using the pulse module for OSX host environments;
  • Audio support for multiple devices, with a configurable script for this purpose;
  • config file already configured, no need to make any changes;
  • bind mounts created to facilitate on-demand changes, such as adding or removing audio;
  • Easy testing of new versions of baresip and new modules, using environment variables;

Enable Audio

Requirements

brew must be installed on the host machine, as it is used to install pulseaudio.

Host changes

The pulse module is used as an audio player and audio source. But on OSX, we don't have direct access to the devices, so we need to configure pulse in the host environment. The container then has the PULSE_SERVER pointing to the host.

To make the process easier, a script has been created for this purpose: configure-pulseaudio-osx.sh. This script is basically responsible for:

  • installing the pulseaudio lib, if it doesn't exist (via brew);
  • Validating which device you want to use as the sink (by default, tries to use: MacBook Pro Speakers);
  • Changes the default-sink to the one you want;
  • Changes the config: default.pa, to accept TCP connections, without requiring authentication;
  • Restart the pulseaudio service;

Execution

chmod 0777 configure-pulseaudio-osx.sh
./configure-pulseaudio-osx.sh

Set a different device - Enabling Device connected on Jack

pactl list sinks ### list the sinks available on host - select the device wanted from description Field
./configure-pulseaudio-osx.sh "External Headphones"

Hint: I recommend to use this approach, because you will get audio, even if a device is not connected to the jack.

Change HOST_PULSE_CONFIG_FOLDER Environment Variable

The container needs access to the pulse sinks, so there is a bind-mount to allow access between host <--> container. It is therefore necessary to identify on the host, where the .config/pulse folder is located, and change the HOST_PULSE_CONFIG_FOLDER (in .env file) accordingly.

For example, if the location on host is: /Users/myuser/.config/pulse, the mount should be: /Users/myuser/.config/pulse:/home/pulseaudio/.config/pulse. The destination in the container must not be changed, only the host source.

How use new Modules

To use new modules, the following is required to be changed:

  • Update MODULES_LIST environment variable in .env file, and add the new module;
  • Check .baresip/config file, and enable the module;
  • Finally, check if the new module, requires to install new libraries, and if yes, update Dockerfile;

.baresip folder

The local .baresip folder contains the basic baresip settings.

By default, the only file to change is : accounts. There are no pre-created accounts, so you need to enter new ones.

Build Image

docker compose build

Run baresip

docker compose run baresip-with-audio

Explore bash

docker compose run baresip-with-audio /bin/bash

Explore baresip commands and usage

baresip-wiki