[host] added DXGI Desktop Duplication support

This commit is contained in:
Geoffrey McRae 2017-11-02 22:37:19 +11:00
parent 44d7e9e77c
commit 7d83af9410
6 changed files with 77 additions and 12 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "vendor/kvm-guest-drivers-windows"]
path = vendor/kvm-guest-drivers-windows
url = https://github.com/virtio-win/kvm-guest-drivers-windows.git
[submodule "vendor/DXGICaptureSample"]
path = vendor/DXGICaptureSample
url = https://github.com/pgurenko/DXGICaptureSample.git

View File

@ -19,10 +19,12 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "DXGI.h"
using namespace Capture;
DXGI::DXGI() :
m_initialized(false)
{
#include "common\debug.h"
DXGI::DXGI() :
m_initialized(false),
m_manager(NULL)
{
}
DXGI::~DXGI()
@ -35,12 +37,32 @@ bool DXGI::Initialize()
if (m_initialized)
DeInitialize();
if (FAILED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
{
DEBUG_ERROR("CoInitializeEx failed");
return false;
}
m_manager = new DXGIManager();
m_manager->SetCaptureSource(CSDesktop);
RECT rect;
m_manager->GetOutputRect(rect);
m_width = rect.right - rect.left;
m_height = rect.bottom - rect.top;
m_initialized = true;
return true;
}
void DXGI::DeInitialize()
{
if (m_manager)
{
delete m_manager;
m_manager = NULL;
}
m_initialized = false;
}
@ -49,7 +71,7 @@ FrameType DXGI::GetFrameType()
if (!m_initialized)
return FRAME_TYPE_INVALID;
return FrameType();
return FRAME_TYPE_ARGB;
}
FrameComp DXGI::GetFrameCompression()
@ -57,15 +79,39 @@ FrameComp DXGI::GetFrameCompression()
if (!m_initialized)
return FRAME_COMP_NONE;
return FrameComp();
return FRAME_COMP_NONE;
}
size_t DXGI::GetMaxFrameSize()
{
return size_t();
if (!m_initialized);
return 0;
return m_width * m_height * 4;
}
bool DXGI::GrabFrame(FrameInfo & frame)
{
RECT rect;
m_manager->GetOutputRect(rect);
m_width = rect.right - rect.left;
m_height = rect.bottom - rect.top;
HRESULT result;
for(int i = 0; i < 2; ++i)
{
result = m_manager->GetOutputBits((BYTE*)frame.buffer, rect);
if (SUCCEEDED(result))
break;
}
if (FAILED(result))
return false;
frame.width = m_width;
frame.height = m_height;
frame.stride = m_width;
frame.outSize = m_width * m_height * 4;
return true;
}

View File

@ -19,6 +19,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#pragma once
#include "ICapture.h"
#include <vendor\DXGICaptureSample\DXGICaptureSample\DXGIManager.h>
#define W32_LEAN_AND_MEAN
#include <windows.h>
namespace Capture
{
@ -36,5 +40,8 @@ namespace Capture
private:
bool m_initialized;
DXGIManager * m_manager;
unsigned int m_width;
unsigned int m_height;
};
};

View File

@ -96,7 +96,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;d3d11.lib;dxgi.lib;gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@ -113,7 +113,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;d3d11.lib;dxgi.lib;gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@ -134,7 +134,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;d3d11.lib;dxgi.lib;gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@ -155,11 +155,12 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;d3d11.lib;dxgi.lib;gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\vendor\DXGICaptureSample\DXGICaptureSample\DXGIManager.cpp" />
<ClCompile Include="Capture\DXGI.cpp" />
<ClCompile Include="Capture\NvFBC.cpp" />
<ClCompile Include="ivshmem.cpp" />
@ -168,6 +169,7 @@
<ClCompile Include="Service.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\vendor\DXGICaptureSample\DXGICaptureSample\DXGIManager.h" />
<ClInclude Include="CaptureFactory.h" />
<ClInclude Include="Capture\DXGI.h" />
<ClInclude Include="Capture\NvFBC.h" />

View File

@ -39,6 +39,9 @@
<ClCompile Include="Capture\DXGI.cpp">
<Filter>Source Files\Capture</Filter>
</ClCompile>
<ClCompile Include="..\vendor\DXGICaptureSample\DXGICaptureSample\DXGIManager.cpp">
<Filter>Source Files\Capture</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ivshmem.h">
@ -65,5 +68,8 @@
<ClInclude Include="Capture\DXGI.h">
<Filter>Header Files\Capture</Filter>
</ClInclude>
<ClInclude Include="..\vendor\DXGICaptureSample\DXGICaptureSample\DXGIManager.h">
<Filter>Header Files\Capture</Filter>
</ClInclude>
</ItemGroup>
</Project>

1
vendor/DXGICaptureSample vendored Submodule

@ -0,0 +1 @@
Subproject commit 9e304f24b5b11bbd1c61a9c1c528693cd2843c5d