#pragma once

#include <windows.h>

#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"
#include "ogg/ogg.h"
#include "kmp_pi.h"
#include "kpi_decoder.h"
#include "kpi_impl.h"

class KbVorbisDecoder : public KbKpiUnknownImpl<IKpiDecoder>
{
private:
    KPI_MEDIAINFO  m_MediaInfo;
    OggVorbis_File m_VorbisFile;
    IKpiFile *m_pFile;
    int       m_current_section;
    void __fastcall GetTagInfo(IKpiTagInfo *pInfo, 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);
    DWORD  WINAPI Render(BYTE *pBuffer, DWORD dwSizeSample);
    UINT64 WINAPI Seek(UINT64 qwPosSample, DWORD dwFlag);
    DWORD  WINAPI UpdateConfig(void *pvReserved){return 0;}
    KbVorbisDecoder(void);
    ~KbVorbisDecoder(void);
};
