[host] mingw-w64 compile fixes (#44)

* [host] rename min() to LG_MIN()

* [host] format string type fixes, %Ix doesn't exist in mingw

* [host] DXGI minor fixes

* [host] mingw lacks media foundation api headers and QISearch
This commit is contained in:
arcnmx
2018-01-30 05:07:46 -05:00
committed by Geoffrey McRae
parent d7321d5f5f
commit 35b4d75eea
6 changed files with 48 additions and 29 deletions

View File

@@ -28,8 +28,23 @@ using namespace Capture;
#include <codecapi.h>
#include <mferror.h>
#include <evr.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#if __MINGW32__
EXTERN_GUID(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 0xa634a91c, 0x822b, 0x41b9, 0xa4, 0x94, 0x4d, 0xe4, 0x64, 0x36, 0x12, 0xb0);
EXTERN_GUID(MF_SOURCE_READER_ENABLE_ADVANCED_VIDEO_PROCESSING, 0xf81da2c, 0xb537, 0x4672, 0xa8, 0xb2, 0xa6, 0x81, 0xb1, 0x73, 0x7, 0xa3);
EXTERN_GUID(MF_SA_D3D11_AWARE, 0x206b4fc8, 0xfcf9, 0x4c51, 0xaf, 0xe3, 0x97, 0x64, 0x36, 0x9e, 0x33, 0xa0);
#define METransformUnknown 600
#define METransformNeedInput 601
#define METransformHaveOutput 602
#define METransformDrainComplete 603
#define METransformMarker 604
#endif
template <class T> void SafeRelease(T **ppT)
{
if (*ppT)
@@ -386,9 +401,9 @@ bool DXGI::InitH264Capture()
return false;
}
m_mfTransform->ProcessMessage(MFT_MESSAGE_COMMAND_FLUSH , NULL);
m_mfTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL);
m_mfTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, NULL);
m_mfTransform->ProcessMessage(MFT_MESSAGE_COMMAND_FLUSH , 0);
m_mfTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0);
m_mfTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, 0);
#if 0
status = MFTRegisterLocalByCLSID(
@@ -415,8 +430,8 @@ void DXGI::DeInitialize()
{
if (m_mediaEventGen)
{
m_mfTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, NULL);
m_mfTransform->ProcessMessage(MFT_MESSAGE_COMMAND_DRAIN, NULL);
m_mfTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0);
m_mfTransform->ProcessMessage(MFT_MESSAGE_COMMAND_DRAIN, 0);
while (WaitForSingleObject(m_shutdownEvent, INFINITE) != WAIT_OBJECT_0) {}
m_mfTransform->DeleteInputStream(0);
}
@@ -761,7 +776,7 @@ GrabStatus Capture::DXGI::GrabFrameRaw(FrameInfo & frame)
frame.stride = m_mapping.RowPitch / 4;
unsigned int size = m_height * m_mapping.RowPitch;
m_memcpy.Copy(frame.buffer, m_mapping.pData, size < frame.bufferSize ? size : frame.bufferSize);
m_memcpy.Copy(frame.buffer, m_mapping.pData, LG_MIN(size, frame.bufferSize));
return GRAB_STATUS_OK;
}
@@ -795,7 +810,7 @@ GrabStatus Capture::DXGI::GrabFrameRaw(FrameInfo & frame)
frame.stride = m_mapping.RowPitch >> 2;
const unsigned int size = m_height * m_mapping.RowPitch;
m_memcpy.Copy(frame.buffer, m_mapping.pData, size < frame.bufferSize ? size : frame.bufferSize);
m_memcpy.Copy(frame.buffer, m_mapping.pData, LG_MIN(size, frame.bufferSize));
TRACE_END;
return GRAB_STATUS_OK;

View File

@@ -86,13 +86,14 @@ namespace Capture
*/
STDMETHODIMP QueryInterface(REFIID riid, void ** ppv)
{
static const QITAB qit[] =
{
QITABENT(DXGI, IMFAsyncCallback),
{ NULL }
};
return QISearch(this, qit, riid, ppv);
if (riid == __uuidof(IUnknown) || riid == __uuidof(IMFAsyncCallback)) {
*ppv = static_cast<IMFAsyncCallback*>(this);
AddRef();
return S_OK;
} else {
*ppv = NULL;
return E_NOINTERFACE;
}
}
STDMETHODIMP_(ULONG) AddRef()
@@ -115,9 +116,9 @@ namespace Capture
bool InitRawCapture();
bool InitH264Capture();
GrabStatus DXGI::GrabFrameTexture(FrameInfo & frame, ID3D11Texture2DPtr & texture, bool & timeout);
GrabStatus DXGI::GrabFrameRaw (FrameInfo & frame);
GrabStatus DXGI::GrabFrameH264 (FrameInfo & frame);
GrabStatus GrabFrameTexture(FrameInfo & frame, ID3D11Texture2DPtr & texture, bool & timeout);
GrabStatus GrabFrameRaw (FrameInfo & frame);
GrabStatus GrabFrameH264 (FrameInfo & frame);
void WaitForDesktop();

View File

@@ -274,8 +274,8 @@ enum GrabStatus NvFBC::GrabFrame(struct FrameInfo & frame)
}
// use the smaller or the two dimensions provided just to be sure we don't overflow the buffer
const unsigned int realHeight = min(m_grabInfo.dwHeight, screenHeight);
const unsigned int realWidth = min(m_grabInfo.dwWidth , screenWidth );
const unsigned int realHeight = LG_MIN(m_grabInfo.dwHeight, screenHeight);
const unsigned int realWidth = LG_MIN(m_grabInfo.dwWidth , screenWidth );
// calculate the new data width and offset to the start of the data
dataWidth = realWidth * 4;