Commit 2720ab1d authored by Simon Morlat's avatar Simon Morlat
Browse files

do not compile aac-eld ios specific filter on other platforms.

fix indentation and add copyright notice.
parent 9fa2247c
......@@ -100,7 +100,6 @@ libmediastreamer_voip_la_SOURCES+= audiofilters/alaw.c \
utils/g722_encode.c \
audiofilters/msg722.c \
audiofilters/l16.c \
audiofilters/aac-eld.c \
audiofilters/genericplc.c \
audiofilters/msfileplayer.c \
audiofilters/msfilerec.c \
......
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2013 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <mediastreamer2/msfilter.h>
#include <AudioToolbox/AudioToolbox.h>
......@@ -12,282 +31,270 @@ struct EncState {
int nbytes; /* amount of data in a processedTime window usually sampling rate*time*number of byte per sample*number of channels */
int nchannels; /* number of channels, default 1(mono) */
MSBufferizer *bufferizer; /* buffer to store data from input queue before processing them */
uint8_t *inputBuffer; /* buffer to store nbytes of input data and send them to the encoder */
/** AAC ELD related properties */
AudioStreamBasicDescription sourceFormat; /* description of input audio format */
AudioStreamBasicDescription destinationFormat; /* description of output audio format */
AudioConverterRef audioConverter;
UInt32 maxOutputPacketSize; /* maximum size of the output packet */
UInt32 bytesToEncode;
uint8_t *inputBuffer; /* buffer to store nbytes of input data and send them to the encoder */
/** AAC ELD related properties */
AudioStreamBasicDescription sourceFormat; /* description of input audio format */
AudioStreamBasicDescription destinationFormat; /* description of output audio format */
AudioConverterRef audioConverter;
UInt32 maxOutputPacketSize; /* maximum size of the output packet */
UInt32 bytesToEncode;
};
/* Encoder */
/* called at init and any modification of ptime: compute the input data length */
static void enc_update(struct EncState *s){
s->nbytes=(sizeof(AudioSampleType)*s->nchannels*s->samplingRate*s->ptime)/1000; /* input is 16 bits LPCM: 2 bytes per sample, ptime is in ms so /1000 */
/* nbytes % SIGNAL_FRAME_SIZE must be 0, min SIGNAL_FRAME_SIZE */
if (s->nbytes > SIGNAL_FRAME_SIZE) {
s->nbytes -= (s->nbytes % SIGNAL_FRAME_SIZE);
} else {
s->nbytes = SIGNAL_FRAME_SIZE;
}
ms_message("nbytes is %d", s->nbytes);
static void enc_update ( struct EncState *s ) {
s->nbytes= ( sizeof ( AudioSampleType ) *s->nchannels*s->samplingRate*s->ptime ) /1000; /* input is 16 bits LPCM: 2 bytes per sample, ptime is in ms so /1000 */
/* nbytes % SIGNAL_FRAME_SIZE must be 0, min SIGNAL_FRAME_SIZE */
if ( s->nbytes > SIGNAL_FRAME_SIZE ) {
s->nbytes -= ( s->nbytes % SIGNAL_FRAME_SIZE );
} else {
s->nbytes = SIGNAL_FRAME_SIZE;
}
ms_message ( "nbytes is %d", s->nbytes );
}
/* init the encoder: create an encoder State structure, initialise it and attach it to the MSFilter structure data property */
static void enc_init(MSFilter *f)
{
ms_message("init AAC");
static void enc_init ( MSFilter *f ) {
ms_message ( "init AAC" );
/* instanciate the encoder status */
struct EncState *s=(struct EncState*)ms_new(struct EncState,1);
struct EncState *s= ( struct EncState* ) ms_new ( struct EncState,1 );
s->timeStamp=0;
s->bufferizer=ms_bufferizer_new();
s->ptime = 10;
s->samplingRate=22050; /* default is narrow band : 22050Hz and 32000b/s */
s->bitRate=32000;
s->nchannels=1;
s->inputBuffer= NULL;
memset(&(s->sourceFormat), 0, sizeof(AudioStreamBasicDescription));
memset(&(s->destinationFormat), 0, sizeof(AudioStreamBasicDescription));
s->inputBuffer = (uint8_t *)malloc(SIGNAL_FRAME_SIZE*sizeof(uint8_t)); /* allocate input buffer */
/* attach it to the MSFilter structure */
s->inputBuffer= NULL;
memset ( & ( s->sourceFormat ), 0, sizeof ( AudioStreamBasicDescription ) );
memset ( & ( s->destinationFormat ), 0, sizeof ( AudioStreamBasicDescription ) );
s->inputBuffer = ( uint8_t * ) malloc ( SIGNAL_FRAME_SIZE*sizeof ( uint8_t ) ); /* allocate input buffer */
/* attach it to the MSFilter structure */
f->data=s;
}
/* pre process: at this point the sampling rate, ptime, number of channels have been correctly setted, so we can initialize the encoder */
static void enc_preprocess(MSFilter *f)
{
ms_message("preprocess AAC");
struct EncState *s=(struct EncState*)f->data;
static void enc_preprocess ( MSFilter *f ) {
ms_message ( "preprocess AAC" );
struct EncState *s= ( struct EncState* ) f->data;
/* check sampling and bit rate, must be either 44100Hz and 64000b/s (wide band) or 22050Hz and 32000b/s(narrow band)*/
if (!((s->samplingRate==22050 && s->bitRate == 32000) || (s->samplingRate==44100 && s->bitRate == 64000))) {
ms_message("AAC-ELD encoder received incorrect sampling/bitrate settings (sr%d br%d). Switch back to narrow band settings: 22050Hz 32000b/s",s->samplingRate, s->bitRate);
s->samplingRate = 22050;
s->bitRate = 32000;
}
/* update the nbytes value */
enc_update(s);
if ( ! ( ( s->samplingRate==22050 && s->bitRate == 32000 ) || ( s->samplingRate==44100 && s->bitRate == 64000 ) ) ) {
ms_message ( "AAC-ELD encoder received incorrect sampling/bitrate settings (sr%d br%d). Switch back to narrow band settings: 22050Hz 32000b/s",s->samplingRate, s->bitRate );
s->samplingRate = 22050;
s->bitRate = 32000;
}
/* update the nbytes value */
enc_update ( s );
/*** initialize the encoder ***/
/* initialise the input audio stream basic description : LPCM */
s->sourceFormat.mSampleRate = s->samplingRate;
s->sourceFormat.mFormatID = kAudioFormatLinearPCM;
s->sourceFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
s->sourceFormat.mBytesPerPacket = s->nchannels * sizeof(AudioSampleType);
s->sourceFormat.mFramesPerPacket = 1;
s->sourceFormat.mBytesPerFrame = s->nchannels * sizeof(AudioSampleType);
s->sourceFormat.mChannelsPerFrame = s->nchannels;
s->sourceFormat.mBitsPerChannel = 8*sizeof(AudioSampleType);
/* initialise the ouput audio stream description AAC-ELD */
s->destinationFormat.mFormatID = kAudioFormatMPEG4AAC_ELD;
s->destinationFormat.mChannelsPerFrame = s->nchannels;
s->destinationFormat.mSampleRate = s->samplingRate;
/* have coreAudio fill the rest of the audio stream description */
UInt32 dataSize = sizeof(s->destinationFormat);
AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &dataSize , &(s->destinationFormat)) ;
/* Create a new audio converter */
AudioConverterNew(&(s->sourceFormat ), &(s->destinationFormat), &(s->audioConverter)) ;
/* Set the output bitrate */
UInt32 outputBitrate = s->bitRate;
dataSize = sizeof(outputBitrate);
AudioConverterSetProperty (s->audioConverter, kAudioConverterEncodeBitRate, dataSize, &outputBitrate);
/* Get the maximum output size of output buffer */
UInt32 maxOutputSizePerPacket = 0;
dataSize = sizeof(maxOutputSizePerPacket);
AudioConverterGetProperty(s->audioConverter,
kAudioConverterPropertyMaximumOutputPacketSize,
&dataSize,
&maxOutputSizePerPacket);
s->maxOutputPacketSize = maxOutputSizePerPacket;
/* initialise the input audio stream basic description : LPCM */
s->sourceFormat.mSampleRate = s->samplingRate;
s->sourceFormat.mFormatID = kAudioFormatLinearPCM;
s->sourceFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
s->sourceFormat.mBytesPerPacket = s->nchannels * sizeof ( AudioSampleType );
s->sourceFormat.mFramesPerPacket = 1;
s->sourceFormat.mBytesPerFrame = s->nchannels * sizeof ( AudioSampleType );
s->sourceFormat.mChannelsPerFrame = s->nchannels;
s->sourceFormat.mBitsPerChannel = 8*sizeof ( AudioSampleType );
/* initialise the ouput audio stream description AAC-ELD */
s->destinationFormat.mFormatID = kAudioFormatMPEG4AAC_ELD;
s->destinationFormat.mChannelsPerFrame = s->nchannels;
s->destinationFormat.mSampleRate = s->samplingRate;
/* have coreAudio fill the rest of the audio stream description */
UInt32 dataSize = sizeof ( s->destinationFormat );
AudioFormatGetProperty ( kAudioFormatProperty_FormatInfo, 0, NULL, &dataSize , & ( s->destinationFormat ) ) ;
/* Create a new audio converter */
AudioConverterNew ( & ( s->sourceFormat ), & ( s->destinationFormat ), & ( s->audioConverter ) ) ;
/* Set the output bitrate */
UInt32 outputBitrate = s->bitRate;
dataSize = sizeof ( outputBitrate );
AudioConverterSetProperty ( s->audioConverter, kAudioConverterEncodeBitRate, dataSize, &outputBitrate );
/* Get the maximum output size of output buffer */
UInt32 maxOutputSizePerPacket = 0;
dataSize = sizeof ( maxOutputSizePerPacket );
AudioConverterGetProperty ( s->audioConverter,
kAudioConverterPropertyMaximumOutputPacketSize,
&dataSize,
&maxOutputSizePerPacket );
s->maxOutputPacketSize = maxOutputSizePerPacket;
}
static OSStatus encoderCallback(AudioConverterRef inAudioConverter, UInt32 *ioNumberDataPackets, AudioBufferList *ioData,
AudioStreamPacketDescription **outDataPacketDescription,void *inUserData)
{
/* Get the current encoder state from the inUserData parameter */
struct EncState *s=(struct EncState*)inUserData;
/* Compute the maximum number of output packets -- useless as we shall always have nbytes at 512 bytes */
UInt32 maxPackets = s->nbytes / s->sourceFormat.mBytesPerPacket;
if (*ioNumberDataPackets > maxPackets)
{
/* If requested number of packets is bigger, adjust */
*ioNumberDataPackets = maxPackets;
}
/* Check to make sure we have only one audio buffer */
if (ioData->mNumberBuffers != 1)
{
return 1;
}
/* Set the data to be encoded */
ioData->mBuffers[0].mDataByteSize = s->nbytes;
ioData->mBuffers[0].mData = s->inputBuffer;
ioData->mBuffers[0].mNumberChannels = s->nchannels;
if (outDataPacketDescription)
{
*outDataPacketDescription = NULL;
}
return noErr;
static OSStatus encoderCallback ( AudioConverterRef inAudioConverter, UInt32 *ioNumberDataPackets, AudioBufferList *ioData,
AudioStreamPacketDescription **outDataPacketDescription,void *inUserData ) {
/* Get the current encoder state from the inUserData parameter */
struct EncState *s= ( struct EncState* ) inUserData;
/* Compute the maximum number of output packets -- useless as we shall always have nbytes at 512 bytes */
UInt32 maxPackets = s->nbytes / s->sourceFormat.mBytesPerPacket;
if ( *ioNumberDataPackets > maxPackets ) {
/* If requested number of packets is bigger, adjust */
*ioNumberDataPackets = maxPackets;
}
/* Check to make sure we have only one audio buffer */
if ( ioData->mNumberBuffers != 1 ) {
return 1;
}
/* Set the data to be encoded */
ioData->mBuffers[0].mDataByteSize = s->nbytes;
ioData->mBuffers[0].mData = s->inputBuffer;
ioData->mBuffers[0].mNumberChannels = s->nchannels;
if ( outDataPacketDescription ) {
*outDataPacketDescription = NULL;
}
return noErr;
}
/* process: get data from MSFilter queue and put it into the EncState buffer, then process it until there is less than nbytes in the input buffer */
static void enc_process(MSFilter *f)
{
struct EncState *s=(struct EncState*)f->data;
static void enc_process ( MSFilter *f ) {
struct EncState *s= ( struct EncState* ) f->data;
/* lock the MSFilter properties in order to delay any change of properties(mostly ptimes which impact nbytes) */
ms_filter_lock(f);
ms_filter_lock ( f );
/* get data from MSFilter queue and put it in the EncState buffer */
ms_bufferizer_put_from_queue(s->bufferizer,f->inputs[0]);
ms_bufferizer_put_from_queue ( s->bufferizer,f->inputs[0] );
/* until we find at least the requested amount of input data in the input buffer, process it */
while (ms_bufferizer_get_avail(s->bufferizer)>=s->nbytes) {
mblk_t *outputMessage=allocb(s->maxOutputPacketSize,0); /* create an output message of requested size(may be actually to big but allocate the maximum output buffer for the encoder */
/*** encoding ***/
/* create an audio stream packet description to feed the encoder in order to get the description of encoded data */
AudioStreamPacketDescription outPacketDesc[1];
/* encode a 512 sample frame (nbytes is 512 or a greater multiple */
UInt32 bufferIndex =0;
for (bufferIndex=0; bufferIndex<s->nbytes; bufferIndex+=SIGNAL_FRAME_SIZE) {
/* Create the output buffer list */
AudioBufferList outBufferList;
outBufferList.mNumberBuffers = 1;
outBufferList.mBuffers[0].mNumberChannels = s->nchannels;
outBufferList.mBuffers[0].mDataByteSize = s->maxOutputPacketSize;
outBufferList.mBuffers[0].mData = outputMessage->b_wptr; /* store output data directly in the output message */
/* get the input data from bufferizer to the input buffer */
ms_bufferizer_read(s->bufferizer, s->inputBuffer, SIGNAL_FRAME_SIZE);
/* start the encoding process, iOS will call back when ready the callback function provided as second arg to get the input data */
UInt32 numOutputDataPackets = 1;
OSStatus status = AudioConverterFillComplexBuffer(s->audioConverter,
encoderCallback,
s, /* to have the MSFilterDesc of encoder available in the callback function */
&numOutputDataPackets,
&outBufferList,
outPacketDesc);
if (status != noErr)
{
ms_message("AAC-ELD unable to encode, exit status : %ld",status);
return;
}
/* get the length of output data and increment the outputMessage write pointer, ouput data is now in the output message */
outputMessage->b_wptr+=(int)(outPacketDesc[0].mDataByteSize);
}
while ( ms_bufferizer_get_avail ( s->bufferizer ) >=s->nbytes ) {
mblk_t *outputMessage=allocb ( s->maxOutputPacketSize,0 ); /* create an output message of requested size(may be actually to big but allocate the maximum output buffer for the encoder */
/*** encoding ***/
/* create an audio stream packet description to feed the encoder in order to get the description of encoded data */
AudioStreamPacketDescription outPacketDesc[1];
/* encode a 512 sample frame (nbytes is 512 or a greater multiple */
UInt32 bufferIndex =0;
for ( bufferIndex=0; bufferIndex<s->nbytes; bufferIndex+=SIGNAL_FRAME_SIZE ) {
/* Create the output buffer list */
AudioBufferList outBufferList;
outBufferList.mNumberBuffers = 1;
outBufferList.mBuffers[0].mNumberChannels = s->nchannels;
outBufferList.mBuffers[0].mDataByteSize = s->maxOutputPacketSize;
outBufferList.mBuffers[0].mData = outputMessage->b_wptr; /* store output data directly in the output message */
/* get the input data from bufferizer to the input buffer */
ms_bufferizer_read ( s->bufferizer, s->inputBuffer, SIGNAL_FRAME_SIZE );
/* start the encoding process, iOS will call back when ready the callback function provided as second arg to get the input data */
UInt32 numOutputDataPackets = 1;
OSStatus status = AudioConverterFillComplexBuffer ( s->audioConverter,
encoderCallback,
s, /* to have the MSFilterDesc of encoder available in the callback function */
&numOutputDataPackets,
&outBufferList,
outPacketDesc );
if ( status != noErr ) {
ms_message ( "AAC-ELD unable to encode, exit status : %ld",status );
return;
}
/* get the length of output data and increment the outputMessage write pointer, ouput data is now in the output message */
outputMessage->b_wptr+= ( int ) ( outPacketDesc[0].mDataByteSize );
}
/* set timeStamp in the output Message */
mblk_set_timestamp_info(outputMessage,s->timeStamp);
s->timeStamp += s->nbytes/(sizeof(AudioSampleType)*s->nchannels); /* increment timeStamp by the number of sample processed (divided by the number of channels) */
mblk_set_timestamp_info ( outputMessage,s->timeStamp );
s->timeStamp += s->nbytes/ ( sizeof ( AudioSampleType ) *s->nchannels ); /* increment timeStamp by the number of sample processed (divided by the number of channels) */
/* insert the output message into the output queue of MSFilter */
ms_queue_put(f->outputs[0],outputMessage);
ms_queue_put ( f->outputs[0],outputMessage );
}
/* release the lock */
ms_filter_unlock(f);
ms_filter_unlock ( f );
}
static void enc_postprocess(MSFilter *f)
{
static void enc_postprocess ( MSFilter *f ) {
}
static void enc_uninit(MSFilter *f)
{
struct EncState *s=(struct EncState*)f->data;
ms_bufferizer_destroy(s->bufferizer);
free(s->inputBuffer);
ms_free(s);
static void enc_uninit ( MSFilter *f ) {
struct EncState *s= ( struct EncState* ) f->data;
ms_bufferizer_destroy ( s->bufferizer );
free ( s->inputBuffer );
ms_free ( s );
f->data = 0;
}
static void set_ptime(struct EncState *s, int value){
if (value>0 && value<=100){
static void set_ptime ( struct EncState *s, int value ) {
if ( value>0 && value<=100 ) {
s->ptime=value;
ms_message("AAC-ELD encoder using ptime=%i",value);
enc_update(s);
ms_message ( "AAC-ELD encoder using ptime=%i",value );
enc_update ( s );
}
}
static int enc_add_attr(MSFilter *f, void *arg)
{
ms_message("add attr AAC");
const char *fmtp=(const char*)arg;
struct EncState *s=(struct EncState*)f->data;
if(strstr(fmtp,"ptime:")){
ms_filter_lock(f);
set_ptime(s,atoi(fmtp+6));
ms_filter_unlock(f);
static int enc_add_attr ( MSFilter *f, void *arg ) {
ms_message ( "add attr AAC" );
const char *fmtp= ( const char* ) arg;
struct EncState *s= ( struct EncState* ) f->data;
if ( strstr ( fmtp,"ptime:" ) ) {
ms_filter_lock ( f );
set_ptime ( s,atoi ( fmtp+6 ) );
ms_filter_unlock ( f );
}
return 0;
};
static int enc_add_fmtp(MSFilter *f, void *arg){
ms_message("add fmtp AAC");
const char *fmtp=(const char*)arg;
struct EncState *s=(struct EncState*)f->data;
char tmp[16]={0};
if (fmtp_get_value(fmtp,"ptime",tmp,sizeof(tmp))){
ms_filter_lock(f);
set_ptime(s,atoi(tmp));
ms_filter_unlock(f);
static int enc_add_fmtp ( MSFilter *f, void *arg ) {
ms_message ( "add fmtp AAC" );
const char *fmtp= ( const char* ) arg;
struct EncState *s= ( struct EncState* ) f->data;
char tmp[16]= {0};
if ( fmtp_get_value ( fmtp,"ptime",tmp,sizeof ( tmp ) ) ) {
ms_filter_lock ( f );
set_ptime ( s,atoi ( tmp ) );
ms_filter_unlock ( f );
}
return 0;
}
static int enc_set_sr(MSFilter *f, void *arg){
ms_message("set sr AAC in to %d",((int*)arg)[0]);
struct EncState *s=(struct EncState*)f->data;
s->samplingRate = ((int*)arg)[0];
static int enc_set_sr ( MSFilter *f, void *arg ) {
ms_message ( "set sr AAC in to %d", ( ( int* ) arg ) [0] );
struct EncState *s= ( struct EncState* ) f->data;
s->samplingRate = ( ( int* ) arg ) [0];
return 0;
}
static int enc_get_sr(MSFilter *f, void *arg){
ms_message("get sr AAC in");
struct EncState *s=(struct EncState*)f->data;
((int*)arg)[0]=s->samplingRate;
static int enc_get_sr ( MSFilter *f, void *arg ) {
ms_message ( "get sr AAC in" );
struct EncState *s= ( struct EncState* ) f->data;
( ( int* ) arg ) [0]=s->samplingRate;
return 0;
}
static int enc_set_br(MSFilter *f, void *arg){
ms_message("set br AAC in to %d",((int*)arg)[0]);
struct EncState *s=(struct EncState*)f->data;
s->bitRate = ((int*)arg)[0];
static int enc_set_br ( MSFilter *f, void *arg ) {
ms_message ( "set br AAC in to %d", ( ( int* ) arg ) [0] );
struct EncState *s= ( struct EncState* ) f->data;
s->bitRate = ( ( int* ) arg ) [0];
return 0;
}
static int enc_get_br(MSFilter *f, void *arg){
ms_message("get br AAC in");
struct EncState *s=(struct EncState*)f->data;
((int*)arg)[0]=s->bitRate;
static int enc_get_br ( MSFilter *f, void *arg ) {
ms_message ( "get br AAC in" );
struct EncState *s= ( struct EncState* ) f->data;
( ( int* ) arg ) [0]=s->bitRate;
return 0;
}
/* attach encoder methods to MSFilter IDs */
static MSFilterMethod enc_methods[]={
static MSFilterMethod enc_methods[]= {
{ MS_FILTER_ADD_ATTR , enc_add_attr},
{ MS_FILTER_ADD_FMTP , enc_add_fmtp},
{ MS_FILTER_SET_SAMPLE_RATE , enc_set_sr },
......@@ -299,7 +306,7 @@ static MSFilterMethod enc_methods[]={
};
MSFilterDesc ms_aac_eld_enc_desc={
MSFilterDesc ms_aac_eld_enc_desc= {
MS_AAC_ELD_ENC_ID, /**< this ID must be declared in allfilter.h */
"MSAACELDEnc", /**< filter name */
"AAC-ELD encoder", /**< filter Description */
......@@ -320,223 +327,214 @@ MSFilterDesc ms_aac_eld_enc_desc={
struct DecState {
int samplingRate; /* sampling rate of decoded signal */
uint8_t audioConverterProperty[512]; /* config string retrieved from SDP message useless?*/
uint8_t audioConverterProperty[512]; /* config string retrieved from SDP message useless?*/
int audioConverterProperty_size; /* previous property size */
int nchannels; /* number of channels, default 1(mono) */
int nbytes; /* size of ouput buffer for the decoder:
int nchannels; /* number of channels, default 1(mono) */
int nbytes; /* size of ouput buffer for the decoder:
// MSConcealerContext *concealer; /* concealment management */
/** AAC ELD related properties */
AudioStreamBasicDescription sourceFormat;
AudioStreamBasicDescription destinationFormat;
AudioConverterRef audioConverter;
UInt32 bytesToDecode;
void *decodeBuffer;
AudioStreamPacketDescription packetDesc[1];
UInt32 maxOutputPacketSize;
/** AAC ELD related properties */
AudioStreamBasicDescription sourceFormat;
AudioStreamBasicDescription destinationFormat;
AudioConverterRef audioConverter;
UInt32 bytesToDecode;
void *decodeBuffer;
AudioStreamPacketDescription packetDesc[1];
UInt32 maxOutputPacketSize;
};
static void dec_init(MSFilter *f)
{
ms_message("dec init");
static void dec_init ( MSFilter *f ) {
ms_message ( "dec init" );
/* instanciate the decoder State structure */
struct DecState *s=(struct DecState *)ms_new(struct DecState,1);
struct DecState *s= ( struct DecState * ) ms_new ( struct DecState,1 );
s->samplingRate=44100;
s->nchannels=1; /* default mono */
s->nchannels=1; /* default mono */
/* attach it to the MSFilter */
f->data=s;
/* initialise source and destination format for AAC-ELD decoder */
memset(&(s->sourceFormat), 0, sizeof(AudioStreamBasicDescription));
memset(&(s->destinationFormat), 0, sizeof(AudioStreamBasicDescription));
/* initialise source and destination format for AAC-ELD decoder */
memset ( & ( s->sourceFormat ), 0, sizeof ( AudioStreamBasicDescription ) );
memset ( & ( s->destinationFormat ), 0, sizeof ( AudioStreamBasicDescription ) );
}
static void dec_preprocess(MSFilter *f)
{
ms_message("dec preprocess");
struct DecState *s=(struct DecState*)f->data;
/*** initialise the AAC-ELD decoder ***/
/* initialise the ouput audio stream basic description : LPCM */
s->destinationFormat.mSampleRate = s->samplingRate;
s->destinationFormat.mFormatID = kAudioFormatLinearPCM;
s->destinationFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
s->destinationFormat.mBytesPerPacket = s->nchannels * sizeof(AudioSampleType);
s->destinationFormat.mFramesPerPacket = 1;