You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to decode alac from a buffer? I have looked at AV carefully, but I only found the way using AV.Asset.fromBuffer(buffer). However, I did not figure out how to define the format to be alac.
Ah, ok. There isn't an easy built-in way to work with raw audio outside a container, but you can write your own "demuxer" for it. Here's an example (untested):
varRawALACDemuxer=AV.Demuxer.extend(function(){AV.Demuxer.register(this);this.probe=function(stream){// if you have some way of detecting your alac stream, use it here.// this assumes it is always ALAC.returntrue;};this.prototype.readChunk=function(){if(!this.emittedFormat){// I *think* airplay always uses 16-bit, 2 channel, 44.1kHz// but I'm not sure.this.emit('format',{formatID: 'alac',sampleRate: 44100,channelsPerFrame: 2,bitsPerChannel: 16});this.emittedFormat=true;}// TODO: figure out where to get the magic cookie from...if(!this.emittedCookie){this.emit('cookie',DATA_HERE);this.emittedCookie=true;}varbuffer=this.stream.readSingleBuffer(this.stream.remainingBytes());this.emit('data',buffer);};});
As mentioned in the comment, ALAC also has a "magic cookie", with some additional information needed by the decoder. This information would normally live in the container, but since you don't have a container, I'm not sure where it should be. My guess is that it would be sent when you initially connect to an airplay stream, but I'm not exactly sure where/how. You'll have to figure that out and emit an AV.Buffer containing the cookie data.
From this Go implementation of airplay, it looks like the data is in the RTSP ANNOUNCE packet, and is then converted to an ALACSpecificConfig struct. Not sure how that fits into your backend.
Activity
devongovett commentedon Apr 23, 2015
Aurora.js will automatically detect that it is alac for you if your audio data is in a supported container format (e.g. MP4, CAF, etc.).
aspergatus commentedon Apr 23, 2015
Thank for reply.
My data is not in a container, but come directly from an airplay sender. As i am trying to add alac support to airsonos. Is there a way to decode it?
Sent from my iPhone
devongovett commentedon Apr 23, 2015
Ah, ok. There isn't an easy built-in way to work with raw audio outside a container, but you can write your own "demuxer" for it. Here's an example (untested):
As mentioned in the comment, ALAC also has a "magic cookie", with some additional information needed by the decoder. This information would normally live in the container, but since you don't have a container, I'm not sure where it should be. My guess is that it would be sent when you initially connect to an airplay stream, but I'm not exactly sure where/how. You'll have to figure that out and emit an
AV.Buffercontaining the cookie data.From this Go implementation of airplay, it looks like the data is in the RTSP ANNOUNCE packet, and is then converted to an ALACSpecificConfig struct. Not sure how that fits into your backend.