diff --git a/host/Capture/DXGI.cpp b/host/Capture/DXGI.cpp new file mode 100644 index 00000000..1b6c5c47 --- /dev/null +++ b/host/Capture/DXGI.cpp @@ -0,0 +1,71 @@ +/* +KVMGFX Client - A KVM Client for VGA Passthrough +Copyright (C) 2017 Geoffrey McRae + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "DXGI.h" +using namespace Capture; + +DXGI::DXGI() : + m_initialized(false) +{ + +} + +DXGI::~DXGI() +{ + +} + +bool DXGI::Initialize() +{ + if (m_initialized) + DeInitialize(); + + m_initialized = true; + return true; +} + +void DXGI::DeInitialize() +{ + m_initialized = false; +} + +FrameType DXGI::GetFrameType() +{ + if (!m_initialized) + return FRAME_TYPE_INVALID; + + return FrameType(); +} + +FrameComp DXGI::GetFrameCompression() +{ + if (!m_initialized) + return FRAME_COMP_NONE; + + return FrameComp(); +} + +size_t DXGI::GetMaxFrameSize() +{ + return size_t(); +} + +bool DXGI::GrabFrame(FrameInfo & frame) +{ + return false; +} \ No newline at end of file diff --git a/host/Capture/DXGI.h b/host/Capture/DXGI.h new file mode 100644 index 00000000..f90b293c --- /dev/null +++ b/host/Capture/DXGI.h @@ -0,0 +1,40 @@ +/* +KVMGFX Client - A KVM Client for VGA Passthrough +Copyright (C) 2017 Geoffrey McRae + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#pragma once + +#include "ICapture.h" + +namespace Capture +{ + class DXGI : public ICapture + { + public: + DXGI(); + ~DXGI(); + bool Initialize(); + void DeInitialize(); + enum FrameType GetFrameType(); + enum FrameComp GetFrameCompression(); + size_t GetMaxFrameSize(); + bool GrabFrame(struct FrameInfo & frame); + + private: + bool m_initialized; + }; +}; \ No newline at end of file diff --git a/host/CaptureFactory.h b/host/CaptureFactory.h index aef3be77..cd0286ff 100644 --- a/host/CaptureFactory.h +++ b/host/CaptureFactory.h @@ -21,14 +21,37 @@ Place, Suite 330, Boston, MA 02111-1307 USA #define W32_LEAN_AND_MEAN #include +#include "common\debug.h" #include "ICapture.h" #include "Capture\NvFBC.h" +#include "Capture\DXGI.h" class CaptureFactory { public: static ICapture * GetCaptureDevice() { - return new Capture::NvFBC(); + ICapture *dev; + + dev = new Capture::NvFBC(); + if (dev->Initialize()) + { + DEBUG_INFO("Using NvFBC"); + return dev; + } + dev->DeInitialize(); + delete dev; + + dev = new Capture::DXGI(); + if (dev->Initialize()) + { + DEBUG_INFO("Using DXGI"); + return dev; + } + dev->DeInitialize(); + delete dev; + + DEBUG_ERROR("Failed to initialize a compatible capture device"); + return NULL; } }; \ No newline at end of file diff --git a/host/Service.cpp b/host/Service.cpp index 4029d57c..48de78ff 100644 --- a/host/Service.cpp +++ b/host/Service.cpp @@ -45,7 +45,7 @@ bool Service::Initialize() DeInitialize(); m_capture = CaptureFactory::GetCaptureDevice(); - if (!m_capture || !m_capture->Initialize()) + if (!m_capture) { DEBUG_ERROR("Failed to initialize capture interface"); DeInitialize(); diff --git a/host/kvm-ivshmem-host.vcxproj b/host/kvm-ivshmem-host.vcxproj index 98c3f669..51b6c650 100644 --- a/host/kvm-ivshmem-host.vcxproj +++ b/host/kvm-ivshmem-host.vcxproj @@ -160,6 +160,7 @@ + @@ -168,6 +169,7 @@ + diff --git a/host/kvm-ivshmem-host.vcxproj.filters b/host/kvm-ivshmem-host.vcxproj.filters index af101ef0..7574fa53 100644 --- a/host/kvm-ivshmem-host.vcxproj.filters +++ b/host/kvm-ivshmem-host.vcxproj.filters @@ -36,6 +36,9 @@ Source Files + + Source Files\Capture + @@ -59,5 +62,8 @@ Header Files + + Header Files\Capture + \ No newline at end of file