mikebrady / shairport-sync-metadata-reader

Sample Shairport Sync Metadata Player
MIT License
126 stars 33 forks source link

shairport-sync-metadata-reader

Sample Shairport Sync Metadata Player

This sample program reads the pipe of metadata optionally generated by Shairport Sync 2.4 and later. Shairport Sync is an AirTunes emulator with audio synchronization and multi-room capability -- https://github.com/mikebrady/shairport-sync. To use shairport-sync-metadata-reader, read the pipe via standard input, e.g.

shairport-sync-metadata-reader < /tmp/shairport-sync-metadata

or

shairport-sync-metadata-reader --raw < /tmp/shairport-sync-metadata

You'll get an output like this:

"ssnc" "pfls": "".
"ssnc" "mdst": "".
Album Name: "Pergolesi: Stabat mater".
Artist: "Andreas Scholl, Barbara Bonney, Christophe Rousset & Les Talens Lyriques".
Comment: "".
Composer: "Giovanni Battista Pergolesi".
Genre: "Classical".
File kind: "Purchased AAC audio file".
Title: "Stabat Mater: I. Stabat mater".
Sort as: "Stabat Mater: I. Stabat mater".
"ssnc" "mden": "".
"ssnc" "sndr": "iTunes/12.1 (Macintosh; OS X 10.10.2)".
Picture received, length 39461 bytes.
"ssnc" "prgr": "2373925818/2373941178/2385081354".
"ssnc" "prsm": "".

With the --raw option, you'll just get the raw metadata items.

Metadata is not used directly by Shairport Sync. Instead, it is routed to a pipe for other apps to use. All metadata received from the player is sent into the pipe in the order it is received. In addition, some metadata is generated by Shairport Sync itself and sent through the pipe. Metadata is sent in a uniform XML-style format, where each item comprises a type, a code, the length of the data and finally the base64-encoded data, if any. The type and code are 4-character codes each encoded as 8 hexadecimal digits -- they can be read into C as 32-bit integers.

In some cases, an "RTP timestamp" is included as a piece of data. This is a 32-bit unsigned integer that can wrap around from its maximum value of 2^32-1 to zero and upwards. It appears to be the index number of an audio frame, with 44,100 frames to the second.

Here are more details:

Here are the 'ssnc' codes defined so far:

The next two two tokens are to facilitiate remote control of the source. There is some information at http://nto.github.io/AirPlay.html about remote control of the source.

Building Instructions

$autoreconf -i -f
$./configure
$make
$sudo make install