|
Packit Service |
cd2a00 |
AVTP Audio Format (AAF) Plugin
|
|
Packit Service |
cd2a00 |
==============================
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Overview
|
|
Packit Service |
cd2a00 |
--------
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The AAF plugin is a PCM plugin that uses Audio Video Transport Protocol (AVTP)
|
|
Packit Service |
cd2a00 |
to transmit/receive audio samples through a Time-Sensitive Network (TSN)
|
|
Packit Service |
cd2a00 |
capable network. The plugin enables media applications to easily implement AVTP
|
|
Packit Service |
cd2a00 |
Talker and Listener functionalities.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
AVTP is designed to take advantage of generalized Precision Time Protocol
|
|
Packit Service |
cd2a00 |
(gPTP) and Forwarding and Queuing Enhancements for Time-Sensitive Streams
|
|
Packit Service |
cd2a00 |
(FQTSS). gPTP ensures AVTP talkers and listeners share the same time reference
|
|
Packit Service |
cd2a00 |
so the presentation time from AVTP can be used to inform when PCM samples
|
|
Packit Service |
cd2a00 |
should be presented to the application layer. FQTSS provides bandwidth
|
|
Packit Service |
cd2a00 |
reservation and traffic prioritization for the AVTP stream.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
gPTP functionality is provided by the Linuxptp project while FQTSS
|
|
Packit Service |
cd2a00 |
functionality is provided by Linux Traffic Control system since kernel version
|
|
Packit Service |
cd2a00 |
4.15.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
gPTP Setup
|
|
Packit Service |
cd2a00 |
----------
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The Linuxptp project provides the ptp4l daemon, which synchronizes the PTP
|
|
Packit Service |
cd2a00 |
clock from NIC, and the pmc tool which communicates with ptp4l to get/set
|
|
Packit Service |
cd2a00 |
some runtime settings. The project also provides the phc2sys daemon which
|
|
Packit Service |
cd2a00 |
synchronizes the PTP clock and system clock.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The AAF Plugin requires system clock is synchronized with PTP clock and TAI
|
|
Packit Service |
cd2a00 |
offset is properly set in the kernel. ptp4l and phc2sys can be set up in many
|
|
Packit Service |
cd2a00 |
different ways, below we provide an example that fullfils the plugin
|
|
Packit Service |
cd2a00 |
requirements. For further information check ptp4l(8) and phc2sys(8).
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
In the following instructions, replace $IFNAME by your PTP capable NIC
|
|
Packit Service |
cd2a00 |
interface. The gPTP.cfg file mentioned below can be found in /usr/share/
|
|
Packit Service |
cd2a00 |
doc/linuxptp/ (depending on your distro).
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Synchronize PTP clock with PTP time:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ ptp4l -f gPTP.cfg -i $IFNAME
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Enable TAI offset to be automatically set by phc2sys:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ pmc -u -t 1 -b 0 'SET GRANDMASTER_SETTINGS_NP \
|
|
Packit Service |
cd2a00 |
clockClass 248 clockAccuracy 0xfe \
|
|
Packit Service |
cd2a00 |
offsetScaledLogVariance 0xffff \
|
|
Packit Service |
cd2a00 |
currentUtcOffset 37 leap61 0 leap59 0 \
|
|
Packit Service |
cd2a00 |
currentUtcOffsetValid 1 pTimescale 1 \
|
|
Packit Service |
cd2a00 |
timeTraceable 1 frequencyTraceable 0 timeSource 0xa0'
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Synchronize system clock with PTP clock:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ phc2sys -f gPTP.cfg -s $IFNAME -c CLOCK_REALTIME -w
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The commands above should be run on both AVTP Talker and Listener hosts.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Traffic Control Setup
|
|
Packit Service |
cd2a00 |
---------------------
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The Linux Traffic Control system provides the mqprio and cbs qdiscs which
|
|
Packit Service |
cd2a00 |
enable FQTSS on Linux. Below we provide an example to configure those qdiscs in
|
|
Packit Service |
cd2a00 |
order to transmit an AAF stream with the following features: class A, 6 audio
|
|
Packit Service |
cd2a00 |
frames per AVTPDU, 48 kHz sampling rate, 16-bit sample size, stereo. For
|
|
Packit Service |
cd2a00 |
further information on how to configure these qdiscs check tc-mqprio(8) and
|
|
Packit Service |
cd2a00 |
tc-cbs(8) man pages.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
On the host that will run as AVTP Talker (i.e. plugin in playback mode), run
|
|
Packit Service |
cd2a00 |
the following commands:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Configure mpqrio qdisc (replace $MQPRIO_HANDLE_ID by an unused handle ID):
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ tc qdisc add dev $IFNAME parent root handle $MQPRIO_HANDLE_ID \
|
|
Packit Service |
cd2a00 |
mqprio num_tc 3 map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
|
|
Packit Service |
cd2a00 |
queues 1@0 1@1 2@2 hw 0
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Configure cbs qdisc (replace $CBS_HANDLE_ID by an unused handle ID):
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ tc qdisc replace dev $IFNAME parent $MQPRIO_HANDLE_ID:1 \
|
|
Packit Service |
cd2a00 |
handle $CBS_HANDLE_ID cbs idleslope 5760 \
|
|
Packit Service |
cd2a00 |
sendslope -994240 hicredit 9 locredit -89 offload 1
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The plugin implements a transmission mechanism that relies on ETF qdisc so make
|
|
Packit Service |
cd2a00 |
sure it is properly configured in the system. It could be configured many way,
|
|
Packit Service |
cd2a00 |
below follows an example.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ tc qdisc add dev $IFNAME parent $CBS_HANDLE_ID:1 etf \
|
|
Packit Service |
cd2a00 |
clockid CLOCK_TAI delta 500000 offload
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
No Traffic Control configuration is required at the host running as AVTP
|
|
Packit Service |
cd2a00 |
Listener.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Plugin Dependencies
|
|
Packit Service |
cd2a00 |
-------------------
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The AAF plugin uses libavtp to handle AVTP packetization. Libavtp source code
|
|
Packit Service |
cd2a00 |
can be found in https://github.com/AVnu/libavtp as well as instructions to
|
|
Packit Service |
cd2a00 |
build and install it.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The plugin also depends on some kernel API headers such as linux/if_ether.h so
|
|
Packit Service |
cd2a00 |
make sure you have them installed in your system.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
If libavtp or the kernel headers aren't detected by configure, the plugin isn't
|
|
Packit Service |
cd2a00 |
built.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Plugin Configuration
|
|
Packit Service |
cd2a00 |
--------------------
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The plugin parameters are passed via ALSA configuration file. They are defined
|
|
Packit Service |
cd2a00 |
as follows:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* ifname: Network interface used to transmit/receive AVTP packets.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* addr: Stream destination MAC address.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* prio: Priority used by the plugin to transmit AVTP traffic. This
|
|
Packit Service |
cd2a00 |
option is relevant only when operating in playback mode.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* streamid: Stream ID associated with the AAF stream transmitted or
|
|
Packit Service |
cd2a00 |
received by the plugin.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* mtt: Maximum Transit Time (in microseconds) as defined in AVTP spec
|
|
Packit Service |
cd2a00 |
section 4.3.3. This option is relevant only when operating in
|
|
Packit Service |
cd2a00 |
playback mode.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* time_uncertainty: Maximum Time Uncertainty (in microseconds) as
|
|
Packit Service |
cd2a00 |
defined by AVTP spec section 4.3.3. This option is relevant only when
|
|
Packit Service |
cd2a00 |
operating in playback mode.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* frames_per_pdu: Number of audio frames transmitted in one AVTPDU.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
* ptime_tolerance: Presentation time tolerance in microseconds.
|
|
Packit Service |
cd2a00 |
AVTPDUs with presentation time off by +- ptime_tolerance are not
|
|
Packit Service |
cd2a00 |
considered invalid. This option is relevant only when operating in
|
|
Packit Service |
cd2a00 |
capture mode.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Plugin Usage
|
|
Packit Service |
cd2a00 |
------------
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
The plugin provides the PCM type "aaf". Configure an AAF PCM virtual device
|
|
Packit Service |
cd2a00 |
according to the AAF stream you want to transmit or receive. A hypothetical
|
|
Packit Service |
cd2a00 |
configuration for the stream described in the 'FQTSS Setup' section is shown
|
|
Packit Service |
cd2a00 |
below:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
pcm.aaf0 {
|
|
Packit Service |
cd2a00 |
type aaf
|
|
Packit Service |
cd2a00 |
ifname eth0
|
|
Packit Service |
cd2a00 |
addr 01:AA:AA:AA:AA:AA
|
|
Packit Service |
cd2a00 |
prio 3
|
|
Packit Service |
cd2a00 |
streamid AA:BB:CC:DD:EE:FF:0000
|
|
Packit Service |
cd2a00 |
mtt 2000
|
|
Packit Service |
cd2a00 |
time_uncertainty 125
|
|
Packit Service |
cd2a00 |
frames_per_pdu 6
|
|
Packit Service |
cd2a00 |
ptime_tolerance 100
|
|
Packit Service |
cd2a00 |
}
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
Put the above to ~/.asoundrc (or /etc/asound.conf), and use the AAF PCM virtual
|
|
Packit Service |
cd2a00 |
device 'aaf0' with your favorite alsa-utils tool. Note that the plugin requires
|
|
Packit Service |
cd2a00 |
the period size is multiple of the 'frames_per_pdu' configuration.
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
For example, to stream the pink noise generated by 'speaker-test', run:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ speaker-test -F S16_BE -c 2 -r 48000 -D aaf0 -p 12500
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
To receive the AAF stream generated by the command above, run the following
|
|
Packit Service |
cd2a00 |
command in another host:
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
$ arecord -t raw -f S16_BE -c 2 -r 48000 -D aaf0 -vv /dev/null -F 12500
|
|
Packit Service |
cd2a00 |
|
|
Packit Service |
cd2a00 |
If you want to playback the contents of the AAF stream, change the command-line
|
|
Packit Service |
cd2a00 |
above so the output from 'arecord' is redirected to 'aplay', or simply use the
|
|
Packit Service |
cd2a00 |
'alsaloop' tool.
|