/aes67-linux-daemon

AES67 Linux Daemon with configuration WebUI

Primary LanguageC++GNU General Public License v3.0GPL-3.0

AES67 Linux Daemon

AES67 Linux Daemon is a Linux implementation of AES67 interoperability standard used to distribute and synchronize real time audio over Ethernet.
See https://en.wikipedia.org/wiki/AES67 for additional info.

Introduction

The daemon is a Linux process that uses the Merging Technologies ALSA RAVENNA/AES67 Driver to handle PTP synchronization and RTP streams and exposes a REST interface for configuration and status monitoring.

The ALSA AES67 Driver implements a virtual ALSA audio device that can be configured using Sources and Sinks and it's clocked using the PTP clock.
A Source reads audio samples from the ALSA playback device and sends RTP packets to a configured multicast address.
A Sink receives RTP packets from a specific multicast address and writes them to the ALSA capture device.

A user can use the ALSA capture device to receive synchronized incoming audio samples from an RTP stream and the ALSA playback device to send synchronized audio samples to an RTP stream.
The binding between a Source and the ALSA playback device is determined by the channels used during the playback and the configured Source channels map. The binding between a Sink and the ALSA capture device is determined by the channels used while recoding and the configured Sink channels map.

The driver handles the PTP and RTP packets processing and acts as a PTP clock slave to synchronize with a master clock on the specified PTP domain. All the configured Sources and Sinks are synchronized using the same PTP clock.

The daemon communicates with the driver for control, configuration and status monitoring only by using netlink sockets.
The daemon implements a REST interface to configure and monitor the Sources, the Sinks and PTP slave. See README for additional info. It also implements SAP sources discovery and advertisement compatible with AES67 standard and mDNS sources discovery and advertisement compatible with Ravenna standard.

A WebUI is provided to allow daemon and driver configuration and monitoring. The WebUI uses the daemon REST API and exposes all the supported configuration paramaters for the daemon, the PTP slave clock, the Sources and the Sinks. The WebUI can also be used to monitor the PTP slave status and the Sinks status and to browse the remote SAP and mDNS sources.

License

AES67 daemon and the WebUI are licensed under GNU GPL.

The daemon uses the following open source:

Repository content

daemon directory

This directory contains the AES67 daemon source code.
The daemon can be cross-compiled for multiple platforms and implements the following functionalities:

  • communication and configuration of the ALSA RAVENNA/AES67 device driver
  • control and configuration of up to 64 sources and sinks using the ALSA RAVENNA/AES67 driver via netlink
  • session handling and SDP parsing and creation
  • HTTP REST API for the daemon control and configuration
  • SAP sources discovery and advertisement compatible with AES67 standard
  • mDNS sources discovery and advertisement (using Linux Avahi) compatible with Ravenna standard
  • RTSP client and server to retrieve or return SDP files via DESCRIBE method compatible with Ravenna standard
  • IGMP handling for SAP, PTP and RTP sessions

The directory also contains the daemon regression tests in the tests subdirectory.
See the README file in this directory for additional information about the AES67 daemon configuration and the HTTP REST API.

webui directory

This directory contains the AES67 daemon WebUI configuration implemented using React.
With the WebUI a user can do the following operations:

  • change the daemon configuration, this causes a daemon restart
  • edit PTP clock slave configuration and monitor PTP slave status
  • add and edit RTP Sources
  • add, edit and monitor RTP Sinks
  • browser remote SAP and mDNS RTP sources

3rdparty directory

This directory is used to download the 3rdparty open source. The patches subdirectory contains patches applied to the ALSA RAVENNA/AES67 module to compile with the Linux Kernel 5.x and on ARMv7 platforms and to enable operations on the network loopback device (for testing purposes).

The ALSA RAVENNA/AES67 kernel module is responsible for:

  • registering as an ALSA driver
  • generating and receiving RTP audio packets
  • PTP slave operations and PTP driven interrupt loop
  • netlink communication between user and kernel

See ALSA RAVENNA/AES67 Driver README for additional information about the Merging Technologies module and for proper Linux Kernel configuration and tuning.

demo directory

This directory contains a the daemon configuration and status files used to run a short demo on the network loopback device. The demo is described below.

Prerequisite

The daemon and the demo have been tested with Ubuntu 18.04 distro on ARMv7 and with Ubuntu 18.04, 19.10 and 20.04 distros on x86 using:

  • Linux kernel version >= 4.14.x
  • GCC version >= 7.4 / clang >= 6.0.0 (C++17 support required)
  • cmake version >= 3.10.2
  • node version >= 8.10.0
  • npm version >= 3.5.2
  • boost libraries version >= 1.65.1
  • Avahi service discovery (if enabled) >= 0.7

