#include "stdafx.h"
#include "kbviv_module.h"
#include "kbviv_player.h"
///////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
static const DWORD kbviv_Version = 0x7FFFFFFF; //デバッグ時は優先度最大
#define KBVIV_VERSION_STR L"0x7FFFFFFF(Debug)"
#else
static const DWORD kbviv_Version = 4;
#define KBVIV_VERSION_STR L"0.04"
#endif
///////////////////////////////////////////////////////////////////////////////
// {80998CA4-E4B0-4B1D-8235-BB3CBA3035E5}
static const GUID kbviv_GUID = 
{ 0x80998ca4, 0xe4b0, 0x4b1d, { 0x82, 0x35, 0xbb, 0x3c, 0xba, 0x30, 0x35, 0xe5 } };

static const wchar_t kbviv_Description[] = L"Vivo Active Player v" KBVIV_VERSION_STR;
static const wchar_t kbviv_Copyright[] = L"Copyright(C) 2016-2024 Kobarin";
static const DWORD kbviv_MultipleInstance = KPI_MULTINST_INFINITE;
static const DWORD kbviv_SupportTagInfo = 0;
static const DWORD kbviv_SupportConfig = 0;
static const wchar_t kbviv_SupportExts[] = L".viv";
static const wchar_t kbviv_MultiSongExts[] = L"";
static void* kbviv_Reserved1 = NULL;
static void* kbviv_Reserved2 = NULL;
///////////////////////////////////////////////////////////////////////////////
KbVivPlayerModule::KbVivPlayerModule(void)
    :m_ModuleInfo{
        sizeof(KPI_PLAYER_MODULEINFO),
        KPI_PLAYER_MODULE_VERSION,
        kbviv_Version,
        kbviv_MultipleInstance,
        kbviv_GUID,
        kbviv_Description,
        kbviv_Copyright,
        kbviv_SupportExts,
        kbviv_MultiSongExts,
        kbviv_Reserved1,
        kbviv_Reserved2,
        kbviv_SupportTagInfo,
        kbviv_SupportConfig,
        0,0,0,0}
{

}
///////////////////////////////////////////////////////////////////////////////
KbVivPlayerModule::~KbVivPlayerModule(void)
{
}
///////////////////////////////////////////////////////////////////////////////
void WINAPI KbVivPlayerModule::GetModuleInfo(const KPI_PLAYER_MODULEINFO **ppInfo)
{
    *ppInfo = &m_ModuleInfo;
}
///////////////////////////////////////////////////////////////////////////////
DWORD WINAPI KbVivPlayerModule::Open(const KPI_MEDIAINFO *cpRequest,
                                     IKpiFile   *pFile,
                                     IKpiFolder *pFolder,
                                     IKpiPlayer **ppPlayer)
{
    KbVivPlayer *pPlayer = new KbVivPlayer;
    DWORD dwRet = pPlayer->Open(pFile, pFolder);
    if(dwRet){
        *ppPlayer = pPlayer;
        return 1;
    }
    else{
        pPlayer->Release();
        *ppPlayer = NULL;
        return 0;
    }
}
///////////////////////////////////////////////////////////////////////////////
//extern "C" { int _afxForceUSRDLL; }
///////////////////////////////////////////////////////////////////////////////
HRESULT WINAPI kpi_CreateInstance(REFIID riid, void **ppvObject, IKpiUnknown *pUnknown)
{
    *ppvObject = NULL;
    if(IsEqualIID(riid, IID_IKpiPlayerModule)){
        IKpiPlayerModule *pPlayerModule = new KbVivPlayerModule();
        *ppvObject = pPlayerModule;
        return S_OK;
    }
    return E_NOINTERFACE;
}
///////////////////////////////////////////////////////////////////////////////
