#pragma once
#include <cstdint>
#include <iostream>
struct AdtsHeader 
{
    unsigned int syncword;  //12 bit ͬ '1111 1111 1111'˵һADTS֡Ŀʼ
    unsigned int id;        //1 bit MPEG ʾ 0 for MPEG-41 for MPEG-2
    unsigned int layer;     //2 bit '00'
    unsigned int protectionAbsent;  //1 bit 1ʾûcrc0ʾcrc
    unsigned int profile;           //1 bit ʾʹĸAAC  //2bit
    unsigned int samplingFreqIndex; //4 bit ʾʹõĲƵ
    unsigned int privateBit;        //1 bit
    unsigned int channelCfg; //3 bit ʾ
    unsigned int originalCopy;         //1 bit
    unsigned int home;                  //1 bit

    /*ΪıĲÿһ֡ͬ*/
    unsigned int copyrightIdentificationBit;   //1 bit
    unsigned int copyrightIdentificationStart; //1 bit
    unsigned int aacFrameLength;               //13 bit һADTS֡ĳȰADTSͷAACԭʼ
    unsigned int adtsBufferFullness;           //11 bit 0x7FF ˵ʿɱ

    /* number_of_raw_data_blocks_in_frame
     * ʾADTS֡number_of_raw_data_blocks_in_frame + 1AACԭʼ֡
     * ˵number_of_raw_data_blocks_in_frame == 0
     * ʾ˵ADTS֡һAACݿ鲢˵ûС(һAACԭʼ֡һʱ1024)
     */
    unsigned int numberOfRawDataBlockInFrame; //2 bit
};
int Parse_AdtsHeader(uint8_t* headerBuf, struct AdtsHeader* adtsHeader);
int Convert_AdtsHeader_ToBuf(struct AdtsHeader* adtsHeader, uint8_t* adtsHeaderBuf);