#pragma once

extern "C"{
#include "neaacdec.h"
#include "mp4ff/mp4ff.h"
}
#include "kbmp4_decoder.h"

//MPEG4 コンテナに格納された AAC をデコードするクラス
class KbMp4AacDecoder : public KbMp4Decoder
{
private:
    NeAACDecHandle   m_hDecoder;
    BYTE    *m_pSample;
    unsigned char m_objectTypeIndex;
    DWORD    m_dwEncDelay;     //encoder delay
    DWORD    m_dwSkippedSample;//読み飛ばしたサンプル数(m_dwEncDelay に到達するまで)
    DWORD    m_dwRemainSample;
    void  __fastcall Close(void);
public:
    DWORD __fastcall Open(const KPI_MEDIAINFO *cpRequest,
                          IKpiFile   *pFile,
                          IKpiFolder *pFolder);
    void __fastcall GetTagInfo(IKpiTagInfo *pTagInfo,
                               DWORD dwTagGetFlags);
    //IKpiDecoder 派生
    UINT64 WINAPI Seek(UINT64 qwPosSample, DWORD dwFlag);
    DWORD  WINAPI Render(BYTE *pBuffer, DWORD dwSizeSample);
    DWORD  WINAPI UpdateConfig(void *pvReserved){return 0;}
    KbMp4AacDecoder(void);
    ~KbMp4AacDecoder(void);
};

