话不多说,测试代码如下:
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include "aacdecoder_lib.h"
#include <iostream>
using namespace std;
int main() {
HANDLE_AACDECODER handle;
handle = aacDecoder_Open(TT_MP4_RAW , 1);
//UCHAR eld_conf[] = { 0xF8, 0xE8, 0x50, 0x00 };//ste eld 44.1k
//UCHAR ld_conf[] = { 0xBA, 0x88, 0x00, 0x00 };//mono ld 32k
//UCHAR ld_conf[] = { 0xBA, 0x89, 0x00, 0x00 };//keda mono ld 32k
//UCHAR ld_conf[] = { 0xB9, 0x90, 0x00, 0x00};//hisi ste ld 48k
//UCHAR ld_conf[] = { 0x11, 0x90};//hisi ste lc 48k
UCHAR ld_conf[] = { 0x12, 0x90};//hisi ste lc 32k
UCHAR *conf[1] = { ld_conf };
static UINT conf_len = sizeof(conf);
AAC_DECODER_ERROR err = aacDecoder_ConfigRaw(handle, conf, &conf_len);
if(err>0)
cout<<"conf err:"<<err<<endl;
CStreamInfo *info = aacDecoder_GetStreamInfo(handle);
cout<<"info->aacSampleRate:"<<info->aacSampleRate<<endl;
cout<<"info->channelConfig:"<<info->channelConfig<<endl;
cout<<"info->aot:"<<info->aot<<endl;
aacDecoder_Close(handle);
return 0;
}
其中sample rate是采样率,channel config是通道数,如果是立体声则是2,aot是类型,aac-lc是2,aac-ld是23,aac-eld是39