Simple test suite to verify playback and recording in memory mapped mode on the network loopback interface.

This can be used t odebug issue #17.
This commit is contained in:
Andrea Bondavalli 2021-01-19 20:38:30 +01:00
parent aa8c08d8a9
commit 21d598c8f7
5 changed files with 205 additions and 0 deletions

98
run_test.sh Executable file
View File

@ -0,0 +1,98 @@
#!/bin/bash
#
# Tested on Ubuntu 18.04
#
function cleanup {
#kill and wait for previous daemon instances to exit
sudo killall -q ptp4l
killall -q aes67-daemon
while killall -0 aes67-daemon 2>/dev/null ; do
sleep 1
done
}
if ! [ -x "$(command -v /usr/sbin/ptp4l)" ]; then
echo 'Error: ptp4l is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v arecord)" ]; then
echo 'Error: arecord is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v speaker-test)" ]; then
echo 'Error: speaker-test is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v ./daemon/aes67-daemon)" ]; then
echo 'Error: aes67-daemon is not compiled.' >&2
exit 1
fi
if ! [ -r "3rdparty/ravenna-alsa-lkm/driver/MergingRavennaALSA.ko" ]; then
echo 'Error: MergingRavennaALSA.ko module is not compiled.' >&2
exit 1
fi
trap cleanup EXIT
#configure system parms
sudo sysctl -w net/ipv4/igmp_max_memberships=66
if [ -x /usr/bin/pulseaudio ]; then
#stop pulseaudio, this seems to open/close ALSA continuosly
echo autospawn = no > $HOME/.config/pulse/client.conf
pulseaudio --kill >/dev/null 2>&1
rm $HOME/.config/pulse/client.conf
#disable pulseaudio
systemctl --user stop pulseaudio.socket > /dev/null 2>&1
systemctl --user stop pulseaudio.sservice > /dev/null 2>&1
fi
#install kernel module
sudo insmod 3rdparty/ravenna-alsa-lkm/driver/MergingRavennaALSA.ko
cleanup
if [ -f ./test/sink_test.wav ] ; then
rm -f sink_test.wav
fi
echo "Starting PTP master ..."
sudo /usr/sbin/ptp4l -i lo -l7 -E -S &
#echo "Starting AES67 daemon ..."
./daemon/aes67-daemon -c ./test/daemon.conf &
#open browser on configuration page
if [ -x "$(command -v xdg-open)" ]; then
xdg-open "http://127.0.0.1:8080/PTP"
fi
echo "Waiting for PTP slave to sync ..."
sleep 30
#starting recording on sink
echo "Starting to record 240 secs from sink ..."
arecord -M -d 240 -D plughw:RAVENNA -f S24_3LE -r 48000 -c 2 -t wav /tmp/sink_test.wav > /dev/null 2>&1 &
sleep 10
#starting playback on source
echo "Starting to playback test on source ..."
aplay -M -D plughw:RAVENNA ./test/test.wav > /dev/null 2>&1 &
while killall -0 arecord 2>/dev/null ; do
sleep 1
done
killall aplay
if [ -f /tmp/sink_test.wav ] ; then
mv /tmp/sink_test.wav test/
echo "Recording to file \"test/sink_test.wav\" successfull"
else
echo "Recording failed"
fi
echo "Terminating processes ..."

57
test/check.cc Normal file
View File

@ -0,0 +1,57 @@
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
fstream fl;
fl.open("./sink_test.wav", ios::in|ios::binary);
if (!fl.is_open()) {
cout << "cannot open file " << endl;
exit(1);
}
auto begin = fl.tellp();
fl.seekp(0, ios::end);
auto end = fl.tellp();
fl.seekp(68, ios::beg);
unsigned char ch = 0;
auto prev = fl.tellp();
while(fl.tellp() < end && ch == 0)
{
prev = fl.tellp();
ch = fl.get();
}
unsigned char curr = 0;
bool first = true;
fl.seekp(prev);
while(fl.tellp() < end)
{
if (!first) {
ch = fl.get();
if (ch != (uint8_t)curr) break;
}
ch = fl.get();
if (ch != (uint8_t)(curr+1)) break;
ch = fl.get();
if (ch != (uint8_t)(curr+2)) break;
ch = fl.get();
if (ch != (uint8_t)curr) break;
ch = fl.get();
if (ch != (uint8_t)(curr+1)) break;
ch = fl.get();
if (ch != (uint8_t)(curr+2)) break;
curr += 3;
first = false;
}
int rc = 0;
if (fl.tellp() != end)
{
cout << "error at position: " << fl.tellp() << endl;
rc = 1;
}
else cout << "ok" << endl;
fl.close();
return rc;
}

22
test/daemon.conf Normal file
View File

@ -0,0 +1,22 @@
{
"http_port": 8080,
"rtsp_port": 8854,
"http_base_dir": "./webui/build",
"log_severity": 3,
"playout_delay": 0,
"tic_frame_size_at_1fs": 192,
"max_tic_frame_size": 1024,
"sample_rate": 48000,
"rtp_mcast_base": "239.1.0.1",
"rtp_port": 5004,
"ptp_domain": 0,
"ptp_dscp": 48,
"sap_interval": 30,
"syslog_proto": "none",
"syslog_server": "255.255.255.254:1234",
"status_file": "./demo/status.json",
"mdns_enabled": false,
"interface_name": "lo",
"mac_addr": "01:00:5e:01:00:01",
"ip_addr": "127.0.0.1"
}

28
test/status.json Normal file
View File

@ -0,0 +1,28 @@
{
"sources": [
{
"id": 0,
"enabled": true,
"name": "ALSA Source 0",
"io": "Audio Device",
"max_samples_per_packet": 48,
"codec": "L24",
"ttl": 15,
"payload_type": 98,
"dscp": 34,
"refclk_ptp_traceable": false,
"map": [ 0, 1 ]
} ],
"sinks": [
{
"id": 0,
"name": "ALSA Sink 0",
"io": "Audio Device",
"use_sdp": true,
"source": "http://127.0.0.1:8080/api/source/sdp/0",
"sdp": "v=0\no=- 657664 657666 IN IP4 127.0.0.1\ns=AES67 daemon 000a0900 ALSA Source 0\nc=IN IP4 239.1.0.1/15\nt=0 0\na=clock-domain:PTPv2 0\nm=audio 5004 RTP/AVP 98\nc=IN IP4 239.1.0.1/15\na=rtpmap:98 L24/48000/2\na=sync-time:0\na=framecount:48\na=ptime:1\na=mediaclk:direct=0\na=ts-refclk:ptp=IEEE1588-2008:00-1D-C1-FF-FE-50-36-33:0\na=recvonly\n",
"delay": 576,
"ignore_refclk_gmid": true,
"map": [ 0, 1 ]
} ]
}

BIN
test/test.wav Normal file

Binary file not shown.