The BeagleBone® Black board with ARM Cortex-A8 32-Bit processor was used for testing on ARMv7. See Ubuntu 18.04 on BeagleBone® Black for additional information about how to setup Ubuntu on this board.

The ubuntu-packages.sh script can be used to install all the packages required to compile and run the AES67 daemon, the daemon tests and the demo.
Important PulseAudio must be disabled or uninstalled for the daemon to work properly, see PulseAudio and scripts notes.

How to build

Make sure you have all the required packages installed, see prerequisite.
To compile the AES67 daemon and the WebUI you can use the build.sh script, see script notes.
The script performs the following operations:

  • checkout, patch and build the Merging Technologies ALSA RAVENNA/AES67 module
  • checkout the cpp-httplib
  • build and deploy the WebUI
  • build the AES67 daemon

Run the regression tests

To run daemon regression tests install the ALSA RAVENNA/AES67 kernel module with:

  sudo insmod 3rdparty/ravenna-alsa-lkm/driver/MergingRavennaALSA.ko

setup the kernel parameters with:

  sudo sysctl -w net/ipv4/igmp_max_memberships=66

make sure that no instances of the aes67-daemon are running, enter the tests subdirectory and run:

  ./daemon-test

Run the demo

To run a simple demo use the run_demo.sh script. See script notes. The demo configures and uses a loopback of 8 channels with AM824 codec (S32 format) at 48Khz and saves the output to a wav file.

The demo performs the following operations:

  • setup system parameters
  • stop PulseAudio (if installed). This uses and keeps busy the ALSA playback and capture devices causing instability problems. See PulseAudio.
  • install the ALSA RAVENNA/AES67 module
  • start the ptp4l as master clock on the network loopback device
  • start the AES67 daemon and creates a source and a sink according to the status file in the demo directory
  • open a browser on the daemon PTP status page
  • wait for the Ravenna driver PTP slave to synchronize
  • start recording on the configured ALSA sink for 60 seconds to the wave file in ./demo/sink_test.wav
  • start playing a test sound on the configured ALSA source
  • wait for the recording to complete and terminate ptp4l and the AES67 daemon

Interoperability tests

To run interoperability tests using the Hasseb audio over Ethernet receiver follow these steps:

  • open the daemon configuration file daemon.conf and change the following parameters:

    • set network interface name to your Ethernet card, e.g.: "interface_name": "eth0"
    • set default sample rate to 48Khz: "sample_rate": 48000
  • verify that PulseAdio is not running. See PulseAudio.

  • install the ALSA RAVENNA/AES67 module with:

    sudo insmod 3rdparty/ravenna-alsa-lkm/driver/MergingRavennaALSA.ko
    
  • run the daemon using the new configuration file:

    aes67-daemon -c daemon.conf
    
  • open the Daemon WebUi http://[address:8080] and do the following:

    • go to Config tab and verify that the sample rate is set to 48KHz
    • go to Sources tab and add a new Source using the plus button, set Codec to L24 and press the Submit button
    • go to Sources tab and click on the info icon on the right of the newly created source and copy the SDP file
  • open the Hasseb WebUI and do the following:

    • deselect the "PTP slave only" checkbox to enable PTP master on Hasseb device
    • select the "Add SDP file manually" checkbox and copy the previous Source SDP into the SDP field
    • alternatively to the step above, select in the "Stream name" drop down the daemon Source just added
    • press the Submit button
  • return to the daemon WebUI, click on the PTP tab and wait for the "PTP Status" to report "locked"

  • open a shell on the Linux host and start the playback on the ravenna ALSA device. For example to playback a test sound use:

        speaker-test -D plughw:RAVENNA -r 48000 -c 2 -t sine
    

Notes

  • All the scripts in this repository are provided as a reference to help setting up the system and run a simple demo.
    They have been tested on Ubuntu 18.04 19.10 20.04 distros.

  • PulseAudio can create instability problems.
    Before running the daemon verify that PulseAudio is not running with:

    ps ax | grep pulseaudio
    

    In case it's running try to execute the following script to stop it:

    daemon/scripts/disable_pulseaudio.sh
    

    If after this the process is still alive considering one of these two solutions and reboot the system afterwards:

    • Uninstall it completely with:

      sudo apt-get remove pulseaudio
      
    • Disable it by renaming the executable with:

       sudo mv /usr/bin/pulseaudio /usr/bin/_pulseaudio
      

    Other methods to disable PulseAudio may fail and just killing it is not enough since it gets immediately re-spawned.