#pragma once

#include <guiddef.h>
// WinRT

#include <winrt/Windows.Foundation.Numerics.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Graphics.Capture.h>
#include <winrt/Windows.Graphics.DirectX.Direct3d11.h>
#include <winrt/Windows.Graphics.DirectX.h>
#include <winrt/Windows.Graphics.Imaging.h>
#include <winrt/Windows.Storage.Streams.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.System.h>
#include <winrt/Windows.UI.Composition.Desktop.h>
#include <winrt/Windows.UI.Composition.h>
#include <winrt/Windows.UI.Popups.h>
#include <winrt/Windows.UI.h>

#include <winrt/Windows.Foundation.Collections.h>

#include "SimpleCapture.h"

class App {
public:
    App() { }
    ~App() { Close(); }

    void Initialize(
        winrt::Windows::UI::Composition::ContainerVisual const& root);

    bool StartCaptureWindow(HWND hwnd, int width, int height);
    bool StartCaptureMonitor(HMONITOR monitor, int width, int height);
    void SetDrawCursor(bool isDrawCursor);
    void Close();
    AVFrame* GetFrame() { return m_capture->GetFrame(); }

private:
    winrt::Windows::UI::Composition::Compositor m_compositor {nullptr};
    winrt::Windows::UI::Composition::ContainerVisual m_root {nullptr};
    winrt::Windows::UI::Composition::SpriteVisual m_content {nullptr};
    winrt::Windows::UI::Composition::CompositionSurfaceBrush m_brush {nullptr};

    winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice m_device {nullptr};
    SimpleCapture* m_capture = nullptr;
};
