/***************************************************************************** * DXGICapture.h * * Copyright (C) 2020 Gokhan Erdogdu * * DXGICapture is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * DXGICapture is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * ******************************************************************************/ #pragma once #ifndef __DXGICAPTURE_H__ #define __DXGICAPTURE_H__ #include #include #include #include #include #include // for ID2D1Effect #include #include "DXGICaptureTypes.h" #define D3D_FEATURE_LEVEL_INVALID ((D3D_FEATURE_LEVEL)0x0) class CDXGICapture { private: ATL::CComAutoCriticalSection m_csLock; BOOL m_bInitialized; DublicatorMonitorInfoVec m_monitorInfos; tagRendererInfo m_rendererInfo; tagMouseInfo m_mouseInfo; tagFrameBufferInfo m_tempMouseBuffer; DXGI_OUTPUT_DESC m_desktopOutputDesc; D3D_FEATURE_LEVEL m_lD3DFeatureLevel; CComPtr m_ipD3D11Device; CComPtr m_ipD3D11DeviceContext; CComPtr m_ipDxgiOutputDuplication; CComPtr m_ipCopyTexture2D; CComPtr m_ipD2D1Device; CComPtr m_ipD2D1Factory; CComPtr m_ipWICImageFactory; CComPtr m_ipWICOutputBitmap; CComPtr m_ipD2D1RenderTarget; public: CDXGICapture(); ~CDXGICapture(); private: HRESULT loadMonitorInfos(ID3D11Device *pDevice); void freeMonitorInfos(); HRESULT createDeviceResource( const tagScreenCaptureFilterConfig *pConfig, const tagDublicatorMonitorInfo *pSelectedMonitorInfo); void terminateDeviceResource(); public: HRESULT Initialize(); HRESULT Terminate(); HRESULT SetConfig(const tagScreenCaptureFilterConfig *pConfig); HRESULT SetConfig(const tagScreenCaptureFilterConfig &config); BOOL IsInitialized() const; D3D_FEATURE_LEVEL GetD3DFeatureLevel() const; int GetDublicatorMonitorInfoCount() const; const tagDublicatorMonitorInfo* GetDublicatorMonitorInfo(int index) const; const tagDublicatorMonitorInfo* FindDublicatorMonitorInfo(int monitorIdx) const; HRESULT CaptureToFile(_In_ LPCWSTR lpcwOutputFileName, _Out_opt_ BOOL *pRetIsTimeout = NULL, _Out_opt_ UINT *pRetRenderDuration = NULL); }; #endif // __DXGICAPTURE_H__