0

I'd like to use PCM instead of ALAC to send audio to an AirPlay compatible. device. The device I'm using all have at least a cn=0 and an et=0 in their mDNS TXT capabilities, so I assume I can use raw PCM/L16 and unencrypted.

But the only doc I've found so far only mention ALAC in the ANNOUNCE RTSP message

ANNOUNCE rtsp://fe80::217:f2ff:fe0f:e0f6/3413821438 RTSP/1.0

CSeq: 3

Content-Type: application/sdp

Content-Length: 348

User-Agent: iTunes/10.6 (Macintosh; Intel Mac OS X 10.7.3) AppleWebKit/535.18.5

Client-Instance: 56B29BB6CB904862

v=0

o=iTunes 3413821438 0 IN IP4 fe80::217:f2ff:fe0f:e0f6

s=iTunes

c=IN IP4 fe80::5a55:caff:fe1a:e187

t=0 0

m=audio 0 RTP/AVP 96

a=rtpmap:96 AppleLossless

a=fmtp:96 352 0 16 40 10 14 2 255 0 0 44100

I cannot find what should be indicated for m= and the various a= (rtmap and fmtp) options when using PCM/L16. I know that the RTP packet type should be 0x0a, but that comes later. Changing the rtmap:96 to rtmap:10 does not work and I don't know what should be set anyway for fmtp

Thank you

philippe_44
  • 337
  • 3
  • 11

1 Answers1

0

You can send uncompressed PCM in ALAC packets

this is how JustePort do it

private static byte [] EncodeALAC( byte [] buffer )
{
    // Frame size is set as 4096 samples, stereo
    BitBuffer bitbuf = new BitBuffer( (4096 * 2 * 2) + 3 );

    bitbuf.WriteBits(1, 3);  // channels -- 0 mono, 1 stereo
    bitbuf.WriteBits(0, 4);  // unknown
    bitbuf.WriteBits(0, 12); // unknown
    bitbuf.WriteBits(0, 1);  // 'has size' flag
    bitbuf.WriteBits(0, 2);  // unknown
    bitbuf.WriteBits(1, 1);  // 'no compression' flag

    for( int i = 0; i < buffer.Length; i += 2 )
    {
        // endian swap 16 bit samples
        bitbuf.WriteBits(buffer[i+1], 8);
        bitbuf.WriteBits(buffer[i], 8);
    }

    return bitbuf.Buffer;
}
wiomoc
  • 1,069
  • 10
  • 17
  • Thank very much you for answering, This is what I'm using currently, but I was hopping, according to these guide https://nto.github.io/AirPlay.html and https://git.zx2c4.com/Airtunes2/about/ that I could send pcm frames without having to encapsulate them in ALAC and especially without the ugly bit-level manipulation required by the non-byte misalignment of ALAC that causes a lot of wasted CPU on more modest platforms – philippe_44 Jul 14 '16 at 03:49