AirPlay.Rtp (AirPlay v0.2.0)

Copy Markdown View Source

RAOP packet builders: audio (PT 0x60), control sync (0xd4), and timing response (0xd3). All multi-byte fields are big-endian.

Summary

Functions

An audio RTP packet: 80 [60|e0] seq ts ssrc <payload>. marker? sets the marker bit (0xe0) on the first packet of a stream.

A control sync packet (PT 0x54). rtp_now is the current RTP timestamp, latency the buffer in samples (RAOP default 88200 = 2 s), ntp the NTP time. first? sets the 0x90 lead byte on the first sync of a stream (else 0x80).

Parse the transmit (origin) NTP timestamp out of a timing request (PT 0x52).

A timing response (PT 0x53) to a received timing request. origin is the request's transmit timestamp; recv/xmit are our NTP receive/send times.

Functions

audio(seq, timestamp, ssrc, payload, marker? \\ false)

An audio RTP packet: 80 [60|e0] seq ts ssrc <payload>. marker? sets the marker bit (0xe0) on the first packet of a stream.

sync(rtp_now, latency, ntp, first? \\ false)

A control sync packet (PT 0x54). rtp_now is the current RTP timestamp, latency the buffer in samples (RAOP default 88200 = 2 s), ntp the NTP time. first? sets the 0x90 lead byte on the first sync of a stream (else 0x80).

timing_request_origin(arg1)

@spec timing_request_origin(binary()) :: {:ok, non_neg_integer()} | :error

Parse the transmit (origin) NTP timestamp out of a timing request (PT 0x52).

timing_response(origin, recv, xmit)

@spec timing_response(non_neg_integer(), non_neg_integer(), non_neg_integer()) ::
  binary()

A timing response (PT 0x53) to a received timing request. origin is the request's transmit timestamp; recv/xmit are our NTP receive/send times.