/** * 添加ADTS头 * 一帧AAC+7 = packetLen * @param packet * @param packetLen */ private void addADTStoPacket(byte[] packet, int packetLen) { int profile = 2; // AAC LC int freqIdx = 8; // 16KHz int chanCfg = 1; // CPE // fill in ADTS data packet[0] = (byte) 0xFF; packet[1] = (byte) 0xF1; packet[2] = (byte) (((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2)); packet[3] = (byte) (((chanCfg & 3) << 6) + (packetLen >> 11)); packet[4] = (byte) ((packetLen & 0x7FF) >> 3); packet[5] = (byte) (((packetLen & 7) << 5) + 0x1F); packet[6] = (byte) 0xFC; }
- profile:表示使用哪个级别的AAC,如01 Low Complexity(LC) -- AAC LC
profile的值等于 Audio Object Type的值减1.
profile = MPEG-4 Audio Object Type - 1
sampling_frequency_index:采样率的下标
- channel_configuration:声道数,比如2表示立体声双声道