#pragma once

#include "kpi_decoder.h"
#include "kpi_impl.h"

#define PUREVOICE_SDK_VER 3 //3 の場合は qscl.dll を、2 の場合は qpl.dll を使う

#if PUREVOICE_SDK_VER == 2
class IQPLQcpFile1;
#else
class IQsclFile;
#endif
class KbQcpDecoder : public KbKpiUnknownImpl<IKpiDecoder>
{
private:
    KPI_MEDIAINFO  m_MediaInfo;
    IKpiFile       *m_pFile;
#if PUREVOICE_SDK_VER == 2
    IQPLQcpFile1 *m_pQcpFile;
    const char   *m_cszFileNameA;
    int           m_nPos;
#else
    IQsclFile    *m_pQcpFile;
    int           m_nSamplesPerBlock;
    int           m_nTotalBlocks;
#endif
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);
    DWORD  WINAPI Render(BYTE *pBuffer, DWORD dwSizeSample);
    UINT64 WINAPI Seek(UINT64 qwPosSample, DWORD dwFlag);
    DWORD  WINAPI UpdateConfig(void *pvReserved){return 0;}
    void __fastcall GetTagInfo(IKpiTagInfo *pTagInfo, DWORD dwTagGetFlags);
    static void __fastcall Uninitialize(void);
    KbQcpDecoder(void);
    ~KbQcpDecoder(void);
};
