#pragma once

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

class KbUsfDecoder : public KbKpiUnknownImpl<IKpiDecoder>
{
private:
    KPI_MEDIAINFO  m_MediaInfo;
    kbusf_Settings m_Settings;
    void       *m_state;
    UINT64      m_qwCurSample;
    UINT64      m_qwEndSample;
    double      m_volume;

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;}
    int write(char *buffer, int length);
    static void __fastcall Init(IKpiConfig *pConfig);
    static void __fastcall Deinit(void);
    KbUsfDecoder(IKpiConfig *pConfig);
    ~KbUsfDecoder(void);
};
