Commit 11a37aa6 authored by jehan's avatar jehan

try to set aac config string to decoder

parent 77ccbf9a
...@@ -581,7 +581,7 @@ static void dec_preprocess ( MSFilter *f ) { ...@@ -581,7 +581,7 @@ static void dec_preprocess ( MSFilter *f ) {
s->destinationFormat.mBitsPerChannel = 8*sizeof ( SInt16 ); s->destinationFormat.mBitsPerChannel = 8*sizeof ( SInt16 );
/* from AAC-ELD, having the same sampling rate, but possibly a different channel configuration */ /* from AAC-ELD, having the same sampling rate, but possibly a different channel configuration */
s->sourceFormat.mFormatID = kAudioFormatMPEG4AAC_ELD; // ELD can handle SBR as well s->sourceFormat.mFormatID = /*kAudioFormatMPEG4AAC*/ kAudioFormatMPEG4AAC_ELD; // ELD can handle SBR as well
s->sourceFormat.mChannelsPerFrame = s->nchannels; s->sourceFormat.mChannelsPerFrame = s->nchannels;
s->sourceFormat.mSampleRate = s->samplingRate; s->sourceFormat.mSampleRate = s->samplingRate;
...@@ -609,7 +609,21 @@ static void dec_preprocess ( MSFilter *f ) { ...@@ -609,7 +609,21 @@ static void dec_preprocess ( MSFilter *f ) {
&dataSize, &dataSize,
&maxOutputSizePerPacket ); &maxOutputSizePerPacket );
s->maxOutputPacketSize = maxOutputSizePerPacket; s->maxOutputPacketSize = maxOutputSizePerPacket;
/* don't know yet how to convert config string in sens of rfc3640 to kAudioConverterDecompressionMagicCookie. hints can be found from https://www.iis.fraunhofer.de/en/ff/amm/prod/kommunikation/komm/aaceld.html application bulletin.
OSStatus status = AudioConverterSetProperty ( s->audioConverter
, kAudioConverterDecompressionMagicCookie
, s->audioConverterProperty_size
, s->audioConverterProperty);
if (status != noErr ) {
ms_error ("Cannot set acc decoder property kAudioConverterDecompressionMagicCookie because [%c%c%c%c]"
,((char*)&status)[3]
,((char*)&status)[2]
,((char*)&status)[1]
,((char*)&status)[0]);
}
*/
/* initialise concealment context */ /* initialise concealment context */
s->concealer = ms_concealer_ts_context_new(UINT32_MAX); s->concealer = ms_concealer_ts_context_new(UINT32_MAX);
} }
...@@ -657,14 +671,13 @@ static void dec_process ( MSFilter *f ) { ...@@ -657,14 +671,13 @@ static void dec_process ( MSFilter *f ) {
mblk_t *inputMessage; mblk_t *inputMessage;
UInt32 numOutputDataPackets; UInt32 numOutputDataPackets;
while ( ( inputMessage=ms_queue_get ( f->inputs[0] ) ) ) { while ( ( inputMessage=ms_queue_get ( f->inputs[0] ) ) ) {
numOutputDataPackets = 4 /*to support up to 2048 frame*/ *SIGNAL_FRAME_SIZE*s->nchannels / (s->maxOutputPacketSize);
/* process the input message */ /* process the input message */
/* parse the haeder to get the number of frames in the message au-headers-length is length of headers in bits, for each frame, 16 bits header */ /* parse the haeder to get the number of frames in the message au-headers-length is length of headers in bits, for each frame, 16 bits header */
UInt16 frameNumber = ((((UInt16)(inputMessage->b_rptr[0]))<<8) + ((UInt16)(inputMessage->b_rptr[1])))/16; UInt16 frameNumber = ((((UInt16)(inputMessage->b_rptr[0]))<<8) + ((UInt16)(inputMessage->b_rptr[1])))/16;
UInt16 headerOffset = 2*frameNumber + 2; /* actual frame start at this offset in input message */ UInt16 headerOffset = 2*frameNumber + 2; /* actual frame start at this offset in input message */
mblk_t *outputMessage = allocb ( numOutputDataPackets*s->maxOutputPacketSize, 0 ); /* fixed size output frame, allocate the requested amount in the output message */ size_t outputMessageSize = frameNumber*4 /*to support up to 2048 audio samples*/ *SIGNAL_FRAME_SIZE * s->nchannels;
mblk_t *outputMessage = allocb ( outputMessageSize, 0 ); /* fixed size output frame, allocate the requested amount in the output message */
int frameIndex; int frameIndex;
s->decodeBuffer=inputMessage->b_rptr + headerOffset; /* initialise the read pointer to the beginning of the first frame */ s->decodeBuffer=inputMessage->b_rptr + headerOffset; /* initialise the read pointer to the beginning of the first frame */
...@@ -672,16 +685,18 @@ static void dec_process ( MSFilter *f ) { ...@@ -672,16 +685,18 @@ static void dec_process ( MSFilter *f ) {
/* get the frame length from the header */ /* get the frame length from the header */
UInt16 frameLength = ((((UInt16)(inputMessage->b_rptr[2+2*frameIndex]))<<8) + ((UInt16)(inputMessage->b_rptr[2+2*frameIndex+1])))>>3; UInt16 frameLength = ((((UInt16)(inputMessage->b_rptr[2+2*frameIndex]))<<8) + ((UInt16)(inputMessage->b_rptr[2+2*frameIndex+1])))>>3;
s->bytesToDecode = frameLength; s->bytesToDecode = frameLength;
/* Create the output buffer list */ /* Create the output buffer list */
AudioBufferList outBufferList; AudioBufferList outBufferList;
outBufferList.mNumberBuffers = 1; outBufferList.mNumberBuffers = 1;
outBufferList.mBuffers[0].mNumberChannels = s->nchannels; outBufferList.mBuffers[0].mNumberChannels = s->nchannels;
outBufferList.mBuffers[0].mDataByteSize = numOutputDataPackets*s->maxOutputPacketSize; outBufferList.mBuffers[0].mDataByteSize = outputMessageSize;
outBufferList.mBuffers[0].mData = outputMessage->b_wptr; outBufferList.mBuffers[0].mData = outputMessage->b_wptr;
OSStatus status = noErr; OSStatus status = noErr;
numOutputDataPackets=outBufferList.mBuffers[0].mDataByteSize/s->maxOutputPacketSize;
AudioStreamPacketDescription outputPacketDesc[numOutputDataPackets]; AudioStreamPacketDescription outputPacketDesc[numOutputDataPackets];
/* Start the decoding process */ /* Start the decoding process */
status = AudioConverterFillComplexBuffer ( s->audioConverter, status = AudioConverterFillComplexBuffer ( s->audioConverter,
...@@ -698,7 +713,8 @@ static void dec_process ( MSFilter *f ) { ...@@ -698,7 +713,8 @@ static void dec_process ( MSFilter *f ) {
,((char*)&status)[0]); ,((char*)&status)[0]);
} }
outputMessage->b_wptr += numOutputDataPackets*sizeof(SInt16)*s->nchannels; // increment write pointer of output message by the amount of data written by the decoder outputMessage->b_wptr += numOutputDataPackets*s->maxOutputPacketSize; // increment write pointer of output message by the amount of data written by the decoder
outputMessageSize = outputMessageSize - numOutputDataPackets*s->maxOutputPacketSize; /*for next frame*/
s->decodeBuffer = (UInt8*)s->decodeBuffer + frameLength; /* increase the read pointer to the begining of next frame (if any, otherwise, it won't be used) */ s->decodeBuffer = (UInt8*)s->decodeBuffer + frameLength; /* increase the read pointer to the begining of next frame (if any, otherwise, it won't be used) */
} }
/* insert the output message with all decoded frame in the queue and free the input message */ /* insert the output message with all decoded frame in the queue and free the input message */
...@@ -764,10 +780,9 @@ static int dec_add_fmtp ( MSFilter *f, void *data ) { ...@@ -764,10 +780,9 @@ static int dec_add_fmtp ( MSFilter *f, void *data ) {
int i,j,max=strlen ( config ); int i,j,max=strlen ( config );
char octet[3]; char octet[3];
octet[2]=0; octet[2]=0;
for ( i=0,j=0; i<max; i+=2,++j ) { for ( i=0,j=0; i<max; i+=2,j++ ) {
octet[0]=config[i]; octet[0]=config[i];
octet[1]=config[i+1]; octet[1]=config[i+1];
s->audioConverterProperty[0]=0;
s->audioConverterProperty[j]= ( uint8_t ) strtol ( octet,NULL,16 ); s->audioConverterProperty[j]= ( uint8_t ) strtol ( octet,NULL,16 );
} }
s->audioConverterProperty_size=j; s->audioConverterProperty_size=j;
......
...@@ -92,7 +92,8 @@ typedef struct _MediastreamDatas { ...@@ -92,7 +92,8 @@ typedef struct _MediastreamDatas {
MSFactory *factory; MSFactory *factory;
int localport,remoteport,payload; int localport,remoteport,payload;
char ip[64]; char ip[64];
char *fmtp; char *send_fmtp;
char *recv_fmtp;
int jitter; int jitter;
int bitrate; int bitrate;
int mtu; int mtu;
...@@ -195,6 +196,7 @@ const char *usage="mediastream --local <port>\n" ...@@ -195,6 +196,7 @@ const char *usage="mediastream --local <port>\n"
"[ --el-thres <(float) [0-1]> (Threshold above which the system becomes active) ]\n" "[ --el-thres <(float) [0-1]> (Threshold above which the system becomes active) ]\n"
"[ --el-transmit-thres <(float) [0-1]> (TO BE DOCUMENTED) ]\n" "[ --el-transmit-thres <(float) [0-1]> (TO BE DOCUMENTED) ]\n"
"[ --fmtp <fmtpline> ]\n" "[ --fmtp <fmtpline> ]\n"
"[ --recv_fmtp <fmtpline passed to decoder> ]\n"
"[ --freeze-on-error (for video, stop upon decoding error until next valid frame) ]\n" "[ --freeze-on-error (for video, stop upon decoding error until next valid frame) ]\n"
"[ --height <pixels> ]\n" "[ --height <pixels> ]\n"
"[ --ice-local-candidate <ip:port:[host|srflx|prflx|relay]> ]\n" "[ --ice-local-candidate <ip:port:[host|srflx|prflx|relay]> ]\n"
...@@ -292,7 +294,8 @@ MediastreamDatas* init_default_args(void) { ...@@ -292,7 +294,8 @@ MediastreamDatas* init_default_args(void) {
args->remoteport=0; args->remoteport=0;
args->payload=0; args->payload=0;
memset(args->ip, 0, sizeof(args->ip)); memset(args->ip, 0, sizeof(args->ip));
args->fmtp=NULL; args->send_fmtp=NULL;
args->recv_fmtp=NULL;
args->jitter=50; args->jitter=50;
args->bitrate=0; args->bitrate=0;
args->ec=FALSE; args->ec=FALSE;
...@@ -417,7 +420,10 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) { ...@@ -417,7 +420,10 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
} }
}else if (strcmp(argv[i],"--fmtp")==0){ }else if (strcmp(argv[i],"--fmtp")==0){
i++; i++;
out->fmtp=argv[i]; out->send_fmtp=argv[i];
}else if (strcmp(argv[i],"--recv_fmtp")==0){
i++;
out->recv_fmtp=argv[i];
}else if (strcmp(argv[i],"--jitter")==0){ }else if (strcmp(argv[i],"--jitter")==0){
i++; i++;
out->jitter=atoi(argv[i]); out->jitter=atoi(argv[i]);
...@@ -757,7 +763,8 @@ void setup_media_streams(MediastreamDatas* args) { ...@@ -757,7 +763,8 @@ void setup_media_streams(MediastreamDatas* args) {
} else { } else {
payload_type_unset_flag(args->pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); payload_type_unset_flag(args->pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED);
} }
if (args->fmtp!=NULL) payload_type_set_send_fmtp(args->pt,args->fmtp); if (args->send_fmtp!=NULL) payload_type_set_send_fmtp(args->pt,args->send_fmtp);
if (args->recv_fmtp!=NULL) payload_type_set_recv_fmtp(args->pt,args->recv_fmtp);
if (args->bitrate>0) args->pt->normal_bitrate=args->bitrate; if (args->bitrate>0) args->pt->normal_bitrate=args->bitrate;
if (args->pt->normal_bitrate==0){ if (args->pt->normal_bitrate==0){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment