#pragma once

#include "kpi_player.h"
#include "kpi_impl.h"
#include "kbmov_player_base.h"
#include <strmif.h>
#include <uuids.h>
#include <control.h>

namespace kpifile_source_filter {
    class MemSourceFilter;
}
interface IVMRWindowlessControl9;
interface IMFVideoDisplayControl;

class KbDShowPlayer : public KbMovPlayerBase
{
protected:
    /*enum {
        COMMAND_CREATEWINDOW = 0,
        COMMAND_STOP,
        COMMAND_PAUSE,
        COMMAND_RESTART,
        COMMAND_RUN,
        COMMAND_QUIT,
        COMMAND_GET_STATUS,
        COMMAND_GET_POSITION,
        COMMAND_GET_VIDEOPOS,
        COMMAND_SET_VIDEOPOS,
        COMMAND_SET_VOLUME,
        COMMAND_SET_TOPMOST,
        COMMAND_SET_TEMPO,
        COMMAND_SET_VISIBLE,
    };
    */
#ifdef _DEBUG
    DWORD  m_dwRegister;
    DWORD  m_dwRegisterV;
#endif
    kpifile_source_filter::MemSourceFilter* m_pSource;
    IGraphBuilder  *m_pGraphBuilder;
    IMediaControl  *m_pMediaControl;
    IMediaSeeking  *m_pMediaSeeking;
    IMediaEventEx  *m_pMediaEvent;
    IVideoWindow   *m_pVideoWindow;
    IVMRWindowlessControl  *m_pVmr7;//VMR7
    IVMRWindowlessControl9 *m_pVmr9;//VMR9
    IMFVideoDisplayControl *m_pEvr; //EVR
    wchar_t                 m_szVrName[128];
    void __fastcall ThreadProc(void);//DirectShow のオブジェクトへのアクセスは全てこのスレッド内で
    void __fastcall MessageLoop(void);
    LRESULT CALLBACK VideoWindowProcInternal(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    static void __fastcall DeleteRegKeyEnableOverlays(void);
public:
    //全て KbMovPlayerBase と同じ
#if 0
    BOOL __fastcall Open(IKpiConfig *pConfig, IKpiFile *pFile, IKpiFolder *pFolder);
    DWORD WINAPI Select(DWORD dwNumber,
                        const KPI_MEDIAINFO **ppInfo,
                        IKpiTagInfo *pTagInfo,
                        DWORD dwTagGetFlags);
    BOOL  WINAPI Play(DWORD dwStartpos, BOOL bVisible);
    BOOL  WINAPI Pause(void);
    BOOL  WINAPI Restart(void);
    void  WINAPI Stop(void);
    DWORD WINAPI GetPosition(void);
    DWORD WINAPI GetStatus(void);
    void  WINAPI SetTempo(int Tempo);
    void  WINAPI SetVolume(int Volume);
    void  WINAPI SetVisible(BOOL bVisible);
    void  WINAPI GetWindowPosition(int* pLeft, int* pTop,
        int* pVideoWidth, int* pVideoHeight);
    void  WINAPI SetWindowPosition(int nLeft, int nTop,
        int nVideoWidth, int nVideoHeight);
    void  WINAPI SetTopMost(BOOL bTopMost);
    void  WINAPI SetRepeat(BOOL bRepeat) {}
    DWORD WINAPI UpdateConfig(void* pvReserved) { return 0; }//設定が変更されたら呼ばれる
#endif
    KbDShowPlayer(void);
    ~KbDShowPlayer(void);
};
