#pragma once

#include "kpi_decoder.h"
#include "kpi_impl.h"
#include "Header/tak_deco_lib.h"

class KbTakDecoder : public KbKpiUnknownImpl<IKpiDecoder>
{
private:
    KPI_MEDIAINFO             m_MediaInfo;
    TtakSeekableStreamDecoder m_TakDecoder;
    TtakStreamIoInterface     m_TakStreamIo;
    IKpiFile                 *m_pFile;
    BOOL  __fastcall GetTagInfo(IKpiTagInfo *pTagInfo, DWORD dwTagGetFlags);
public:
    DWORD __fastcall Open(const KPI_MEDIAINFO *cpRequest,
                          IKpiFile *pFile,
                          IKpiFolder *pFolder);
    DWORD  WINAPI Select(DWORD dwNumber,
                         const KPI_MEDIAINFO **ppMediaInfo,
                         IKpiTagInfo *pTagInfo,
                         DWORD dwTagGetFlags);
    UINT64 WINAPI Seek(UINT64 qwPosSample, DWORD dwFlag);
    DWORD  WINAPI Render(BYTE *pBuffer, DWORD dwSizeSample);
    DWORD  WINAPI UpdateConfig(void *pvReserved){return 0;}
    static BOOL Initialize(HINSTANCE hKpi, TtakInt32* pnVersion, TtakInt32* pnCompatibility);
    static void Uninitialize(void);
    KbTakDecoder(void);
    ~KbTakDecoder(void);
};
